Support for Bridge Endpoint Profiles
Add a resource for managing create/list/delete operation on Bridge Endpoint Profiles Also, switch Bridge Endpoints to leverage Bridge Endpoint Profiles rather than Bridge Clusters. Change-Id: I6540937b7f6584a2e28e7a62a7b0503db9d8e8f0
This commit is contained in:
parent
69568d0073
commit
5e0e2eed1c
|
@ -1796,6 +1796,13 @@ class NsxLibBridgeEndpointTestCase(BaseTestResource):
|
|||
core_resources.NsxLibBridgeEndpoint)
|
||||
|
||||
|
||||
class NsxLibBridgeEndpointProfileTestCase(BaseTestResource):
|
||||
|
||||
def setUp(self):
|
||||
super(NsxLibBridgeEndpointProfileTestCase, self).setUp(
|
||||
core_resources.NsxLibBridgeEndpointProfile)
|
||||
|
||||
|
||||
class NsxLibEdgeClusterTestCase(BaseTestResource):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -42,6 +42,9 @@ class NsxLib(lib.NsxLibBase):
|
|||
self.client, self.nsxlib_config, nsxlib=self)
|
||||
self.bridge_endpoint = core_resources.NsxLibBridgeEndpoint(
|
||||
self.client, self.nsxlib_config, nsxlib=self)
|
||||
self.bridge_endpoint_profile = (
|
||||
core_resources.NsxLibBridgeEndpointProfile(
|
||||
self.client, self.nsxlib_config, nsxlib=self))
|
||||
self.logical_switch = core_resources.NsxLibLogicalSwitch(
|
||||
self.client, self.nsxlib_config, nsxlib=self)
|
||||
self.logical_router = core_resources.NsxLibLogicalRouter(
|
||||
|
|
|
@ -74,6 +74,61 @@ class NsxLibPortMirror(utils.NsxLibApiBase):
|
|||
self.client.delete(self.get_path(mirror_session_id))
|
||||
|
||||
|
||||
class NsxLibBridgeEndpointProfile(utils.NsxLibApiBase):
|
||||
|
||||
@property
|
||||
def uri_segment(self):
|
||||
return 'bridge-endpoint-profiles'
|
||||
|
||||
@property
|
||||
def resource_type(self):
|
||||
return 'BridgeEndpointProfile'
|
||||
|
||||
def create(self, display_name, edge_cluster_id, tags,
|
||||
edge_cluster_member_indexes=None, failover_mode=None):
|
||||
"""Create a bridge endpoint profile on the backend.
|
||||
|
||||
Create a bridge endpoint profile for a given edge cluster.
|
||||
:param display_name: name of the bridge endpoint profile
|
||||
:param edge_cluster_id: identifier of the edge cluster this profile
|
||||
should be associated with.
|
||||
:param tags: tags for the newly created resource.
|
||||
:param edge_cluster_member_indexes: iterable of integers specifying
|
||||
edge cluster members where the
|
||||
bridge endpoints will be created
|
||||
:param failover_mode: failover mode for the profile. Could be either
|
||||
PREEMPTIVE or NON_PREEMPTIVE.
|
||||
"""
|
||||
tags = tags or []
|
||||
body = {'display_name': display_name,
|
||||
'tags': tags}
|
||||
if failover_mode:
|
||||
body['failover_mode'] = failover_mode
|
||||
if edge_cluster_member_indexes:
|
||||
# Test for a list of integers
|
||||
try:
|
||||
member_indexes = [int(member_idx) for member_idx in
|
||||
edge_cluster_member_indexes]
|
||||
body['edge_cluster_member_indexes'] = member_indexes
|
||||
except (TypeError, ValueError) as e:
|
||||
LOG.Error("Invalid values for member indexes: %s", e)
|
||||
raise exceptions.InvalidInput(
|
||||
operation='Create BridgeEndpointProfile',
|
||||
arg_val=edge_cluster_member_indexes,
|
||||
arg_name='edge_cluster_member_indexes')
|
||||
|
||||
return self.client.create(self.get_path(), body)
|
||||
|
||||
def delete(self, bridge_endpoint_profile_id):
|
||||
"""Delete a bridge endpoint profile on the backend.
|
||||
|
||||
:param bridge_endpoint_profile_id: string representing the UUID of
|
||||
the bridge endpoint profile to be
|
||||
deleted.
|
||||
"""
|
||||
self.client.delete(self.get_path(bridge_endpoint_profile_id))
|
||||
|
||||
|
||||
class NsxLibBridgeEndpoint(utils.NsxLibApiBase):
|
||||
|
||||
@property
|
||||
|
@ -84,19 +139,24 @@ class NsxLibBridgeEndpoint(utils.NsxLibApiBase):
|
|||
def resource_type(self):
|
||||
return 'BridgeEndpoint'
|
||||
|
||||
def create(self, device_name, seg_id, tags):
|
||||
def create(self, device_name, vlan_transport_zone_id, vlan_id, tags):
|
||||
"""Create a bridge endpoint on the backend.
|
||||
|
||||
Create a bridge endpoint resource on a bridge cluster for the L2
|
||||
gateway network connection.
|
||||
:param device_name: device_name actually refers to the bridge cluster's
|
||||
UUID.
|
||||
:param seg_id: integer representing the VLAN segmentation ID.
|
||||
:param vlan_transport_zone_id: identifier of the transport zone id
|
||||
where the endpoint will be created.
|
||||
Mandatory for endpoints on edge
|
||||
clusters.
|
||||
:param vlan_id: integer representing the VLAN segmentation ID.
|
||||
:param tags: nsx backend specific tags.
|
||||
"""
|
||||
body = {'bridge_cluster_id': device_name,
|
||||
body = {'bridge_endpoint_profile_id': device_name,
|
||||
'vlan_transport_zone_id': vlan_transport_zone_id,
|
||||
'tags': tags,
|
||||
'vlan': seg_id}
|
||||
'vlan': vlan_id}
|
||||
return self.client.create(self.get_path(), body)
|
||||
|
||||
def delete(self, bridge_endpoint_id):
|
||||
|
|
|
@ -35,6 +35,8 @@ ALLOCATE_ADDRESS_NONE = "None"
|
|||
|
||||
# NSXv3 L2 Gateway constants
|
||||
BRIDGE_ENDPOINT = "BRIDGEENDPOINT"
|
||||
FAILOVER_MODE_PREEMPTIVE = "PREEMPTIVE"
|
||||
FAILOVER_MODE_NONPREEMPTIVE = "NON_PREEMPTIVE"
|
||||
|
||||
# Router type
|
||||
ROUTER_TYPE_TIER0 = "TIER0"
|
||||
|
|
Loading…
Reference in New Issue