Merge ~cgrabowski/maas:provide_pool_id_for_vmhost_resources into maas:master

Proposed by Christian Grabowski
Status: Merged
Approved by: Christian Grabowski
Approved revision: c95009d6b3b04156e574c15177c9657bd793ced9
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~cgrabowski/maas:provide_pool_id_for_vmhost_resources
Merge into: maas:master
Diff against target: 63 lines (+34/-0)
2 files modified
src/maasserver/models/virtualmachine.py (+2/-0)
src/maasserver/websockets/handlers/tests/test_pod.py (+32/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato Approve
Review via email: mp+411360@code.launchpad.net

Commit message

add storage pool's pool_id on pod resources

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b provide_pool_id_for_vmhost_resources lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/11463/console
COMMIT: 1319e4f3c0c56acfc799fa594eaa6f2a2a3eb5a7

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b provide_pool_id_for_vmhost_resources lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: c95009d6b3b04156e574c15177c9657bd793ced9

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/models/virtualmachine.py b/src/maasserver/models/virtualmachine.py
index 3c12020..fbf4839 100644
--- a/src/maasserver/models/virtualmachine.py
+++ b/src/maasserver/models/virtualmachine.py
@@ -251,6 +251,7 @@ class VMHostVirtualMachineResources:
251class VMHostStoragePool:251class VMHostStoragePool:
252 """Storage pool available on a VM host"""252 """Storage pool available on a VM host"""
253253
254 id: str = ""
254 name: str = ""255 name: str = ""
255 path: str = ""256 path: str = ""
256 backend: str = ""257 backend: str = ""
@@ -447,6 +448,7 @@ def _get_global_vm_host_storage(pod, resources):
447 total_storage = 0448 total_storage = 0
448 for pool in storage_pools:449 for pool in storage_pools:
449 resources.storage_pools[pool.name] = VMHostStoragePool(450 resources.storage_pools[pool.name] = VMHostStoragePool(
451 id=pool.pool_id,
450 name=pool.name,452 name=pool.name,
451 path=pool.path,453 path=pool.path,
452 backend=pool.pool_type,454 backend=pool.pool_type,
diff --git a/src/maasserver/websockets/handlers/tests/test_pod.py b/src/maasserver/websockets/handlers/tests/test_pod.py
index 67c9ae6..b435859 100644
--- a/src/maasserver/websockets/handlers/tests/test_pod.py
+++ b/src/maasserver/websockets/handlers/tests/test_pod.py
@@ -164,6 +164,38 @@ class TestPodHandler(MAASTransactionServerTestCase):
164 )164 )
165 self.assertEqual(result["power_parameters"], power_params)165 self.assertEqual(result["power_parameters"], power_params)
166166
167 def test_get_with_storage_pool(self):
168 admin = factory.make_admin()
169 handler = PodHandler(admin, {}, None)
170 power_params = {
171 "power_address": "1.2.3.4",
172 "certificate": SAMPLE_CERTIFICATE.certificate_pem(),
173 "key": SAMPLE_CERTIFICATE.private_key_pem(),
174 "project": "maas",
175 }
176 pod = self.make_pod_with_hints(
177 pod_type="lxd",
178 parameters=power_params,
179 )
180 factory.make_Node()
181 factory.make_Node(bmc=pod)
182 factory.make_Node(bmc=pod, owner=admin)
183 factory.make_Node(bmc=pod, owner=factory.make_User())
184 storage_pool = factory.make_PodStoragePool(pod=pod)
185 expected_data = handler.full_dehydrate(pod)
186 result = handler.get({"id": pod.id})
187 self.assertEqual(expected_data.keys(), result.keys())
188 self.assertEqual(
189 result["storage_pools"], expected_data["storage_pools"]
190 )
191 storage_pool_ids = [pool["id"] for pool in result["storage_pools"]]
192 self.assertIn(storage_pool.pool_id, storage_pool_ids)
193 resource_storage_pool_ids = [
194 pool["id"]
195 for pool in result["resources"]["storage_pools"].values()
196 ]
197 self.assertIn(storage_pool.pool_id, resource_storage_pool_ids)
198
167 def test_get_with_pod_host(self):199 def test_get_with_pod_host(self):
168 admin = factory.make_admin()200 admin = factory.make_admin()
169 handler = PodHandler(admin, {}, None)201 handler = PodHandler(admin, {}, None)

Subscribers

People subscribed via source and target branches