:param db_session: database session
:param network_id: UUID representing the network
- :param network_type: string representing type of network (VLAN, VXLAN,
+ :param network_type: string representing type of network (VLAN, OVERLAY,
MULTI_SEGMENT or TRUNK)
:param physical_network: Only applicable for VLAN networks. It
represents a L2 Domain
:param segmentation_id: integer representing VLAN or VXLAN ID
- :param multicast_ip: VXLAN technology needs a multicast IP to be associated
- with every VXLAN ID to deal with broadcast packets. A
- single multicast IP can be shared by multiple VXLAN
- IDs.
+ :param multicast_ip: Native VXLAN technology needs a multicast IP to be
+ associated with every VXLAN ID to deal with broadcast
+ packets. A single multicast IP can be shared by
+ multiple VXLAN IDs.
:param network_profile_id: network profile ID based on which this network
is created
:param add_segments: List of segment UUIDs in pairs to be added to either a
:param network_profile: network profile object
"""
seg_min, seg_max = get_segment_range(network_profile)
- segment_type = c_const.NETWORK_TYPE_VXLAN
+ segment_type = c_const.NETWORK_TYPE_OVERLAY
physical_network = ""
with db_session.begin(subtransactions=True):
if alloc:
segment_id = alloc.vxlan_id
alloc.allocated = True
- return (physical_network, segment_type,
- segment_id, get_multicast_ip(network_profile))
- raise c_exc.NoMoreNetworkSegments(
- network_profile_name=network_profile.name)
+ if network_profile.sub_type == (c_const.
+ NETWORK_SUBTYPE_NATIVE_VXLAN):
+ return (physical_network, segment_type,
+ segment_id, get_multicast_ip(network_profile))
+ else:
+ return (physical_network, segment_type, segment_id, "0.0.0.0")
+ raise q_exc.NoNetworkAvailable()
def alloc_network(db_session, network_profile_id):
network_profile_id)
if network_profile.segment_type == c_const.NETWORK_TYPE_VLAN:
return reserve_vlan(db_session, network_profile)
- if network_profile.segment_type == c_const.NETWORK_TYPE_VXLAN:
+ if network_profile.segment_type == c_const.NETWORK_TYPE_OVERLAY:
return reserve_vxlan(db_session, network_profile)
return (None, network_profile.segment_type, 0, "0.0.0.0")
if network_profile["segment_type"] == c_const.NETWORK_TYPE_VLAN:
kwargs["physical_network"] = network_profile["physical_network"]
kwargs["segment_range"] = network_profile["segment_range"]
- elif network_profile["segment_type"] == c_const.NETWORK_TYPE_VXLAN:
+ elif network_profile["segment_type"] == c_const.NETWORK_TYPE_OVERLAY:
kwargs["multicast_ip_index"] = 0
kwargs["multicast_ip_range"] = network_profile[
"multicast_ip_range"]
raise q_exc.InvalidInput(error_message=msg)
segment_type = net_p["segment_type"].lower()
if segment_type not in [c_const.NETWORK_TYPE_VLAN,
- c_const.NETWORK_TYPE_VXLAN,
+ c_const.NETWORK_TYPE_OVERLAY,
c_const.NETWORK_TYPE_TRUNK,
c_const.NETWORK_TYPE_MULTI_SEGMENT]:
- msg = _("segment_type should either be vlan, vxlan, "
+ msg = _("segment_type should either be vlan, overlay, "
"multi-segment or trunk")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
"for network profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
- if segment_type == c_const.NETWORK_TYPE_TRUNK:
+ if segment_type in [c_const.NETWORK_TYPE_TRUNK,
+ c_const.NETWORK_TYPE_OVERLAY]:
if "sub_type" not in net_p:
msg = _("argument sub_type missing "
- "for trunk network profile")
+ "for network profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
if segment_type in [c_const.NETWORK_TYPE_VLAN,
- c_const.NETWORK_TYPE_VXLAN]:
+ c_const.NETWORK_TYPE_OVERLAY]:
if "segment_range" not in net_p:
msg = _("argument segment_range missing "
"for network profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
self._validate_segment_range(net_p)
- if segment_type != c_const.NETWORK_TYPE_VXLAN:
- net_p["multicast_ip_range"] = "0.0.0.0"
+ if segment_type == c_const.NETWORK_TYPE_OVERLAY:
+ if net_p['sub_type'] != c_const.NETWORK_SUBTYPE_NATIVE_VXLAN:
+ net_p['multicast_ip_range'] = '0.0.0.0'
+ else:
+ net_p['multicast_ip_range'] = '0.0.0.0'
def _validate_segment_range_uniqueness(self, context, net_p):
"""
"""
n1kv_db_v2.initialize()
c_cred.Store.initialize()
- self._initialize_network_vlan_ranges()
+ self._initialize_network_ranges()
# If no api_extensions_path is provided set the following
if not q_conf.CONF.api_extensions_path:
q_conf.CONF.set_override(
tenant-ids.
"""
LOG.debug(_('_populate_policy_profiles'))
- n1kvclient = n1kv_client.Client()
- policy_profiles = n1kvclient.list_port_profiles()
- LOG.debug(_('_populate_policy_profiles %s'), policy_profiles)
- if policy_profiles:
- for profile in policy_profiles['body'][c_const.SET]:
- if c_const.ID and c_const.NAME in profile:
- profile_id = profile[c_const.PROPERTIES][c_const.ID]
- profile_name = profile[c_const.PROPERTIES][c_const.NAME]
- self._add_policy_profile(profile_name, profile_id)
- else:
+ try:
+ n1kvclient = n1kv_client.Client()
+ policy_profiles = n1kvclient.list_port_profiles()
+ LOG.debug(_('_populate_policy_profiles %s'), policy_profiles)
+ if policy_profiles:
+ for profile in policy_profiles['body'][c_const.SET]:
+ if c_const.ID and c_const.NAME in profile:
+ profile_id = profile[c_const.PROPERTIES][c_const.ID]
+ profile_name = profile[c_const.
+ PROPERTIES][c_const.NAME]
+ self._add_policy_profile(profile_name, profile_id)
+ self._remove_all_fake_policy_profiles()
+ except (cisco_exceptions.VSMError,
+ cisco_exceptions.VSMConnectionFailed):
LOG.warning(_('No policy profile populated from VSM'))
- self._remove_all_fake_policy_profiles()
def _poll_policies(self, event_type=None, epoch=None, tenant_id=None):
"""
Poll for Policy Profiles from Cisco Nexus1000V for any update/delete.
"""
LOG.debug(_('_poll_policies'))
- n1kvclient = n1kv_client.Client()
- policy_profiles = n1kvclient.list_events(event_type, epoch)
- if policy_profiles:
- for profile in policy_profiles['body'][c_const.SET]:
- if c_const.NAME in profile:
- # Extract commands from the events XML.
- cmd = profile[c_const.PROPERTIES]['cmd']
- cmds = cmd.split(';')
- cmdwords = cmds[1].split()
- profile_name = profile[c_const.PROPERTIES][c_const.NAME]
- # Delete the policy profile from db if it's deleted on VSM
- if 'no' in cmdwords[0]:
- p = self._get_policy_profile_by_name(profile_name)
- if p:
- self._delete_policy_profile(p['id'])
- # Add policy profile to neutron DB idempotently
- elif c_const.ID in profile[c_const.PROPERTIES]:
- profile_id = profile[c_const.PROPERTIES][c_const.ID]
- self._add_policy_profile(
- profile_name, profile_id, tenant_id)
- # Replace tenant-id for profile bindings with admin's tenant-id
- self._remove_all_fake_policy_profiles()
-
- def _initialize_network_vlan_ranges(self):
+ try:
+ n1kvclient = n1kv_client.Client()
+ policy_profiles = n1kvclient.list_events(event_type, epoch)
+ if policy_profiles:
+ for profile in policy_profiles['body'][c_const.SET]:
+ if c_const.NAME in profile:
+ # Extract commands from the events XML.
+ cmd = profile[c_const.PROPERTIES]['cmd']
+ cmds = cmd.split(';')
+ cmdwords = cmds[1].split()
+ profile_name = profile[c_const.
+ PROPERTIES][c_const.NAME]
+ # Delete the policy profile from db if deleted on VSM
+ if 'no' in cmdwords[0]:
+ p = self._get_policy_profile_by_name(profile_name)
+ if p:
+ self._delete_policy_profile(p['id'])
+ # Add policy profile to neutron DB idempotently
+ elif c_const.ID in profile[c_const.PROPERTIES]:
+ profile_id = profile[c_const.
+ PROPERTIES][c_const.ID]
+ self._add_policy_profile(
+ profile_name, profile_id, tenant_id)
+ # Replace tenant-id for profile bindings with admin's tenant-id
+ self._remove_all_fake_policy_profiles()
+ except (cisco_exceptions.VSMError,
+ cisco_exceptions.VSMConnectionFailed):
+ LOG.warning(_('No policy profile updated from VSM'))
+
+ def _initialize_network_ranges(self):
self.network_vlan_ranges = {}
+ self.vxlan_id_ranges = []
network_profiles = n1kv_db_v2._get_network_profiles()
for network_profile in network_profiles:
+ seg_min, seg_max = self._get_segment_range(
+ network_profile['segment_range'])
if network_profile['segment_type'] == c_const.NETWORK_TYPE_VLAN:
- seg_min, seg_max = self._get_segment_range(
- network_profile['segment_range'])
self._add_network_vlan_range(network_profile[
'physical_network'], int(seg_min), int(seg_max))
+ elif network_profile['segment_type'] == (c_const.
+ NETWORK_TYPE_OVERLAY):
+ self.vxlan_id_ranges.append((int(seg_min), int(seg_max)))
def _add_network_vlan_range(self, physical_network, vlan_min, vlan_max):
self._add_network(physical_network)
binding = n1kv_db_v2.get_network_binding(context.session,
network['id'])
network[providernet.NETWORK_TYPE] = binding.network_type
- if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
+ if binding.network_type == c_const.NETWORK_TYPE_OVERLAY:
network[providernet.PHYSICAL_NETWORK] = None
network[providernet.SEGMENTATION_ID] = binding.segmentation_id
network[n1kv_profile.MULTICAST_IP] = binding.multicast_ip
msg = _("provider:segmentation_id out of range "
"(1 through 4094)")
raise q_exc.InvalidInput(error_message=msg)
- elif network_type == c_const.NETWORK_TYPE_VXLAN:
+ elif network_type == c_const.NETWORK_TYPE_OVERLAY:
if physical_network_set:
- msg = _("provider:physical_network specified for VXLAN "
+ msg = _("provider:physical_network specified for Overlay "
"network")
raise q_exc.InvalidInput(error_message=msg)
else:
def _extend_mapping_dict(self, context, mapping_dict, segment):
"""
- Extends a mapping dictionary by populating dot1q tag and
- bridge-domain name.
+ Extend a mapping dictionary with dot1q tag and bridge-domain name.
:param context: neutron api request context
:param mapping_dict: dictionary to populate values
def _parse_multi_segments(self, context, attrs, param):
"""
- Parse the multi-segment network attributes
+ Parse the multi-segment network attributes.
:param context: neutron api request context
:param attrs: Attributes of the network
"""
pair_list = []
valid_seg_types = [c_const.NETWORK_TYPE_VLAN,
- c_const.NETWORK_TYPE_VXLAN]
+ c_const.NETWORK_TYPE_OVERLAY]
segments = attrs.get(param)
if not attributes.is_attr_set(segments):
return pair_list
def _parse_trunk_segments(self, context, attrs, param, physical_network,
sub_type):
"""
- Parse the trunk network attributes
+ Parse the trunk network attributes.
:param context: neutron api request context
:param attrs: Attributes of the network
"another trunk segment") % segment
raise q_exc.InvalidInput(error_message=msg)
elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
- if sub_type == c_const.NETWORK_TYPE_VXLAN:
+ if sub_type == c_const.NETWORK_TYPE_OVERLAY:
msg = _("Cannot add vlan segment '%s' as a member of "
"a vxlan trunk segment") % segment
raise q_exc.InvalidInput(error_message=msg)
msg = _("Network UUID '%s' belongs to a different "
"physical network") % segment
raise q_exc.InvalidInput(error_message=msg)
- elif binding.network_type == c_const.NETWORK_TYPE_VXLAN:
+ elif binding.network_type == c_const.NETWORK_TYPE_OVERLAY:
if sub_type == c_const.NETWORK_TYPE_VLAN:
msg = _("Cannot add vxlan segment '%s' as a member of "
"a vlan trunk segment") % segment
"""
Send create network request to VSM.
- Create a bridge domain for network of type VXLAN.
+ Create a bridge domain for network of type Overlay.
:param context: neutron api request context
:param network: network dictionary
:param segment_pairs: List of segments in UUID pairs
profile = self.get_network_profile(context,
network[n1kv_profile.PROFILE_ID])
n1kvclient = n1kv_client.Client()
- if network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_VXLAN:
- n1kvclient.create_bridge_domain(network)
+ if network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_OVERLAY:
+ n1kvclient.create_bridge_domain(network, profile['sub_type'])
if network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_TRUNK:
self._populate_member_segments(context, network, segment_pairs,
n1kv_profile.SEGMENT_ADD)
network['del_segment_list'] = []
- if profile['sub_type'] == c_const.NETWORK_TYPE_VXLAN:
+ if profile['sub_type'] == c_const.NETWORK_TYPE_OVERLAY:
encap_dict = {'name': (network['name'] +
c_const.ENCAPSULATION_PROFILE_SUFFIX),
'add_segment_list': (
body['delSegments'] = network['del_segment_list']
LOG.debug(_('add_segments=%s'), body['addSegments'])
LOG.debug(_('del_segments=%s'), body['delSegments'])
- if profile['sub_type'] == c_const.NETWORK_TYPE_VXLAN:
+ if profile['sub_type'] == c_const.NETWORK_TYPE_OVERLAY:
encap_profile = (network['name'] +
c_const.ENCAPSULATION_PROFILE_SUFFIX)
encap_dict = {'name': encap_profile,
"""
Send delete network request to VSM.
- Delete bridge domain if network is of type VXLAN.
- Delete encapsulation profile if network is of type VXLAN Trunk.
+ Delete bridge domain if network is of type Overlay.
+ Delete encapsulation profile if network is of type OVERLAY Trunk.
:param context: neutron api request context
:param network: network dictionary
"""
LOG.debug(_('_send_delete_network_request: %s'), network['id'])
n1kvclient = n1kv_client.Client()
session = context.session
- if network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_VXLAN:
+ if network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_OVERLAY:
name = network['name'] + c_const.BRIDGE_DOMAIN_SUFFIX
n1kvclient.delete_bridge_domain(name)
elif network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_TRUNK:
profile = self.get_network_profile(
context, network[n1kv_profile.PROFILE_ID])
- if profile['sub_type'] == c_const.NETWORK_TYPE_VXLAN:
+ if profile['sub_type'] == c_const.NETWORK_TYPE_OVERLAY:
profile_name = (network['name'] +
c_const.ENCAPSULATION_PROFILE_SUFFIX)
n1kvclient.delete_encapsulation_profile(profile_name)
binding = n1kv_db_v2.get_network_binding(session, id)
network = self.get_network(context, id)
if n1kv_db_v2.is_trunk_member(session, id):
- msg = _("Cannot delete a network "
- "that is a member of a trunk segment")
+ msg = _("Cannot delete network '%s' "
+ "that is member of a trunk segment") % network['name']
raise q_exc.InvalidInput(error_message=msg)
if n1kv_db_v2.is_multi_segment_member(session, id):
- msg = _("Cannot delete a network "
- "that is a member of a multi-segment network")
+ msg = _("Cannot delete network '%s' that is a member of a "
+ "multi-segment network") % network['name']
raise q_exc.InvalidInput(error_message=msg)
if self.agent_vsm:
try:
cisco_exceptions.VSMConnectionFailed):
LOG.debug(_('Delete failed in VSM'))
super(N1kvNeutronPluginV2, self).delete_network(context, id)
- if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
+ if binding.network_type == c_const.NETWORK_TYPE_OVERLAY:
n1kv_db_v2.release_vxlan(session, binding.segmentation_id,
self.vxlan_id_ranges)
elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
Create a network profile.
Create a network profile, which represents a pool of networks
- belonging to one type (VLAN or VXLAN). On creation of network
+ belonging to one type (VLAN or Overlay). On creation of network
profile, we retrieve the admin tenant-id which we use to replace
the previously stored fake tenant-id in tenant-profile bindings.
:param context: neutron api request context
N1kvNeutronPluginV2, self).create_network_profile(context,
network_profile)
if _network_profile['segment_type'] in [c_const.NETWORK_TYPE_VLAN,
- c_const.NETWORK_TYPE_VXLAN]:
+ c_const.NETWORK_TYPE_OVERLAY]:
seg_min, seg_max = self._get_segment_range(
_network_profile['segment_range'])
if _network_profile['segment_type'] == c_const.NETWORK_TYPE_VLAN:
int(seg_max))
n1kv_db_v2.delete_vlan_allocations(context.session,
self.network_vlan_ranges)
- elif _network_profile['segment_type'] == c_const.NETWORK_TYPE_VXLAN:
- self.delete_vxlan_ranges = [(int(seg_min), int(seg_max))]
+ elif _network_profile['segment_type'] == c_const.NETWORK_TYPE_OVERLAY:
+ self.delete_vxlan_ranges = []
+ self.delete_vxlan_ranges.append((int(seg_min), int(seg_max)))
n1kv_db_v2.delete_vxlan_allocations(context.session,
self.delete_vxlan_ranges)
self._send_delete_network_profile_request(_network_profile)