sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #03902
[Merge] ~igor-brovtsin/maas:lp-1994945 into maas:master
Igor Brovtsin has proposed merging ~igor-brovtsin/maas:lp-1994945 into maas:master.
Commit message:
fix(LP#1994945): don't try to set default value when no values are present
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~igor-brovtsin/maas/+git/maas/+merge/434359
This MP fixes an issue preventing users from allocating machines when at least one virsh host is uninitialized
--
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/src/maasserver/forms/pods.py b/src/maasserver/forms/pods.py
index ed406fb..55c527a 100644
--- a/src/maasserver/forms/pods.py
+++ b/src/maasserver/forms/pods.py
@@ -425,7 +425,9 @@ class ComposeMachineForm(forms.Form):
choices=[(arch, arch) for arch in self.pod.architectures],
required=False,
)
- self.initial["architecture"] = self.pod.architectures[0]
+ if self.pod.architectures:
+ self.initial["architecture"] = self.pod.architectures[0]
+
if self.pod.hints.cpu_speed > 0:
self.fields["cpu_speed"] = IntegerField(
min_value=300,
diff --git a/src/maasserver/forms/tests/test_pods.py b/src/maasserver/forms/tests/test_pods.py
index fbdeaef..bb3c6fc 100644
--- a/src/maasserver/forms/tests/test_pods.py
+++ b/src/maasserver/forms/tests/test_pods.py
@@ -638,6 +638,25 @@ class TestComposeMachineForm(MAASTransactionServerTestCase):
),
)
+ def test_sets_up_fields_based_on_pod_no_architectures(self):
+ request = MagicMock()
+ pod = make_pod_with_hints()
+ pod.architectures = []
+ form = ComposeMachineForm(request=request, pod=pod)
+ self.assertThat(
+ form.fields["architecture"],
+ MatchesStructure(
+ required=Equals(False),
+ choices=MatchesSetwise(
+ *[
+ Equals((architecture, architecture))
+ for architecture in pod.architectures
+ ]
+ ),
+ ),
+ )
+ self.assertNotIn("architecture", form.initial)
+
def test_sets_up_fields_based_on_pod_no_max_cpu_speed(self):
request = MagicMock()
pod = make_pod_with_hints()
Follow ups