Merge ~ltrager/maas:lp1877126 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 0e06d77a1b2f0096ee22067b5d55055c069e8f40
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1877126
Merge into: maas:master
Diff against target: 203 lines (+61/-20)
3 files modified
src/maasserver/clusterrpc/driver_parameters.py (+15/-1)
src/maasserver/forms/pods.py (+20/-5)
src/maasserver/forms/tests/test_pods.py (+26/-14)
Reviewer Review Type Date Requested Status
Björn Tillenius Approve
MAAS Lander Approve
Review via email: mp+383915@code.launchpad.net

Commit message

LP: #1877126 - Set the default composed machine memory amount to 2048M.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1877126 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: ab6b5dfe5afafb7e8cf11b9d2d8312437e4c5ab6

review: Approve
~ltrager/maas:lp1877126 updated
0e06d77... by Lee Trager

Add storage

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

UNIT TESTS
-b lp1877126 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 0e06d77a1b2f0096ee22067b5d55055c069e8f40

review: Approve
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/clusterrpc/driver_parameters.py b/src/maasserver/clusterrpc/driver_parameters.py
2index 830a06f..3c2175e 100644
3--- a/src/maasserver/clusterrpc/driver_parameters.py
4+++ b/src/maasserver/clusterrpc/driver_parameters.py
5@@ -1,4 +1,4 @@
6-# Copyright 2012-2018 Canonical Ltd. This software is licensed under the
7+# Copyright 2012-2020 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """
11@@ -140,6 +140,20 @@ def add_power_driver_parameters(
12 }
13 if queryable is not None:
14 params["queryable"] = queryable
15+ # Add default values if the BMC is also a Pod.
16+ if driver_type == "pod":
17+ # Avoid circular dependencies
18+ from maasserver.forms.pods import (
19+ DEFAULT_COMPOSED_CORES,
20+ DEFAULT_COMPOSED_MEMORY,
21+ DEFAULT_COMPOSED_STORAGE,
22+ )
23+
24+ params["defaults"] = {
25+ "cores": DEFAULT_COMPOSED_CORES,
26+ "memory": DEFAULT_COMPOSED_MEMORY,
27+ "storage": DEFAULT_COMPOSED_STORAGE,
28+ }
29 parameters_set.append(params)
30
31
32diff --git a/src/maasserver/forms/pods.py b/src/maasserver/forms/pods.py
33index 97c59e0..03a62e3 100644
34--- a/src/maasserver/forms/pods.py
35+++ b/src/maasserver/forms/pods.py
36@@ -3,7 +3,12 @@
37
38 """Pod forms."""
39
40-__all__ = ["PodForm"]
41+__all__ = [
42+ "DEFAULT_COMPOSED_CORES",
43+ "DEFAULT_COMPOSED_MEMORY",
44+ "DEFAULT_COMPOSED_STORAGE",
45+ "PodForm",
46+]
47
48 from functools import partial
49 from urllib.parse import urlparse
50@@ -83,6 +88,13 @@ from provisioningserver.utils.twisted import asynchronous
51 log = LegacyLogger()
52
53
54+DEFAULT_COMPOSED_CORES = 1
55+# Size is in MB
56+DEFAULT_COMPOSED_MEMORY = 2048
57+# Size is in GB
58+DEFAULT_COMPOSED_STORAGE = 8
59+
60+
61 def make_unique_hostname():
62 """Returns a unique machine hostname."""
63 while True:
64@@ -502,11 +514,14 @@ class ComposeMachineForm(forms.Form):
65 self.fields["cores"] = IntegerField(
66 min_value=1, max_value=self.pod.hints.cores, required=False
67 )
68- self.initial["cores"] = 1
69+ self.initial["cores"] = DEFAULT_COMPOSED_CORES
70+ # LP:1877126 - Focal requires 2048M of memory to deploy, older
71+ # versions of Ubuntu only need 1024M. The default is 2048M so all
72+ # versions of Ubuntu work but users may use 1024M.
73 self.fields["memory"] = IntegerField(
74 min_value=1024, max_value=self.pod.hints.memory, required=False
75 )
76- self.initial["memory"] = 1024
77+ self.initial["memory"] = DEFAULT_COMPOSED_MEMORY
78 self.fields["architecture"] = ChoiceField(
79 choices=[(arch, arch) for arch in self.pod.architectures],
80 required=False,
81@@ -548,7 +563,7 @@ class ComposeMachineForm(forms.Form):
82 self.fields["storage"] = CharField(
83 validators=[storage_validator], required=False
84 )
85- self.initial["storage"] = "root:8(local)"
86+ self.initial["storage"] = f"root:{DEFAULT_COMPOSED_STORAGE}(local)"
87 self.fields["interfaces"] = LabeledConstraintMapField(
88 validators=[interfaces_validator],
89 label="Interface constraints",
90@@ -766,7 +781,7 @@ class ComposeMachineForm(forms.Form):
91 power_type,
92 power_paramaters,
93 requested_machine,
94- **kwargs
95+ **kwargs,
96 )
97 return requested_machine, result
98
99diff --git a/src/maasserver/forms/tests/test_pods.py b/src/maasserver/forms/tests/test_pods.py
100index 8b8fcce..10828ad 100644
101--- a/src/maasserver/forms/tests/test_pods.py
102+++ b/src/maasserver/forms/tests/test_pods.py
103@@ -36,6 +36,9 @@ from maasserver.forms import pods as pods_module
104 from maasserver.forms.pods import (
105 ComposeMachineForm,
106 ComposeMachineForPodsForm,
107+ DEFAULT_COMPOSED_CORES,
108+ DEFAULT_COMPOSED_MEMORY,
109+ DEFAULT_COMPOSED_STORAGE,
110 get_known_host_interfaces,
111 PodForm,
112 )
113@@ -900,8 +903,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
114 composed_machine = DiscoveredMachine(
115 hostname=factory.make_name("hostname"),
116 architecture=pod.architectures[0],
117- cores=1,
118- memory=1024,
119+ cores=DEFAULT_COMPOSED_CORES,
120+ memory=DEFAULT_COMPOSED_MEMORY,
121 cpu_speed=300,
122 block_devices=[],
123 interfaces=[],
124@@ -1034,14 +1037,18 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
125 IsInstance(RequestedMachine),
126 MatchesStructure(
127 architecture=Equals(pod.architectures[0]),
128- cores=Equals(1),
129- memory=Equals(1024),
130+ cores=Equals(DEFAULT_COMPOSED_CORES),
131+ memory=Equals(DEFAULT_COMPOSED_MEMORY),
132 cpu_speed=Is(None),
133 block_devices=MatchesListwise(
134 [
135 MatchesAll(
136 IsInstance(RequestedMachineBlockDevice),
137- MatchesStructure(size=Equals(8 * (1000 ** 3))),
138+ MatchesStructure(
139+ size=Equals(
140+ DEFAULT_COMPOSED_STORAGE * (1000 ** 3)
141+ )
142+ ),
143 )
144 ]
145 ),
146@@ -1959,8 +1966,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
147 MatchesAll(
148 IsInstance(Machine),
149 MatchesStructure(
150- cpu_count=Equals(1),
151- memory=Equals(1024),
152+ cpu_count=Equals(DEFAULT_COMPOSED_CORES),
153+ memory=Equals(DEFAULT_COMPOSED_MEMORY),
154 cpu_speed=Equals(300),
155 ),
156 ),
157@@ -2069,8 +2076,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
158 MatchesAll(
159 IsInstance(Machine),
160 MatchesStructure(
161- cpu_count=Equals(1),
162- memory=Equals(1024),
163+ cpu_count=Equals(DEFAULT_COMPOSED_CORES),
164+ memory=Equals(DEFAULT_COMPOSED_MEMORY),
165 cpu_speed=Equals(300),
166 ),
167 ),
168@@ -2106,8 +2113,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
169 MatchesAll(
170 IsInstance(Machine),
171 MatchesStructure(
172- cpu_count=Equals(1),
173- memory=Equals(1024),
174+ cpu_count=Equals(DEFAULT_COMPOSED_CORES),
175+ memory=Equals(DEFAULT_COMPOSED_MEMORY),
176 cpu_speed=Equals(300),
177 ),
178 ),
179@@ -2249,7 +2256,12 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
180 "Unable to compose KVM instance in '%s'. "
181 "Memory overcommit ratio is %s and there are %s "
182 "available resources; %s requested."
183- % (pod.name, pod.memory_over_commit_ratio, pod.memory, 1024),
184+ % (
185+ pod.name,
186+ pod.memory_over_commit_ratio,
187+ pod.memory,
188+ DEFAULT_COMPOSED_MEMORY,
189+ ),
190 str(error),
191 )
192
193@@ -2323,8 +2335,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
194 MatchesAll(
195 IsInstance(Machine),
196 MatchesStructure(
197- cpu_count=Equals(1),
198- memory=Equals(1024),
199+ cpu_count=Equals(DEFAULT_COMPOSED_CORES),
200+ memory=Equals(DEFAULT_COMPOSED_MEMORY),
201 cpu_speed=Equals(300),
202 ),
203 ),

Subscribers

People subscribed via source and target branches