当前位置: 首页>>代码示例>>Python>>正文


Python api.muranoclient函数代码示例

本文整理汇总了Python中muranodashboard.api.muranoclient函数的典型用法代码示例。如果您正苦于以下问题:Python muranoclient函数的具体用法?Python muranoclient怎么用?Python muranoclient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了muranoclient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

 def delete(self, request, obj_id):
     try:
         api.muranoclient(request).categories.delete(obj_id)
     except exc.HTTPException:
         LOG.exception(_("Unable to delete category"))
         url = reverse("horizon:murano:categories:index")
         exceptions.handle(request, _("Unable to delete category."), redirect=url)
开发者ID:olivierlemasle,项目名称:murano-dashboard,代码行数:7,代码来源:tables.py

示例2: delete

 def delete(self, request, obj_id):
     try:
         api.muranoclient(request).categories.delete(obj_id)
     except exc.HTTPException:
         LOG.exception(_('Unable to delete category'))
         exceptions.handle(request,
                           _('Unable to remove package.'),
                           redirect='horizon:murano:categories:index')
开发者ID:mssumanth,项目名称:murano-dashboard,代码行数:8,代码来源:tables.py

示例3: delete

 def delete(self, request, obj_id):
     try:
         api.muranoclient(request).categories.delete(obj_id)
     except exc.HTTPException:
         msg = _('Unable to delete category')
         LOG.exception(msg)
         url = reverse('horizon:murano:categories:index')
         exceptions.handle(request, msg, redirect=url)
开发者ID:satish-avninetworks,项目名称:murano-dashboard,代码行数:8,代码来源:tables.py

示例4: services_list

def services_list(request, environment_id, environment=None):
    if hasattr(request, 'services') and request.services.has_key(environment_id):
        return request.services[environment_id]

    """Get environment applications.

       This function collects data from Murano API and modifies it only for
       dashboard purposes. Those changes don't impact application
       deployment parameters.
    """
    def strip(msg, to=100):
        return u'%s...' % msg[:to] if len(msg) > to else msg

    services = []
    # need to create new session to see services deployed be other user
    session_id = Session.get(request, environment_id)

    if environment is None:
        get_environment = api.muranoclient(request).environments.get
        environment = get_environment(environment_id, session_id)
    try:
        client = api.muranoclient(request)
        reports = client.environments.last_status(environment_id, session_id)
    except exc.HTTPNotFound:
        LOG.exception(_('Could not retrieve latest status for '
                        'the {0} environment').format(environment_id))
        reports = {}

    for service_item in environment.services or []:
        service_data = service_item
        service_id = service_data['?']['id']

        if service_id in reports and reports[service_id]:
            last_operation = strip(reports[service_id].text)
            time = reports[service_id].updated
        else:
            last_operation = 'Component draft created' \
                if environment.version == 0 else ''
            try:
                time = service_data['updated'][:-7]
            except KeyError:
                time = None

        service_data['environment_id'] = environment_id
        service_data['environment_version'] = environment.version
        service_data['operation'] = last_operation
        service_data['operation_updated'] = time
        if service_data['?'].get('name'):
            service_data['name'] = service_data['?']['name']

        services.append(service_data)

    LOG.debug('Service::List')
    svcs = [utils.Bunch(**service) for service in services]
    request.services = getattr(request, 'services', {})
    request.services[environment_id] = svcs
    return svcs
开发者ID:hybrid-murano,项目名称:murano-mitaka,代码行数:57,代码来源:api.py

示例5: action

 def action(self, request, obj_id):
     try:
         api.muranoclient(request).packages.toggle_active(obj_id)
         LOG.debug("Toggle Active for package {0}.".format(obj_id))
     except exc.HTTPForbidden:
         msg = _("You are not allowed to perform this operation")
         LOG.exception(msg)
         messages.error(request, msg)
         exceptions.handle(request, msg, redirect=reverse("horizon:murano:packages:index"))
开发者ID:olivierlemasle,项目名称:murano-dashboard,代码行数:9,代码来源:tables.py

