|
@@ -13,6 +13,7 @@ from api.utils.docker_api import (
|
|
)
|
|
)
|
|
from api.utils.git_api import clone_repo
|
|
from api.utils.git_api import clone_repo
|
|
from api.utils.command import execute
|
|
from api.utils.command import execute
|
|
|
|
+from api.utils.email import send_email
|
|
from api.utils.logger import info
|
|
from api.utils.logger import info
|
|
import os
|
|
import os
|
|
import socket
|
|
import socket
|
|
@@ -205,57 +206,65 @@ def get_odoo_internal_ip(name=None):
|
|
|
|
|
|
return get_internal_ip(name)
|
|
return get_internal_ip(name)
|
|
|
|
|
|
-
|
|
|
|
'''
|
|
'''
|
|
'''
|
|
'''
|
|
-def install_module(system_name=None, module_name=None):
|
|
|
|
|
|
+def install_modules(system_name=None, module_names=[]):
|
|
if not system_name:
|
|
if not system_name:
|
|
- return {'error': 'system name is required'}
|
|
|
|
|
|
+ return {'error': 'system name is required'}
|
|
|
|
|
|
- if not module_name:
|
|
|
|
- return {'error': 'module name is required'}
|
|
|
|
|
|
+ if len(module_names) == 0:
|
|
|
|
+ return {'error': 'module names is required'}
|
|
|
|
|
|
- # 1. check system path
|
|
|
|
|
|
+ # 1. check system path
|
|
system_path = os.path.join(settings.ODOO_ROOT_PATH, system_name)
|
|
system_path = os.path.join(settings.ODOO_ROOT_PATH, system_name)
|
|
|
|
|
|
if not os.path.exists(system_path):
|
|
if not os.path.exists(system_path):
|
|
return {'error': 'system path not exists'}
|
|
return {'error': 'system path not exists'}
|
|
|
|
|
|
- # 2. stop system container
|
|
|
|
- stopped = stop_container(system_name)
|
|
|
|
|
|
+ # # 2. stop system container
|
|
|
|
+ # stopped = stop_container(system_name)
|
|
|
|
|
|
- if not stopped:
|
|
|
|
- return {'error': 'cannot stop system'}
|
|
|
|
|
|
+ # if not stopped:
|
|
|
|
+ # return {'error': 'cannot stop system'}
|
|
|
|
|
|
- # 3. check module path and remove it
|
|
|
|
- module_path = os.path.join(system_path, 'custom-addons', module_name)
|
|
|
|
|
|
+ for module_name in module_names:
|
|
|
|
+ # 3. check module path and remove it
|
|
|
|
+ module_path = os.path.join(system_path, 'custom-addons', module_name)
|
|
|
|
|
|
- if os.path.exists(module_path):
|
|
|
|
- execute(['rm', '-Rf', module_path])
|
|
|
|
|
|
+ if os.path.exists(module_path):
|
|
|
|
+ execute(['rm', '-Rf', module_path])
|
|
|
|
|
|
- # 4. clone repo
|
|
|
|
- cloned = clone_repo(module_name, os.path.join(system_path, 'custom-addons'))
|
|
|
|
|
|
+ # 4. clone repo
|
|
|
|
+ addons_path = os.path.join(system_path, 'custom-addons')
|
|
|
|
+ cloned = clone_repo(module_name, addons_path)
|
|
|
|
|
|
- if not cloned:
|
|
|
|
- return {'error': 'cannot clone repo'}
|
|
|
|
|
|
+ if not cloned:
|
|
|
|
+ return {'error': 'cannot clone repo'}
|
|
|
|
|
|
- # 5. remove git data
|
|
|
|
- git_data_path = os.path.join(module_name, '.git')
|
|
|
|
|
|
+ # 5. remove git data
|
|
|
|
+ git_data_path = os.path.join(module_path, '.git')
|
|
|
|
|
|
- if os.path.exists(git_data_path):
|
|
|
|
- execute(['rm', '-Rf', git_data_path])
|
|
|
|
|
|
+ if os.path.exists(git_data_path):
|
|
|
|
+ execute(['rm', '-Rf', git_data_path])
|
|
|
|
+
|
|
|
|
+ try:
|
|
|
|
+ execute(['chmod', '-R', '777', module_path])
|
|
|
|
+ except Exception:
|
|
|
|
+ pass
|
|
|
|
|
|
- # 6. apply permissions
|
|
|
|
- execute(['chmod', '-Rf', '777', module_path])
|
|
|
|
|
|
+ # # 7. start system container
|
|
|
|
+ # started = start_container(system_name)
|
|
|
|
|
|
- # 7. start system container
|
|
|
|
- started = start_container(system_name)
|
|
|
|
-
|
|
|
|
- if not started:
|
|
|
|
- return {'error': 'cannot start system'}
|
|
|
|
|
|
+ # if not started:
|
|
|
|
+ # return {'error': 'cannot start system'}
|
|
|
|
|
|
return {'result': '%s installed' % module_name}
|
|
return {'result': '%s installed' % module_name}
|
|
|
|
|
|
|
|
+'''
|
|
|
|
+'''
|
|
|
|
+def install_module(system_name=None, module_name=None):
|
|
|
|
+ return install_modules(system_name, [module_name])
|
|
|
|
+
|
|
'''
|
|
'''
|
|
'''
|
|
'''
|
|
def up():
|
|
def up():
|