本文整理汇总了Python中neutron_lib.db.utils.resource_fields函数的典型用法代码示例。如果您正苦于以下问题:Python resource_fields函数的具体用法?Python resource_fields怎么用?Python resource_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resource_fields函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_networks
def get_networks(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False):
# if id is not specified in the filter, we just return network data in
# local Neutron server, otherwise id is specified, we need to retrieve
# network data from central Neutron server and create network which
# doesn't exist in local Neutron server.
if not filters or 'id' not in filters:
return self.core_plugin.get_networks(
context, filters, fields, sorts, limit, marker, page_reverse)
b_full_networks = self.core_plugin.get_networks(
context, filters, None, sorts, limit, marker, page_reverse)
b_networks = []
for b_network in b_full_networks:
subnet_ids = self._ensure_subnet(context, b_network, False)
if subnet_ids:
b_network['subnets'] = subnet_ids
b_networks.append(db_utils.resource_fields(b_network, fields))
if len(b_networks) == len(filters['id']):
return b_networks
t_ctx = t_context.get_context_from_neutron_context(context)
if self._skip_non_api_query(t_ctx):
return b_networks
t_ctx.auth_token = client.Client.get_admin_token(context.project_id)
raw_client = self.neutron_handle._get_client(t_ctx)
params = self._construct_params(filters, sorts, limit, marker,
page_reverse)
t_networks = raw_client.list_networks(**params)['networks']
t_id_set = set([network['id'] for network in t_networks])
b_id_set = set([network['id'] for network in b_networks])
missing_id_set = t_id_set - b_id_set
if missing_id_set:
missing_networks = [network for network in t_networks if (
network['id'] in missing_id_set)]
for network in missing_networks:
region_name = self._get_neutron_region()
located = self._is_network_located_in_region(network,
region_name)
if not located:
LOG.error('network: %(net_id)s not located in current '
'region: %(region_name)s, '
'az_hints: %(az_hints)s',
{'net_id': network['id'],
'region_name': region_name,
'az_hints': network[az_def.AZ_HINTS]})
continue
self._adapt_network_body(network)
network.pop('qos_policy_id', None)
b_network = self.core_plugin.create_network(
context, {'network': network})
subnet_ids = self._ensure_subnet(context, network)
if subnet_ids:
b_network['subnets'] = subnet_ids
b_networks.append(db_utils.resource_fields(b_network, fields))
return b_networks
开发者ID:openstack,项目名称:tricircle,代码行数:60,代码来源:local_plugin.py
示例2: inner
def inner(*args, **kwargs):
fields = kwargs.get('fields')
result = f(*args, **kwargs)
if fields is None:
return result
elif isinstance(result, list):
return [db_utils.resource_fields(r, fields) for r in result]
else:
return db_utils.resource_fields(result, fields)
开发者ID:cubeek,项目名称:neutron,代码行数:9,代码来源:pf_plugin.py
示例3: _make_pathport_assoc_dict
def _make_pathport_assoc_dict(self, assoc, fields=None):
res = {'pathnode_id': assoc['pathnode_id'],
'portpair_id': assoc['portpair_id'],
'weight': assoc['weight'],
}
return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:networking-sfc,代码行数:7,代码来源:db.py
示例4: _make_graph_chain_assoc_dict
def _make_graph_chain_assoc_dict(self, assoc_db, fields=None):
res = {
'service_graph_id': assoc_db['service_graph_id'],
'src_chain': assoc_db['src_chain'],
'dst_chain': assoc_db['dst_chain']
}
return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:networking-sfc,代码行数:7,代码来源:sfc_db.py
示例5: _make_flow_classifier_dict
def _make_flow_classifier_dict(self, flow_classifier, fields=None):
res = {
'id': flow_classifier['id'],
'name': flow_classifier['name'],
'description': flow_classifier['description'],
'project_id': flow_classifier['project_id'],
'ethertype': flow_classifier['ethertype'],
'protocol': flow_classifier['protocol'],
'source_port_range_min': flow_classifier['source_port_range_min'],
'source_port_range_max': flow_classifier['source_port_range_max'],
'destination_port_range_min': (
flow_classifier['destination_port_range_min']),
'destination_port_range_max': (
flow_classifier['destination_port_range_max']),
'source_ip_prefix': flow_classifier['source_ip_prefix'],
'destination_ip_prefix': flow_classifier[
'destination_ip_prefix'],
'logical_source_port': flow_classifier['logical_source_port'],
'logical_destination_port': flow_classifier[
'logical_destination_port'],
'l7_parameters': {
param['keyword']: param['value']
for k, param in flow_classifier.l7_parameters.items()
}
}
return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:networking-sfc,代码行数:26,代码来源:flowclassifier_db.py
示例6: _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:igordcard,项目名称:neutron,代码行数:7,代码来源:metering_db.py
示例7: _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:noironetworks,项目名称:neutron,代码行数:7,代码来源:address_scope_db.py
示例8: _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:cubeek,项目名称:neutron,代码行数:7,代码来源:db.py
示例9: 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 flav_exc.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 flav_exc.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 flav_exc.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:openstack,项目名称:neutron,代码行数:35,代码来源:flavors_db.py
示例10: get_network_ip_availabilities
def get_network_ip_availabilities(self, context, filters=None,
fields=None):
"""Returns ip availability data for a collection of networks."""
net_ip_availabilities = super(NetworkIPAvailabilityPlugin,
self).get_network_ip_availabilities(context, filters)
return [db_utils.resource_fields(net_ip_availability, fields)
for net_ip_availability in net_ip_availabilities]
开发者ID:cubeek,项目名称:neutron,代码行数:7,代码来源:plugin.py
示例11: _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:igordcard,项目名称:neutron,代码行数:7,代码来源:metering_db.py
示例12: _make_port_dict
def _make_port_dict(self, port, fields=None,
process_extensions=True):
mac = port["mac_address"]
if isinstance(mac, netaddr.EUI):
mac.dialect = netaddr.mac_unix_expanded
res = {"id": port["id"],
'name': port['name'],
"network_id": port["network_id"],
'tenant_id': port['tenant_id'],
"mac_address": str(mac),
"admin_state_up": port["admin_state_up"],
"status": port["status"],
"fixed_ips": [{'subnet_id': ip["subnet_id"],
'ip_address': ip["ip_address"]}
for ip in port["fixed_ips"]],
"device_id": port["device_id"],
"device_owner": port["device_owner"]}
# Call auxiliary extend functions, if any
if process_extensions:
port_data = port
if isinstance(port, port_obj.Port):
port_data = port.db_obj
resource_extend.apply_funcs(
port_def.COLLECTION_NAME, res, port_data)
return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:neutron,代码行数:25,代码来源:db_base_plugin_common.py
示例13: _make_floatingip_pool_dict
def _make_floatingip_pool_dict(context, subnet, fields=None):
res = {'subnet_id': subnet.id,
'subnet_name': subnet.name,
'tenant_id': context.tenant_id,
'network_id': subnet.network_id,
'cidr': str(subnet.cidr)}
return lib_db_utils.resource_fields(res, fields)
开发者ID:igordcard,项目名称:neutron,代码行数:8,代码来源:l3_fip_pools_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:openstack,项目名称:neutron,代码行数:8,代码来源:flavors_db.py
示例15: get_network_ip_availability
def get_network_ip_availability(self, context, id=None, fields=None):
"""Return ip availability data for a specific network id."""
filters = {'network_id': [id]}
result = self.get_network_ip_availabilities(context, filters)
if result:
return db_utils.resource_fields(result[0], fields)
else:
raise exceptions.NetworkNotFound(net_id=id)
开发者ID:cubeek,项目名称:neutron,代码行数:8,代码来源:plugin.py
示例16: 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:cubeek,项目名称:neutron,代码行数:8,代码来源:provider_configuration.py
示例17: _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:openstack,项目名称:neutron,代码行数:9,代码来源:flavors_db.py
示例18: get_port
def get_port(self, context, id, fields=None):
port = super(NsxDvsV2, self).get_port(context, id, fields=None)
if 'id' in port:
port_model = self._get_port(context, port['id'])
resource_extend.apply_funcs('ports', port, port_model)
self._extend_port_dict_binding(port, port_model)
else:
port[pbin.VIF_TYPE] = nsx_constants.VIF_TYPE_DVS
return db_utils.resource_fields(port, fields)
开发者ID:openstack,项目名称:vmware-nsx,代码行数:9,代码来源:plugin.py
示例19: _make_tap_service_dict
def _make_tap_service_dict(self, tap_service, fields=None):
res = {'id': tap_service['id'],
'tenant_id': tap_service['tenant_id'],
'name': tap_service['name'],
'description': tap_service['description'],
'port_id': tap_service['port_id'],
'status': tap_service['status']}
return db_utils.resource_fields(res, fields)
开发者ID:openstack,项目名称:tap-as-a-service,代码行数:9,代码来源:taas_db.py
示例20: get_trunks
def get_trunks(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False):
ret = []
bottom_top_map = {}
top_bottom_map = {}
t_ctx = t_context.get_context_from_neutron_context(context)
route_filters = [{'key': 'resource_type',
'comparator': 'eq',
'value': t_constants.RT_TRUNK}]
routes = db_api.list_resource_routings(t_ctx, route_filters)
for route in routes:
bottom_top_map[route['bottom_id']] = route['top_id']
top_bottom_map[route['top_id']] = route['bottom_id']
if limit:
if marker:
mappings = db_api.get_bottom_mappings_by_top_id(
t_ctx, marker, t_constants.RT_TRUNK)
# if mapping exists, we retrieve trunk information
# from bottom, otherwise from top
if mappings:
pod_id = mappings[0][0]['pod_id']
current_pod = db_api.get_pod(t_ctx, pod_id)
ret = self._get_trunks_from_pod_with_limit(
context, current_pod, bottom_top_map, top_bottom_map,
filters, limit, marker)
else:
ret = self._get_trunks_from_top_with_limit(
context, top_bottom_map, filters, limit, marker)
else:
current_pod = db_api.get_next_bottom_pod(t_ctx)
# if current_pod exists, we retrieve trunk information
# from bottom, otherwise from top
if current_pod:
ret = self._get_trunks_from_pod_with_limit(
context, current_pod, bottom_top_map, top_bottom_map,
filters, limit, None)
else:
ret = self._get_trunks_from_top_with_limit(
context, top_bottom_map, filters, limit, None)
else:
pods = db_api.list_pods(t_ctx)
_filters = self._transform_trunk_filters(filters, top_bottom_map)
for pod in pods:
if not pod['az_name']:
continue
client = self._get_client(pod['region_name'])
pod_trunks = client.list_trunks(t_ctx, filters=_filters)
ret.extend(pod_trunks)
ret = self._map_trunks_from_bottom_to_top(ret, bottom_top_map)
top_trunks = self._get_trunks_from_top(context,
top_bottom_map, filters)
ret.extend(top_trunks)
return [db_utils.resource_fields(trunk, fields) for trunk in ret]
开发者ID:openstack,项目名称:tricircle,代码行数:56,代码来源:central_trunk_driver.py
注:本文中的neutron_lib.db.utils.resource_fields函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论