Added fixed_ip support for standalone-ironic

This commit adds support for connect_method fixed in case of
standalone ironic. Previously it supported only floating_ip.

Change-Id: I6c0631972b9e898ec492a9de355c29e79ca2aa5c
This commit is contained in:
ankit 2018-02-09 12:09:26 +00:00
parent 9bc0598ff9
commit ba4a6ec7f8
1 changed files with 22 additions and 2 deletions

View File

@ -145,6 +145,18 @@ class BaremetalStandaloneManager(bm.BaremetalScenarioTest,
port_id=vif)
return floating_ip['floating_ip_address']
@classmethod
def get_server_ip(cls, node_id):
"""Get the server fixed IP.
:param node_id: Name or UUID of the node.
:returns: IP address of associated fixed IP.
"""
vif = cls.get_node_vifs(node_id)[0]
body = cls.ports_client.show_port(vif)['port']
fixed_ip = body['fixed_ips'][0]
return fixed_ip['ip_address']
@classmethod
def cleanup_floating_ip(cls, ip_address):
"""Removes floating IP."""
@ -337,11 +349,19 @@ class BaremetalStandaloneScenarioTest(BaremetalStandaloneManager):
if cls.deploy_interface:
boot_kwargs['deploy_interface'] = cls.deploy_interface
cls.node = cls.boot_node(cls.driver, cls.image_ref, **boot_kwargs)
cls.node_ip = cls.add_floatingip_to_node(cls.node['uuid'])
if CONF.validation.connect_method == 'floating':
cls.node_ip = cls.add_floatingip_to_node(cls.node['uuid'])
elif CONF.validation.connect_method == 'fixed':
cls.node_ip = cls.get_server_ip(cls.node['uuid'])
else:
m = ('Configuration option "[validation]/connect_method" '
'must be set.')
raise lib_exc.InvalidConfiguration(m)
@classmethod
def resource_cleanup(cls):
cls.cleanup_floating_ip(cls.node_ip)
if CONF.validation.connect_method == 'floating':
cls.cleanup_floating_ip(cls.node_ip)
vifs = cls.get_node_vifs(cls.node['uuid'])
# Remove ports before deleting node, to catch regression for cases
# when user did this prior unprovision node.