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

Python _utils.resource_fields函数代码示例

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

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



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

示例1: get_flavor_next_provider

    def get_flavor_next_provider(
        self, context, flavor_id, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False
    ):
        """From flavor, choose service profile and find provider for driver."""

        with db_api.context_manager.reader.using(context):
            bind_qry = context.session.query(flavor_models.FlavorServiceProfileBinding)
            binding = bind_qry.filter_by(flavor_id=flavor_id).first()
            if not binding:
                raise ext_flavors.FlavorServiceProfileBindingNotFound(sp_id="", fl_id=flavor_id)

        # Get the service profile from the first binding
        # TODO(jwarendt) Should become a scheduling framework instead
        sp_db = self._get_service_profile(context, binding["service_profile_id"])

        if not sp_db.enabled:
            raise ext_flavors.ServiceProfileDisabled()

        LOG.debug("Found driver %s.", sp_db.driver)

        service_type_manager = sdb.ServiceTypeManager.get_instance()
        providers = service_type_manager.get_service_providers(context, filters={"driver": sp_db.driver})

        if not providers:
            raise ext_flavors.ServiceProfileDriverNotFound(driver=sp_db.driver)

        LOG.debug("Found providers %s.", providers)

        res = {"driver": sp_db.driver, "provider": providers[0].get("name")}

        return [db_utils.resource_fields(res, fields)]
开发者ID:openstack,项目名称:neutron,代码行数:31,代码来源:flavors_db.py


示例2: _response

 def _response(network_id, tenant_id, fields=None):
     """Build response for auto-allocated network."""
     res = {
         'id': network_id,
         'tenant_id': tenant_id
     }
     return db_utils.resource_fields(res, fields)
开发者ID:eayunstack,项目名称:neutron,代码行数:7,代码来源:db.py


示例3: _make_metering_label_rule_dict

 def _make_metering_label_rule_dict(metering_label_rule, fields=None):
     res = {'id': metering_label_rule['id'],
            'metering_label_id': metering_label_rule['metering_label_id'],
            'direction': metering_label_rule['direction'],
            'remote_ip_prefix': metering_label_rule['remote_ip_prefix'],
            'excluded': metering_label_rule['excluded']}
     return db_utils.resource_fields(res, fields)
开发者ID:mmalchuk,项目名称:openstack-neutron,代码行数:7,代码来源:metering_db.py


示例4: _make_metering_label_dict

 def _make_metering_label_dict(metering_label, fields=None):
     res = {'id': metering_label['id'],
            'name': metering_label['name'],
            'description': metering_label['description'],
            'shared': metering_label['shared'],
            'tenant_id': metering_label['tenant_id']}
     return db_utils.resource_fields(res, fields)
开发者ID:mmalchuk,项目名称:openstack-neutron,代码行数:7,代码来源:metering_db.py


示例5: _make_subnet_dict

 def _make_subnet_dict(self, subnet, fields=None, context=None):
     res = {'id': subnet['id'],
            'name': subnet['name'],
            'tenant_id': subnet['tenant_id'],
            'network_id': subnet['network_id'],
            'ip_version': subnet['ip_version'],
            'cidr': subnet['cidr'],
            'subnetpool_id': subnet.get('subnetpool_id'),
            'allocation_pools': [{'start': pool['first_ip'],
                                  'end': pool['last_ip']}
                                 for pool in subnet['allocation_pools']],
            'gateway_ip': subnet['gateway_ip'],
            'enable_dhcp': subnet['enable_dhcp'],
            'ipv6_ra_mode': subnet['ipv6_ra_mode'],
            'ipv6_address_mode': subnet['ipv6_address_mode'],
            'dns_nameservers': [dns['address']
                                for dns in subnet['dns_nameservers']],
            'host_routes': [{'destination': route['destination'],
                             'nexthop': route['nexthop']}
                            for route in subnet['routes']],
            }
     # The shared attribute for a subnet is the same as its parent network
     res['shared'] = self._is_network_shared(context, subnet.networks)
     # Call auxiliary extend functions, if any
     self._apply_dict_extend_functions(attributes.SUBNETS, res, subnet)
     return db_utils.resource_fields(res, fields)
开发者ID:cloudbase,项目名称:neutron,代码行数:26,代码来源:db_base_plugin_common.py


