Pass FQDN to host_evacuate.sh command
FQDN is required for nova to identify the host since version 6.1.
Pass FQDN value from node's data hash to command host_evacuate.sh
if version of the original environment is 6.1 or higher. Pass
the short name (node-N) of the node otherwise.
Closes-bug: 1523469
Change-Id: I5be715f4eab445f3cf823526a98a23e7a1749f2a
(cherry picked from commit 8c615af7ac
)
This commit is contained in:
parent
2519727b03
commit
10bc5e84eb
|
@ -78,7 +78,7 @@ class ComputeUpgrade(upgrade.UpgradeHandler):
|
|||
sftp.put(local_path, remote_path)
|
||||
sftp.chmod(remote_path, stat.S_IRWXO)
|
||||
ssh.call(
|
||||
[remote_path, 'node-{0}'.format(self.node.data['id'])],
|
||||
[remote_path, node_util.get_nova_node_handle(self.node)],
|
||||
node=controller,
|
||||
)
|
||||
|
||||
|
|
|
@ -20,13 +20,16 @@ from octane.util import ssh
|
|||
|
||||
|
||||
NODES = [
|
||||
{'fqdn': 'node-1',
|
||||
{'id': '1',
|
||||
'fqdn': 'node-1.domain.tld',
|
||||
'network_data': [{'name': 'management', 'ip': '10.20.0.2'},
|
||||
{'name': 'public', 'ip': '172.167.0.2'}]},
|
||||
{'fqdn': 'node-2',
|
||||
{'id': '2',
|
||||
'fqdn': 'node-2.domain.tld',
|
||||
'network_data': [{'name': 'management', 'ip': '10.20.0.3'},
|
||||
{'name': 'public', 'ip': '172.167.0.3'}]},
|
||||
{'fqdn': 'node-3',
|
||||
{'id': '3',
|
||||
'fqdn': 'node-3.domain.tld',
|
||||
'network_data': [{'name': 'management', 'ip': '10.20.0.4'},
|
||||
{'name': 'public', 'ip': '172.167.0.4'}]},
|
||||
]
|
||||
|
@ -44,7 +47,7 @@ def test_get_ip(node_data, network_name, expected_ip):
|
|||
|
||||
|
||||
def create_node(data):
|
||||
return mock.Mock(data=data, spec_set=['data'])
|
||||
return mock.Mock(data=data, spec_set=['data', 'env'])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -63,7 +66,9 @@ def test_get_ips(nodes, network_name, expected_ips):
|
|||
|
||||
def test_get_hostnames(nodes):
|
||||
hostnames = node_util.get_hostnames(nodes)
|
||||
assert hostnames == ['node-1', 'node-2', 'node-3']
|
||||
assert hostnames == ['node-1.domain.tld',
|
||||
'node-2.domain.tld',
|
||||
'node-3.domain.tld']
|
||||
|
||||
|
||||
def test_tar_files(node, mock_ssh_popen, mock_open):
|
||||
|
@ -162,3 +167,19 @@ def test_is_live_migration_supported(mocker, node, content, expected_res):
|
|||
|
||||
res = node_util.is_live_migration_supported(node)
|
||||
assert res == expected_res
|
||||
|
||||
|
||||
@pytest.mark.parametrize('node_data,fuel_version,expected_name', [
|
||||
(NODES[0], '6.0', 'node-1'),
|
||||
(NODES[0], '6.1', 'node-1.domain.tld'),
|
||||
(NODES[0], 'invalid', None)
|
||||
])
|
||||
def test_get_nova_node_handle(mocker, node_data, fuel_version, expected_name):
|
||||
node = create_node(node_data)
|
||||
node.env.data.get.return_value = fuel_version
|
||||
if expected_name:
|
||||
name = node_util.get_nova_node_handle(node)
|
||||
assert name == expected_name
|
||||
else:
|
||||
with pytest.raises(Exception):
|
||||
node_util.get_nova_node_handle(node)
|
||||
|
|
|
@ -17,6 +17,7 @@ import socket
|
|||
import sys
|
||||
import time
|
||||
|
||||
from distutils import version
|
||||
from octane.util import ssh
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -70,6 +71,16 @@ def get_hostname_remotely(node):
|
|||
return hostname[:-1]
|
||||
|
||||
|
||||
def get_nova_node_handle(node):
|
||||
version_num = node.env.data.get('fuel_version')
|
||||
if not version_num:
|
||||
raise Exception("Cannot determine Fuel version for node {0}"
|
||||
.format(node.data['id']))
|
||||
if version.StrictVersion(version_num) < version.StrictVersion('6.1'):
|
||||
return "node-{0}".format(node.data['id'])
|
||||
return node.data['fqdn']
|
||||
|
||||
|
||||
def reboot_nodes(nodes, timeout=600):
|
||||
old_clients = dict((node, ssh.get_client(node)) for node in nodes)
|
||||
for node in nodes:
|
||||
|
|
Loading…
Reference in New Issue