Merge ~andreserl/maas:install_kvm into maas:master

Proposed by Andres Rodriguez
Status: Rejected
Rejected by: Adam Collard
Proposed branch: ~andreserl/maas:install_kvm
Merge into: maas:master
Diff against target: 139 lines (+31/-0)
6 files modified
src/maasserver/api/machines.py (+11/-0)
src/maasserver/forms/__init__.py (+6/-0)
src/maasserver/models/node.py (+6/-0)
src/maasserver/preseed.py (+6/-0)
src/maasserver/websockets/handlers/device.py (+1/-0)
src/maasserver/websockets/handlers/machine.py (+1/-0)
Reviewer Review Type Date Requested Status
MAAS Maintainers Pending
Review via email: mp+354262@code.launchpad.net

Description of the change

This branch is just some initial code to actually install kvm to the machine. This branch doesnt handle:

1. adding the machine as a pod once deployed.
2. figuring out ssh keys (e.g. maas should create a ssh key for itself, and inject it to the deployed machine).
3. Removing the machine from the listing page and/or preventing from it being released. (we should track that a machine was deployed as a pod to not allow the release without confirmation or automatically lock it)./

To post a comment you must log in.

Unmerged commits

53ae52e... by Andres Rodriguez

Initial work to install kvm

2bb405d... by Andres Rodriguez

Fix tests which was cuasing infinite loop

6a8f245... by Andres Rodriguez

Fix lint

18a37f5... by Andres Rodriguez