示例6: get_flavor_next_provider

    def get_flavor_next_provider(
        self, context, flavor_id, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False
    ):
        """From flavor, choose service profile and find provider for driver."""

        objs = obj_flavor.FlavorServiceProfileBinding.get_objects(context, flavor_id=flavor_id)
        if not objs:
            raise ext_flavors.FlavorServiceProfileBindingNotFound(sp_id="", fl_id=flavor_id)
        # Get the service profile from the first binding
        # TODO(jwarendt) Should become a scheduling framework instead
        sp_obj = self._get_service_profile(context, objs[0].service_profile_id)

        if not sp_obj.enabled:
            raise ext_flavors.ServiceProfileDisabled()

        LOG.debug("Found driver %s.", sp_obj.driver)

        service_type_manager = sdb.ServiceTypeManager.get_instance()
        providers = service_type_manager.get_service_providers(context, filters={"driver": sp_obj.driver})

        if not providers:
            raise ext_flavors.ServiceProfileDriverNotFound(driver=sp_obj.driver)

        LOG.debug("Found providers %s.", providers)

        res = {"driver": sp_obj.driver, "provider": providers[0].get("name")}

        return [db_utils.resource_fields(res, fields)]
开发者ID:noironetworks,项目名称:neutron,代码行数:28,代码来源:flavors_db.py


示例7: get_flavor_service_profile

 def get_flavor_service_profile(context, service_profile_id, flavor_id, fields=None):
     if not obj_flavor.FlavorServiceProfileBinding.objects_exist(
         context, service_profile_id=service_profile_id, flavor_id=flavor_id
     ):
         raise ext_flavors.FlavorServiceProfileBindingNotFound(sp_id=service_profile_id, fl_id=flavor_id)
     res = {"service_profile_id": service_profile_id, "flavor_id": flavor_id}
     return db_utils.resource_fields(res, fields)
开发者ID:noironetworks,项目名称:neutron,代码行数:7,代码来源:flavors_db.py


示例8: _make_address_scope_dict

 def _make_address_scope_dict(address_scope, fields=None):
     res = {'id': address_scope['id'],
            'name': address_scope['name'],
            'tenant_id': address_scope['tenant_id'],
            'shared': address_scope['shared'],
            'ip_version': address_scope['ip_version']}
     return db_utils.resource_fields(res, fields)
开发者ID:eayunstack,项目名称:neutron,代码行数:7,代码来源:address_scope_db.py


示例9: _make_networks_dict

    def _make_networks_dict(self, networks, context):
        nets = []
        for network in networks:
            if network.mtu is None:
                # TODO(ivar): also refactor this to run for bulk networks
                network.mtu = self._get_network_mtu(network, validate=False)
            res = {'id': network['id'],
                   'name': network['name'],
                   'tenant_id': network['tenant_id'],
                   'admin_state_up': network['admin_state_up'],
                   'mtu': network.get('mtu', n_const.DEFAULT_NETWORK_MTU),
                   'status': network['status'],
                   'subnets': [subnet['id']
                               for subnet in network['subnets']]}
            res['shared'] = self._is_network_shared(context,
                                                    network.rbac_entries)
            nets.append((res, network))

        # Bulk extend first
        resource_extend.apply_funcs(net_def.COLLECTION_NAME + '_BULK', nets,
                                    None)

        result = []
        for res, network in nets:
            res[api_plus.BULK_EXTENDED] = True
            resource_extend.apply_funcs(net_def.COLLECTION_NAME, res, network)
            res.pop(api_plus.BULK_EXTENDED, None)
            result.append(db_utils.resource_fields(res, []))
        return result
开发者ID:openstack,项目名称:group-based-policy,代码行数:29,代码来源:plugin.py


示例10: _make_service_profile_dict

 def _make_service_profile_dict(sp_obj, fields=None):
     res = {'id': sp_obj['id'],
            'description': sp_obj['description'],
            'driver': sp_obj['driver'],
            'enabled': sp_obj['enabled'],
            'metainfo': sp_obj['metainfo'],
            'flavors': list(sp_obj['flavor_ids'])}
     return db_utils.resource_fields(res, fields)
开发者ID:eayunstack,项目名称:neutron,代码行数:8,代码来源:flavors_db.py


示例11: get_service_providers

 def get_service_providers(self, filters=None, fields=None):
     return [db_utils.resource_fields({'service_type': k[0],
                                       'name': k[1],
                                       'driver': v['driver'],
                                       'default': v['default']},
                                      fields)
             for k, v in self.providers.items()
             if self._check_entry(k, v, filters)]
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:8,代码来源:provider_configuration.py


示例12: _make_flavor_dict

    def _make_flavor_dict(flavor_obj, fields=None):
        res = {'id': flavor_obj['id'],
               'name': flavor_obj['name'],
               'description': flavor_obj['description'],
               'service_type': flavor_obj['service_type'],
               'enabled': flavor_obj['enabled'],
               'service_profiles': list(flavor_obj['service_profile_ids'])}

        return db_utils.resource_fields(res, fields)
开发者ID:eayunstack,项目名称:neutron,代码行数:9,代码来源:flavors_db.py


