From b897c5e75c27e08931593e7a906f4b8d3adadc75 Mon Sep 17 00:00:00 2001 From: Kload Date: Fri, 16 Nov 2012 13:16:37 +0100 Subject: [PATCH] Multiple fixes --- README.md | 19 +++++--------- action_map.yml | 60 +++++++------------------------------------- firewall.yml | 8 ++++++ parse_args | 4 +-- yunohost_firewall.py | 8 ++++++ 5 files changed, 32 insertions(+), 67 deletions(-) create mode 100644 firewall.yml create mode 100644 yunohost_firewall.py diff --git a/README.md b/README.md index e380b692..ab8fb7fe 100644 --- a/README.md +++ b/README.md @@ -35,26 +35,19 @@ Specifications ### App + yunohost app updatelist [-h] [-u URL] yunohost app list [-h] [--fields FIELDS [FIELDS ...]] [-o OFFSET] [-f FILTER] [-l LIMIT] yunohost app install [-h] [-d DOMAIN] [--public] [-l LABEL] [-p PATH] [--protected] - app [app ...] + app yunohost app remove [-h] app [app ...] yunohost app upgrade [-h] [app [app ...]] yunohost app info [-h] app yunohost app addaccess [-h] [-u USER [USER ...]] app [app ...] yunohost app removeaccess [-h] [-u USER [USER ...]] app [app ...] - - -### Repo - - yunohost repo list [-h] [-l LIMIT] [-o OFFSET] [-f FILTER] - yunohost repo add [-h] [-n NAME] url - yunohost repo remove [-h] repo - yunohost repo update [-h] - - + + ### Firewall yunohost firewall list [-h] @@ -97,7 +90,7 @@ We decided to regroup all YunoHost related operations into a single program call ### Important files * `` parse_args `` File executed on function calling - i.e `` ./parse_args user create ``. Will be renamed `` yunohost `` when packaged. * `` action_map.yml `` Defines all CLI actions and links arguments. -* `` yunohost.py `` Contains all YunoHost functions likely to be shared between moulinette files. Also contains service connections classes (erk). Refers to "Service connections" paragraph. +* `` yunohost.py `` Contains all YunoHost functions likely to be shared between moulinette files. Also contains service connections classes (erk). * `` yunohost_*.py `` Files containing action functions. `` * `` is the category: user, domain, firewall, etc. ### How to add a function ? @@ -105,7 +98,7 @@ We decided to regroup all YunoHost related operations into a single program call 2. Also check if the file `` yunohost_category.py `` is created in the working tree. If not, just create it (you may take example of `` yunohost_user.py `` file). 3. Add your function `` category_action() `` in this file - i.e `` user_create() `` -**Note:** `` category_action() `` takes one parameter plus an optional one : `` args `` and `` connections `` if connections were set. `` args `` contains the arguments passed to the command. Refers to `` action_map.yml `` documentation for more informations. +**Note:** `` category_action() `` takes one parameter,`` args `` which contains the arguments passed to the command. Refers to `` action_map.yml `` documentation for more informations. ### Error handling Moulinette has a unified way to handle errors. First, you need to import the ``YunoHostError`` exception: diff --git a/action_map.yml b/action_map.yml index b30909b0..18f032be 100644 --- a/action_map.yml +++ b/action_map.yml @@ -49,8 +49,6 @@ user: ### user_list() list: action_help: List users - connections: - - ldap arguments: --fields: help: fields to fetch @@ -68,8 +66,6 @@ user: ### user_create() create: action_help: Create user - connections: - - ldap arguments: -u: full: --username @@ -95,8 +91,6 @@ user: ### user_delete() delete: action_help: Delete user - connections: - - ldap arguments: users: help: Username of users to delete @@ -107,8 +101,6 @@ user: ### user_update() update: action_help: Update user informations - connections: - - ldap arguments: user: help: Username of user to update @@ -142,8 +134,6 @@ user: ### user_info() info: action_help: Get user informations - connections: - - ldap arguments: -u: full: --user @@ -161,8 +151,6 @@ domain: ### domain_list() list: action_help: List domains - connections: - - ldap arguments: -f: full: --filter @@ -177,8 +165,6 @@ domain: ### domain_add() add: action_help: Create a custom domain - connections: - - ldap arguments: domain: help: Domain name to add @@ -189,8 +175,6 @@ domain: ### domain_remove() remove: action_help: Delete domains - connections: - - ldap arguments: domain: help: Domain(s) to delete @@ -201,8 +185,6 @@ domain: ### domain_info() info: action_help: Get domain informations - connections: - - ldap arguments: domain: help: "" @@ -222,12 +204,18 @@ domain: app: category_help: Manage apps actions: + + ### app_updatelist() + updatelist: + action_help: Fetch application list from app server + arguments: + -u: + full: --url + help: URL of remote JSON list (default http://fapp.yunohost.org/app/list/raw) ### app_list() list: action_help: List apps - connections: - - ldap arguments: --fields: help: fields to fetch @@ -245,12 +233,9 @@ app: ### app_install() TODO: Write help install: action_help: Install apps - connections: - - ldap - - dns arguments: app: - nargs: "+" + help: App to install -d: full: --domain -p: @@ -265,9 +250,6 @@ app: ### app_remove() TODO: Write help remove: action_help: Remove app - connections: - - ldap - - dns arguments: app: help: App(s) to delete @@ -276,8 +258,6 @@ app: ### app_upgrade() upgrade: action_help: Upgrade app - connections: - - ldap arguments: app: help: App(s) to upgrade (default all) @@ -286,8 +266,6 @@ app: ### app_info() TODO: Write help info: action_help: Get app informations - connections: - - ldap arguments: app: help: "" @@ -295,8 +273,6 @@ app: ### app_addaccess() TODO: Write help addaccess: action_help: Grant access right to users (everyone by default) - connections: - - ldap arguments: app: nargs: "+" @@ -307,8 +283,6 @@ app: ### app_removeaccess() TODO: Write help removeaccess: action_help: Revoke access right to users (everyone by default) - connections: - - ldap arguments: app: nargs: "+" @@ -327,8 +301,6 @@ repo: ### repo_list() list: action_help: List repositories - connections: - - repo arguments: -f: full: --filter @@ -343,8 +315,6 @@ repo: ### repo_add() add: action_help: Add app repository - connections: - - repo arguments: url: help: URL of the repository @@ -355,8 +325,6 @@ repo: ### repo_remove() remove: action_help: Remove repository - connections: - - repo arguments: repo: help: Name or URL of the repository @@ -364,8 +332,6 @@ repo: ### repo_update() update: action_help: Update app list from the repositories - connections: - - repo ############################# @@ -440,14 +406,10 @@ firewall: ### firewall_list() list: action_help: List all firewall rules - connections: - - firewall ### firewall_allow() allow: action_help: Allow connection port/protocol - connections: - - firewall arguments: port: help: Port to open @@ -463,8 +425,6 @@ firewall: ### firewall_disallow() disallow: action_help: Disallow connection - connections: - - firewall arguments: name: help: Reference name of the rule to delete @@ -480,8 +440,6 @@ tools: ### tools_ldapinit() ldapinit: action_help: YunoHost LDAP initialization - connections: - - ldap arguments: -d: full: --domain diff --git a/firewall.yml b/firewall.yml new file mode 100644 index 00000000..909be1a7 --- /dev/null +++ b/firewall.yml @@ -0,0 +1,8 @@ +# Ports to open +# + +ipv4: + tcp: [22, 25, 53, 80, 443, 5222, 5269, 5280] + udp: [53] + +ipv6: diff --git a/parse_args b/parse_args index 1bffd177..6e9b617f 100755 --- a/parse_args +++ b/parse_args @@ -31,7 +31,6 @@ except ImportError: sys.stderr.write('Error: Yunohost CLI Require yaml lib\n') sys.stderr.write('apt-get install python-yaml\n') sys.exit(1) -import yaml import json if not __debug__: import traceback @@ -57,11 +56,10 @@ def parse_dict(action_map): """ # Intialize parsers - parsers = subparsers_category = subparsers_action = {} + parsers = subparsers_category = subparsers_action = patterns = {} parsers['general'] = argparse.ArgumentParser() subparsers = parsers['general'].add_subparsers() new_args = [] - patterns = {} # Add general arguments for arg_name, arg_params in action_map['general_arguments'].items(): diff --git a/yunohost_firewall.py b/yunohost_firewall.py new file mode 100644 index 00000000..7e04a45a --- /dev/null +++ b/yunohost_firewall.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +import os +import sys +import yaml + +def firewall_allow(args): + pass