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
1diff --git a/src/maasserver/models/virtualmachine.py b/src/maasserver/models/virtualmachine.py
2index 3c12020..fbf4839 100644
3--- a/src/maasserver/models/virtualmachine.py
4+++ b/src/maasserver/models/virtualmachine.py
5@@ -251,6 +251,7 @@ class VMHostVirtualMachineResources:
6 class VMHostStoragePool:
7 """Storage pool available on a VM host"""
8
9+ id: str = ""
10 name: str = ""
11 path: str = ""
12 backend: str = ""
13@@ -447,6 +448,7 @@ def _get_global_vm_host_storage(pod, resources):
14 total_storage = 0
15 for pool in storage_pools:
16 resources.storage_pools[pool.name] = VMHostStoragePool(
17+ id=pool.pool_id,
18 name=pool.name,
19 path=pool.path,
20 backend=pool.pool_type,
21diff --git a/src/maasserver/websockets/handlers/tests/test_pod.py b/src/maasserver/websockets/handlers/tests/test_pod.py
22index 67c9ae6..b435859 100644
23--- a/src/maasserver/websockets/handlers/tests/test_pod.py
24+++ b/src/maasserver/websockets/handlers/tests/test_pod.py
25@@ -164,6 +164,38 @@ class TestPodHandler(MAASTransactionServerTestCase):
26 )
27 self.assertEqual(result["power_parameters"], power_params)
28
29+ def test_get_with_storage_pool(self):
30+ admin = factory.make_admin()
31+ handler = PodHandler(admin, {}, None)
32+ power_params = {
33+ "power_address": "1.2.3.4",
34+ "certificate": SAMPLE_CERTIFICATE.certificate_pem(),
35+ "key": SAMPLE_CERTIFICATE.private_key_pem(),
36+ "project": "maas",
37+ }
38+ pod = self.make_pod_with_hints(
39+ pod_type="lxd",
40+ parameters=power_params,
41+ )
42+ factory.make_Node()
43+ factory.make_Node(bmc=pod)
44+ factory.make_Node(bmc=pod, owner=admin)
45+ factory.make_Node(bmc=pod, owner=factory.make_User())
46+ storage_pool = factory.make_PodStoragePool(pod=pod)
47+ expected_data = handler.full_dehydrate(pod)
48+ result = handler.get({"id": pod.id})
49+ self.assertEqual(expected_data.keys(), result.keys())
50+ self.assertEqual(
51+ result["storage_pools"], expected_data["storage_pools"]
52+ )
53+ storage_pool_ids = [pool["id"] for pool in result["storage_pools"]]
54+ self.assertIn(storage_pool.pool_id, storage_pool_ids)
55+ resource_storage_pool_ids = [
56+ pool["id"]
57+ for pool in result["resources"]["storage_pools"].values()
58+ ]
59+ self.assertIn(storage_pool.pool_id, resource_storage_pool_ids)
60+
61 def test_get_with_pod_host(self):
62 admin = factory.make_admin()
63 handler = PodHandler(admin, {}, None)

Subscribers

People subscribed via source and target branches