Merge "Allow specific floating_ip_address when creation"
This commit is contained in:
@@ -25,11 +25,11 @@ from heat.engine import support
|
||||
|
||||
class FloatingIP(neutron.NeutronResource):
|
||||
PROPERTIES = (
|
||||
FLOATING_NETWORK_ID, FLOATING_NETWORK,
|
||||
VALUE_SPECS, PORT_ID, FIXED_IP_ADDRESS,
|
||||
FLOATING_NETWORK_ID, FLOATING_NETWORK, VALUE_SPECS,
|
||||
PORT_ID, FIXED_IP_ADDRESS, FLOATING_IP_ADDRESS,
|
||||
) = (
|
||||
'floating_network_id', 'floating_network',
|
||||
'value_specs', 'port_id', 'fixed_ip_address',
|
||||
'floating_network_id', 'floating_network', 'value_specs',
|
||||
'port_id', 'fixed_ip_address', 'floating_ip_address',
|
||||
)
|
||||
|
||||
ATTRIBUTES = (
|
||||
@@ -80,6 +80,13 @@ class FloatingIP(neutron.NeutronResource):
|
||||
_('IP address to use if the port has multiple addresses.'),
|
||||
update_allowed=True
|
||||
),
|
||||
FLOATING_IP_ADDRESS: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('IP address of the floating IP. NOTE: The default policy '
|
||||
'setting in Neutron restricts usage of this property to '
|
||||
'administrative users only.'),
|
||||
support_status=support.SupportStatus(version='2015.2'),
|
||||
),
|
||||
}
|
||||
|
||||
attributes_schema = {
|
||||
|
||||
@@ -549,6 +549,42 @@ class NeutronFloatingIPTest(common.HeatTestCase):
|
||||
self.assertIn(stack['floating_ip'], required_by)
|
||||
p_show.assert_called_once_with('net_uuid')
|
||||
|
||||
def test_floatingip_create_specify_ip_address(self):
|
||||
t = template_format.parse(neutron_floating_template)
|
||||
props = t['resources']['floating_ip']['properties']
|
||||
props['floating_ip_address'] = '172.24.4.98'
|
||||
stack = utils.parse_stack(t)
|
||||
|
||||
self.stub_NetworkConstraint_validate()
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
mox.IsA(neutronclient.Client),
|
||||
'network',
|
||||
'abcd1234'
|
||||
).AndReturn('xyz1234')
|
||||
neutronclient.Client.create_floatingip({
|
||||
'floatingip': {'floating_network_id': u'xyz1234',
|
||||
'floating_ip_address': '172.24.4.98'}
|
||||
}).AndReturn({'floatingip': {
|
||||
'status': 'ACTIVE',
|
||||
'id': 'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||
'floating_ip_address': '172.24.4.98'
|
||||
}})
|
||||
neutronclient.Client.show_floatingip(
|
||||
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
|
||||
).MultipleTimes().AndReturn({'floatingip': {
|
||||
'status': 'ACTIVE',
|
||||
'id': 'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||
'floating_ip_address': '172.24.4.98'
|
||||
}})
|
||||
|
||||
self.m.ReplayAll()
|
||||
fip = stack['floating_ip']
|
||||
scheduler.TaskRunner(fip.create)()
|
||||
self.assertEqual((fip.CREATE, fip.COMPLETE), fip.state)
|
||||
self.assertEqual('172.24.4.98', fip.FnGetAtt('floating_ip_address'))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_floatip_port(self):
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
mox.IsA(neutronclient.Client),
|
||||
|
||||
Reference in New Issue
Block a user