Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
 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
Пример #8
0
 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
Пример #9
0
 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
Пример #10
0
    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
Пример #11
0
    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
Пример #12
0
    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)
Пример #13
0
    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
Пример #14
0
    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)
Пример #15
0
    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
Пример #16
0
    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}
Пример #17
0
    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
Пример #18
0
    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
Пример #19
0
 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
Пример #20
0
 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
Пример #21
0
    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
Пример #22
0
    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
Пример #23
0
    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}
Пример #24
0
    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
Пример #25
0
    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
Пример #26
0
 def get_data(self, request, languagepack_id):
     solum = solumclient(request)
     return solum.languagepacks.find(name_or_id=languagepack_id)
Пример #27
0
 def delete(self, request, languagepack_id):
     solum = solumclient(request)
     solum.languagepacks.delete(lp_id=languagepack_id)
Пример #28
0
 def delete(self, request, languagepack_id):
     solum = solumclient(request)
     solum.languagepacks.delete(lp_id=languagepack_id)
Пример #29
0
 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}
Пример #30
0
 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
Пример #31
0
 def action(self, request, assembly_id):
     solum = solumclient(request)
     solum.assemblies.delete(assembly_id=assembly_id)
Пример #32
0
 def get_data(self):
     solum = solumclient(self.request)
     return solum.assemblies.list()
Пример #33
0
 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}
Пример #34
0
 def get_data(self):
     solum = solumclient(self.request)
     return solum.assemblies.list()
Пример #35
0
 def action(self, request, application_id):
     solum = solumclient(request)
     solum.plans.delete(plan_id=application_id)
Пример #36
0
 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
Пример #37
0
 def action(self, request, assembly_id):
     solum = solumclient(request)
     solum.assemblies.delete(assembly_id=assembly_id)
Пример #38
0
 def delete(self, request, application_id):
     solum = solumclient(request)
     cli_app.AppManager(solum).delete(app_id=application_id)
Пример #39
0
 def get_data(self):
     solum = solumclient(self.request)
     return solum.plans.list()
Пример #40
0
 def action(self, request, application_id):
     solum = solumclient(request)
     solum.plans.delete(plan_id=application_id)
Пример #41
0
 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}
Пример #42
0
 def delete(self, request, application_id):
     solum = solumclient(request)
     cli_app.AppManager(solum).delete(app_id=application_id)
Пример #43
0
 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
Пример #44
0
 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
Пример #45
0
 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}
Пример #46
0
    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
Пример #47
0
    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
Пример #48
0
 def get_data(self, request, languagepack_id):
     solum = solumclient(request)
     return solum.languagepacks.find(name_or_id=languagepack_id)