mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Move action_map to a YAML file :)
This commit is contained in:
parent
cb2b8dbf3c
commit
dd7b0b9878
2 changed files with 451 additions and 540 deletions
444
action_map.yml
Normal file
444
action_map.yml
Normal file
|
@ -0,0 +1,444 @@
|
||||||
|
##########################################################################
|
||||||
|
# Category/actions/arguments file
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Except for general_arguments, this file contains 3 levels
|
||||||
|
# as in this sample command line:
|
||||||
|
#
|
||||||
|
# yunohost monitor info --cpu --ram
|
||||||
|
# ^ ^ ^ ^
|
||||||
|
# (script) | category | action | parameters
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Above example will lead to the function "monitor_info(args)"
|
||||||
|
# in the file "yunohost_monitor.py" with "cpu" and "ram"
|
||||||
|
# stored in an "args" dictionnary.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# You can add a category at the first level, action at the second one,
|
||||||
|
# and arguments at the third one.
|
||||||
|
# If a connexion is needed for the action, don't forget to add it to
|
||||||
|
# the action parameters (ldap, repo, dns or firewall).
|
||||||
|
#
|
||||||
|
# Documentation:
|
||||||
|
# You can see all arguments settings at the argparse documentation:
|
||||||
|
# http://docs.python.org/dev/library/argparse.html
|
||||||
|
# #argparse.ArgumentParser.add_argument
|
||||||
|
#
|
||||||
|
# Don't forget to turn argument yaml style setting: "value"
|
||||||
|
#
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# General args #
|
||||||
|
#############################
|
||||||
|
"general_arguments":
|
||||||
|
"-v":
|
||||||
|
"full": "--version"
|
||||||
|
"help": "Display YunoHost version"
|
||||||
|
"action": "version"
|
||||||
|
"version": "YunoHost 2.0 beta1"
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# User #
|
||||||
|
#############################
|
||||||
|
"user":
|
||||||
|
"category_help": "Manage users"
|
||||||
|
"actions":
|
||||||
|
|
||||||
|
### user_list()
|
||||||
|
"list":
|
||||||
|
"action_help": "List users"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"--fields":
|
||||||
|
"help": "fields to fetch"
|
||||||
|
"nargs": "+"
|
||||||
|
"-f":
|
||||||
|
"full": "--filter"
|
||||||
|
"help": "LDAP filter used to search"
|
||||||
|
"-l":
|
||||||
|
"full": "--limit"
|
||||||
|
"help": "Maximum number of user fetched"
|
||||||
|
"-o":
|
||||||
|
"full": "--offset"
|
||||||
|
"help": "Starting number for user fetching"
|
||||||
|
|
||||||
|
### user_create()
|
||||||
|
"create":
|
||||||
|
"action_help": "Create user"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"-u":
|
||||||
|
"full": "--username"
|
||||||
|
"help": "Must be unique"
|
||||||
|
"-f":
|
||||||
|
"full": "--firstname"
|
||||||
|
"-l":
|
||||||
|
"full": "--lastname"
|
||||||
|
"-m":
|
||||||
|
"full": "--mail"
|
||||||
|
"help": "Main mail address must be unique"
|
||||||
|
"-p":
|
||||||
|
"full": "--password"
|
||||||
|
|
||||||
|
### user_delete()
|
||||||
|
"delete":
|
||||||
|
"action_help": "Delete user"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"users":
|
||||||
|
"help": "Username of users to delete"
|
||||||
|
"nargs": "+"
|
||||||
|
|
||||||
|
### user_update()
|
||||||
|
"update":
|
||||||
|
"action_help": "Update user informations"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"user":
|
||||||
|
"help": "Username of user to update"
|
||||||
|
"-f":
|
||||||
|
"full": "--firstname"
|
||||||
|
"-l":
|
||||||
|
"full": "--lastname"
|
||||||
|
"-m":
|
||||||
|
"full": "--mail"
|
||||||
|
"-cp":
|
||||||
|
"full": "--change-password"
|
||||||
|
"help": "New password to set"
|
||||||
|
"metavar": "PASSWORD"
|
||||||
|
"--add-mailforward":
|
||||||
|
"help": "Mailforward addresses to add"
|
||||||
|
"nargs": "+"
|
||||||
|
"metavar": "MAIL"
|
||||||
|
"--remove-mailforward":
|
||||||
|
"help": "Mailforward addresses to remove"
|
||||||
|
"nargs": "+"
|
||||||
|
"metavar": "MAIL"
|
||||||
|
"-add-mailalias":
|
||||||
|
"help": "Mail aliases to add"
|
||||||
|
"nargs": "+"
|
||||||
|
"metavar": "MAIL"
|
||||||
|
"-remove-mailalias":
|
||||||
|
"help": "Mail aliases to remove"
|
||||||
|
"nargs": "+"
|
||||||
|
"metavar": "MAIL"
|
||||||
|
|
||||||
|
### user_info()
|
||||||
|
"info":
|
||||||
|
"action_help": "Get user informations"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"user":
|
||||||
|
"nargs": "?"
|
||||||
|
"-m":
|
||||||
|
"full": "--mail"
|
||||||
|
"-cn":
|
||||||
|
"full": "--fullname"
|
||||||
|
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Domain #
|
||||||
|
#############################
|
||||||
|
"domain":
|
||||||
|
"category_help": "Manage domains"
|
||||||
|
"actions":
|
||||||
|
|
||||||
|
### domain_list()
|
||||||
|
"list":
|
||||||
|
"action_help": "List domains"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"-f":
|
||||||
|
"full": "--filter"
|
||||||
|
"help": "LDAP filter used to search"
|
||||||
|
"-l":
|
||||||
|
"full": "--limit"
|
||||||
|
"help": "Maximum number of domain fetched"
|
||||||
|
"-o":
|
||||||
|
"full": "--offset"
|
||||||
|
"help": "Starting number for domain fetching"
|
||||||
|
|
||||||
|
### domain_add()
|
||||||
|
"add":
|
||||||
|
"action_help": "Create a custom domain"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"domain":
|
||||||
|
"help": "Domain name to add"
|
||||||
|
|
||||||
|
### domain_remove()
|
||||||
|
"remove":
|
||||||
|
"action_help": "Delete domains"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"domain":
|
||||||
|
"help": "Domain(s) to delete"
|
||||||
|
"nargs": "+"
|
||||||
|
|
||||||
|
### domain_info()
|
||||||
|
"info":
|
||||||
|
"action_help": "Get domain informations"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"domain":
|
||||||
|
"help": ""
|
||||||
|
|
||||||
|
### domain_renewcert()
|
||||||
|
"renewcert":
|
||||||
|
"action_help": "Renew domain certificate"
|
||||||
|
"arguments":
|
||||||
|
"domain":
|
||||||
|
"help": ""
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# App #
|
||||||
|
#############################
|
||||||
|
"app":
|
||||||
|
"category_help": "Manage apps"
|
||||||
|
"actions":
|
||||||
|
|
||||||
|
### app_list()
|
||||||
|
"list":
|
||||||
|
"action_help": "List apps"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"--fields":
|
||||||
|
"help": "fields to fetch"
|
||||||
|
"nargs": "+"
|
||||||
|
"-f":
|
||||||
|
"full": "--filter"
|
||||||
|
"help": "LDAP filter used to search"
|
||||||
|
"-l":
|
||||||
|
"full": "--limit"
|
||||||
|
"help": "Maximum number of app fetched"
|
||||||
|
"-o":
|
||||||
|
"full": "--offset"
|
||||||
|
"help": "Starting number for app fetching"
|
||||||
|
|
||||||
|
### app_install() TODO: Write help
|
||||||
|
"install":
|
||||||
|
"action_help": "Install apps"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
- "dns"
|
||||||
|
"arguments":
|
||||||
|
"app":
|
||||||
|
"nargs": "+"
|
||||||
|
"-d":
|
||||||
|
"full": "--domain"
|
||||||
|
"-p":
|
||||||
|
"full": "--path"
|
||||||
|
"-l":
|
||||||
|
"full": "--label"
|
||||||
|
"--public":
|
||||||
|
"action": "store_true"
|
||||||
|
"--protected":
|
||||||
|
"action": "store_true"
|
||||||
|
|
||||||
|
### app_remove() TODO: Write help
|
||||||
|
"remove":
|
||||||
|
"action_help": "Remove app"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
- "dns"
|
||||||
|
"arguments":
|
||||||
|
"app":
|
||||||
|
"help": "App(s) to delete"
|
||||||
|
"nargs": "+"
|
||||||
|
|
||||||
|
### app_upgrade()
|
||||||
|
"upgrade":
|
||||||
|
"action_help": "Upgrade app"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"app":
|
||||||
|
"help": "App(s) to upgrade (default all)"
|
||||||
|
"nargs": "*"
|
||||||
|
|
||||||
|
### app_info() TODO: Write help
|
||||||
|
"info":
|
||||||
|
"action_help": "Get app informations"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"app":
|
||||||
|
"help": ""
|
||||||
|
|
||||||
|
### app_addaccess() TODO: Write help
|
||||||
|
"addaccess":
|
||||||
|
"action_help": "Grant access right to users (everyone by default)"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"app":
|
||||||
|
"nargs": "+"
|
||||||
|
"-u":
|
||||||
|
"full": "--user"
|
||||||
|
"nargs": "+"
|
||||||
|
|
||||||
|
### app_removeaccess() TODO: Write help
|
||||||
|
"removeaccess":
|
||||||
|
"action_help": "Revoke access right to users (everyone by default)"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
||||||
|
"arguments":
|
||||||
|
"app":
|
||||||
|
"nargs": "+"
|
||||||
|
"-u":
|
||||||
|
"full": "--user"
|
||||||
|
"nargs": "+"
|
||||||
|
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Repository #
|
||||||
|
#############################
|
||||||
|
"repo":
|
||||||
|
"category_help": "Manage app repositories"
|
||||||
|
"actions":
|
||||||
|
|
||||||
|
### repo_list()
|
||||||
|
"list":
|
||||||
|
"action_help": "List repositories"
|
||||||
|
"connections":
|
||||||
|
- "repo"
|
||||||
|
"arguments":
|
||||||
|
"-f":
|
||||||
|
"full": "--filter"
|
||||||
|
"help": "LDAP filter used to search"
|
||||||
|
"-l":
|
||||||
|
"full": "--limit"
|
||||||
|
"help": "Maximum number of repository fetched"
|
||||||
|
"-o":
|
||||||
|
"full": "--offset"
|
||||||
|
"help": "Starting number for repository fetching"
|
||||||
|
|
||||||
|
### repo_add()
|
||||||
|
"add":
|
||||||
|
"action_help": "Add app repository"
|
||||||
|
"connections":
|
||||||
|
- "repo"
|
||||||
|
"arguments":
|
||||||
|
"url":
|
||||||
|
"help": "URL of the repository"
|
||||||
|
"-n":
|
||||||
|
"full": "--name"
|
||||||
|
"help": "Unique name of the repository"
|
||||||
|
|
||||||
|
### repo_remove()
|
||||||
|
"remove":
|
||||||
|
"action_help": "Remove repository"
|
||||||
|
"connections":
|
||||||
|
- "repo"
|
||||||
|
"arguments":
|
||||||
|
"repo":
|
||||||
|
"help": "Name or URL of the repository"
|
||||||
|
|
||||||
|
### repo_update()
|
||||||
|
"update":
|
||||||
|
"action_help": "Update app list from the repositories"
|
||||||
|
"connections":
|
||||||
|
- "repo"
|
||||||
|
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Monitor #
|
||||||
|
#############################
|
||||||
|
"monitor":
|
||||||
|
"category_help": "Monitoring functions"
|
||||||
|
"actions":
|
||||||
|
|
||||||
|
### monitor_info()
|
||||||
|
"info":
|
||||||
|
"action_help": "Check System"
|
||||||
|
"arguments":
|
||||||
|
"-m":
|
||||||
|
"full": "--memory"
|
||||||
|
"help": "Check Memory"
|
||||||
|
"action": "store_true"
|
||||||
|
"-c":
|
||||||
|
"full": "--cpu"
|
||||||
|
"help": "Check CPU"
|
||||||
|
"action": "store_true"
|
||||||
|
"-d":
|
||||||
|
"full": "--disk"
|
||||||
|
"help": "Check Disk"
|
||||||
|
"action": "store_true"
|
||||||
|
"-i":
|
||||||
|
"full": "--ifconfig"
|
||||||
|
"help": "Ifconfig"
|
||||||
|
"action": "store_true"
|
||||||
|
"-u":
|
||||||
|
"full": "--uptime"
|
||||||
|
"help": "Show Uptime"
|
||||||
|
"action": "store_true"
|
||||||
|
"-p":
|
||||||
|
"full": "--process"
|
||||||
|
"help": "Show Process Account"
|
||||||
|
"action": "store_true"
|
||||||
|
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Firewall #
|
||||||
|
#############################
|
||||||
|
"firewall":
|
||||||
|
"category_help": "Manage firewall rules"
|
||||||
|
"actions":
|
||||||
|
|
||||||
|
### 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"
|
||||||
|
"protocol":
|
||||||
|
"help": "Protocol associated with port"
|
||||||
|
"choices":
|
||||||
|
- "UDP"
|
||||||
|
- "TCP"
|
||||||
|
- "Both"
|
||||||
|
"name":
|
||||||
|
"help": "Reference name of the rule"
|
||||||
|
|
||||||
|
### firewall_disallow()
|
||||||
|
"disallow":
|
||||||
|
"action_help": "Disallow connection"
|
||||||
|
"connections":
|
||||||
|
- "firewall"
|
||||||
|
"arguments":
|
||||||
|
"name":
|
||||||
|
"help": "Reference name of the rule to delete"
|
||||||
|
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Tools #
|
||||||
|
#############################
|
||||||
|
"tools":
|
||||||
|
"category_help": "Specific tools"
|
||||||
|
"actions":
|
||||||
|
|
||||||
|
### tools_install()
|
||||||
|
"install":
|
||||||
|
"action_help": "Install YunoHost LDAP initialization"
|
||||||
|
"connections":
|
||||||
|
- "ldap"
|
547
parse_args
547
parse_args
|
@ -24,6 +24,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import gettext
|
import gettext
|
||||||
|
import yaml
|
||||||
import json
|
import json
|
||||||
if not __debug__:
|
if not __debug__:
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -36,543 +37,6 @@ except ImportError:
|
||||||
sys.stderr.write('Error: Yunohost CLI Require YunoHost lib\n')
|
sys.stderr.write('Error: Yunohost CLI Require YunoHost lib\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
"""
|
|
||||||
Category/actions/arguments dictionnary
|
|
||||||
|
|
||||||
|
|
||||||
Except for general_arguments, this dictionary contains 3 levels
|
|
||||||
as in this sample command line :
|
|
||||||
|
|
||||||
yunohost monitor info --cpu --ram
|
|
||||||
^ ^ ^ ^
|
|
||||||
(script) | category | action | parameters
|
|
||||||
|
|
||||||
|
|
||||||
Above example will lead to the function 'monitor_info(args)'
|
|
||||||
in the file 'yunohost_monitor.py' with 'cpu' and 'ram'
|
|
||||||
stored in args dictionnary.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
You can add a category at the first level, action at the second one,
|
|
||||||
and arguments at the third one.
|
|
||||||
If a connexion is needed for the action, don't forget to add it to
|
|
||||||
the action parameters (ldap, repo, dns or firewall).
|
|
||||||
|
|
||||||
Documentation:
|
|
||||||
You can see all arguments settings at the argparse documentation:
|
|
||||||
http://docs.python.org/dev/library/argparse.html
|
|
||||||
#argparse.ArgumentParser.add_argument
|
|
||||||
|
|
||||||
Don't forget to turn argument as dictionnary ('setting' : 'value')
|
|
||||||
|
|
||||||
"""
|
|
||||||
action_map = {
|
|
||||||
#############################
|
|
||||||
# General args #
|
|
||||||
#############################
|
|
||||||
'general_arguments' : {
|
|
||||||
'-v' : {
|
|
||||||
'full' : '--version',
|
|
||||||
'help' : _("Display %(prog)s version"),
|
|
||||||
'action' : 'version',
|
|
||||||
'version' : '%(prog)s ' + __version__,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# User #
|
|
||||||
#############################
|
|
||||||
'user' : {
|
|
||||||
'category_help' : _("Manage users"),
|
|
||||||
'actions' : {
|
|
||||||
### user_list()
|
|
||||||
'list' : {
|
|
||||||
'action_help' : _("List users"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'--fields' : {
|
|
||||||
'help' : _("fields to fetch"),
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
'-f' : {
|
|
||||||
'full' : '--filter',
|
|
||||||
'help' : _("LDAP filter used to search"),
|
|
||||||
},
|
|
||||||
'-l' : {
|
|
||||||
'full' : '--limit',
|
|
||||||
'help' : _("Maximum number of user fetched"),
|
|
||||||
},
|
|
||||||
'-o' : {
|
|
||||||
'full' : '--offset',
|
|
||||||
'help' : _("Starting number for user fetching"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### user_create()
|
|
||||||
'create' : {
|
|
||||||
'action_help' : _("Create user"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'-u' : {
|
|
||||||
'full' : '--username',
|
|
||||||
'help' : _("Must be unique"),
|
|
||||||
},
|
|
||||||
'-f' : {
|
|
||||||
'full' : '--firstname',
|
|
||||||
},
|
|
||||||
'-l' : {
|
|
||||||
'full' : '--lastname',
|
|
||||||
},
|
|
||||||
'-m' : {
|
|
||||||
'full' : '--mail',
|
|
||||||
'help' : _("Main mail address, must be unique"),
|
|
||||||
},
|
|
||||||
'-p' : {
|
|
||||||
'full' : '--password',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### user_delete()
|
|
||||||
'delete' : {
|
|
||||||
'action_help' : _("Delete user"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'users' : {
|
|
||||||
'help' : _("Username of users to delete"),
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### user_update()
|
|
||||||
'update' : {
|
|
||||||
'action_help' : _("Update user informations"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'user' : {
|
|
||||||
'help' : _("Username of user to update"),
|
|
||||||
},
|
|
||||||
'-f' : {
|
|
||||||
'full' : '--firstname',
|
|
||||||
},
|
|
||||||
'-l' : {
|
|
||||||
'full' : '--lastname',
|
|
||||||
},
|
|
||||||
'-m' : {
|
|
||||||
'full' : '--mail',
|
|
||||||
},
|
|
||||||
'-cp' : {
|
|
||||||
'full' : '--change-password',
|
|
||||||
'help' : _("New password to set"),
|
|
||||||
'metavar' : 'PASSWORD',
|
|
||||||
},
|
|
||||||
'--add-mailforward' : {
|
|
||||||
'help' : _("Mailforward addresses to add"),
|
|
||||||
'nargs' : '+',
|
|
||||||
'metavar' : 'MAIL',
|
|
||||||
},
|
|
||||||
'--remove-mailforward' : {
|
|
||||||
'help' : _("Mailforward addresses to remove"),
|
|
||||||
'nargs' : '+',
|
|
||||||
'metavar' : 'MAIL',
|
|
||||||
},
|
|
||||||
'-add-mailalias' : {
|
|
||||||
'help' : _("Mail aliases to add"),
|
|
||||||
'nargs' : '+',
|
|
||||||
'metavar' : 'MAIL',
|
|
||||||
},
|
|
||||||
'-remove-mailalias' : {
|
|
||||||
'help' : _("Mail aliases to remove"),
|
|
||||||
'nargs' : '+',
|
|
||||||
'metavar' : 'MAIL',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### user_info()
|
|
||||||
'info' : {
|
|
||||||
'action_help' : _("Get user informations"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'user' : {
|
|
||||||
'nargs' : '?',
|
|
||||||
},
|
|
||||||
'-m' : {
|
|
||||||
'full' : '--mail',
|
|
||||||
},
|
|
||||||
'-cn' : {
|
|
||||||
'full' : '--fullname',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# Domain #
|
|
||||||
#############################
|
|
||||||
'domain' : {
|
|
||||||
'category_help' : _("Manage domains"),
|
|
||||||
'actions' : {
|
|
||||||
### domain_list()
|
|
||||||
'list' : {
|
|
||||||
'action_help' : _("List domains"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'-f' : {
|
|
||||||
'full' : '--filter',
|
|
||||||
'help' : _("LDAP filter used to search"),
|
|
||||||
},
|
|
||||||
'-l' : {
|
|
||||||
'full' : '--limit',
|
|
||||||
'help' : _("Maximum number of domain fetched"),
|
|
||||||
},
|
|
||||||
'-o' : {
|
|
||||||
'full' : '--offset',
|
|
||||||
'help' : _("Starting number for domain fetching"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### domain_add()
|
|
||||||
'add' : {
|
|
||||||
'action_help' : _("Create a custom domain"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'domain' : {
|
|
||||||
'help' : _("Domain name to add"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### domain_remove()
|
|
||||||
'remove' : {
|
|
||||||
'action_help' : _("Delete domains"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'domain' : {
|
|
||||||
'help' : _("Domain(s) to delete"),
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### domain_info()
|
|
||||||
'info' : {
|
|
||||||
'action_help' : _("Get domain informations"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'domain' : {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### domain_renewcert()
|
|
||||||
'renewcert' : {
|
|
||||||
'action_help' : _("Renew domain certificate"),
|
|
||||||
'arguments' : {
|
|
||||||
'domain' : {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# App #
|
|
||||||
#############################
|
|
||||||
'app' : {
|
|
||||||
'category_help' : _("Manage apps"),
|
|
||||||
'actions' : {
|
|
||||||
### app_list()
|
|
||||||
'list' : {
|
|
||||||
'action_help' : _("List apps"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'--fields' : {
|
|
||||||
'help' : _("fields to fetch"),
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
'-f' : {
|
|
||||||
'full' : '--filter',
|
|
||||||
'help' : _("LDAP filter used to search"),
|
|
||||||
},
|
|
||||||
'-l' : {
|
|
||||||
'full' : '--limit',
|
|
||||||
'help' : _("Maximum number of app fetched"),
|
|
||||||
},
|
|
||||||
'-o' : {
|
|
||||||
'full' : '--offset',
|
|
||||||
'help' : _("Starting number for app fetching"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### app_install() TODO: Write help
|
|
||||||
'install' : {
|
|
||||||
'action_help' : _("Install apps"),
|
|
||||||
'connections' : ['ldap', 'dns'],
|
|
||||||
'arguments' : {
|
|
||||||
'app' : {
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
'-d' : {
|
|
||||||
'full' : '--domain',
|
|
||||||
},
|
|
||||||
'-p' : {
|
|
||||||
'full' : '--path',
|
|
||||||
},
|
|
||||||
'-l' : {
|
|
||||||
'full' : '--label',
|
|
||||||
},
|
|
||||||
'--public' : {
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
'--protected' : {
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### app_remove() TODO: Write help
|
|
||||||
'remove' : {
|
|
||||||
'action_help' : _("Remove app"),
|
|
||||||
'connections' : ['ldap', 'dns'],
|
|
||||||
'arguments' : {
|
|
||||||
'app' : {
|
|
||||||
'help' : _("App(s) to delete"),
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### app_upgrade()
|
|
||||||
'upgrade' : {
|
|
||||||
'action_help' : _("Upgrade app"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'app' : {
|
|
||||||
'help' : _("App(s) to upgrade (default all)"),
|
|
||||||
'nargs' : '*',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### app_info() TODO: Write help
|
|
||||||
'info' : {
|
|
||||||
'action_help' : _("Get app informations"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'app' : {},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### app_addaccess() TODO: Write help
|
|
||||||
'addaccess' : {
|
|
||||||
'action_help' : _("Grant access right to users (everyone by default)"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'app' : {
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
'-u' : {
|
|
||||||
'full' : '--user',
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### app_removeaccess() TODO: Write help
|
|
||||||
'removeaccess' : {
|
|
||||||
'action_help' : _("Revoke access right to users (everyone by default)"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
'arguments' : {
|
|
||||||
'app' : {
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
'-u' : {
|
|
||||||
'full' : '--user',
|
|
||||||
'nargs' : '+',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# Repository #
|
|
||||||
#############################
|
|
||||||
'repo' : {
|
|
||||||
'category_help' : _("Manage app repositories"),
|
|
||||||
'actions' : {
|
|
||||||
### repo_list()
|
|
||||||
'list' : {
|
|
||||||
'action_help' : _("List repositories"),
|
|
||||||
'connections' : ['repo'],
|
|
||||||
'arguments' : {
|
|
||||||
'-f' : {
|
|
||||||
'full' : '--filter',
|
|
||||||
'help' : _("LDAP filter used to search"),
|
|
||||||
},
|
|
||||||
'-l' : {
|
|
||||||
'full' : '--limit',
|
|
||||||
'help' : _("Maximum number of repository fetched"),
|
|
||||||
},
|
|
||||||
'-o' : {
|
|
||||||
'full' : '--offset',
|
|
||||||
'help' : _("Starting number for repository fetching"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### repo_add()
|
|
||||||
'add' : {
|
|
||||||
'action_help' : _("Add app repository"),
|
|
||||||
'connections' : ['repo'],
|
|
||||||
'arguments' : {
|
|
||||||
'url' : {
|
|
||||||
'help' : _("URL of the repository"),
|
|
||||||
},
|
|
||||||
'-n' : {
|
|
||||||
'full' : '--name',
|
|
||||||
'help' : _("Unique name of the repository"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### repo_remove()
|
|
||||||
'remove' : {
|
|
||||||
'action_help' : _("Remove repository"),
|
|
||||||
'connections' : ['repo'],
|
|
||||||
'arguments' : {
|
|
||||||
'repo' : {
|
|
||||||
'help' : _("Name or URL of the repository"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'update' : {
|
|
||||||
'action_help' : _("Update app list from the repositories"),
|
|
||||||
'connections' : ['repo'],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# Monitor #
|
|
||||||
#############################
|
|
||||||
'monitor' : {
|
|
||||||
'category_help' : _("Monitoring functions"),
|
|
||||||
'actions' : {
|
|
||||||
'info': {
|
|
||||||
'action_help' : _("Check System"),
|
|
||||||
'arguments' : {
|
|
||||||
'-m' : {
|
|
||||||
'full' : '--memory',
|
|
||||||
'help' : _("Check Memory"),
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
'-c' : {
|
|
||||||
'full' : '--cpu',
|
|
||||||
'help' : _("Check CPU"),
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
'-d' : {
|
|
||||||
'full' : '--disk',
|
|
||||||
'help' : _("Check Disk"),
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
'-i' : {
|
|
||||||
'full' : '--ifconfig',
|
|
||||||
'help' : _("Ifconfig"),
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
'-u' : {
|
|
||||||
'full' : '--uptime',
|
|
||||||
'help' : _("Show Uptime"),
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
'-p' : {
|
|
||||||
'full' : '--process',
|
|
||||||
'help' : _("Show Process Account"),
|
|
||||||
'action' : 'store_true',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# Firewall #
|
|
||||||
#############################
|
|
||||||
'firewall' : {
|
|
||||||
'category_help' : _("Manage firewall rules"),
|
|
||||||
'actions' : {
|
|
||||||
### 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"),
|
|
||||||
},
|
|
||||||
'protocol' : {
|
|
||||||
'help' : _("Protocol associated with port"),
|
|
||||||
'choices' : ['UDP', 'TCP', 'Both'],
|
|
||||||
},
|
|
||||||
'name' : {
|
|
||||||
'help' : _("Reference name of the rule"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### firewall_disallow()
|
|
||||||
'disallow' : {
|
|
||||||
'action_help' : _("Disallow connection"),
|
|
||||||
'connections' : ['firewall'],
|
|
||||||
'arguments' : {
|
|
||||||
'name' : {
|
|
||||||
'help' : _("Reference name of the rule to delete"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# Firewall #
|
|
||||||
#############################
|
|
||||||
'firewall' : {
|
|
||||||
'category_help' : _("Manage firewall rules"),
|
|
||||||
'actions' : {
|
|
||||||
### 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"),
|
|
||||||
},
|
|
||||||
'protocol' : {
|
|
||||||
'help' : _("Protocol associated with port"),
|
|
||||||
'choices' : ['UDP', 'TCP', 'Both'],
|
|
||||||
},
|
|
||||||
'name' : {
|
|
||||||
'help' : _("Reference name of the rule"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
### firewall_disallow()
|
|
||||||
'disallow' : {
|
|
||||||
'action_help' : _("Disallow connection"),
|
|
||||||
'connections' : ['firewall'],
|
|
||||||
'arguments' : {
|
|
||||||
'name' : {
|
|
||||||
'help' : _("Reference name of the rule to delete"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#############################
|
|
||||||
# Tools #
|
|
||||||
#############################
|
|
||||||
'tools' : {
|
|
||||||
'category_help' : _("Specific tools"),
|
|
||||||
'actions' : {
|
|
||||||
### tools_install()
|
|
||||||
'install' : {
|
|
||||||
'action_help' : _("Install YunoHost LDAP initialization"),
|
|
||||||
'connections' : ['ldap'],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
def parse_dict(action_map):
|
def parse_dict(action_map):
|
||||||
"""
|
"""
|
||||||
|
@ -628,7 +92,7 @@ def parse_dict(action_map):
|
||||||
return parsers['general'].parse_args()
|
return parsers['general'].parse_args()
|
||||||
|
|
||||||
|
|
||||||
def main(action_map):
|
def main():
|
||||||
"""
|
"""
|
||||||
Main instructions
|
Main instructions
|
||||||
|
|
||||||
|
@ -638,7 +102,10 @@ def main(action_map):
|
||||||
Returns:
|
Returns:
|
||||||
int -- 0 or error code
|
int -- 0 or error code
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
with open('action_map.yml') as f:
|
||||||
|
action_map = yaml.load(f)
|
||||||
|
|
||||||
args = parse_dict(action_map)
|
args = parse_dict(action_map)
|
||||||
connections = connect_services(action_map)
|
connections = connect_services(action_map)
|
||||||
|
|
||||||
|
@ -666,4 +133,4 @@ def main(action_map):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main(action_map))
|
sys.exit(main())
|
||||||
|
|
Loading…
Add table
Reference in a new issue