fixed_ips for PT and reuse_bd option for L2P
fixed_ips option was added to the GBP neutron mapping a while back and is similar to the fixed_ips option for the Neutron Port. The reuse_bd option is used by the apic driver. Change-Id: Ie3f76ac4b9ed04354079e28a6be911b85856cc6b
This commit is contained in:
parent
545eec2fe4
commit
77b2787cdd
|
@ -25,16 +25,22 @@ class PolicyTarget(gbpresource.GBPResource):
|
|||
|
||||
PROPERTIES = (
|
||||
TENANT_ID, NAME, DESCRIPTION, POLICY_TARGET_GROUP_ID,
|
||||
PORT_ID
|
||||
PORT_ID, FIXED_IPS
|
||||
) = (
|
||||
'tenant_id', 'name', 'description', 'policy_target_group_id',
|
||||
'port_id'
|
||||
'port_id', 'fixed_ips'
|
||||
)
|
||||
|
||||
_FIXED_IP_KEYS = (
|
||||
FIXED_IP_SUBNET_ID, FIXED_IP_IP_ADDRESS,
|
||||
) = (
|
||||
'subnet_id', 'ip_address',
|
||||
)
|
||||
|
||||
ATTRIBUTES = (
|
||||
PORT_ID_ATTR
|
||||
PORT_ID_ATTR, FIXED_IPS_ATTR
|
||||
) = (
|
||||
'port_id'
|
||||
'port_id', 'fixed_ips'
|
||||
)
|
||||
|
||||
properties_schema = {
|
||||
|
@ -62,13 +68,39 @@ class PolicyTarget(gbpresource.GBPResource):
|
|||
properties.Schema.STRING,
|
||||
_('Neutron port id of the policy target.'),
|
||||
update_allowed=False
|
||||
)
|
||||
),
|
||||
FIXED_IPS: properties.Schema(
|
||||
properties.Schema.LIST,
|
||||
_('Desired IPs for this port.'),
|
||||
default=[],
|
||||
schema=properties.Schema(
|
||||
properties.Schema.MAP,
|
||||
schema={
|
||||
FIXED_IP_SUBNET_ID: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('Subnet ID to associate with this interface.'),
|
||||
),
|
||||
FIXED_IP_IP_ADDRESS: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('IP address desired in the subnet for this port.'),
|
||||
constraints=[
|
||||
constraints.CustomConstraint('ip_addr')
|
||||
]
|
||||
),
|
||||
},
|
||||
),
|
||||
update_allowed=True
|
||||
),
|
||||
}
|
||||
|
||||
attributes_schema = {
|
||||
PORT_ID_ATTR: attributes.Schema(
|
||||
_('Neutron port id of this policy target.')
|
||||
)
|
||||
),
|
||||
FIXED_IPS_ATTR: attributes.Schema(
|
||||
_("Fixed IP addresses."),
|
||||
type=attributes.Schema.LIST
|
||||
),
|
||||
}
|
||||
|
||||
def _show_resource(self):
|
||||
|
@ -83,6 +115,7 @@ class PolicyTarget(gbpresource.GBPResource):
|
|||
for key in self.properties:
|
||||
if self.properties.get(key) is not None:
|
||||
props[key] = self.properties.get(key)
|
||||
self._prepare_port_properties(props)
|
||||
|
||||
pt = client.create_policy_target(
|
||||
{'policy_target': props})['policy_target']
|
||||
|
@ -106,6 +139,12 @@ class PolicyTarget(gbpresource.GBPResource):
|
|||
self.grouppolicy().update_policy_target(
|
||||
self.resource_id, {'policy_target': prop_diff})
|
||||
|
||||
def _prepare_port_properties(self, props):
|
||||
for fixed_ip in props.get(self.FIXED_IPS, []):
|
||||
for key, value in list(fixed_ip.items()):
|
||||
if value is None:
|
||||
fixed_ip.pop(key)
|
||||
|
||||
|
||||
class PolicyTargetGroup(gbpresource.GBPResource):
|
||||
|
||||
|
@ -258,9 +297,10 @@ class PolicyTargetGroup(gbpresource.GBPResource):
|
|||
class L2Policy(gbpresource.GBPResource):
|
||||
|
||||
PROPERTIES = (
|
||||
TENANT_ID, NAME, DESCRIPTION, L3_POLICY_ID, SHARED
|
||||
TENANT_ID, NAME, DESCRIPTION, L3_POLICY_ID, SHARED, REUSE_BD
|
||||
) = (
|
||||
'tenant_id', 'name', 'description', 'l3_policy_id', 'shared'
|
||||
'tenant_id', 'name', 'description', 'l3_policy_id', 'shared',
|
||||
'reuse_bd'
|
||||
)
|
||||
|
||||
properties_schema = {
|
||||
|
@ -288,6 +328,11 @@ class L2Policy(gbpresource.GBPResource):
|
|||
properties.Schema.BOOLEAN,
|
||||
_('Shared.'),
|
||||
update_allowed=True, required=True
|
||||
),
|
||||
REUSE_BD: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('Existing L2P ID in same L3P.'),
|
||||
default=None, update_allowed=False
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,12 @@ policy_target_template = '''
|
|||
"Properties": {
|
||||
"name": "test-policy-target",
|
||||
"policy_target_group_id": "ptg-id",
|
||||
"description": "test policy target resource"
|
||||
"description": "test policy target resource",
|
||||
"port_id": "some-port-id",
|
||||
"fixed_ips": [{
|
||||
"subnet_id": "test-subnet",
|
||||
"ip_address": "10.0.3.21"
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +89,8 @@ l2_policy_template = '''
|
|||
"name": "test-l2-policy",
|
||||
"description": "test L2 policy resource",
|
||||
"l3_policy_id": "l3-policy-id",
|
||||
"shared": True
|
||||
"shared": True,
|
||||
"reuse_bd": "other-l2p"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +324,11 @@ class PolicyTargetTest(HeatTestCase):
|
|||
'policy_target': {
|
||||
'name': 'test-policy-target',
|
||||
'policy_target_group_id': 'ptg-id',
|
||||
"description": "test policy target resource"
|
||||
"description": "test policy target resource",
|
||||
"port_id": "some-port-id",
|
||||
'fixed_ips': [
|
||||
{'subnet_id': u'test-subnet', 'ip_address': u'10.0.3.21'}
|
||||
],
|
||||
}
|
||||
}).AndReturn({'policy_target': {'id': '5678'}})
|
||||
|
||||
|
@ -340,7 +350,11 @@ class PolicyTargetTest(HeatTestCase):
|
|||
'policy_target': {
|
||||
'name': 'test-policy-target',
|
||||
'policy_target_group_id': 'ptg-id',
|
||||
"description": "test policy target resource"
|
||||
"description": "test policy target resource",
|
||||
"port_id": "some-port-id",
|
||||
'fixed_ips': [
|
||||
{'subnet_id': u'test-subnet', 'ip_address': u'10.0.3.21'}
|
||||
],
|
||||
}
|
||||
}).AndRaise(grouppolicy.NeutronClientException())
|
||||
self.m.ReplayAll()
|
||||
|
@ -610,7 +624,8 @@ class L2PolicyTest(HeatTestCase):
|
|||
"name": "test-l2-policy",
|
||||
"description": "test L2 policy resource",
|
||||
"l3_policy_id": "l3-policy-id",
|
||||
"shared": True
|
||||
"shared": True,
|
||||
"reuse_bd": "other-l2p",
|
||||
}
|
||||
}).AndReturn({'l2_policy': {'id': '5678'}})
|
||||
|
||||
|
@ -633,7 +648,8 @@ class L2PolicyTest(HeatTestCase):
|
|||
"name": "test-l2-policy",
|
||||
"description": "test L2 policy resource",
|
||||
"l3_policy_id": "l3-policy-id",
|
||||
"shared": True
|
||||
"shared": True,
|
||||
"reuse_bd": "other-l2p",
|
||||
}
|
||||
}).AndRaise(grouppolicy.NeutronClientException())
|
||||
self.m.ReplayAll()
|
||||
|
|
|
@ -17,6 +17,7 @@ oslotest>=1.10.0 # Apache-2.0
|
|||
paramiko>=1.16.0 # LGPL
|
||||
qpid-python;python_version=='2.7' # Apache-2.0
|
||||
psycopg2>=2.5 # LGPL/ZPL
|
||||
python-troveclient<2.6.0
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD
|
||||
testrepository>=0.0.18 # Apache-2.0/BSD
|
||||
testscenarios>=0.4 # Apache-2.0/BSD
|
||||
|
|
Loading…
Reference in New Issue