Merge lp:~tycho-s/maas/add-missing-node-fields into lp:~maas-committers/maas/trunk

Proposed by Tycho Andersen
Status: Merged
Approved by: Tycho Andersen
Approved revision: no longer in the source branch.
Merged at revision: 1753
Proposed branch: lp:~tycho-s/maas/add-missing-node-fields
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 68 lines (+30/-0)
3 files modified
src/maasserver/forms.py (+13/-0)
src/maasserver/tests/test_api_node.py (+14/-0)
src/maasserver/tests/test_forms.py (+3/-0)
To merge this branch: bzr merge lp:~tycho-s/maas/add-missing-node-fields
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+196946@code.launchpad.net

Commit message

Add cpu_count, memory, storage to the list of updateable fields via the API.

Description of the change

Add cpu_count, memory, storage to the list of updateable fields via the API.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

Aren't these fields ones that are pulled from the hardware inventory, and the next run of the tags processing is going to reset them to whatever the value was before?

Revision history for this message
Julian Edwards (julian-edwards) wrote :

Indeed - it's why they're not writable by the API or the UI, the are supposed
to come from hardware inventory. If that process is not working, we should
fix it, not paper over it.

However, I'll change my vote if you can justify it :)

review: Disapprove
Revision history for this message
Gavin Panella (allenap) wrote :

Fwiw, I would have approved this but for the reasons already mentioned.
It's a good change. Have a quick (<5 minute) pre-implementation call next
time, with any of us.

Revision history for this message
Tycho Andersen (tycho-s) wrote :

On Wed, Nov 27, 2013 at 11:01:54PM -0000, Julian Edwards wrote:
> Review: Disapprove
>
> Indeed - it's why they're not writable by the API or the UI, the are supposed
> to come from hardware inventory. If that process is not working, we should
> fix it, not paper over it.
>
> However, I'll change my vote if you can justify it :)

If I create a node via `maas-cli maas nodes new', there is currently
no way to set the hwinfo that I can see. I spoke with jtv, and he
seemed to think this was an oversight. That said, is there any reason
/not/ to support this? What happens if I add some RAM to a box?

Revision history for this message
Tycho Andersen (tycho-s) wrote :

On Wed, Nov 27, 2013 at 11:09:17PM -0000, Gavin Panella wrote:
> Fwiw, I would have approved this but for the reasons already mentioned.
> It's a good change. Have a quick (<5 minute) pre-implementation call next
> time, with any of us.

Yes, I did speak with jtv.

Revision history for this message
Gavin Panella (allenap) wrote :

> On Wed, Nov 27, 2013 at 11:01:54PM -0000, Julian Edwards wrote:
> > Review: Disapprove
> >
> > Indeed - it's why they're not writable by the API or the UI, the are
> supposed
> > to come from hardware inventory. If that process is not working, we should
> > fix it, not paper over it.
> >
> > However, I'll change my vote if you can justify it :)
>
> If I create a node via `maas-cli maas nodes new', there is currently
> no way to set the hwinfo that I can see. I spoke with jtv, and he
> seemed to think this was an oversight. That said, is there any reason
> /not/ to support this? What happens if I add some RAM to a box?

In theory, that would be done by a mini-commissioning cycle. However, we don't have one, though we can force a machine through a full commissioning cycle. That means deallocating the machine from the user, which may not be desirable. There's merit in letting people fix their own data while MAAS does not provide convenient means to update itself.

I don't want to flip-flop on this, so let's see what others think. Jeroen was in favour, I'm on the fence. Does anyone else want to chime in?

As a compromise, we could land this so that people using dailies can use it. However, we'd also file a bug against 14.04 to review its inclusion in the LTS; perhaps there would be a better way to do it at that point.

Revision history for this message
Julian Edwards (julian-edwards) wrote :

So, if you add a new node it is supposed to go through commissioning and that will set the hwinfo. However, your more compelling case is the one where you change the RAM, for example, and don't want to deallocate the machine. Until we have a better solution to do that automatically then I'm happy for this to land.

Thanks for doing it!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/forms.py'
2--- src/maasserver/forms.py 2013-11-25 10:33:08 +0000
3+++ src/maasserver/forms.py 2013-11-27 17:08:38 +0000
4@@ -199,6 +199,16 @@
5 'power_parameters'.
6 """
7
8+ cpu_count = forms.IntegerField(
9+ required=False, initial=0,
10+ label="CPU Count")
11+ memory = forms.IntegerField(
12+ required=False, initial=0,
13+ label="Memory")
14+ storage = forms.IntegerField(
15+ required=False, initial=0,
16+ label="Disk space")
17+
18 class Meta:
19 model = Node
20
21@@ -207,6 +217,9 @@
22 fields = NodeForm.Meta.fields + (
23 'power_type',
24 'power_parameters',
25+ 'cpu_count',
26+ 'memory',
27+ 'storage',
28 )
29
30 def __init__(self, data=None, files=None, instance=None, initial=None):
31
32=== modified file 'src/maasserver/tests/test_api_node.py'
33--- src/maasserver/tests/test_api_node.py 2013-10-18 16:35:07 +0000
34+++ src/maasserver/tests/test_api_node.py 2013-11-27 17:08:38 +0000
35@@ -537,6 +537,20 @@
36 {'mac_address': new_power_address},
37 reload_object(node).power_parameters)
38
39+ def test_PUT_updates_cpu_memory_storage(self):
40+ self.become_admin()
41+ node = factory.make_node(
42+ owner=self.logged_in_user,
43+ power_type=POWER_TYPE.WAKE_ON_LAN)
44+ response = self.client_put(
45+ self.get_node_uri(node),
46+ {'cpu_count': 1, 'memory': 1024, 'storage': 2048})
47+ self.assertEqual(httplib.OK, response.status_code)
48+ node = reload_object(node)
49+ self.assertEqual(1, node.cpu_count)
50+ self.assertEqual(1024, node.memory)
51+ self.assertEqual(2048, node.storage)
52+
53 def test_PUT_updates_power_parameters_accepts_only_mac_for_wol(self):
54 self.become_admin()
55 node = factory.make_node(
56
57=== modified file 'src/maasserver/tests/test_forms.py'
58--- src/maasserver/tests/test_forms.py 2013-10-20 19:50:56 +0000
59+++ src/maasserver/tests/test_forms.py 2013-11-27 17:08:38 +0000
60@@ -336,6 +336,9 @@
61 'distro_series',
62 'power_type',
63 'power_parameters',
64+ 'cpu_count',
65+ 'memory',
66+ 'storage',
67 ],
68 list(form.fields))
69