Multiple fixes

This commit is contained in:
Kload 2012-11-16 13:16:37 +01:00
parent 411304311a
commit b897c5e75c
5 changed files with 32 additions and 67 deletions

View file

@ -35,11 +35,12 @@ Specifications
### App ### App
yunohost app updatelist [-h] [-u URL]
yunohost app list [-h] [--fields FIELDS [FIELDS ...]] [-o OFFSET] yunohost app list [-h] [--fields FIELDS [FIELDS ...]] [-o OFFSET]
[-f FILTER] [-l LIMIT] [-f FILTER] [-l LIMIT]
yunohost app install [-h] [-d DOMAIN] [--public] [-l LABEL] [-p PATH] yunohost app install [-h] [-d DOMAIN] [--public] [-l LABEL] [-p PATH]
[--protected] [--protected]
app [app ...] app
yunohost app remove [-h] app [app ...] yunohost app remove [-h] app [app ...]
yunohost app upgrade [-h] [app [app ...]] yunohost app upgrade [-h] [app [app ...]]
yunohost app info [-h] app yunohost app info [-h] app
@ -47,14 +48,6 @@ Specifications
yunohost app removeaccess [-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 ### Firewall
yunohost firewall list [-h] yunohost firewall list [-h]
@ -97,7 +90,7 @@ We decided to regroup all YunoHost related operations into a single program call
### Important files ### Important files
* `` parse_args `` File executed on function calling - i.e `` ./parse_args user create ``. Will be renamed `` yunohost `` when packaged. * `` 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. * `` 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. * `` yunohost_*.py `` Files containing action functions. `` * `` is the category: user, domain, firewall, etc.
### How to add a function ? ### 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). 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() `` 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 ### Error handling
Moulinette has a unified way to handle errors. First, you need to import the ``YunoHostError`` exception: Moulinette has a unified way to handle errors. First, you need to import the ``YunoHostError`` exception:

View file

@ -49,8 +49,6 @@ user:
### user_list() ### user_list()
list: list:
action_help: List users action_help: List users
connections:
- ldap
arguments: arguments:
--fields: --fields:
help: fields to fetch help: fields to fetch
@ -68,8 +66,6 @@ user:
### user_create() ### user_create()
create: create:
action_help: Create user action_help: Create user
connections:
- ldap
arguments: arguments:
-u: -u:
full: --username full: --username
@ -95,8 +91,6 @@ user:
### user_delete() ### user_delete()
delete: delete:
action_help: Delete user action_help: Delete user
connections:
- ldap
arguments: arguments:
users: users:
help: Username of users to delete help: Username of users to delete
@ -107,8 +101,6 @@ user:
### user_update() ### user_update()
update: update:
action_help: Update user informations action_help: Update user informations
connections:
- ldap
arguments: arguments:
user: user:
help: Username of user to update help: Username of user to update
@ -142,8 +134,6 @@ user:
### user_info() ### user_info()
info: info:
action_help: Get user informations action_help: Get user informations
connections:
- ldap
arguments: arguments:
-u: -u:
full: --user full: --user
@ -161,8 +151,6 @@ domain:
### domain_list() ### domain_list()
list: list:
action_help: List domains action_help: List domains
connections:
- ldap
arguments: arguments:
-f: -f:
full: --filter full: --filter
@ -177,8 +165,6 @@ domain:
### domain_add() ### domain_add()
add: add:
action_help: Create a custom domain action_help: Create a custom domain
connections:
- ldap
arguments: arguments:
domain: domain:
help: Domain name to add help: Domain name to add
@ -189,8 +175,6 @@ domain:
### domain_remove() ### domain_remove()
remove: remove:
action_help: Delete domains action_help: Delete domains
connections:
- ldap
arguments: arguments:
domain: domain:
help: Domain(s) to delete help: Domain(s) to delete
@ -201,8 +185,6 @@ domain:
### domain_info() ### domain_info()
info: info:
action_help: Get domain informations action_help: Get domain informations
connections:
- ldap
arguments: arguments:
domain: domain:
help: "" help: ""
@ -223,11 +205,17 @@ app:
category_help: Manage apps category_help: Manage apps
actions: 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() ### app_list()
list: list:
action_help: List apps action_help: List apps
connections:
- ldap
arguments: arguments:
--fields: --fields:
help: fields to fetch help: fields to fetch
@ -245,12 +233,9 @@ app:
### app_install() TODO: Write help ### app_install() TODO: Write help
install: install:
action_help: Install apps action_help: Install apps
connections:
- ldap
- dns
arguments: arguments:
app: app:
nargs: "+" help: App to install
-d: -d:
full: --domain full: --domain
-p: -p:
@ -265,9 +250,6 @@ app:
### app_remove() TODO: Write help ### app_remove() TODO: Write help
remove: remove:
action_help: Remove app action_help: Remove app
connections:
- ldap
- dns
arguments: arguments:
app: app:
help: App(s) to delete help: App(s) to delete
@ -276,8 +258,6 @@ app:
### app_upgrade() ### app_upgrade()
upgrade: upgrade:
action_help: Upgrade app action_help: Upgrade app
connections:
- ldap
arguments: arguments:
app: app:
help: App(s) to upgrade (default all) help: App(s) to upgrade (default all)
@ -286,8 +266,6 @@ app:
### app_info() TODO: Write help ### app_info() TODO: Write help
info: info:
action_help: Get app informations action_help: Get app informations
connections:
- ldap
arguments: arguments:
app: app:
help: "" help: ""
@ -295,8 +273,6 @@ app:
### app_addaccess() TODO: Write help ### app_addaccess() TODO: Write help
addaccess: addaccess:
action_help: Grant access right to users (everyone by default) action_help: Grant access right to users (everyone by default)
connections:
- ldap
arguments: arguments:
app: app:
nargs: "+" nargs: "+"
@ -307,8 +283,6 @@ app:
### app_removeaccess() TODO: Write help ### app_removeaccess() TODO: Write help
removeaccess: removeaccess:
action_help: Revoke access right to users (everyone by default) action_help: Revoke access right to users (everyone by default)
connections:
- ldap
arguments: arguments:
app: app:
nargs: "+" nargs: "+"
@ -327,8 +301,6 @@ repo:
### repo_list() ### repo_list()
list: list:
action_help: List repositories action_help: List repositories
connections:
- repo
arguments: arguments:
-f: -f:
full: --filter full: --filter
@ -343,8 +315,6 @@ repo:
### repo_add() ### repo_add()
add: add:
action_help: Add app repository action_help: Add app repository
connections:
- repo
arguments: arguments:
url: url:
help: URL of the repository help: URL of the repository
@ -355,8 +325,6 @@ repo:
### repo_remove() ### repo_remove()
remove: remove:
action_help: Remove repository action_help: Remove repository
connections:
- repo
arguments: arguments:
repo: repo:
help: Name or URL of the repository help: Name or URL of the repository
@ -364,8 +332,6 @@ repo:
### repo_update() ### repo_update()
update: update:
action_help: Update app list from the repositories action_help: Update app list from the repositories
connections:
- repo
############################# #############################
@ -440,14 +406,10 @@ firewall:
### firewall_list() ### firewall_list()
list: list:
action_help: List all firewall rules action_help: List all firewall rules
connections:
- firewall
### firewall_allow() ### firewall_allow()
allow: allow:
action_help: Allow connection port/protocol action_help: Allow connection port/protocol
connections:
- firewall
arguments: arguments:
port: port:
help: Port to open help: Port to open
@ -463,8 +425,6 @@ firewall:
### firewall_disallow() ### firewall_disallow()
disallow: disallow:
action_help: Disallow connection action_help: Disallow connection
connections:
- firewall
arguments: arguments:
name: name:
help: Reference name of the rule to delete help: Reference name of the rule to delete
@ -480,8 +440,6 @@ tools:
### tools_ldapinit() ### tools_ldapinit()
ldapinit: ldapinit:
action_help: YunoHost LDAP initialization action_help: YunoHost LDAP initialization
connections:
- ldap
arguments: arguments:
-d: -d:
full: --domain full: --domain

8
firewall.yml Normal file
View file

@ -0,0 +1,8 @@
# Ports to open
#
ipv4:
tcp: [22, 25, 53, 80, 443, 5222, 5269, 5280]
udp: [53]
ipv6:

View file

@ -31,7 +31,6 @@ except ImportError:
sys.stderr.write('Error: Yunohost CLI Require yaml lib\n') sys.stderr.write('Error: Yunohost CLI Require yaml lib\n')
sys.stderr.write('apt-get install python-yaml\n') sys.stderr.write('apt-get install python-yaml\n')
sys.exit(1) sys.exit(1)
import yaml
import json import json
if not __debug__: if not __debug__:
import traceback import traceback
@ -57,11 +56,10 @@ def parse_dict(action_map):
""" """
# Intialize parsers # Intialize parsers
parsers = subparsers_category = subparsers_action = {} parsers = subparsers_category = subparsers_action = patterns = {}
parsers['general'] = argparse.ArgumentParser() parsers['general'] = argparse.ArgumentParser()
subparsers = parsers['general'].add_subparsers() subparsers = parsers['general'].add_subparsers()
new_args = [] new_args = []
patterns = {}
# Add general arguments # Add general arguments
for arg_name, arg_params in action_map['general_arguments'].items(): for arg_name, arg_params in action_map['general_arguments'].items():

8
yunohost_firewall.py Normal file
View file

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
import os
import sys
import yaml
def firewall_allow(args):
pass