def _update_apps(self, args): self.log( 'Updating all installed Apps to use the new App Center server') logfile_logger = get_logfile_logger('dev-use-test-appcenter') for app in Apps().get_all_locally_installed_apps(): self.log('Updating %s' % app) register = get_action('register') # we should only use ['component'] in container_mode() # and None otherwise, because it is more correct. however, # this would require credentials (for potential schema updates etc) register.call(apps=[app], register_task=['component']) if app.docker and not container_mode(): try: from univention.appcenter.docker import Docker except ImportError: # should not happen self.log('univention-appcenter-docker is not installed') continue start = get_action('start') start.call(app=app) docker = Docker(app, self.logger) self.log('Updating container... (checking for appbox)') if docker.execute('which', 'univention-app').returncode == 0: self.log( '... setting the new App Center inside the container') returncode = docker.execute( 'univention-install', '-y', 'univention-appcenter-dev', _logger=logfile_logger).returncode if returncode != 0: self.warn( 'univention-install univention-appcenter-dev failed!' ) if args.revert: returncode = docker.execute( 'univention-app', 'dev-use-test-appcenter', '--revert', _logger=logfile_logger).returncode else: returncode = docker.execute( 'univention-app', 'dev-use-test-appcenter', '--appcenter-host', args.appcenter_host, _logger=logfile_logger).returncode if returncode != 0: self.fatal( 'univention-app dev-use-test-appcenter failed!') else: self.log('... nothing to do here')
def get_connector(cls, app): value = app.database if value: if app.docker and container_mode(): database_logger.warn('No database integration within container') return None if value.lower() == 'postgresql': database_logger.debug('%s uses PostgreSQL' % app) return PostgreSQL(app) elif value.lower() == 'mysql': database_logger.debug('%s uses MySQL' % app) return MySQL(app) else: raise DatabaseInfoError('%s wants %r as database. This is unsupported!' % (app, value)) return None
def _register_component(self, app, delay=False): if app.docker and not container_mode(): self.log('Component needs to be registered in the container') return {} if app.without_repository: self.log('No repository to register') return {} updates = {} self.log('Registering component for %s' % app.id) for _app in Apps().get_all_apps_with_id(app.id): if _app == app: updates.update(self._register_component_dict(_app)) else: updates.update(self._unregister_component_dict(_app)) if not delay: with catch_stdout(self.logger): ucr_save(updates) return updates
def _update_local_files(self): self.debug('Updating app files...') if container_mode(): self.debug('do not update files in container mode...') return update_files = { 'inst': lambda x: self._get_joinscript_path(x, unjoin=False), 'schema': lambda x: x.get_share_file('schema'), 'univention-config-registry-variables': lambda x: x.get_share_file('univention-config-registry-variables'), } for app in Apps().get_all_locally_installed_apps(): for file in update_files: src = app.get_cache_file(file) dest = update_files[file](app) if not os.path.exists(src): if app.docker: # remove files that do not exist on server anymore if os.path.exists(dest): self.log('Deleting obsolete app file %s' % dest) os.unlink(dest) else: # update local files if downloaded component_file = '%s.%s' % (app.component_id, file) if component_file not in self._files_downloaded: continue src_md5 = self._files_downloaded[component_file] dest_md5 = None if os.path.exists(dest): dest_md5 = get_md5_from_file(dest) if dest_md5 is None or src_md5 != dest_md5: self.log('Copying %s to %s' % (src, dest)) shutil.copy2(src, dest) if file == 'inst': os.chmod(dest, 0o755) # some variables could change UCR templates # e.g. Name, Description self._update_conffiles()
def is_inside(self, app): # only for Docker Apps (and called from the Docker Host). And not only 'outside' is specified return app.docker and not container_mode() and ('inside' in self.scope or self.scope == [])
def is_outside(self, app): # for Non-Docker Apps, Docker Apps when called from inside, Settings specified for 'outside' return not app.docker or container_mode() or 'outside' in self.scope
def test_install(self, app): return not app.docker or not container_mode()