mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Some unit operation setup
This commit is contained in:
parent
6601fb13fc
commit
65d8d88a09
6 changed files with 20 additions and 11 deletions
|
@ -217,6 +217,7 @@
|
|||
"log_app_addaccess": "Add access to '{}'",
|
||||
"log_app_removeaccess": "Remove access to '{}'",
|
||||
"log_app_clearaccess": "Remove all access to '{}'",
|
||||
"log_app_fetchlist": "Add an application list",
|
||||
"log_app_removelist": "Remove an application list",
|
||||
"log_app_change_url": "Change the url of '{}' application",
|
||||
"log_app_install": "Install '{}' application",
|
||||
|
@ -234,6 +235,7 @@
|
|||
"log_letsencrypt_cert_install": "Install Let's encrypt certificate on '{}' domain",
|
||||
"log_selfsigned_cert_install": "Install self signed certificate on '{}' domain",
|
||||
"log_letsencrypt_cert_renew": "Renew '{}' Let's encrypt certificate",
|
||||
"log_service_enable": "Enable '{}' service",
|
||||
"log_service_regen_conf": "Regenerate system configurations '{}'",
|
||||
"log_user_create": "Add '{}' user",
|
||||
"log_user_delete": "Delete '{}' user",
|
||||
|
|
|
@ -44,7 +44,7 @@ from moulinette.utils.log import getActionLogger
|
|||
|
||||
from yunohost.service import service_log, _run_service_command
|
||||
from yunohost.utils import packages
|
||||
from yunohost.log import is_unit_operation
|
||||
from yunohost.log import is_unit_operation, UnitOperation
|
||||
|
||||
logger = getActionLogger('yunohost.app')
|
||||
|
||||
|
@ -110,10 +110,13 @@ def app_fetchlist(url=None, name=None):
|
|||
# the fetch only this list
|
||||
if url is not None:
|
||||
if name:
|
||||
uo = UnitOperation('app_fetchlist')
|
||||
uo.start()
|
||||
_register_new_appslist(url, name)
|
||||
# Refresh the appslists dict
|
||||
appslists = _read_appslist_list()
|
||||
appslists_to_be_fetched = [name]
|
||||
uo.success()
|
||||
else:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('custom_appslist_name_required'))
|
||||
|
@ -622,7 +625,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
|||
|
||||
# Start register change on system
|
||||
related_to = [('app', app_instance_name)]
|
||||
uo = UnitOperation('app_upgrade', related_to, env=env_dict)
|
||||
uo = unitoperation('app_upgrade', related_to, env=env_dict)
|
||||
uo.start()
|
||||
|
||||
# Execute App upgrade script
|
||||
|
@ -950,7 +953,7 @@ def app_addaccess(auth, apps, users=[]):
|
|||
logger.warning(m18n.n('user_unknown', user=allowed_user))
|
||||
continue
|
||||
allowed_users.add(allowed_user)
|
||||
uo.related_to.add(('user', allowed_user))
|
||||
uo.related_to.append(('user', allowed_user))
|
||||
|
||||
uo.flush()
|
||||
new_users = ','.join(allowed_users)
|
||||
|
@ -1010,7 +1013,7 @@ def app_removeaccess(auth, apps, users=[]):
|
|||
else:
|
||||
for allowed_user in user_list(auth)['users'].keys():
|
||||
if allowed_user not in users:
|
||||
allowed_users.add(allowed_user)
|
||||
allowed_users.append(allowed_user)
|
||||
|
||||
uo.related_to += [ ('user', x) for x in allowed_users ]
|
||||
uo.flush()
|
||||
|
|
|
@ -51,6 +51,7 @@ from yunohost.hook import (
|
|||
from yunohost.monitor import binary_to_human
|
||||
from yunohost.tools import tools_postinstall
|
||||
from yunohost.service import service_regen_conf
|
||||
from yunohost.log import UnitOperation, is_unit_operation
|
||||
|
||||
BACKUP_PATH = '/home/yunohost.backup'
|
||||
ARCHIVES_PATH = '%s/archives' % BACKUP_PATH
|
||||
|
@ -1132,7 +1133,7 @@ class RestoreManager():
|
|||
logger.info(m18n.n('restore_running_hooks'))
|
||||
|
||||
env_dict = self._get_env_var()
|
||||
uo.extra.env = env_dict
|
||||
uo.extra['env'] = env_dict
|
||||
uo.flush()
|
||||
ret = hook_callback('restore',
|
||||
system_targets,
|
||||
|
@ -1247,7 +1248,7 @@ class RestoreManager():
|
|||
# Prepare env. var. to pass to script
|
||||
env_dict = self._get_env_var(app_instance_name)
|
||||
|
||||
uo.extra.env = env_dict
|
||||
uo.extra['env'] = env_dict
|
||||
uo.flush()
|
||||
|
||||
# Execute app restore script
|
||||
|
|
|
@ -287,7 +287,7 @@ def _certificate_install_letsencrypt(auth, domain_list, force=False, no_checks=F
|
|||
# Actual install steps
|
||||
for domain in domain_list:
|
||||
|
||||
uo = UnitOperation('letsencrypt_cert_install', [{'domain', domain}],
|
||||
uo = UnitOperation('letsencrypt_cert_install', [{'domain': domain}],
|
||||
args={'force': force, 'no_checks': no_checks,
|
||||
'staging': staging})
|
||||
uo.start()
|
||||
|
@ -388,7 +388,7 @@ def certificate_renew(auth, domain_list, force=False, no_checks=False, email=Fal
|
|||
# Actual renew steps
|
||||
for domain in domain_list:
|
||||
|
||||
uo = UnitOperation('letsencrypt_cert_renew', [{'domain', domain}],
|
||||
uo = UnitOperation('letsencrypt_cert_renew', [{'domain': domain}],
|
||||
args={'force': force, 'no_checks': no_checks,
|
||||
'staging': staging, 'email': email})
|
||||
uo.start()
|
||||
|
|
|
@ -68,7 +68,7 @@ def log_list(category=[], limit=None):
|
|||
|
||||
category_path = os.path.join(CATEGORIES_PATH, category)
|
||||
if not os.path.exists(category_path):
|
||||
logger.warning(m18n.n('log_category_404', category=category))
|
||||
logger.debug(m18n.n('log_category_404', category=category))
|
||||
|
||||
continue
|
||||
|
||||
|
@ -327,7 +327,10 @@ class UnitOperation(object):
|
|||
name = [self.started_at.strftime("%Y%m%d-%H%M%S")]
|
||||
name += [self.operation]
|
||||
if self.related_to:
|
||||
name += [self.related_to[0][1]]
|
||||
if isinstance(self.related_to[0], tuple):
|
||||
name += [self.related_to[0][1]]
|
||||
else:
|
||||
name += self.related_to[0].values()
|
||||
return '-'.join(name)
|
||||
|
||||
@property
|
||||
|
|
|
@ -52,7 +52,7 @@ from yunohost.service import service_status, service_regen_conf, service_log, se
|
|||
from yunohost.monitor import monitor_disk, monitor_system
|
||||
from yunohost.utils.packages import ynh_packages_version
|
||||
from yunohost.utils.network import get_public_ip
|
||||
from yunohost.log import is_unit_operation
|
||||
from yunohost.log import is_unit_operation, UnitOperation
|
||||
|
||||
# FIXME this is a duplicate from apps.py
|
||||
APPS_SETTING_PATH = '/etc/yunohost/apps/'
|
||||
|
|
Loading…
Add table
Reference in a new issue