Merge "Added fixed_ip support for standalone-ironic"

This commit is contained in:
Zuul 2018-04-05 10:56:51 +00:00 committed by Gerrit Code Review
commit f125363565
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."""
@ -370,11 +382,19 @@ class BaremetalStandaloneScenarioTest(BaremetalStandaloneManager):
if cls.rescue_interface:
boot_kwargs['rescue_interface'] = cls.rescue_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.