• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.muranoclient函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: done

    def done(self, form_list, **kwargs):
        data = self.get_all_cleaned_data()
        app_id = self.storage.get_step_data("upload")["package"].id
        # Remove package file from result data
        for key in ("package", "import_type", "url", "repo_version", "repo_name"):
            del data[key]

        dep_pkgs = self.storage.get_step_data("upload").get("dependencies", [])

        redirect = reverse("horizon:murano:packages:index")
        dep_data = {"enabled": data["enabled"], "is_public": data["is_public"]}
        murano_client = api.muranoclient(self.request)
        for dep_pkg in dep_pkgs:
            try:
                murano_client.packages.update(dep_pkg.id, dep_data)
            except Exception as e:
                msg = _("Couldn't update package {0} parameters. Error: {1}").format(dep_pkg.fully_qualified_name, e)
                LOG.warning(msg)
                messages.warning(self.request, msg)

        try:
            data["tags"] = [t.strip() for t in data["tags"].split(",")]
            murano_client.packages.update(app_id, data)
        except exc.HTTPForbidden:
            msg = _("You are not allowed to change" " this properties of the package")
            LOG.exception(msg)
            exceptions.handle(self.request, msg, redirect=reverse("horizon:murano:packages:index"))
        except (exc.HTTPException, Exception):
            LOG.exception(_("Modifying package failed"))
            exceptions.handle(self.request, _("Unable to modify package"), redirect=redirect)
        else:
            msg = _("Package parameters successfully updated.")
            LOG.info(msg)
            messages.success(self.request, msg)
            return http.HttpResponseRedirect(redirect)
开发者ID:mssumanth,项目名称:murano-dashboard,代码行数:35,代码来源:views.py


示例17: package_list

def package_list(request, marker=None, filters=None, paginate=False,
                 page_size=20, sort_dir=None, limit=None):
    limit = limit or getattr(settings, 'PACKAGES_LIMIT', 100)
    filters = filters or {}

    if paginate:
        request_size = page_size + 1
    else:
        request_size = limit

    if marker:
        filters['marker'] = marker
    if sort_dir:
        filters['sort_dir'] = sort_dir

    client = api.muranoclient(request)

    packages_iter = client.packages.filter(limit=request_size,
                                           **filters)

    has_more_data = False
    if paginate:
        packages = list(itertools.islice(packages_iter, request_size))
        if len(packages) > page_size:
            packages.pop()
            has_more_data = True
    else:
        packages = list(packages_iter)

    return packages, has_more_data
开发者ID:openstack,项目名称:murano-dashboard,代码行数:30,代码来源:packages.py


示例18: handle

    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 exc.HTTPForbidden:
            msg = _("You are not allowed to perform this operation")
            LOG.exception(msg)
            exceptions.handle(
                request,
                msg,
                redirect=reverse('horizon:murano:packages:index'))
        except Exception as original_e:
            reason = ''

            exc_info = sys.exc_info()
            if hasattr(original_e, 'details'):
                try:
                    error = json.loads(original_e.details).get('error')
                    if error:
                        reason = error.get('message')
                except ValueError:
                    # Let horizon operate with original exception
                    raise exc_info[0], exc_info[1], exc_info[2]

            msg = _('Failed to upload the package. {0}').format(reason)
            LOG.exception(msg)
            redirect = reverse('horizon:murano:packages:index')
            exceptions.handle(request,
                              _(msg),
                              redirect=redirect)
开发者ID:alexvassel,项目名称:sbrf,代码行数:34,代码来源:forms.py


示例19: __init__

 def __init__(self, request, package, *args, **kwargs):
     super(UpdatePackageForm, self).__init__(*args, **kwargs)
     if package.type == 'Application':
         self.fields['categories'].choices = [('',
                                               'No categories available')]
         try:
             categories = api.muranoclient(request).packages.categories()
             if categories:
                 self.fields['categories'].choices = [(c, c)
                                                      for c in categories]
             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:murano:packages:index')
             exceptions.handle(request,
                               _(msg),
                               redirect=redirect)
     else:
         del self.fields['categories']
     self.fields['name'].initial = package.name
     self.fields['tags'].initial = ', '.join(package.tags)
     self.fields['is_public'].initial = package.is_public
     self.fields['enabled'].initial = package.enabled
     self.fields['description'].initial = package.description
开发者ID:alexvassel,项目名称:sbrf,代码行数:27,代码来源:forms.py


示例20: get_context_data

    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 = self.storage.extra_data.get('app')

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

        env_name = mc.environments.get(self.environment_id).name

        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.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,
                        'got_picture': app.supplier.has_key('Logo'),
                        })
        return context
开发者ID:hybrid-murano,项目名称:murano-mitaka,代码行数:25,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gettextutils._函数代码示例发布时间:2022-05-27
下一篇:
Python gettextutils._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap