def version(self, version=None):
     info = get_action('info')
     ret = info.get_compatibility()
     if not info.is_compatible(version):
         raise umcm.UMC_Error(
             'The App Center version of the requesting host is not compatible with the version of %s (%s)'
             % (get_local_fqdn(), ret))
     return ret
예제 #2
0
 def _make_run_args(self, apps, host=None):
     # missing: dry_run: True / False and action: "install"/"upgrade"/"remove"
     host = host or get_local_fqdn()
     return {
         "apps": apps,
         "auto_installed": [],
         "hosts": {
             host: apps
         },
         "settings": {app: {}
                      for app in apps},
     }
예제 #3
0
 def make_args(self, action, app):
     host = get_local_fqdn()
     settings = get_default_values(app)
     return {
         "action": action,
         "auto_installed": [],
         "hosts": {
             host: app
         },
         "apps": [app],
         "dry_run": False,
         "settings": {
             app: settings
         },
     }
 def _get_installations(self, app, hosts, app_ldap_objects):
     ret = {}
     local_ucs_version = ucr_get('version/version')
     for host in hosts:
         candidate = self._find_latest_app_version(app)
         role = host.info.get('serverRole')[0]
         description = host.info.get('description')
         remote_ucs_version = host.info.get('operatingSystemVersion')
         is_local = host.info.get('fqdn') == get_local_fqdn()
         if remote_ucs_version:
             remote_ucs_version = re.sub('.*([0-9]+\.[0-9]+).*', '\\1',
                                         remote_ucs_version)
         ip = host.info.get('ip')  # list
         version = None
         update_available = None
         for app_obj in app_ldap_objects:
             app_obj_version = app_obj.info.get('version')
             app_obj_id = app_obj.info.get('id')[:-len(app_obj_version) - 1]
             if app_obj_id == app.id:
                 if host.info.get('fqdn') in app_obj.info.get('server', []):
                     version = app_obj_version
                     break
         if local_ucs_version != remote_ucs_version:
             # unable to compute directly... better treat as not available
             update_available = False
         elif version:
             remote_app = Apps().find(app.id, app_version=version)
             if remote_app:
                 prevent_docker = None
                 if not is_local:
                     prevent_docker = True
                 candidate = Apps().find_candidate(
                     remote_app,
                     prevent_docker=prevent_docker) or remote_app
                 update_available = remote_app < candidate
         ret[host['name']] = {
             'ucs_version': remote_ucs_version,
             'version': version,
             'update_available': update_available,
             'candidate_version': candidate.version,
             'description': description,
             'ip': ip,
             'role': role,
         }
     return ret
예제 #5
0
 def wait(self, result, app):
     pid = result['id']
     path = 'appcenter/progress'
     data = dict(progress_id=pid)
     waited = 0
     while waited <= 720:
         time.sleep(10)
         waited += 1
         try:
             result = self.umc(path, data)
         except univention.lib.umc.ConnectionError:
             print('... Apache down? Ignoring...')
             continue
         for message in result.get('intermediate', []):
             print('   {msg}'.format(msg=message.get('message')))
         if result.get('finished', False):
             break
     else:
         raise Exception("wait timeout")
     print(result)
     assert result['result'][get_local_fqdn()][app]['success'] is True
 def run(self, progress, apps, auto_installed, action, hosts, settings,
         dry_run):
     localhost = get_local_fqdn()
     ret = {}
     if dry_run:
         for host in hosts:
             _apps = [
                 next(app for app in apps if app.id == _app)
                 for _app in hosts[host]
             ]
             if host == localhost:
                 ret[host] = self._run_local_dry_run(
                     _apps, action, {}, progress)
             else:
                 try:
                     ret[host] = self._run_remote_dry_run(
                         host, _apps, action, auto_installed, {}, progress)
                 except umcm.UMC_Error:
                     ret[host] = {'unreachable': [app.id for app in _apps]}
     else:
         for app in apps:
             for host in hosts:
                 if app.id not in hosts[host]:
                     continue
                 host_result = ret.get(host, {})
                 ret[host] = host_result
                 _settings = {app.id: settings[app.id]}
                 if host == localhost:
                     host_result[app.id] = self._run_local(
                         app, action, _settings, auto_installed, progress)
                 else:
                     host_result[app.id] = self._run_remote(
                         host, app, action, auto_installed, _settings,
                         progress)[app.id]
                 if not host_result[app.id]['success']:
                     break
     return ret