示例13: _make_security_group_dict

 def _make_security_group_dict(self, security_group, fields=None):
     res = {'id': security_group['id'],
            'name': security_group['name'],
            'tenant_id': security_group['tenant_id'],
            'description': security_group['description']}
     res['security_group_rules'] = [self._make_security_group_rule_dict(r)
                                    for r in security_group.rules]
     self._apply_dict_extend_functions(ext_sg.SECURITYGROUPS, res,
                                       security_group)
     return db_utils.resource_fields(res, fields)
开发者ID:cloudbase,项目名称:neutron,代码行数:10,代码来源:securitygroups_db.py


示例14: _make_service_profile_dict

 def _make_service_profile_dict(sp_obj, fields=None):
     res = {
         "id": sp_obj["id"],
         "description": sp_obj["description"],
         "driver": sp_obj["driver"],
         "enabled": sp_obj["enabled"],
         "metainfo": sp_obj["metainfo"],
         "flavors": list(sp_obj["flavor_ids"]),
     }
     return db_utils.resource_fields(res, fields)
开发者ID:noironetworks,项目名称:neutron,代码行数:10,代码来源:flavors_db.py


示例15: _make_flavor_dict

    def _make_flavor_dict(flavor_obj, fields=None):
        res = {
            "id": flavor_obj["id"],
            "name": flavor_obj["name"],
            "description": flavor_obj["description"],
            "service_type": flavor_obj["service_type"],
            "enabled": flavor_obj["enabled"],
            "service_profiles": list(flavor_obj["service_profile_ids"]),
        }

        return db_utils.resource_fields(res, fields)
开发者ID:noironetworks,项目名称:neutron,代码行数:11,代码来源:flavors_db.py


示例16: get_networks

    def get_networks(self, context, filters=None, fields=None,
                     sorts=None, limit=None, marker=None, page_reverse=False):
        with db_api.context_manager.writer.using(context):
            nets_db = super(Ml2PlusPlugin, self)._get_networks(
                context, filters, None, sorts, limit, marker, page_reverse)

            net_data = self._make_networks_dict(nets_db, context)

            self.type_manager.extend_networks_dict_provider(context, net_data)
            nets = self._filter_nets_provider(context, net_data, filters)
        return [db_utils.resource_fields(net, fields) for net in nets]
开发者ID:openstack,项目名称:group-based-policy,代码行数:11,代码来源:plugin.py


示例17: _make_service_profile_dict

 def _make_service_profile_dict(sp_db, fields=None):
     res = {
         "id": sp_db["id"],
         "description": sp_db["description"],
         "driver": sp_db["driver"],
         "enabled": sp_db["enabled"],
         "metainfo": sp_db["metainfo"],
     }
     if sp_db.flavors:
         res["flavors"] = [fl["flavor_id"] for fl in sp_db.flavors]
     return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:neutron,代码行数:11,代码来源:flavors_db.py


示例18: _make_segment_dict

 def _make_segment_dict(segment_obj, fields=None):
     res = {'id': segment_obj['id'],
            'network_id': segment_obj['network_id'],
            'name': segment_obj['name'],
            'description': segment_obj['description'],
            db.PHYSICAL_NETWORK: segment_obj[db.PHYSICAL_NETWORK],
            db.NETWORK_TYPE: segment_obj[db.NETWORK_TYPE],
            db.SEGMENTATION_ID: segment_obj[db.SEGMENTATION_ID],
            'hosts': segment_obj['hosts'],
            'segment_index': segment_obj['segment_index']}
     return db_utils.resource_fields(res, fields)
开发者ID:eayunstack,项目名称:neutron,代码行数:11,代码来源:db.py


示例19: get_flavor_service_profile

 def get_flavor_service_profile(context, service_profile_id, flavor_id, fields=None):
     with db_api.context_manager.reader.using(context):
         binding = (
             context.session.query(flavor_models.FlavorServiceProfileBinding)
             .filter_by(service_profile_id=service_profile_id, flavor_id=flavor_id)
             .first()
         )
         if not binding:
             raise ext_flavors.FlavorServiceProfileBindingNotFound(sp_id=service_profile_id, fl_id=flavor_id)
     res = {"service_profile_id": service_profile_id, "flavor_id": flavor_id}
     return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:neutron,代码行数:11,代码来源:flavors_db.py


示例20: _make_flavor_dict

 def _make_flavor_dict(flavor_db, fields=None):
     res = {
         "id": flavor_db["id"],
         "name": flavor_db["name"],
         "description": flavor_db["description"],
         "service_type": flavor_db["service_type"],
         "enabled": flavor_db["enabled"],
         "service_profiles": [],
     }
     if flavor_db.service_profiles:
         res["service_profiles"] = [sp["service_profile_id"] for sp in flavor_db.service_profiles]
     return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:neutron,代码行数:12,代码来源:flavors_db.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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