diff --git a/nodepool/driver/fake/provider.py b/nodepool/driver/fake/provider.py index 9a52c8719..5d67914f3 100644 --- a/nodepool/driver/fake/provider.py +++ b/nodepool/driver/fake/provider.py @@ -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 diff --git a/nodepool/driver/openstack/handler.py b/nodepool/driver/openstack/handler.py index f1e82dd9b..b72de912d 100644 --- a/nodepool/driver/openstack/handler.py +++ b/nodepool/driver/openstack/handler.py @@ -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 = [] diff --git a/nodepool/tests/unit/test_launcher.py b/nodepool/tests/unit/test_launcher.py index 46f62d6ba..f9f0e84c0 100644 --- a/nodepool/tests/unit/test_launcher.py +++ b/nodepool/tests/unit/test_launcher.py @@ -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') diff --git a/nodepool/tests/unit/test_zk.py b/nodepool/tests/unit/test_zk.py index 401196ac2..857ba1401 100644 --- a/nodepool/tests/unit/test_zk.py +++ b/nodepool/tests/unit/test_zk.py @@ -855,6 +855,7 @@ class TestZKModel(tests.BaseTestCase): o.public_ipv4 = '' o.private_ipv4 = '' o.public_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': '', 'private_ipv4': '', 'public_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']) diff --git a/nodepool/zk.py b/nodepool/zk.py index e42f64488..ee456c4dd 100755 --- a/nodepool/zk.py +++ b/nodepool/zk.py @@ -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')