示例6: get_initial

 def get_initial(self):
     app_id = self.kwargs['app_id']
     package = api.muranoclient(self.request).packages.get(app_id)
     return {
         'package': package,
         'app_id': app_id,
     }
开发者ID:satish-avninetworks,项目名称:murano-dashboard,代码行数:7,代码来源:views.py

示例7: init_usages

    def init_usages(self):
        stored_data = self.storage.extra_data
        step_usages = stored_data.get('step_usages')
        if step_usages is None:
            step_usages = [
                collections.defaultdict(dict)
                for step in self.steps.all
            ]
            stored_data['step_usages'] = step_usages

            environment_id = self.kwargs.get('environment_id')
            environment_id = utils.ensure_python_obj(environment_id)
            if environment_id is not None:
                session_id = env_api.Session.get(self.request, environment_id)
                client = api.muranoclient(self.request)
                all_services = client.environments.get(
                    environment_id, session_id).services
                env_usages = self.aggregate_usages(map(
                    lambda svc: svc['?'].get('resourceUsages', {}),
                    all_services))
            else:
                env_usages = collections.defaultdict(dict)
            step_usages.insert(0, env_usages)

        return step_usages
开发者ID:openstack,项目名称:murano-dashboard,代码行数:25,代码来源:views.py

示例8: update_cell

    def update_cell(self, request, datum, obj_id, cell_name, new_cell_value):
        try:
            if not new_cell_value or new_cell_value.isspace():
                message = _("The environment name field cannot be empty.")
                messages.warning(request, message)
                raise ValueError(message)
            mc = api_utils.muranoclient(request)
            mc.environments.update(datum.id, name=new_cell_value)
        except exc.HTTPConflict:
            message = _("This name is already taken.")
            messages.warning(request, message)
            LOG.warning(_("Couldn't update environment. Reason: ") + message)

            # FIXME(kzaitsev): There is a bug in horizon and inline error
            # icons are missing. This means, that if we return 400 here, by
            # raising django.core.exceptions.ValidationError(message) the UI
            # will break a little. Until the bug is fixed this will raise 500
            # bug link: https://bugs.launchpad.net/horizon/+bug/1359399
            # Alternatively this could somehow raise 409, which would result
            # in the same behaviour.
            raise ValueError(message)
        except Exception:
            exceptions.handle(request, ignore=True)
            return False
        return True
开发者ID:hybrid-murano,项目名称:murano-mitaka,代码行数:25,代码来源:tables.py

示例9: __init__

    def __init__(self, request, *args, **kwargs):
        super(ModifyPackageForm, self).__init__(request, *args, **kwargs)

        package = kwargs['initial']['package']
        self.set_initial(request, package)

        if package.type == 'Application':
            self.fields['categories'] = forms.MultipleChoiceField(
                label=_('Application Category'),
                choices=[('', 'No categories available')],
                required=False)
            try:
                categories = api.muranoclient(request).categories.list()
                if categories:
                    category_names = [(c.name, c.name) for c in categories]
                    self.fields['categories'].choices = category_names
                if package.categories:
                    self.fields['categories'].initial = dict(
                        (key, True) for key in package.categories)
            except (exc.HTTPException, Exception):
                msg = _('Unable to get list of categories')
                LOG.exception(msg)
                redirect = reverse('horizon:app-catalog:packages:index')
                exceptions.handle(request,
                                  msg,
                                  redirect=redirect)
开发者ID:openstack,项目名称:murano-dashboard,代码行数:26,代码来源:forms.py

示例10: post

    def post(self, request, environment, component):
        """Set a metadata object for a component in a given environment

        Example POST:
        http://localhost/api/app-catalog/environments/123/components/456/metadata

        The following get parameters may be passed in the GET
        request:

        :param environment: identifier of the environment
        :param component: identifier of the component

        Any additionally a "session" parameter should be passed through the API
        as a keyword. Request body should contain 'updated' keyword, contain
        all the updated metadata attributes. If it is empty, the metadata is
        considered to be deleted.
        """
        client = api.muranoclient(request)
        filters, keywords = rest_utils.parse_filters_kwargs(request,
                                                            ['session'])
        session = keywords.get('session')
        if not session:
            session = env_api.Session.get_or_create_or_delete(request,
                                                              environment)
        updated = request.DATA.get('updated', {})
        path = '/{0}/%3F/metadata'.format(component)

        if updated:
            client.services.put(environment, path, updated, session)
        else:
            client.services.delete(environment, path, session)
