diff --git a/nodepool/driver/openstack/handler.py b/nodepool/driver/openstack/handler.py index 218f21a12..47123923c 100644 --- a/nodepool/driver/openstack/handler.py +++ b/nodepool/driver/openstack/handler.py @@ -142,6 +142,11 @@ class OpenStackNodeLauncher(NodeLauncher): self.node.external_id = server.id self.node.hostname = hostname self.node.image_id = image_id + + pool = self.handler.provider.pools.get(self.node.pool) + resources = self.handler.manager.quotaNeededByNodeType( + self.node.type[0], pool) + self.node.resources = resources.quota['compute'] if username: self.node.username = username self.node.connection_type = connection_type diff --git a/nodepool/tests/unit/test_launcher.py b/nodepool/tests/unit/test_launcher.py index 27c3ec34f..a55d0d0f7 100644 --- a/nodepool/tests/unit/test_launcher.py +++ b/nodepool/tests/unit/test_launcher.py @@ -70,6 +70,12 @@ class TestLauncher(tests.DBTestCase): image.provider_name), id=image.id) self.assertEqual(node.image_id, p) + resources = { + 'cores': 4, + 'instances': 1, + 'ram': 8192, + } + self.assertEqual(node.resources, resources) self.zk.lockNode(node, blocking=False) self.zk.unlockNode(node) diff --git a/nodepool/zk.py b/nodepool/zk.py index dcb6fec62..8fc433eec 100755 --- a/nodepool/zk.py +++ b/nodepool/zk.py @@ -515,6 +515,7 @@ class Node(BaseModel): self.connection_type = None self.host_keys = [] self.hold_expiration = None + self.resources = None def __repr__(self): d = self.toDict() @@ -549,7 +550,8 @@ class Node(BaseModel): self.connection_type == other.connection_type and self.connection_port == other.connection_port and self.host_keys == other.host_keys and - self.hold_expiration == other.hold_expiration) + self.hold_expiration == other.hold_expiration and + self.resources == other.resources) else: return False @@ -595,6 +597,7 @@ class Node(BaseModel): d['connection_type'] = self.connection_type d['connection_port'] = self.connection_port d['hold_expiration'] = self.hold_expiration + d['resources'] = self.resources return d @staticmethod @@ -644,6 +647,7 @@ class Node(BaseModel): o.hold_expiration = 0 else: o.hold_expiration = hold_expiration + o.resources = d.get('resources') return o