Merge "External subnet for floating ip."
This commit is contained in:
commit
a9f543d4dd
heat
@ -38,12 +38,12 @@ class FloatingIP(neutron.NeutronResource):
|
||||
entity = 'floatingip'
|
||||
|
||||
PROPERTIES = (
|
||||
FLOATING_NETWORK_ID, FLOATING_NETWORK, VALUE_SPECS,
|
||||
PORT_ID, FIXED_IP_ADDRESS, FLOATING_IP_ADDRESS,
|
||||
FLOATING_NETWORK_ID, FLOATING_NETWORK, FLOATING_SUBNET,
|
||||
VALUE_SPECS, PORT_ID, FIXED_IP_ADDRESS, FLOATING_IP_ADDRESS,
|
||||
DNS_NAME, DNS_DOMAIN,
|
||||
) = (
|
||||
'floating_network_id', 'floating_network', 'value_specs',
|
||||
'port_id', 'fixed_ip_address', 'floating_ip_address',
|
||||
'floating_network_id', 'floating_network', 'floating_subnet',
|
||||
'value_specs', 'port_id', 'fixed_ip_address', 'floating_ip_address',
|
||||
'dns_name', 'dns_domain',
|
||||
)
|
||||
|
||||
@ -80,6 +80,14 @@ class FloatingIP(neutron.NeutronResource):
|
||||
constraints.CustomConstraint('neutron.network')
|
||||
],
|
||||
),
|
||||
FLOATING_SUBNET: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('Subnet to allocate floating IP from.'),
|
||||
support_status=support.SupportStatus(version='9.0.0'),
|
||||
constraints=[
|
||||
constraints.CustomConstraint('neutron.subnet')
|
||||
],
|
||||
),
|
||||
VALUE_SPECS: properties.Schema(
|
||||
properties.Schema.MAP,
|
||||
_('Extra parameters to include in the "floatingip" object in the '
|
||||
@ -179,6 +187,14 @@ class FloatingIP(neutron.NeutronResource):
|
||||
client_plugin=self.client_plugin(),
|
||||
finder='find_resourceid_by_name_or_id',
|
||||
entity='network'
|
||||
),
|
||||
translation.TranslationRule(
|
||||
props,
|
||||
translation.TranslationRule.RESOLVE,
|
||||
[self.FLOATING_SUBNET],
|
||||
client_plugin=self.client_plugin(),
|
||||
finder='find_resourceid_by_name_or_id',
|
||||
entity='subnet',
|
||||
)
|
||||
]
|
||||
|
||||
@ -266,6 +282,8 @@ class FloatingIP(neutron.NeutronResource):
|
||||
self.properties,
|
||||
self.physical_resource_name())
|
||||
props['floating_network_id'] = props.pop(self.FLOATING_NETWORK)
|
||||
if self.FLOATING_SUBNET in props:
|
||||
props['subnet_id'] = props.pop(self.FLOATING_SUBNET)
|
||||
fip = self.client().create_floatingip({
|
||||
'floatingip': props})['floatingip']
|
||||
self.resource_id_set(fip['id'])
|
||||
|
@ -592,6 +592,40 @@ class NeutronFloatingIPTest(common.HeatTestCase):
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_floatingip_create_specify_subnet(self):
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
mox.IsA(neutronclient.Client),
|
||||
'network',
|
||||
'abcd1234',
|
||||
cmd_resource=None,
|
||||
).MultipleTimes().AndReturn('abcd1234')
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
mox.IsA(neutronclient.Client),
|
||||
'subnet',
|
||||
'sub1234',
|
||||
cmd_resource=None,
|
||||
).MultipleTimes().AndReturn('sub1234')
|
||||
self.stub_NetworkConstraint_validate()
|
||||
neutronclient.Client.create_floatingip({
|
||||
'floatingip': {'floating_network_id': u'abcd1234',
|
||||
'subnet_id': u'sub1234'}
|
||||
}).AndReturn({'floatingip': {
|
||||
'status': 'ACTIVE',
|
||||
'id': 'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||
'floating_ip_address': '172.24.4.98'
|
||||
}})
|
||||
|
||||
self.m.ReplayAll()
|
||||
t = template_format.parse(neutron_floating_template)
|
||||
props = t['resources']['floating_ip']['properties']
|
||||
props['floating_subnet'] = 'sub1234'
|
||||
stack = utils.parse_stack(t)
|
||||
fip = stack['floating_ip']
|
||||
scheduler.TaskRunner(fip.create)()
|
||||
self.assertEqual((fip.CREATE, fip.COMPLETE), fip.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_floatip_port(self):
|
||||
t = template_format.parse(neutron_floating_no_assoc_template)
|
||||
t['resources']['port_floating']['properties']['network'] = "xyz1234"
|
||||
|
Loading…
x
Reference in New Issue
Block a user