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
diff --git a/src/maasserver/clusterrpc/driver_parameters.py b/src/maasserver/clusterrpc/driver_parameters.py
index 830a06f..3c2175e 100644
--- a/src/maasserver/clusterrpc/driver_parameters.py
+++ b/src/maasserver/clusterrpc/driver_parameters.py
@@ -1,4 +1,4 @@
1# Copyright 2012-2018 Canonical Ltd. This software is licensed under the1# Copyright 2012-2020 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""4"""
@@ -140,6 +140,20 @@ def add_power_driver_parameters(
140 }140 }
141 if queryable is not None:141 if queryable is not None:
142 params["queryable"] = queryable142 params["queryable"] = queryable
143 # Add default values if the BMC is also a Pod.
144 if driver_type == "pod":
145 # Avoid circular dependencies
146 from maasserver.forms.pods import (
147 DEFAULT_COMPOSED_CORES,
148 DEFAULT_COMPOSED_MEMORY,
149 DEFAULT_COMPOSED_STORAGE,
150 )
151
152 params["defaults"] = {
153 "cores": DEFAULT_COMPOSED_CORES,
154 "memory": DEFAULT_COMPOSED_MEMORY,
155 "storage": DEFAULT_COMPOSED_STORAGE,
156 }
143 parameters_set.append(params)157 parameters_set.append(params)
144158
145159
diff --git a/src/maasserver/forms/pods.py b/src/maasserver/forms/pods.py
index 97c59e0..03a62e3 100644
--- a/src/maasserver/forms/pods.py
+++ b/src/maasserver/forms/pods.py
@@ -3,7 +3,12 @@
33
4"""Pod forms."""4"""Pod forms."""
55
6__all__ = ["PodForm"]6__all__ = [
7 "DEFAULT_COMPOSED_CORES",
8 "DEFAULT_COMPOSED_MEMORY",
9 "DEFAULT_COMPOSED_STORAGE",
10 "PodForm",
11]
712
8from functools import partial13from functools import partial
9from urllib.parse import urlparse14from urllib.parse import urlparse
@@ -83,6 +88,13 @@ from provisioningserver.utils.twisted import asynchronous
83log = LegacyLogger()88log = LegacyLogger()
8489
8590
91DEFAULT_COMPOSED_CORES = 1
92# Size is in MB
93DEFAULT_COMPOSED_MEMORY = 2048
94# Size is in GB
95DEFAULT_COMPOSED_STORAGE = 8
96
97
86def make_unique_hostname():98def make_unique_hostname():
87 """Returns a unique machine hostname."""99 """Returns a unique machine hostname."""
88 while True:100 while True:
@@ -502,11 +514,14 @@ class ComposeMachineForm(forms.Form):
502 self.fields["cores"] = IntegerField(514 self.fields["cores"] = IntegerField(
503 min_value=1, max_value=self.pod.hints.cores, required=False515 min_value=1, max_value=self.pod.hints.cores, required=False
504 )516 )
505 self.initial["cores"] = 1517 self.initial["cores"] = DEFAULT_COMPOSED_CORES
518 # LP:1877126 - Focal requires 2048M of memory to deploy, older
519 # versions of Ubuntu only need 1024M. The default is 2048M so all
520 # versions of Ubuntu work but users may use 1024M.
506 self.fields["memory"] = IntegerField(521 self.fields["memory"] = IntegerField(
507 min_value=1024, max_value=self.pod.hints.memory, required=False522 min_value=1024, max_value=self.pod.hints.memory, required=False
508 )523 )
509 self.initial["memory"] = 1024524 self.initial["memory"] = DEFAULT_COMPOSED_MEMORY
510 self.fields["architecture"] = ChoiceField(525 self.fields["architecture"] = ChoiceField(
511 choices=[(arch, arch) for arch in self.pod.architectures],526 choices=[(arch, arch) for arch in self.pod.architectures],
512 required=False,527 required=False,
@@ -548,7 +563,7 @@ class ComposeMachineForm(forms.Form):
548 self.fields["storage"] = CharField(563 self.fields["storage"] = CharField(
549 validators=[storage_validator], required=False564 validators=[storage_validator], required=False
550 )565 )
551 self.initial["storage"] = "root:8(local)"566 self.initial["storage"] = f"root:{DEFAULT_COMPOSED_STORAGE}(local)"
552 self.fields["interfaces"] = LabeledConstraintMapField(567 self.fields["interfaces"] = LabeledConstraintMapField(
553 validators=[interfaces_validator],568 validators=[interfaces_validator],
554 label="Interface constraints",569 label="Interface constraints",
@@ -766,7 +781,7 @@ class ComposeMachineForm(forms.Form):
766 power_type,781 power_type,
767 power_paramaters,782 power_paramaters,
768 requested_machine,783 requested_machine,
769 **kwargs784 **kwargs,
770 )785 )
771 return requested_machine, result786 return requested_machine, result
772787
diff --git a/src/maasserver/forms/tests/test_pods.py b/src/maasserver/forms/tests/test_pods.py
index 8b8fcce..10828ad 100644
--- a/src/maasserver/forms/tests/test_pods.py
+++ b/src/maasserver/forms/tests/test_pods.py
@@ -36,6 +36,9 @@ from maasserver.forms import pods as pods_module
36from maasserver.forms.pods import (36from maasserver.forms.pods import (
37 ComposeMachineForm,37 ComposeMachineForm,
38 ComposeMachineForPodsForm,38 ComposeMachineForPodsForm,
39 DEFAULT_COMPOSED_CORES,
40 DEFAULT_COMPOSED_MEMORY,
41 DEFAULT_COMPOSED_STORAGE,
39 get_known_host_interfaces,42 get_known_host_interfaces,
40 PodForm,43 PodForm,
41)44)
@@ -900,8 +903,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
900 composed_machine = DiscoveredMachine(903 composed_machine = DiscoveredMachine(
901 hostname=factory.make_name("hostname"),904 hostname=factory.make_name("hostname"),
902 architecture=pod.architectures[0],905 architecture=pod.architectures[0],
903 cores=1,906 cores=DEFAULT_COMPOSED_CORES,
904 memory=1024,907 memory=DEFAULT_COMPOSED_MEMORY,
905 cpu_speed=300,908 cpu_speed=300,
906 block_devices=[],909 block_devices=[],
907 interfaces=[],910 interfaces=[],
@@ -1034,14 +1037,18 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
1034 IsInstance(RequestedMachine),1037 IsInstance(RequestedMachine),
1035 MatchesStructure(1038 MatchesStructure(
1036 architecture=Equals(pod.architectures[0]),1039 architecture=Equals(pod.architectures[0]),
1037 cores=Equals(1),1040 cores=Equals(DEFAULT_COMPOSED_CORES),
1038 memory=Equals(1024),1041 memory=Equals(DEFAULT_COMPOSED_MEMORY),
1039 cpu_speed=Is(None),1042 cpu_speed=Is(None),
1040 block_devices=MatchesListwise(1043 block_devices=MatchesListwise(
1041 [1044 [
1042 MatchesAll(1045 MatchesAll(
1043 IsInstance(RequestedMachineBlockDevice),1046 IsInstance(RequestedMachineBlockDevice),
1044 MatchesStructure(size=Equals(8 * (1000 ** 3))),1047 MatchesStructure(
1048 size=Equals(
1049 DEFAULT_COMPOSED_STORAGE * (1000 ** 3)
1050 )
1051 ),
1045 )1052 )
1046 ]1053 ]
1047 ),1054 ),
@@ -1959,8 +1966,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
1959 MatchesAll(1966 MatchesAll(
1960 IsInstance(Machine),1967 IsInstance(Machine),
1961 MatchesStructure(1968 MatchesStructure(
1962 cpu_count=Equals(1),1969 cpu_count=Equals(DEFAULT_COMPOSED_CORES),
1963 memory=Equals(1024),1970 memory=Equals(DEFAULT_COMPOSED_MEMORY),
1964 cpu_speed=Equals(300),1971 cpu_speed=Equals(300),
1965 ),1972 ),
1966 ),1973 ),
@@ -2069,8 +2076,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
2069 MatchesAll(2076 MatchesAll(
2070 IsInstance(Machine),2077 IsInstance(Machine),
2071 MatchesStructure(2078 MatchesStructure(
2072 cpu_count=Equals(1),2079 cpu_count=Equals(DEFAULT_COMPOSED_CORES),
2073 memory=Equals(1024),2080 memory=Equals(DEFAULT_COMPOSED_MEMORY),
2074 cpu_speed=Equals(300),2081 cpu_speed=Equals(300),
2075 ),2082 ),
2076 ),2083 ),
@@ -2106,8 +2113,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
2106 MatchesAll(2113 MatchesAll(
2107 IsInstance(Machine),2114 IsInstance(Machine),
2108 MatchesStructure(2115 MatchesStructure(
2109 cpu_count=Equals(1),2116 cpu_count=Equals(DEFAULT_COMPOSED_CORES),
2110 memory=Equals(1024),2117 memory=Equals(DEFAULT_COMPOSED_MEMORY),
2111 cpu_speed=Equals(300),2118 cpu_speed=Equals(300),
2112 ),2119 ),
2113 ),2120 ),
@@ -2249,7 +2256,12 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
2249 "Unable to compose KVM instance in '%s'. "2256 "Unable to compose KVM instance in '%s'. "
2250 "Memory overcommit ratio is %s and there are %s "2257 "Memory overcommit ratio is %s and there are %s "
2251 "available resources; %s requested."2258 "available resources; %s requested."
2252 % (pod.name, pod.memory_over_commit_ratio, pod.memory, 1024),2259 % (
2260 pod.name,
2261 pod.memory_over_commit_ratio,
2262 pod.memory,
2263 DEFAULT_COMPOSED_MEMORY,
2264 ),
2253 str(error),2265 str(error),
2254 )2266 )
22552267
@@ -2323,8 +2335,8 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
2323 MatchesAll(2335 MatchesAll(
2324 IsInstance(Machine),2336 IsInstance(Machine),
2325 MatchesStructure(2337 MatchesStructure(
2326 cpu_count=Equals(1),2338 cpu_count=Equals(DEFAULT_COMPOSED_CORES),
2327 memory=Equals(1024),2339 memory=Equals(DEFAULT_COMPOSED_MEMORY),
2328 cpu_speed=Equals(300),2340 cpu_speed=Equals(300),
2329 ),2341 ),
2330 ),2342 ),

Subscribers

People subscribed via source and target branches