LP: #1790015 - Fix no_proxy to also use IPv6 addresses inside brackets.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/machines.py b/src/maasserver/api/machines.py
2index 9a95cc8..31c12fe 100644
3--- a/src/maasserver/api/machines.py
4+++ b/src/maasserver/api/machines.py
5@@ -556,6 +556,9 @@ class MachineHandler(NodeHandler, OwnerDataMixin, PowerMixin):
6 :param install_rackd: If True, the Rack Controller will be installed on
7 this machine.
8 :type install_rackd: boolean
9+ :param install_kvm: If True, KVM will be installed on this machine and
10+ added to MAAS.
11+ :type install_kvm: boolean
12
13 Ideally we'd have MIME multipart and content-transfer-encoding etc.
14 deal with the encapsulation of binary data, but couldn't make it work
15@@ -573,6 +576,8 @@ class MachineHandler(NodeHandler, OwnerDataMixin, PowerMixin):
16 hwe_kernel = request.POST.get('hwe_kernel', None)
17 install_rackd = get_optional_param(
18 request.POST, 'install_rackd', default=False, validator=StringBool)
19+ install_kvm = get_optional_param(
20+ request.POST, 'install_kvm', default=False, validator=StringBool)
21 # Acquiring a node requires VIEW permissions.
22 machine = self.model.objects.get_node_or_404(
23 system_id=system_id, user=request.user,
24@@ -603,6 +608,10 @@ class MachineHandler(NodeHandler, OwnerDataMixin, PowerMixin):
25 if (install_rackd and not
26 request.user.has_perm(NODE_PERMISSION.ADMIN, machine)):
27 raise PermissionDenied()
28+ # Deploying with 'install_kvm' requires ADMIN permissions.
29+ if (install_kvm and not
30+ request.user.has_perm(NODE_PERMISSION.ADMIN, machine)):
31+ raise PermissionDenied()
32 if not machine.distro_series and not series:
33 series = Config.objects.get_config('default_distro_series')
34 Form = get_machine_edit_form(request.user)
35@@ -615,6 +624,8 @@ class MachineHandler(NodeHandler, OwnerDataMixin, PowerMixin):
36 form.set_hwe_kernel(hwe_kernel=hwe_kernel)
37 if install_rackd:
38 form.set_install_rackd(install_rackd=install_rackd)
39+ if install_kvm:
40+ form.set_install_rackd(install_kvm=install_kvm)
41 if form.is_valid():
42 form.save()
43 else:
44diff --git a/src/maasserver/forms/__init__.py b/src/maasserver/forms/__init__.py
45index 69440fa..9ad9129 100644
46--- a/src/maasserver/forms/__init__.py
47+++ b/src/maasserver/forms/__init__.py
48@@ -842,6 +842,11 @@ class MachineForm(NodeForm):
49 self.is_bound = True
50 self.data['install_rackd'] = install_rackd
51
52+ def set_install_kvm(self, install_kvm=False):
53+ """Sets whether to deploy the rack alongside this machine."""
54+ self.is_bound = True
55+ self.data['install_kvm'] = install_kvm
56+
57 class Meta:
58 model = Machine
59
60@@ -853,6 +858,7 @@ class MachineForm(NodeForm):
61 'min_hwe_kernel',
62 'hwe_kernel',
63 'install_rackd',
64+ 'install_kvm',
65 )
66
67
68diff --git a/src/maasserver/models/node.py b/src/maasserver/models/node.py
69index b09d0dc..977e4b2 100644
70--- a/src/maasserver/models/node.py
71+++ b/src/maasserver/models/node.py
72@@ -864,6 +864,8 @@ class Node(CleanSave, TimestampedModel):
73 :ivar objects: The :class:`GeneralManager`.
74 :ivar install_rackd: An optional flag to indicate if this node should be
75 deployed with the rack controller.
76+ :ivar install_kvm: An optional flag to indicate if this node should be
77+ deployed with KVM and added to MAAS.
78 :ivar enable_ssh: An optional flag to indicate if this node can have
79 ssh enabled during commissioning, allowing the user to ssh into the
80 machine's commissioning environment using the user's SSH key.
81@@ -1046,6 +1048,9 @@ class Node(CleanSave, TimestampedModel):
82 # Used to deploy the rack controller on a installation machine.
83 install_rackd = BooleanField(default=False)
84
85+ # Used to deploy the rack controller on a installation machine.
86+ install_kvm = BooleanField(default=False)
87+
88 # Used to determine whether to:
89 # 1. Import the SSH Key during commissioning and keep power on.
90 # 2. Skip reconfiguring networking when a node is commissioned.
91@@ -2957,6 +2962,7 @@ class Node(CleanSave, TimestampedModel):
92 self.hwe_kernel = None
93 self.current_installation_script_set = None
94 self.install_rackd = False
95+ self.install_kvm = False
96 self.save()
97
98 # Clear the nodes acquired filesystems.
99diff --git a/src/maasserver/preseed.py b/src/maasserver/preseed.py
100index e795f96..2e2eab6 100644
101--- a/src/maasserver/preseed.py
102+++ b/src/maasserver/preseed.py
103@@ -497,6 +497,12 @@ def get_curtin_config(request, node):
104 if 's390x' in node.architecture:
105 command = {'maas_00': 'chreipl node /dev/' + node.get_boot_disk().name}
106 config['late_commands'].update(command)
107+ # TODO: Add commands that install and configure KVM for MAAS' KVM Pod
108+ # Customizations are needed for the different architectures. See qa-lab-tests
109+ # to determine how to do it.
110+ if node.install_kvm:
111+ command = {'kmv_pod': 'apt-get install qemu-kvm'}
112+ config['late_commands'].update(command)
113 return yaml.safe_dump(config)
114
115
116diff --git a/src/maasserver/websockets/handlers/device.py b/src/maasserver/websockets/handlers/device.py
117index c3cf5c1..4c964a8 100644
118--- a/src/maasserver/websockets/handlers/device.py
119+++ b/src/maasserver/websockets/handlers/device.py
120@@ -131,6 +131,7 @@ class DeviceHandler(NodeHandler):
121 "last_image_sync",
122 "default_user",
123 "install_rackd",
124+ "install_kvm",
125 ]
126 list_fields = [
127 "id",
128diff --git a/src/maasserver/websockets/handlers/machine.py b/src/maasserver/websockets/handlers/machine.py
129index 244ae66..5bb677b 100644
130--- a/src/maasserver/websockets/handlers/machine.py
131+++ b/src/maasserver/websockets/handlers/machine.py
132@@ -172,6 +172,7 @@ class MachineHandler(NodeHandler):
133 "managing_process",
134 "last_image_sync",
135 "install_rackd",
136+ "install_kvm",
137 ]
138 list_fields = [
139 "id",

Subscribers

People subscribed via source and target branches