more fixes for compatiblity with Havana
This commit is contained in:
parent
9394a5d19d
commit
f95b57423d
@ -28,7 +28,6 @@ from neutron.openstack.common import rpc
|
|||||||
from neutron.plugins.nicira.dhcp_meta import rpc as nvp_rpc
|
from neutron.plugins.nicira.dhcp_meta import rpc as nvp_rpc
|
||||||
from neutron.plugins.nicira.NeutronPlugin import nicira_db
|
from neutron.plugins.nicira.NeutronPlugin import nicira_db
|
||||||
from neutron.plugins.nicira import NeutronPlugin as nvp
|
from neutron.plugins.nicira import NeutronPlugin as nvp
|
||||||
from neutron.plugins.nicira.NeutronPlugin import nvplib
|
|
||||||
|
|
||||||
from akanda.neutron.plugins import decorators as akanda
|
from akanda.neutron.plugins import decorators as akanda
|
||||||
|
|
||||||
@ -39,9 +38,12 @@ akanda.monkey_patch_ipv6_generator()
|
|||||||
def akanda_nvp_ipv6_port_security_wrapper(f):
|
def akanda_nvp_ipv6_port_security_wrapper(f):
|
||||||
@functools.wraps(f)
|
@functools.wraps(f)
|
||||||
def wrapper(lport_obj, mac_address, fixed_ips, port_security_enabled,
|
def wrapper(lport_obj, mac_address, fixed_ips, port_security_enabled,
|
||||||
security_profiles, queue_id):
|
security_profiles, queue_id, mac_learning_enabled,
|
||||||
|
allowed_address_pairs):
|
||||||
|
|
||||||
f(lport_obj, mac_address, fixed_ips, port_security_enabled,
|
f(lport_obj, mac_address, fixed_ips, port_security_enabled,
|
||||||
security_profiles, queue_id)
|
security_profiles, queue_id, mac_learning_enabled,
|
||||||
|
allowed_address_pairs)
|
||||||
|
|
||||||
# evaulate the state so that we only override the value when enabled
|
# evaulate the state so that we only override the value when enabled
|
||||||
# otherwise we are preserving the underlying behavior of the NVP plugin
|
# otherwise we are preserving the underlying behavior of the NVP plugin
|
||||||
@ -49,6 +51,8 @@ def akanda_nvp_ipv6_port_security_wrapper(f):
|
|||||||
# hotfix to enable egress mulitcast
|
# hotfix to enable egress mulitcast
|
||||||
lport_obj['allow_egress_multicast'] = True
|
lport_obj['allow_egress_multicast'] = True
|
||||||
|
|
||||||
|
# TODO(mark): investigate moving away from this an wrapping
|
||||||
|
# (create|update)_port
|
||||||
# add link-local and subnet cidr for IPv6 temp addresses
|
# add link-local and subnet cidr for IPv6 temp addresses
|
||||||
special_ipv6_addrs = akanda.get_special_ipv6_addrs(
|
special_ipv6_addrs = akanda.get_special_ipv6_addrs(
|
||||||
(p['ip_address'] for p in lport_obj['allowed_address_pairs']),
|
(p['ip_address'] for p in lport_obj['allowed_address_pairs']),
|
||||||
@ -144,6 +148,7 @@ class NvpPluginV2(nvp.NvpPluginV2):
|
|||||||
get_floatingip = l3_db.L3_NAT_db_mixin.get_floatingip
|
get_floatingip = l3_db.L3_NAT_db_mixin.get_floatingip
|
||||||
get_floatings = l3_db.L3_NAT_db_mixin.get_floatingips
|
get_floatings = l3_db.L3_NAT_db_mixin.get_floatingips
|
||||||
_update_fip_assoc = l3_db.L3_NAT_db_mixin._update_fip_assoc
|
_update_fip_assoc = l3_db.L3_NAT_db_mixin._update_fip_assoc
|
||||||
|
_update_router_gw_info = l3_db.L3_NAT_db_mixin._update_router_gw_info
|
||||||
disassociate_floatingips = l3_db.L3_NAT_db_mixin.disassociate_floatingips
|
disassociate_floatingips = l3_db.L3_NAT_db_mixin.disassociate_floatingips
|
||||||
|
|
||||||
def _ensure_metadata_host_route(self, *args, **kwargs):
|
def _ensure_metadata_host_route(self, *args, **kwargs):
|
||||||
@ -153,70 +158,56 @@ class NvpPluginV2(nvp.NvpPluginV2):
|
|||||||
def _nvp_create_port(self, context, port_data):
|
def _nvp_create_port(self, context, port_data):
|
||||||
""" Driver for creating a logical switch port on NVP platform """
|
""" Driver for creating a logical switch port on NVP platform """
|
||||||
# NOTE(mark): Akanda does want ports for external networks so
|
# NOTE(mark): Akanda does want ports for external networks so
|
||||||
# this method is basically same with external check removed
|
# this method is basically same with external check removed and
|
||||||
network = self._get_network(context, port_data['network_id'])
|
# the auto plugging of router ports
|
||||||
network_binding = nicira_db.get_network_binding(
|
lport = None
|
||||||
context.session, port_data['network_id'])
|
selected_lswitch = None
|
||||||
max_ports = self.nvp_opts.max_lp_per_overlay_ls
|
|
||||||
allow_extra_lswitches = False
|
|
||||||
if (network_binding and
|
|
||||||
network_binding.binding_type in (NetworkTypes.FLAT,
|
|
||||||
NetworkTypes.VLAN)):
|
|
||||||
max_ports = self.nvp_opts.max_lp_per_bridged_ls
|
|
||||||
allow_extra_lswitches = True
|
|
||||||
try:
|
try:
|
||||||
cluster = self._find_target_cluster(port_data)
|
selected_lswitch = self._nvp_find_lswitch_for_port(context,
|
||||||
selected_lswitch = self._handle_lswitch_selection(
|
port_data)
|
||||||
cluster, network, network_binding, max_ports,
|
lport = self._nvp_create_port_helper(self.cluster,
|
||||||
allow_extra_lswitches)
|
selected_lswitch['uuid'],
|
||||||
lswitch_uuid = selected_lswitch['uuid']
|
port_data,
|
||||||
lport = nvplib.create_lport(cluster,
|
True)
|
||||||
lswitch_uuid,
|
|
||||||
port_data['tenant_id'],
|
|
||||||
port_data['id'],
|
|
||||||
port_data['name'],
|
|
||||||
port_data['device_id'],
|
|
||||||
port_data['admin_state_up'],
|
|
||||||
port_data['mac_address'],
|
|
||||||
port_data['fixed_ips'],
|
|
||||||
port_data[psec.PORTSECURITY],
|
|
||||||
port_data[ext_sg.SECURITYGROUPS])
|
|
||||||
nicira_db.add_neutron_nvp_port_mapping(
|
nicira_db.add_neutron_nvp_port_mapping(
|
||||||
context.session, port_data['id'], lport['uuid'])
|
context.session, port_data['id'], lport['uuid'])
|
||||||
d_owner = port_data['device_owner']
|
|
||||||
|
|
||||||
nvplib.plug_interface(cluster, lswitch_uuid,
|
nvp.nvplib.plug_interface(self.cluster, selected_lswitch['uuid'],
|
||||||
lport['uuid'], "VifAttachment",
|
lport['uuid'], "VifAttachment",
|
||||||
port_data['id'])
|
port_data['id'])
|
||||||
LOG.debug(_("_nvp_create_port completed for port %(port_name)s "
|
|
||||||
"on network %(net_id)s. The new port id is "
|
LOG.debug(_("_nvp_create_port completed for port %(name)s "
|
||||||
"%(port_id)s. NVP port id is %(nvp_port_id)s"),
|
"on network %(network_id)s. The new port id is "
|
||||||
{'port_name': port_data['name'],
|
"%(id)s."), port_data)
|
||||||
'net_id': port_data['network_id'],
|
except (nvp.NvpApiClient.NvpApiException, nvp.q_exc.NeutronException):
|
||||||
'port_id': port_data['id'],
|
self._handle_create_port_exception(
|
||||||
'nvp_port_id': lport['uuid']})
|
context, port_data['id'],
|
||||||
except Exception:
|
selected_lswitch and selected_lswitch['uuid'],
|
||||||
# failed to create port in NVP delete port from neutron_db
|
lport and lport['uuid'])
|
||||||
LOG.exception(_("An exception occured while plugging "
|
|
||||||
"the interface"))
|
|
||||||
raise
|
|
||||||
|
|
||||||
def _nvp_delete_port(self, context, port_data):
|
def _nvp_delete_port(self, context, port_data):
|
||||||
# NOTE(mark): Akanda does want ports for external networks so
|
# NOTE(mark): Akanda does want ports for external networks so
|
||||||
# this method is basically same with external check removed
|
# this method is basically same with external check removed
|
||||||
port = nicira_db.get_nvp_port_id(context.session, port_data['id'])
|
nvp_port_id = self._nvp_get_port_id(context, self.cluster,
|
||||||
if port is None:
|
port_data)
|
||||||
raise q_exc.PortNotFound(port_id=port_data['id'])
|
if not nvp_port_id:
|
||||||
|
LOG.debug(_("Port '%s' was already deleted on NVP platform"), id)
|
||||||
|
return
|
||||||
# TODO(bgh): if this is a bridged network and the lswitch we just got
|
# TODO(bgh): if this is a bridged network and the lswitch we just got
|
||||||
# back will have zero ports after the delete we should garbage collect
|
# back will have zero ports after the delete we should garbage collect
|
||||||
# the lswitch.
|
# the lswitch.
|
||||||
nvplib.delete_port(self.default_cluster,
|
try:
|
||||||
port_data['network_id'],
|
nvp.nvplib.delete_port(self.cluster,
|
||||||
port)
|
port_data['network_id'],
|
||||||
LOG.debug(_("_nvp_delete_port completed for port %(port_id)s "
|
nvp_port_id)
|
||||||
"on network %(net_id)s"),
|
LOG.debug(_("_nvp_delete_port completed for port %(port_id)s "
|
||||||
{'port_id': port_data['id'],
|
"on network %(net_id)s"),
|
||||||
'net_id': port_data['network_id']})
|
{'port_id': port_data['id'],
|
||||||
|
'net_id': port_data['network_id']})
|
||||||
|
|
||||||
|
except q_exc.NotFound:
|
||||||
|
LOG.warning(_("Port %s not found in NVP"), port_data['id'])
|
||||||
|
|
||||||
|
|
||||||
def noop(*args, **kwargs):
|
def noop(*args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user