"which performs the networking configuration. Note that "
"only one server is needed per deployment, but you may "
"wish to deploy multiple servers to support failover.")),
- cfg.StrOpt('server_auth', default='username:password', secret=True,
+ cfg.StrOpt('server_auth', default=None, secret=True,
help=_("The username and password for authenticating against "
" the BigSwitch or Floodlight controller.")),
cfg.BoolOpt('server_ssl', default=False,
headers['Authorization'] = self.auth
LOG.debug(_("ServerProxy: server=%(server)s, port=%(port)d, "
- "ssl=%(ssl)r, action=%(action)s"),
- {'server': self.server, 'port': self.port, 'ssl': self.ssl,
+ "ssl=%(ssl)r"),
+ {'server': self.server, 'port': self.port, 'ssl': self.ssl})
+ LOG.debug(_("ServerProxy: resource=%(resource)s, action=%(action)s, "
+ "data=%(data)r, headers=%(headers)r"),
+ {'resource': resource, 'data': data, 'headers': headers,
'action': action})
- LOG.debug(_("ServerProxy: resource=%(resource)s, data=%(data)r, "
- "headers=%(headers)r"),
- {'resource': resource, 'data': data, 'headers': headers})
conn = None
if self.ssl:
class ServerPool(object):
- def __init__(self, servers, ssl, auth, neutron_id, timeout=10,
- base_uri='/quantum/v1.0', name='NeutronRestProxy'):
+ def __init__(self, timeout=10,
+ base_uri=BASE_URI, name='NeutronRestProxy'):
+ LOG.debug(_("ServerPool: initializing"))
+ # 'servers' is the list of network controller REST end-points
+ # (used in order specified till one succeeds, and it is sticky
+ # till next failure). Use 'server_auth' to encode api-key
+ servers = cfg.CONF.RESTPROXY.servers
+ self.auth = cfg.CONF.RESTPROXY.server_auth
+ self.ssl = cfg.CONF.RESTPROXY.server_ssl
+ self.neutron_id = cfg.CONF.RESTPROXY.neutron_id
self.base_uri = base_uri
- self.timeout = timeout
self.name = name
- self.auth = auth
- self.ssl = ssl
- self.neutron_id = neutron_id
- self.servers = []
- for server_port in servers:
- self.servers.append(self.server_proxy_for(*server_port))
+ timeout = cfg.CONF.RESTPROXY.server_timeout
+ if timeout is not None:
+ self.timeout = timeout
+
+ # validate config
+ if not servers:
+ raise cfg.Error(_('Servers not defined. Aborting plugin'))
+ if any((len(spl) != 2) for spl in [sp.split(':', 1)
+ for sp in servers.split(',')]):
+ raise cfg.Error(_('Servers must be defined as <ip>:<port>'))
+ self.servers = [
+ self.server_proxy_for(server, int(port))
+ for server, port in (s.rsplit(':', 1) for s in servers.split(','))
+ ]
+ LOG.debug(_("ServerPool: initialization done"))
def server_proxy_for(self, server, port):
return ServerProxy(server, port, self.ssl, self.auth, self.neutron_id,
errstr = _("Unable to update remote network: %s")
self.rest_action('DELETE', resource, errstr=errstr)
- def rest_create_port(self, net, port):
- resource = PORT_RESOURCE_PATH % (net["tenant_id"], net["id"])
+ def rest_create_port(self, tenant_id, net_id, port):
+ resource = ATTACHMENT_PATH % (tenant_id, net_id, port["id"])
data = {"port": port}
+ device_id = port.get("device_id")
+ if not port["mac_address"] or not device_id:
+ # controller only cares about ports attached to devices
+ LOG.warning(_("No device attached to port %s. "
+ "Skipping notification to controller."), port["id"])
+ return
+ data["attachment"] = {"id": device_id,
+ "mac": port["mac_address"]}
errstr = _("Unable to create remote port: %s")
- self.rest_action('POST', resource, data, errstr)
-
- def rest_update_port(self, tenant_id, network_id, port, port_id):
- resource = PORTS_PATH % (tenant_id, network_id, port_id)
- data = {"port": port}
- errstr = _("Unable to update remote port: %s")
self.rest_action('PUT', resource, data, errstr)
def rest_delete_port(self, tenant_id, network_id, port_id):
- resource = PORTS_PATH % (tenant_id, network_id, port_id)
+ resource = ATTACHMENT_PATH % (tenant_id, network_id, port_id)
errstr = _("Unable to delete remote port: %s")
self.rest_action('DELETE', resource, errstr=errstr)
- def rest_plug_interface(self, tenant_id, net_id, port,
- remote_interface_id):
- if port["mac_address"] is not None:
- resource = ATTACHMENT_PATH % (tenant_id, net_id, port["id"])
- data = {"attachment":
- {"id": remote_interface_id,
- "mac": port["mac_address"],
- }
- }
- errstr = _("Unable to plug in interface: %s")
- self.rest_action('PUT', resource, data, errstr)
-
- def rest_unplug_interface(self, tenant_id, net_id, port_id):
- resource = ATTACHMENT_PATH % (tenant_id, net_id, port_id)
- errstr = _("Unable to unplug interface: %s")
- self.rest_action('DELETE', resource, errstr=errstr)
+ def rest_update_port(self, tenant_id, net_id, port):
+ # Controller has no update operation for the port endpoint
+ self.rest_create_port(tenant_id, net_id, port)
class RpcProxy(dhcp_rpc_base.DhcpRpcCallbackMixin):
agents_db.AgentExtRpcCallback()])
-class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2,
- external_net_db.External_net_db_mixin,
- routerrule_db.RouterRule_db_mixin,
+class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
+ external_net_db.External_net_db_mixin,
+ routerrule_db.RouterRule_db_mixin):
+
+ supported_extension_aliases = ["binding"]
+ servers = None
+
+ def __init__(self, server_timeout=None):
+ # This base class is not intended to be instantiated directly.
+ # Extending class should set ServerPool.
+ if not self.servers:
+ LOG.warning(_("ServerPool not set!"))
+
+ def _send_all_data(self, send_ports=True, send_floating_ips=True,
+ send_routers=True):
+ """Pushes all data to network ctrl (networks/ports, ports/attachments).
+
+ This gives the controller an option to re-sync it's persistent store
+ with neutron's current view of that data.
+ """
+ admin_context = qcontext.get_admin_context()
+ networks = []
+
+ all_networks = self.get_networks(admin_context) or []
+ for net in all_networks:
+ mapped_network = self._get_mapped_network_with_subnets(net)
+ flips_n_ports = {}
+ if send_floating_ips:
+ flips_n_ports = self._get_network_with_floatingips(
+ mapped_network)
+
+ if send_ports:
+ ports = []
+ net_filter = {'network_id': [net.get('id')]}
+ net_ports = self.get_ports(admin_context,
+ filters=net_filter) or []
+ for port in net_ports:
+ mapped_port = self._map_state_and_status(port)
+ mapped_port['attachment'] = {
+ 'id': port.get('device_id'),
+ 'mac': port.get('mac_address'),
+ }
+ mapped_port = self._extend_port_dict_binding(admin_context,
+ mapped_port)
+ ports.append(mapped_port)
+ flips_n_ports['ports'] = ports
+
+ if flips_n_ports:
+ networks.append(flips_n_ports)
+
+ resource = '/topology'
+ data = {
+ 'networks': networks,
+ }
+
+ if send_routers:
+ routers = []
+ all_routers = self.get_routers(admin_context) or []
+ for router in all_routers:
+ interfaces = []
+ mapped_router = self._map_state_and_status(router)
+ router_filter = {
+ 'device_owner': ["network:router_interface"],
+ 'device_id': [router.get('id')]
+ }
+ router_ports = self.get_ports(admin_context,
+ filters=router_filter) or []
+ for port in router_ports:
+ net_id = port.get('network_id')
+ subnet_id = port['fixed_ips'][0]['subnet_id']
+ intf_details = self._get_router_intf_details(admin_context,
+ net_id,
+ subnet_id)
+ interfaces.append(intf_details)
+ mapped_router['interfaces'] = interfaces
+
+ routers.append(mapped_router)
+
+ data.update({'routers': routers})
+
+ errstr = _("Unable to update remote topology: %s")
+ return self.servers.rest_action('PUT', resource, data, errstr)
+
+ def _get_network_with_floatingips(self, network, context=None):
+ if context is None:
+ context = qcontext.get_admin_context()
+
+ net_id = network['id']
+ net_filter = {'floating_network_id': [net_id]}
+ fl_ips = self.get_floatingips(context,
+ filters=net_filter) or []
+ network['floatingips'] = fl_ips
+
+ return network
+
+ def _get_all_subnets_json_for_network(self, net_id, context=None):
+ if context is None:
+ context = qcontext.get_admin_context()
+ # start a sub-transaction to avoid breaking parent transactions
+ with context.session.begin(subtransactions=True):
+ subnets = self._get_subnets_by_network(context,
+ net_id)
+ subnets_details = []
+ if subnets:
+ for subnet in subnets:
+ subnet_dict = self._make_subnet_dict(subnet)
+ mapped_subnet = self._map_state_and_status(subnet_dict)
+ subnets_details.append(mapped_subnet)
+
+ return subnets_details
+
+ def _get_mapped_network_with_subnets(self, network, context=None):
+ # if context is not provided, admin context is used
+ if context is None:
+ context = qcontext.get_admin_context()
+ network = self._map_state_and_status(network)
+ subnets = self._get_all_subnets_json_for_network(network['id'],
+ context)
+ network['subnets'] = subnets
+ for subnet in (subnets or []):
+ if subnet['gateway_ip']:
+ # FIX: For backward compatibility with wire protocol
+ network['gateway'] = subnet['gateway_ip']
+ break
+ else:
+ network['gateway'] = ''
+ network[external_net.EXTERNAL] = self._network_is_external(
+ context, network['id'])
+ # include ML2 segmentation types
+ network['segmentation_types'] = getattr(self, "segmentation_types", "")
+ return network
+
+ def _send_create_network(self, network, context=None):
+ tenant_id = network['tenant_id']
+ mapped_network = self._get_mapped_network_with_subnets(network,
+ context)
+ self.servers.rest_create_network(tenant_id, mapped_network)
+
+ def _send_update_network(self, network, context=None):
+ net_id = network['id']
+ tenant_id = network['tenant_id']
+ mapped_network = self._get_mapped_network_with_subnets(network,
+ context)
+ net_fl_ips = self._get_network_with_floatingips(mapped_network,
+ context)
+ self.servers.rest_update_network(tenant_id, net_id, net_fl_ips)
+
+ def _send_delete_network(self, network, context=None):
+ net_id = network['id']
+ tenant_id = network['tenant_id']
+ self.servers.rest_delete_network(tenant_id, net_id)
+
+ def _map_state_and_status(self, resource):
+ resource = copy.copy(resource)
+
+ resource['state'] = ('UP' if resource.pop('admin_state_up',
+ True) else 'DOWN')
+
+ if 'status' in resource:
+ del resource['status']
+
+ return resource
+
+ def _warn_on_state_status(self, resource):
+ if resource.get('admin_state_up', True) is False:
+ LOG.warning(_("Setting admin_state_up=False is not supported "
+ "in this plugin version. Ignoring setting for "
+ "resource: %s"), resource)
+
+ if 'status' in resource:
+ if resource['status'] is not const.NET_STATUS_ACTIVE:
+ LOG.warning(_("Operational status is internally set by the "
+ "plugin. Ignoring setting status=%s."),
+ resource['status'])
+
+ def _get_router_intf_details(self, context, intf_id, subnet_id):
+
+ # we will use the network id as interface's id
+ net_id = intf_id
+ network = self.get_network(context, net_id)
+ subnet = self.get_subnet(context, subnet_id)
+ mapped_network = self._get_mapped_network_with_subnets(network)
+ mapped_subnet = self._map_state_and_status(subnet)
+
+ data = {
+ 'id': intf_id,
+ "network": mapped_network,
+ "subnet": mapped_subnet
+ }
+
+ return data
+
+ def _extend_port_dict_binding(self, context, port):
+ cfg_vif_type = cfg.CONF.NOVA.vif_type.lower()
+ if not cfg_vif_type in (portbindings.VIF_TYPE_OVS,
+ portbindings.VIF_TYPE_IVS):
+ LOG.warning(_("Unrecognized vif_type in configuration "
+ "[%s]. Defaulting to ovs."),
+ cfg_vif_type)
+ cfg_vif_type = portbindings.VIF_TYPE_OVS
+ hostid = porttracker_db.get_port_hostid(context, port['id'])
+ if hostid:
+ port[portbindings.HOST_ID] = hostid
+ override = self._check_hostvif_override(hostid)
+ if override:
+ cfg_vif_type = override
+ port[portbindings.VIF_TYPE] = cfg_vif_type
+
+ port[portbindings.CAPABILITIES] = {
+ portbindings.CAP_PORT_FILTER:
+ 'security-group' in self.supported_extension_aliases}
+ return port
+
+ def _check_hostvif_override(self, hostid):
+ for v in cfg.CONF.NOVA.vif_types:
+ if hostid in getattr(cfg.CONF.NOVA, "node_override_vif_" + v, []):
+ return v
+ return False
+
+
+class NeutronRestProxyV2(NeutronRestProxyV2Base,
extradhcpopt_db.ExtraDhcpOptMixin,
agentschedulers_db.DhcpAgentSchedulerDbMixin):
# Include the BigSwitch Extensions path in the api_extensions
neutron_extensions.append_api_extensions_path(extensions.__path__)
- # 'servers' is the list of network controller REST end-points
- # (used in order specified till one succeeds, and it is sticky
- # till next failure). Use 'server_auth' to encode api-key
- servers = cfg.CONF.RESTPROXY.servers
- server_auth = cfg.CONF.RESTPROXY.server_auth
- server_ssl = cfg.CONF.RESTPROXY.server_ssl
- sync_data = cfg.CONF.RESTPROXY.sync_data
- neutron_id = cfg.CONF.RESTPROXY.neutron_id
self.add_meta_server_route = cfg.CONF.RESTPROXY.add_meta_server_route
- timeout = cfg.CONF.RESTPROXY.server_timeout
- if server_timeout is not None:
- timeout = server_timeout
-
- # validate config
- assert servers is not None, _('Servers not defined. Aborting plugin')
- servers = tuple(s.rsplit(':', 1) for s in servers.split(','))
- servers = tuple((server, int(port)) for server, port in servers)
- assert all(len(s) == 2 for s in servers), SYNTAX_ERROR_MESSAGE
# init network ctrl connections
- self.servers = ServerPool(servers, server_ssl, server_auth, neutron_id,
- timeout, BASE_URI)
+ self.servers = ServerPool(server_timeout, BASE_URI)
# init dhcp support
self.topic = topics.PLUGIN
fanout=False)
# Consume from all consumers in a thread
self.conn.consume_in_thread()
- if sync_data:
+ if cfg.CONF.RESTPROXY.sync_data:
self._send_all_data()
LOG.debug(_("NeutronRestProxyV2: initialization done"))
self._warn_on_state_status(network['network'])
with context.session.begin(subtransactions=True):
- # Validate args
- tenant_id = self._get_tenant_id_for_create(context,
- network["network"])
-
# create network in DB
new_net = super(NeutronRestProxyV2, self).create_network(context,
network)
self._process_l3_create(context, new_net, network['network'])
- mapped_network = self._get_mapped_network_with_subnets(new_net,
- context)
-
# create network on the network controller
- self.servers.rest_create_network(tenant_id, mapped_network)
+ self._send_create_network(new_net, context)
# return created network
return new_net
# Validate args
orig_net = super(NeutronRestProxyV2, self).get_network(context, net_id)
- tenant_id = orig_net["tenant_id"]
filter = {'network_id': [net_id]}
ports = self.get_ports(context, filters=filter)
with context.session.begin(subtransactions=True):
ret_val = super(NeutronRestProxyV2, self).delete_network(context,
net_id)
- self.servers.rest_delete_network(tenant_id, net_id)
+ self._send_delete_network(orig_net, context)
return ret_val
def create_port(self, context, port):
# Update DB in new session so exceptions rollback changes
with context.session.begin(subtransactions=True):
- port["port"]["admin_state_up"] = False
dhcp_opts = port['port'].get(edo_ext.EXTRADHCPOPTS, [])
new_port = super(NeutronRestProxyV2, self).create_port(context,
port)
new_port = self._extend_port_dict_binding(context, new_port)
net = super(NeutronRestProxyV2,
self).get_network(context, new_port["network_id"])
-
if self.add_meta_server_route:
if new_port['device_owner'] == 'network:dhcp':
destination = METADATA_SERVER_IP + '/32'
# create on network ctrl
mapped_port = self._map_state_and_status(new_port)
- self.servers.rest_create_port(net, mapped_port)
-
- # connect device to network, if present
- device_id = port["port"].get("device_id")
- if device_id:
- try:
- self.servers.rest_plug_interface(net["tenant_id"], net["id"],
- new_port, device_id)
- except RemoteRestError:
- with excutils.save_and_reraise_exception():
- port_update = {"port": {"status": "ERROR"}}
- super(NeutronRestProxyV2, self).update_port(
- context,
- new_port["id"],
- port_update
- )
- # Set port state up and return that port
- port_update = {"port": {"admin_state_up": True}}
- new_port = super(NeutronRestProxyV2, self).update_port(context,
- new_port["id"],
- port_update)
- return self._extend_port_dict_binding(context, new_port)
+ self.servers.rest_create_port(net["tenant_id"],
+ new_port["network_id"],
+ mapped_port)
+ return new_port
def get_port(self, context, id, fields=None):
with context.session.begin(subtransactions=True):
self).update_port(context, port_id, port)
self._update_extra_dhcp_opts_on_port(context, port_id, port,
new_port)
+ ctrl_update_required = False
+ old_host_id = porttracker_db.get_port_hostid(context,
+ orig_port['id'])
if (portbindings.HOST_ID in port['port']
and 'id' in new_port):
host_id = port['port'][portbindings.HOST_ID]
porttracker_db.put_port_hostid(context, new_port['id'],
host_id)
- new_port = self._extend_port_dict_binding(context, new_port)
+ if old_host_id != host_id:
+ ctrl_update_required = True
- # update on networl ctrl
- mapped_port = self._map_state_and_status(new_port)
- self.servers.rest_update_port(orig_port["tenant_id"],
- orig_port["network_id"],
- mapped_port, port_id)
+ if (new_port.get("device_id") != orig_port.get("device_id") and
+ orig_port.get("device_id")):
+ ctrl_update_required = True
- if (new_port.get("device_id") != orig_port.get("device_id") and
- orig_port.get("device_id")):
- try:
- self.servers.rest_unplug_interface(orig_port["tenant_id"],
- orig_port["network_id"],
- orig_port["id"])
- device_id = new_port.get("device_id")
- if device_id:
- self.rest_plug_interface(new_port["tenant_id"],
- new_port["network_id"],
- new_port, device_id)
-
- except RemoteRestError:
- with excutils.save_and_reraise_exception():
- port_update = {"port": {"status": "ERROR"}}
- super(NeutronRestProxyV2, self).update_port(
- context,
- new_port["id"],
- port_update
- )
+ if ctrl_update_required:
+ new_port = self._extend_port_dict_binding(context, new_port)
+ mapped_port = self._map_state_and_status(new_port)
+ self.servers.rest_update_port(new_port["tenant_id"],
+ new_port["network_id"],
+ mapped_port)
# return new_port
return new_port
self.prevent_l3_port_deletion(context, port_id)
with context.session.begin(subtransactions=True):
self.disassociate_floatingips(context, port_id)
- self._unplug_port(context, port_id)
- # Separate transaction for delete in case unplug passes
- # but delete fails on controller
- with context.session.begin(subtransactions=True):
super(NeutronRestProxyV2, self).delete_port(context, port_id)
- def _unplug_port(self, context, port_id):
- port = super(NeutronRestProxyV2, self).get_port(context, port_id)
- tenant_id = port['tenant_id']
- net_id = port['network_id']
- if tenant_id == '':
- net = super(NeutronRestProxyV2, self).get_network(context, net_id)
- tenant_id = net['tenant_id']
- if port.get("device_id"):
- self.servers.rest_unplug_interface(tenant_id, net_id, port_id)
- # Port should transition to error state now that it's unplugged
- # but not yet deleted
- port_update = {"port": {"status": "ERROR"}}
- super(NeutronRestProxyV2, self).update_port(context,
- port_id,
- port_update)
-
def _delete_port(self, context, port_id):
port = super(NeutronRestProxyV2, self).get_port(context, port_id)
tenant_id = port['tenant_id']
# networks are detected, which isn't supported by the Plugin
LOG.error(_("NeutronRestProxyV2: too many external networks"))
- def _send_all_data(self):
- """Pushes all data to network ctrl (networks/ports, ports/attachments).
-
- This gives the controller an option to re-sync it's persistent store
- with neutron's current view of that data.
- """
- admin_context = qcontext.get_admin_context()
- networks = []
- routers = []
-
- all_networks = super(NeutronRestProxyV2,
- self).get_networks(admin_context) or []
- for net in all_networks:
- mapped_network = self._get_mapped_network_with_subnets(net)
- net_fl_ips = self._get_network_with_floatingips(mapped_network)
-
- ports = []
- net_filter = {'network_id': [net.get('id')]}
- net_ports = super(NeutronRestProxyV2,
- self).get_ports(admin_context,
- filters=net_filter) or []
- for port in net_ports:
- mapped_port = self._map_state_and_status(port)
- mapped_port['attachment'] = {
- 'id': port.get('device_id'),
- 'mac': port.get('mac_address'),
- }
- ports.append(mapped_port)
- net_fl_ips['ports'] = ports
-
- networks.append(net_fl_ips)
-
- all_routers = super(NeutronRestProxyV2,
- self).get_routers(admin_context) or []
- for router in all_routers:
- interfaces = []
- mapped_router = self._map_state_and_status(router)
- router_filter = {
- 'device_owner': ["network:router_interface"],
- 'device_id': [router.get('id')]
- }
- router_ports = super(NeutronRestProxyV2,
- self).get_ports(admin_context,
- filters=router_filter) or []
- for port in router_ports:
- net_id = port.get('network_id')
- subnet_id = port['fixed_ips'][0]['subnet_id']
- intf_details = self._get_router_intf_details(admin_context,
- net_id,
- subnet_id)
- interfaces.append(intf_details)
- mapped_router['interfaces'] = interfaces
-
- routers.append(mapped_router)
-
- resource = '/topology'
- data = {
- 'networks': networks,
- 'routers': routers,
- }
- errstr = _("Unable to update remote topology: %s")
- return self.servers.rest_action('PUT', resource, data, errstr)
-
def _add_host_route(self, context, destination, port):
subnet = {}
for fixed_ip in port['fixed_ips']:
LOG.debug(_("Adding host route: "))
LOG.debug(_("Destination:%(dst)s nexthop:%(next)s"),
{'dst': destination, 'next': nexthop})
-
- def _get_network_with_floatingips(self, network, context=None):
- if context is None:
- context = qcontext.get_admin_context()
-
- net_id = network['id']
- net_filter = {'floating_network_id': [net_id]}
- fl_ips = super(NeutronRestProxyV2,
- self).get_floatingips(context,
- filters=net_filter) or []
- network['floatingips'] = fl_ips
-
- return network
-
- def _get_all_subnets_json_for_network(self, net_id, context=None):
- if context is None:
- context = qcontext.get_admin_context()
- # start a sub-transaction to avoid breaking parent transactions
- with context.session.begin(subtransactions=True):
- subnets = self._get_subnets_by_network(context,
- net_id)
- subnets_details = []
- if subnets:
- for subnet in subnets:
- subnet_dict = self._make_subnet_dict(subnet)
- mapped_subnet = self._map_state_and_status(subnet_dict)
- subnets_details.append(mapped_subnet)
-
- return subnets_details
-
- def _get_mapped_network_with_subnets(self, network, context=None):
- # if context is not provided, admin context is used
- if context is None:
- context = qcontext.get_admin_context()
- network = self._map_state_and_status(network)
- subnets = self._get_all_subnets_json_for_network(network['id'],
- context)
- network['subnets'] = subnets
- for subnet in (subnets or []):
- if subnet['gateway_ip']:
- # FIX: For backward compatibility with wire protocol
- network['gateway'] = subnet['gateway_ip']
- break
- else:
- network['gateway'] = ''
- network[external_net.EXTERNAL] = self._network_is_external(
- context, network['id'])
-
- return network
-
- def _send_update_network(self, network, context):
- net_id = network['id']
- tenant_id = network['tenant_id']
- # update network on network controller
- mapped_network = self._get_mapped_network_with_subnets(network,
- context)
- net_fl_ips = self._get_network_with_floatingips(mapped_network,
- context)
- self.servers.rest_update_network(tenant_id, net_id, net_fl_ips)
-
- def _map_state_and_status(self, resource):
- resource = copy.copy(resource)
-
- resource['state'] = ('UP' if resource.pop('admin_state_up',
- True) else 'DOWN')
-
- if 'status' in resource:
- del resource['status']
-
- return resource
-
- def _warn_on_state_status(self, resource):
- if resource.get('admin_state_up', True) is False:
- LOG.warning(_("Setting admin_state_up=False is not supported"
- " in this plugin version. Ignoring setting for "
- "resource: %s"), resource)
-
- if 'status' in resource:
- if resource['status'] is not const.NET_STATUS_ACTIVE:
- LOG.warning(_("Operational status is internally set by the"
- " plugin. Ignoring setting status=%s."),
- resource['status'])
-
- def _get_router_intf_details(self, context, intf_id, subnet_id):
-
- # we will use the network id as interface's id
- net_id = intf_id
- network = super(NeutronRestProxyV2, self).get_network(context,
- net_id)
- subnet = super(NeutronRestProxyV2, self).get_subnet(context,
- subnet_id)
- mapped_network = self._get_mapped_network_with_subnets(network)
- mapped_subnet = self._map_state_and_status(subnet)
-
- data = {
- 'id': intf_id,
- "network": mapped_network,
- "subnet": mapped_subnet
- }
-
- return data
-
- def _extend_port_dict_binding(self, context, port):
- cfg_vif_type = cfg.CONF.NOVA.vif_type.lower()
- if not cfg_vif_type in (portbindings.VIF_TYPE_OVS,
- portbindings.VIF_TYPE_IVS):
- LOG.warning(_("Unrecognized vif_type in configuration "
- "[%s]. Defaulting to ovs. "),
- cfg_vif_type)
- cfg_vif_type = portbindings.VIF_TYPE_OVS
- hostid = porttracker_db.get_port_hostid(context,
- port['id'])
- if hostid:
- override = self._check_hostvif_override(hostid)
- if override:
- cfg_vif_type = override
- port[portbindings.VIF_TYPE] = cfg_vif_type
-
- port[portbindings.CAPABILITIES] = {
- portbindings.CAP_PORT_FILTER:
- 'security-group' in self.supported_extension_aliases}
- return port
-
- def _check_hostvif_override(self, hostid):
- for v in cfg.CONF.NOVA.vif_types:
- if hostid in getattr(cfg.CONF.NOVA, "node_override_vif_" + v, []):
- return v
- return False