Esempio n. 1
0
 def delete(self, request, obj_id):
     try:
         api.muranoclient(request).packages.delete(obj_id)
     except exc.HTTPException:
         LOG.exception(_('Unable to delete package in murano-api server'))
         exceptions.handle(request,
                           _('Unable to remove package.'),
                           redirect='horizon:murano:packages:index')
Esempio n. 2
0
    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        app_ids = self.request.session.get('latest_apps', [])
        context['latest_list'] = [self.mappings[app_id] for app_id in app_ids
                                  if app_id in self.mappings]

        categories = []
        with api.handled_exceptions(self.request):
            client = api.muranoclient(self.request)
            categories = client.packages.categories()

        if not ALL_CATEGORY_NAME in categories:
            categories.insert(0, ALL_CATEGORY_NAME)
        current_category = self.kwargs.get('category', categories[0])
        context['categories'] = categories
        context['current_category'] = current_category

        search = self.request.GET.get('search')
        if search:
            context['search'] = search

        context.update(get_environments_context(self.request))

        return context
Esempio n. 3
0
 def handle(self, table, request, obj_ids):
     for obj_id in obj_ids:
         try:
             api.muranoclient(request).packages.toggle_active(obj_id)
         except exc.HTTPException:
             LOG.exception(
                 _('Toggling package state in package '
                   'repository failed'))
             exceptions.handle(request,
                               _('Unable to toggle package state.'))
         else:
             obj = table.get_object_by_id(obj_id)
             obj.enabled = not obj.enabled
             messages.success(
                 request,
                 _("Package '{package}' successfully toggled".format(
                     package=obj.name)))
Esempio n. 4
0
 def build_service_list(self, request, env):
     serv_list = api.muranoclient(request).services.list(env.id)
     LOG.debug('Got Service List: {0}'.format(serv_list))
     ids = {}
     for service in serv_list:
         id_list = self._get_instances_ids(service)
         service_meta_info = getattr(service, '?')
         storage = service_meta_info[consts.DASHBOARD_ATTRS_KEY]
         info = {'name': storage['name'],
                 'type': service_meta_info['type']}
         ids.update(dict((_id, info) for _id in id_list))
     return ids
Esempio n. 5
0
 def get_initial(self):
     app_id = self.kwargs['app_id']
     package = api.muranoclient(self.request).packages.get(app_id)
     return {
         'name': package.name,
         'enabled': package.enabled,
         'description': package.description,
         'categories': package.categories,
         'tags': ','.join(package.tags),
         'is_public': package.is_public,
         'app_id': app_id
     }
Esempio n. 6
0
 def handle(self, request, data):
     app_id = self.initial.get('app_id')
     LOG.debug('Updating package {0} with {1}'.format(app_id, data))
     try:
         data['tags'] = [t.strip() for t in data['tags'].split(',')]
         result = api.muranoclient(request).packages.update(app_id, data)
         messages.success(request, _('Package modified.'))
         return result
     except HTTPException:
         LOG.exception(_('Modifying package failed'))
         redirect = reverse('horizon:murano:packages:index')
         exceptions.handle(request,
                           _('Unable to modify package'),
                           redirect=redirect)
Esempio n. 7
0
    def single(self, data_table, request, app_id):
        try:
            body = api.muranoclient(request).packages.download(app_id)

            content_type = 'application/octet-stream'
            response = HttpResponse(body, content_type=content_type)
            response['Content-Disposition'] = 'filename={name}.package'.format(
                name=self.get_package_name(data_table, app_id))
            return response
        except exc.HTTPException:
            LOG.exception(_('Something went wrong during package downloading'))
            redirect = reverse('horizon:murano:packages:index')
            exceptions.handle(request,
                              _('Unable to download package.'),
                              redirect=redirect)
