def get_context_data(self, **kwargs): context = super(DetailView, self).get_context_data(**kwargs) assem_id = kwargs['assembly_id'] solum = solumclient(self.request) assem = solum.assemblies.get(assembly_id=assem_id) context["assem"] = assem return context
def handle(self, request, data): LOG.info('CreateLanguagepack %s' % data) solum = solumclient(request) param_data = {} if data['param_file']: inf = data['param_file'].read() param_data = yaml.load(inf) lp_metadata = None if data['lp_metadata']: lp_metadata = json.dumps(json.load(data['lp_metadata'])) try: solum.languagepacks.create(name=data['name'], source_uri=data['source_uri'], lp_metadata=lp_metadata, lp_params=param_data, description=data['description']) message = _( 'Languagepack %s was successfully created.') % data['name'] messages.success(request, message) except Exception: redirect = reverse('horizon:solum:languagepacks:index') exceptions.handle(self.request, _('Unable to create languagepack.'), redirect=redirect) return True
def handle(self, request, data): LOG.info('CreateLanguagepack %s' % data) solum = solumclient(request) param_data = {} if data['param_file']: inf = data['param_file'].read() param_data = yamlutils.load(inf) lp_metadata = None if data['lp_metadata']: lp_metadata = json.dumps(json.load(data['lp_metadata'])) try: solum.languagepacks.create( name=data['name'], source_uri=data['source_uri'], lp_metadata=lp_metadata, lp_params=param_data, description=data['description']) message = _( 'Languagepack %s was successfully created.') % data['name'] messages.success(request, message) except Exception: redirect = reverse('horizon:solum:languagepacks:index') exceptions.handle(self.request, _('Unable to create languagepack.'), redirect=redirect) return True
def get_data(self): try: solum = solumclient(self.request) assemblies = solum.assemblies.list() except Exception: assemblies = [] exceptions.handle(self.request, 'Unable to retrieve assemblies.') return assemblies
def get_data(self): try: solum = solumclient(self.request) apps = solum.apps.list() except Exception: apps = [] exceptions.handle(self.request, _('Unable to retrieve apps.')) return apps
def get_data(self): try: solum = solumclient(self.request) languagepacks = solum.languagepacks.list() except Exception: languagepacks = [] exceptions.handle(self.request, _('Unable to retrieve languagepacks.')) return languagepacks
def handle(self, request, data): to_update = {} for field in data: if data[field] and field != 'application_id': to_update[field] = data[field] solum = solumclient(request) solum.apps.patch(data["application_id"], data=to_update) return True
def __init__(self, request, *args, **kwargs): super(ConfigAssemblyAction, self).__init__(request, *args, **kwargs) if 'application_id' in request.REQUEST: plan_id = request.REQUEST['application_id'] solum = solumclient(request) plan = solum.plans.get(plan_id=plan_id) plan_uri = plan.uri else: plan_uri = request.POST['plan_uri'] self.fields["plan_uri"] = forms.CharField(widget=forms.HiddenInput(), initial=plan_uri)
def handle(self, request, data): app_id = self.initial.get('application_id') LOG.info('ScaleApplication %s' % data) if data["target"] <= 0: exceptions.handle(self.request, _("Scale target must be greater than zero")) solum = solumclient(request) actions = ['scale'] cli_wf.WorkflowManager(solum, app_id=app_id).create(actions=actions) return True
def __init__(self, request, *args, **kwargs): super(ConfigAssemblyAction, self).__init__(request, *args, **kwargs) if 'application_id' in request.REQUEST: plan_id = request.REQUEST['application_id'] solum = solumclient(request) plan = solum.plans.get(plan_id=plan_id) plan_uri = plan.uri else: plan_uri = request.POST['plan_uri'] self.fields["plan_uri"] = forms.CharField( widget=forms.HiddenInput(), initial=plan_uri)
def handle(self, request, data): app_id = self.initial.get('application_id') LOG.info('ScaleApplication %s' % data) if data["target"] <= 0: exceptions.handle(self.request, _("Scale target must be greater than zero")) solum = solumclient(request) actions = ['scale'] cli_wf.WorkflowManager(solum, app_id=app_id).create( actions=actions) return True
def get_context_data(self, request): app_id = self.tab_group.kwargs['application_id'] solum = solumclient(request) app = solum.apps.find(name_or_id=app_id) app.trigger = app.trigger_actions app.workflow = app.workflow_config if app.scale_config: app.target_instances = app.scale_config[app.name].get('target', '') workflowman = cli_wf.WorkflowManager(solum, app_id=app_id) workflows = workflowman.list() return {"application": app, "workflows": workflows}
def handle(self, request, context): LOG.warn('CreateApplication %s' % context) solum = solumclient(request) arti = {} arti['name'] = context.get('name', 'generated_artifact') arti['artifact_type'] = 'application.heroku' arti['content'] = {'href': context['git_url']} arti['language_pack'] = 'auto' plan = {} plan['name'] = context.get('name', 'generated_plan') plan['description'] = context.get('description', None) plan['artifacts'] = [arti] solum.plans.create(json.dumps(plan)) return True
def handle(self, request, context): LOG.warning('CreateApplication %s' % context) solum = solumclient(request) arti = {} arti['name'] = context.get('name', 'generated_artifact') arti['artifact_type'] = 'application.heroku' arti['content'] = {'href': context['git_url']} arti['language_pack'] = 'auto' plan = {} plan['name'] = context.get('name', 'generated_plan') plan['description'] = context.get('description', None) plan['artifacts'] = [arti] solum.plans.create(json.dumps(plan)) return True
def get_context_data(self, **kwargs): context = super(DetailView, self).get_context_data(**kwargs) application_id = self.kwargs['application_id'] app = None try: solum = solumclient(self.request) app = solum.apps.find(name_or_id=application_id) except Exception: INDEX_URL = 'horizon:solum:applications:index' exceptions.handle(self.request, _('Unable to retrieve application details.'), redirect=reverse(INDEX_URL)) context["app"] = app table = app_tables.ApplicationsTable(self.request) context["actions"] = table.render_row_actions(app) return context
def handle(self, request, data): app_id = self.initial.get('application_id') LOG.info('LaunchApplication %s' % data) solum = solumclient(request) if data["du_id"]: actions = ['deploy'] cli_wf.WorkflowManager(solum, app_id=app_id).create(actions=actions, du_id=data["du_id"]) else: actions = ['unittest', 'build', 'deploy'] cli_wf.WorkflowManager(solum, app_id=app_id).create(actions=actions) return True
def handle(self, request, data): app_id = self.initial.get('application_id') LOG.info('LaunchApplication %s' % data) solum = solumclient(request) if data["du_id"]: actions = ['deploy'] cli_wf.WorkflowManager( solum, app_id=app_id).create( actions=actions, du_id=data["du_id"]) else: actions = ['unittest', 'build', 'deploy'] cli_wf.WorkflowManager( solum, app_id=app_id).create( actions=actions) return True
def get_context_data(self, request): app_id = self.tab_group.kwargs['application_id'] solum = solumclient(request) app = solum.apps.find(name_or_id=app_id) workflowman = cli_wf.WorkflowManager(solum, app_id=app_id) workflows = workflowman.list() logs_list = [] for workflow in workflows: revision = workflow.wf_id loglist = workflowman.logs(revision_or_id=revision) for log in loglist: logs_list.append(log) strategy_info = json.loads(log.strategy_info) if log.strategy == 'local': log.local_storage = log.location elif log.strategy == 'swift': log.swift_container = strategy_info['container'] log.swift_path = log.location return {"logs": logs_list, "application": app}
def get_data(self): lp_id = self.kwargs['languagepack_id'] solum = solumclient(self.request) languagepack = None loglist = [] try: languagepack = solum.languagepacks.find(name_or_id=lp_id) loglist = cli_lp.LanguagePackManager(solum).logs(lp_id=lp_id) except Exception: INDEX_URL = 'horizon:solum:languagepacks:index' exceptions.handle(self.request, _('Unable to retrieve languagepack details.'), redirect=reverse(INDEX_URL)) for log in loglist: strategy_info = json.loads(log.strategy_info) if log.strategy == 'local': log.local_storage = log.location elif log.strategy == 'swift': log.swift_container = strategy_info['container'] log.swift_path = log.location return languagepack, loglist
def get_data(self): lp_id = self.kwargs['languagepack_id'] solum = solumclient(self.request) languagepack = None loglist = [] try: languagepack = solum.languagepacks.find(name_or_id=lp_id) loglist = cli_lp.LanguagePackManager(solum).logs( lp_id=lp_id) except Exception: INDEX_URL = 'horizon:solum:languagepacks:index' exceptions.handle(self.request, _('Unable to retrieve languagepack details.'), redirect=reverse(INDEX_URL)) for log in loglist: strategy_info = json.loads(log.strategy_info) if log.strategy == 'local': log.local_storage = log.location elif log.strategy == 'swift': log.swift_container = strategy_info['container'] log.swift_path = log.location return languagepack, loglist
def get_data(self, request, languagepack_id): solum = solumclient(request) return solum.languagepacks.find(name_or_id=languagepack_id)
def delete(self, request, languagepack_id): solum = solumclient(request) solum.languagepacks.delete(lp_id=languagepack_id)
def get_context_data(self, request): assem_id = self.tab_group.kwargs['assembly_id'] solum = solumclient(request) assem = solum.assemblies.get(assembly_id=assem_id) return {"assembly": assem}
def handle(self, request, context): solum = solumclient(request) # Note: solum client seems to ignore description solum.assemblies.create(name=context.get('name'), plan_uri=context.get('plan_uri')) return True
def action(self, request, assembly_id): solum = solumclient(request) solum.assemblies.delete(assembly_id=assembly_id)
def get_data(self): solum = solumclient(self.request) return solum.assemblies.list()
def action(self, request, application_id): solum = solumclient(request) solum.plans.delete(plan_id=application_id)
def _get_object(self, *args, **kwargs): application_id = self.kwargs['application_id'] solum = solumclient(self.request) app = solum.apps.find(name_or_id=application_id) return app
def delete(self, request, application_id): solum = solumclient(request) cli_app.AppManager(solum).delete(app_id=application_id)
def get_data(self): solum = solumclient(self.request) return solum.plans.list()
def get_context_data(self, request): app_id = self.tab_group.kwargs['application_id'] solum = solumclient(request) plan = solum.plans.get(plan_id=app_id) return {"application": plan}
def handle(self, request, data): LOG.info('CreateApplication %s' % data) solum = solumclient(request) app_data = None if data['source'] == 'app_file': inf = data['app_file'].read() app_data = yaml.load(inf) if 'repo_token' not in app_data: app_data['repo_token'] = '' else: app_data = { 'version': 1, 'description': 'default app description', 'source': { 'repository': '', 'revision': 'master', 'repo_token': '' }, 'workflow_config': { 'test_cmd': '', 'run_cmd': '' } } if data['name']: app_data['name'] = data['name'] if data['languagepack']: app_data['languagepack'] = data['languagepack'] if data['git_url']: app_data['source'] = dict() app_data['source']['repository'] = data['git_url'] app_data['source']['revision'] = 'master' if data['run_cmd']: if app_data.get('workflow_config') is None: app_data['workflow_config'] = dict() if not app_data['workflow_config']['run_cmd']: app_data['workflow_config']['run_cmd'] = data['run_cmd'] if data['unittest_cmd']: if app_data.get('workflow_config') is None: app_data['workflow_config'] = dict() if not app_data['workflow_config']['test_cmd']: app_data['workflow_config']['test_cmd'] = data['unittest_cmd'] if not app_data.get('ports'): app_data['ports'] = [] if data['port']: app_data['ports'].append(data['port']) else: app_data['ports'].append(80) if data['param_file']: param_def = data['param_file'].read() app_data['parameters'] = yaml.load(param_def) try: solum.apps.create(**app_data) messages.success(request, _('Application was successfully created.')) return True except Exception: msg = _('Unable to create application.') redirect = reverse("horizon:solum:applications:index") exceptions.handle(request, msg, redirect=redirect) return False
def handle(self, request, data): LOG.info('CreateApplication %s' % data) solum = solumclient(request) app_data = None if data['source'] == 'app_file': inf = data['app_file'].read() app_data = yamlutils.load(inf) if 'repo_token' not in app_data: app_data['repo_token'] = '' else: app_data = { 'version': 1, 'description': 'default app description', 'source': { 'repository': '', 'revision': 'master', 'repo_token': '' }, 'workflow_config': { 'test_cmd': '', 'run_cmd': '' } } if data['name']: app_data['name'] = data['name'] if data['languagepack']: app_data['languagepack'] = data['languagepack'] if data['git_url']: app_data['source'] = dict() app_data['source']['repository'] = data['git_url'] app_data['source']['revision'] = 'master' if data['run_cmd']: if app_data.get('workflow_config') is None: app_data['workflow_config'] = dict() if not app_data['workflow_config']['run_cmd']: app_data['workflow_config']['run_cmd'] = data['run_cmd'] if data['unittest_cmd']: if app_data.get('workflow_config') is None: app_data['workflow_config'] = dict() if not app_data['workflow_config']['test_cmd']: app_data['workflow_config']['test_cmd'] = data['unittest_cmd'] if not app_data.get('ports'): app_data['ports'] = [] if data['port']: app_data['ports'].append(data['port']) else: app_data['ports'].append(80) if data['param_file']: param_def = data['param_file'].read() app_data['parameters'] = yamlutils.load(param_def) try: solum.apps.create(**app_data) messages.success(request, _('Application was successfully created.')) return True except Exception: msg = _('Unable to create application') redirect = reverse("horizon:solum:applications:index") exceptions.handle(request, msg, redirect=redirect) return False