Add NSX policy tier1 segment port resource
Change-Id: Iebf93b46c39635da0b5d75ee3d53a53bfd40e8b5
This commit is contained in:
parent
27714e8663
commit
566f27f3da
@ -53,7 +53,7 @@ path.append(os.path.abspath("../../"))
|
||||
|
||||
OPERATIONS = ("create", "update", "delete", "get", "state")
|
||||
RESOURCES = ("domain", "service", "icmp_service", "group", "tier1",
|
||||
"segment", "tier1_segment", "segment_port")
|
||||
"segment", "tier1_segment", "segment_port", "tier1_segment_port")
|
||||
|
||||
|
||||
def get_resource_api(lib, resource_type):
|
||||
|
@ -396,6 +396,8 @@ class NsxPolicyLib(NsxLibBase):
|
||||
self.segment = policy_resources.NsxPolicySegmentApi(self.policy_api)
|
||||
self.segment_port = policy_resources.NsxPolicySegmentPortApi(
|
||||
self.policy_api)
|
||||
self.tier1_segment_port = (
|
||||
policy_resources.NsxPolicyTier1SegmentPortApi(self.policy_api))
|
||||
self.comm_map = policy_resources.NsxPolicyCommunicationMapApi(
|
||||
self.policy_api)
|
||||
self.enforcement_point = policy_resources.NsxPolicyEnforcementPointApi(
|
||||
|
@ -510,6 +510,21 @@ class SegmentPortDef(ResourceDef):
|
||||
return body
|
||||
|
||||
|
||||
class Tier1SegmentPortDef(SegmentPortDef):
|
||||
'''Tier1 segment port'''
|
||||
|
||||
@property
|
||||
def path_pattern(self):
|
||||
return TIER1S_PATH_PATTERN + "%s/segments/%s/ports/"
|
||||
|
||||
@property
|
||||
def path_ids(self):
|
||||
return ('tenant', 'tier1_id', 'segment_id', 'port_id')
|
||||
|
||||
def path_defs(self):
|
||||
return (TenantDef, Tier1Def, SegmentDef)
|
||||
|
||||
|
||||
class Condition(object):
|
||||
def __init__(self, value, key=policy_constants.CONDITION_KEY_TAG,
|
||||
member_type=policy_constants.CONDITION_MEMBER_PORT,
|
||||
|
@ -1054,6 +1054,142 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase):
|
||||
return self._get_realization_info(port_def)
|
||||
|
||||
|
||||
class NsxPolicyTier1SegmentPortApi(NsxPolicyResourceBase):
|
||||
"""NSX Tier1 Segment Port API """
|
||||
@property
|
||||
def entry_def(self):
|
||||
return policy_defs.Tier1SegmentPortDef
|
||||
|
||||
def build_address_binding(self, ip_address, mac_address,
|
||||
vlan_id=None):
|
||||
return policy_defs.PortAddressBinding(ip_address,
|
||||
mac_address,
|
||||
vlan_id)
|
||||
|
||||
def create_or_overwrite(self, name,
|
||||
tier1_id,
|
||||
segment_id,
|
||||
port_id=None,
|
||||
description=IGNORE,
|
||||
address_bindings=IGNORE,
|
||||
attachment_type=IGNORE,
|
||||
vif_id=IGNORE,
|
||||
app_id=IGNORE,
|
||||
context_id=IGNORE,
|
||||
traffic_tag=IGNORE,
|
||||
allocate_addresses=IGNORE,
|
||||
tags=IGNORE,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
port_id = self._init_obj_uuid(port_id)
|
||||
port_def = self._init_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
name=name,
|
||||
description=description,
|
||||
address_bindings=address_bindings,
|
||||
attachment_type=attachment_type,
|
||||
vif_id=vif_id,
|
||||
app_id=app_id,
|
||||
context_id=context_id,
|
||||
allocate_addresses=allocate_addresses,
|
||||
tags=tags,
|
||||
tenant=tenant)
|
||||
self._create_or_store(port_def)
|
||||
return port_id
|
||||
|
||||
def delete(self, tier1_id, segment_id, port_id,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
tenant=tenant)
|
||||
self.policy_api.delete(port_def)
|
||||
|
||||
def get(self, tier1_id, segment_id, port_id,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
tenant=tenant)
|
||||
return self.policy_api.get(port_def)
|
||||
|
||||
def list(self, tier1_id, segment_id,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
port_def = self.entry_def(segment_id=segment_id, tier1_id=tier1_id,
|
||||
tenant=tenant)
|
||||
return self._list(port_def)
|
||||
|
||||
def update(self, tier1_id, segment_id, port_id,
|
||||
name=IGNORE,
|
||||
description=IGNORE,
|
||||
address_bindings=IGNORE,
|
||||
tags=IGNORE,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
|
||||
self._update(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
name=name,
|
||||
description=description,
|
||||
address_bindings=address_bindings,
|
||||
tags=tags,
|
||||
tenant=tenant)
|
||||
|
||||
def detach(self, tier1_id, segment_id, port_id,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
attachment_type=None,
|
||||
tenant=tenant)
|
||||
self.policy_api.create_or_update(port_def)
|
||||
|
||||
def attach(self, tier1_id, segment_id, port_id,
|
||||
attachment_type,
|
||||
vif_id,
|
||||
allocate_addresses,
|
||||
app_id=None,
|
||||
context_id=None,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
attachment_type=attachment_type,
|
||||
allocate_addresses=allocate_addresses,
|
||||
vif_id=vif_id,
|
||||
app_id=app_id,
|
||||
context_id=context_id,
|
||||
tenant=tenant)
|
||||
|
||||
self.policy_api.create_or_update(port_def)
|
||||
|
||||
def get_realized_state(self, tier1_id, segment_id, port_id,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
tenant=tenant)
|
||||
return self._get_realized_state(port_def)
|
||||
|
||||
def get_realized_id(self, tier1_id, segment_id, port_id,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
tenant=tenant)
|
||||
return self._get_realized_id(port_def)
|
||||
|
||||
def get_realization_info(self, tier1_id, segment_id, port_id,
|
||||
tenant=policy_constants.POLICY_INFRA_TENANT):
|
||||
port_def = self.entry_def(segment_id=segment_id,
|
||||
tier1_id=tier1_id,
|
||||
port_id=port_id,
|
||||
tenant=tenant)
|
||||
return self._get_realization_info(port_def)
|
||||
|
||||
|
||||
class NsxPolicyCommunicationMapApi(NsxPolicyResourceBase):
|
||||
"""NSX Policy CommunicationMap (Under a Domain)."""
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user