Esempio n. 8
0
    def get_context_data(self, form, **kwargs):
        context = super(Wizard, self).get_context_data(form=form, **kwargs)
        app_id = self.kwargs.get('app_id')
        app = api.muranoclient(self.request).packages.get(app_id)

        context['field_descriptions'] = services.get_app_field_descriptions(
            self.request, app_id, self.steps.index)
        context.update({'type': app.fully_qualified_name,
                        'service_name': app.name,
                        'app_id': app_id,
                        'environment_id': self.kwargs.get('environment_id'),
                        'do_redirect': self.get_wizard_flag('do_redirect'),
                        'drop_wm_form': self.get_wizard_flag('drop_wm_form'),
                        'prefix': self.prefix,
                        })
        return context
Esempio n. 9
0
    def handle(self, request, data):
        LOG.debug('Uploading package {0}'.format(data))
        try:
            data, files = split_post_data(data)
            package = api.muranoclient(request).packages.create(data, files)

            @views.update_latest_apps
            def _handle(_request, app_id):
                messages.success(_request, _('Package uploaded.'))
                return package

            return _handle(request, app_id=package.id)

        except HTTPException:
            LOG.exception(_('Uploading package failed'))
            redirect = reverse('horizon:murano:packages:index')
            exceptions.handle(request,
                              _('Unable to upload package'),
                              redirect=redirect)
Esempio n. 10
0
    def get_queryset(self):
        category = self.kwargs.get('category', ALL_CATEGORY_NAME)
        query_params = {'type': 'Application'}
        search = self.request.GET.get('search')
        if search:
            query_params['search'] = search
        else:
            if category != ALL_CATEGORY_NAME:
                query_params['category'] = category

        pkgs, self.mappings = [], {}
        with api.handled_exceptions(self.request):
            client = api.muranoclient(self.request)
            pkgs = client.packages.filter(**query_params)

        for pkg in pkgs:
            self.mappings[pkg.id] = pkg

        return pkgs
Esempio n. 11
0
 def get_data(self, **kwargs):
     LOG.debug(('AppDetailsView get_data: {0}'.format(kwargs)))
     app_id = kwargs.get('application_id')
     self.app = api.muranoclient(self.request).packages.get(app_id)
     return self.app
Esempio n. 12
0
 def get_stats_for_env(self, request, environment_id):
     st_list = api.muranoclient(request).instance_statistics.get(
         environment_id)
     return st_list
Esempio n. 13
0
 def get_api_stats(self, request):
     st_list = api.muranoclient(request).request_statistics.list()
     for srv in st_list:
         srv.max_cpu = srv.cpu_count * 100
     return st_list
Esempio n. 14
0
def get_service_name(request, app_id):
    from muranodashboard.environments import api
    app = api.muranoclient(request).packages.get(app_id)
    return app.name
Esempio n. 15
0
 def _get(_request, _app_id):
     return api.muranoclient(_request).packages.get_ui(
         _app_id, make_loader_cls())
Esempio n. 16
0
 def __init__(self, request, **kwargs):
     super(UploadPackageForm, self).__init__(request, **kwargs)
     categories = api.muranoclient(request).packages.categories()
     self.fields['categories'].choices = [(c, c) for c in categories]
Esempio n. 17
0
 def __init__(self, request, *args, **kwargs):
     super(ModifyPackageForm, self).__init__(request, *args, **kwargs)
     category_values = api.muranoclient(request).packages.categories()
     categories = self.fields['categories']
     categories.choices = [(c, c) for c in category_values]
     categories.initial = kwargs.get('initial', {}).get('categories')
Esempio n. 18
0
 def allowed(self, request, image):
     _allowed = False
     with api.handled_exceptions(request):
         client = api.muranoclient(request)
         _allowed = client.packages.categories() is not None
     return _allowed
Esempio n. 19
0
 def _get(_request, _app_id):
     return api.muranoclient(_request).packages.get_logo(_app_id)
Esempio n. 20
0
 def get_data(self):
     pkgs = []
     with api.handled_exceptions(self.request):
         pkgs = api.muranoclient(self.request).packages.filter(
             include_disabled=True, owned=True)
     return pkgs