Include host_id for openstack provider
When we create a server using the openstack provider, in certain conditions it is helpful to collect the host_id value. As an example, Zuul will pass through this information into a job inventory file which will allow an operator to better profile where jobs run with in a cloud. This can be helpful trying to debug random jobs timing out within a cloud. Change-Id: If29397e67a470462561f24c746375b8291ac43ab Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
a3e9ebf9f1
commit
cc994d3a6a
|
@ -141,6 +141,7 @@ class FakeOpenStackCloud(object):
|
|||
public_v6 = 'fake_v6'
|
||||
public_v4 = 'fake'
|
||||
private_v4 = 'fake'
|
||||
host_id = 'fake_host_id'
|
||||
interface_ip = 'fake_v6'
|
||||
break
|
||||
if not addresses:
|
||||
|
@ -151,6 +152,7 @@ class FakeOpenStackCloud(object):
|
|||
public_v6 = ''
|
||||
public_v4 = 'fake'
|
||||
private_v4 = 'fake'
|
||||
host_id = 'fake'
|
||||
interface_ip = 'fake'
|
||||
over_quota = False
|
||||
if (instance_type == Dummy.INSTANCE and
|
||||
|
@ -173,6 +175,7 @@ class FakeOpenStackCloud(object):
|
|||
public_v4=public_v4,
|
||||
public_v6=public_v6,
|
||||
private_v4=private_v4,
|
||||
host_id=host_id,
|
||||
interface_ip=interface_ip,
|
||||
security_groups=security_groups,
|
||||
location=Dummy(Dummy.LOCATION, zone=kw.get('az')),
|
||||
|
@ -238,6 +241,7 @@ class FakeOpenStackCloud(object):
|
|||
server.public_v4 = 'fake'
|
||||
server.public_v6 = 'fake'
|
||||
server.private_v4 = 'fake'
|
||||
server.host_id = 'fake'
|
||||
server.interface_ip = 'fake'
|
||||
return server
|
||||
|
||||
|
|
|
@ -189,6 +189,7 @@ class OpenStackNodeLauncher(NodeLauncher):
|
|||
raise exceptions.LaunchNetworkException(
|
||||
"Unable to find public IP of server")
|
||||
|
||||
self.node.host_id = server.host_id
|
||||
self.node.interface_ip = interface_ip
|
||||
self.node.public_ipv4 = server.public_v4
|
||||
self.node.public_ipv6 = server.public_v6
|
||||
|
@ -204,10 +205,10 @@ class OpenStackNodeLauncher(NodeLauncher):
|
|||
|
||||
self.log.debug(
|
||||
"Node %s is running [region: %s, az: %s, ip: %s ipv4: %s, "
|
||||
"ipv6: %s]" %
|
||||
"ipv6: %s, hostid: %s]" %
|
||||
(self.node.id, self.node.region, self.node.az,
|
||||
self.node.interface_ip, self.node.public_ipv4,
|
||||
self.node.public_ipv6))
|
||||
self.node.public_ipv6, self.node.host_id))
|
||||
|
||||
# wait and scan the new node and record in ZooKeeper
|
||||
host_keys = []
|
||||
|
|
|
@ -678,12 +678,14 @@ class TestLauncher(tests.DBTestCase):
|
|||
self.assertEqual(label1_nodes[0].public_ipv4, 'fake')
|
||||
self.assertEqual(label1_nodes[0].public_ipv6, 'fake_v6')
|
||||
self.assertEqual(label1_nodes[0].interface_ip, 'fake_v6')
|
||||
self.assertEqual(label1_nodes[0].host_id, 'fake_host_id')
|
||||
|
||||
# ipv6 address unavailable
|
||||
self.assertEqual(label2_nodes[0].provider, 'fake-provider2')
|
||||
self.assertEqual(label2_nodes[0].public_ipv4, 'fake')
|
||||
self.assertEqual(label2_nodes[0].public_ipv6, '')
|
||||
self.assertEqual(label2_nodes[0].interface_ip, 'fake')
|
||||
self.assertEqual(label2_nodes[0].host_id, 'fake')
|
||||
|
||||
def test_node_delete_success(self):
|
||||
configfile = self.setup_config('node.yaml')
|
||||
|
|
|
@ -855,6 +855,7 @@ class TestZKModel(tests.BaseTestCase):
|
|||
o.public_ipv4 = '<ipv4>'
|
||||
o.private_ipv4 = '<pvt-ipv4>'
|
||||
o.public_ipv6 = '<ipv6>'
|
||||
o.host_id = 'fake-host-id'
|
||||
o.image_id = 'image-id'
|
||||
o.launcher = 'launcher-id'
|
||||
o.external_id = 'ABCD'
|
||||
|
@ -877,6 +878,7 @@ class TestZKModel(tests.BaseTestCase):
|
|||
self.assertEqual(d['public_ipv4'], o.public_ipv4)
|
||||
self.assertEqual(d['private_ipv4'], o.private_ipv4)
|
||||
self.assertEqual(d['public_ipv6'], o.public_ipv6)
|
||||
self.assertEqual(d['host_id'], o.host_id)
|
||||
self.assertEqual(d['image_id'], o.image_id)
|
||||
self.assertEqual(d['launcher'], o.launcher)
|
||||
self.assertEqual(d['external_id'], o.external_id)
|
||||
|
@ -901,6 +903,7 @@ class TestZKModel(tests.BaseTestCase):
|
|||
'public_ipv4': '<ipv4>',
|
||||
'private_ipv4': '<pvt-ipv4>',
|
||||
'public_ipv6': '<ipv6>',
|
||||
'host_id': 'fake-host-id',
|
||||
'image_id': 'image-id',
|
||||
'launcher': 'launcher-id',
|
||||
'external_id': 'ABCD',
|
||||
|
@ -925,6 +928,7 @@ class TestZKModel(tests.BaseTestCase):
|
|||
self.assertEqual(o.public_ipv4, d['public_ipv4'])
|
||||
self.assertEqual(o.private_ipv4, d['private_ipv4'])
|
||||
self.assertEqual(o.public_ipv6, d['public_ipv6'])
|
||||
self.assertEqual(o.host_id, d['host_id'])
|
||||
self.assertEqual(o.image_id, d['image_id'])
|
||||
self.assertEqual(o.launcher, d['launcher'])
|
||||
self.assertEqual(o.external_id, d['external_id'])
|
||||
|
|
|
@ -521,6 +521,7 @@ class Node(BaseModel):
|
|||
self.public_ipv4 = None
|
||||
self.private_ipv4 = None
|
||||
self.public_ipv6 = None
|
||||
self.host_id = None
|
||||
self.interface_ip = None
|
||||
self.connection_port = 22
|
||||
self.image_id = None
|
||||
|
@ -558,6 +559,7 @@ class Node(BaseModel):
|
|||
self.public_ipv4 == other.public_ipv4 and
|
||||
self.private_ipv4 == other.private_ipv4 and
|
||||
self.public_ipv6 == other.public_ipv6 and
|
||||
self.host_id == other.host_id and
|
||||
self.interface_ip == other.interface_ip and
|
||||
self.image_id == other.image_id and
|
||||
self.launcher == other.launcher and
|
||||
|
@ -601,6 +603,7 @@ class Node(BaseModel):
|
|||
d['public_ipv4'] = self.public_ipv4
|
||||
d['private_ipv4'] = self.private_ipv4
|
||||
d['public_ipv6'] = self.public_ipv6
|
||||
d['host_id'] = self.host_id
|
||||
d['interface_ip'] = self.interface_ip
|
||||
d['connection_port'] = self.connection_port
|
||||
# TODO(tobiash): ssh_port is kept for backwards compatibility reasons
|
||||
|
@ -655,6 +658,7 @@ class Node(BaseModel):
|
|||
self.public_ipv4 = d.get('public_ipv4')
|
||||
self.private_ipv4 = d.get('private_ipv4')
|
||||
self.public_ipv6 = d.get('public_ipv6')
|
||||
self.host_id = d.get('host_id')
|
||||
self.interface_ip = d.get('interface_ip')
|
||||
self.connection_port = d.get('connection_port', d.get('ssh_port', 22))
|
||||
self.image_id = d.get('image_id')
|
||||
|
|
Loading…
Reference in New Issue