开发者ID:openstack,项目名称:murano-dashboard,代码行数:31,代码来源:environments.py

示例11: get

    def get(self, request, environment, component):
        """Get a metadata object for a component in a given environment

        Example GET:
        http://localhost/api/app-catalog/environments/123/components/456/metadata

        The following get parameters may be passed in the GET
        request:

        :param environment: identifier of the environment
        :param component: identifier of the component

        Any additionally a "session" parameter should be passed through the API
        as a keyword.
        """
        filters, keywords = rest_utils.parse_filters_kwargs(request,
                                                            ['session'])
        session = keywords.get('session')
        if not session:
            session = env_api.Session.get_or_create_or_delete(request,
                                                              environment)
        component = api.muranoclient(request).services.get(
            environment, '/' + component, session)
        if component:
            return component.to_dict()['?'].get('metadata', {})
        return {}
开发者ID:openstack,项目名称:murano-dashboard,代码行数:26,代码来源:environments.py

示例12: handle

 def handle(self, request, data):
     if data:
         with api.handled_exceptions(self.request):
             category = api.muranoclient(self.request).categories.add(data)
         messages.success(request,
                          _('Category {0} created.').format(data['name']))
         return category
开发者ID:mssumanth,项目名称:murano-dashboard,代码行数:7,代码来源:forms.py

示例13: get_deployment_start

def get_deployment_start(request, environment_id, deployment_id):
    deployments = api.muranoclient(request).deployments.list(environment_id)
    LOG.debug('Get deployment start time')
    for deployment in deployments:
        if deployment.id == deployment_id:
            return utils.adjust_datestr(request, deployment.started)
    return None
开发者ID:openstack,项目名称:murano-dashboard,代码行数:7,代码来源:api.py

示例14: cleaned_latest_apps

def cleaned_latest_apps(request):
    """Returns a list of recently used apps

    Verifies, that apps in the list are either public or belong to current
    project.
    """

    cleaned_apps, cleaned_app_ids = [], []
    for app_id in request.session.get('latest_apps', []):
        try:
            # TODO(kzaitsev): we have to update this to 1 request per list of
            # apps. Should be trivial and should remove the need to verify that
            # apps are available. bug/1559066
            app = api.muranoclient(request).packages.get(app_id)
        except exc.HTTPNotFound:
            continue
        else:
            if app.type != 'Application':
                continue
            if (app.owner_id == request.session['token'].project['id'] or
                    app.is_public):
                cleaned_apps.append(app)
                cleaned_app_ids.append(app_id)
    request.session['latest_apps'] = collections.deque(cleaned_app_ids)
    return cleaned_apps
开发者ID:hybrid-murano,项目名称:murano-mitaka,代码行数:25,代码来源:views.py

示例15: get_context_data

    def get_context_data(self, form, **kwargs):
        context = super(Wizard, self).get_context_data(form=form, **kwargs)
        mc = api.muranoclient(self.request)
        app_id = self.kwargs.get('app_id')
        app = self.storage.extra_data.get('app')

        # Save extra data to prevent extra API calls
        if not app:
            app = mc.packages.get(app_id)
            self.storage.extra_data['app'] = app

        environment_id = self.kwargs.get('environment_id')
        environment_id = utils.ensure_python_obj(environment_id)
        if environment_id is not None:
            env_name = mc.environments.get(environment_id).name
        else:
            env_name = get_next_quick_environment_name(self.request)

        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': environment_id,
                        'environment_name': env_name,
                        'do_redirect': self.get_wizard_flag('do_redirect'),
                        'drop_wm_form': self.get_wizard_flag('drop_wm_form'),
                        'prefix': self.prefix,
                        })
        return context
开发者ID:hybrid-murano,项目名称:hybrid-dashboard,代码行数:30,代码来源:views.py


注:本文中的muranodashboard.api.muranoclient函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。