p/fuel: Retire Armband repos in favor of MCP ones
[armband.git] / patches / opnfv-fuel / 0008-virtng.py-virt.sls-Extend-libvirt_domain.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Enea AB and others.
3 :
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Mon, 21 Aug 2017 01:10:16 +0200
11 Subject: [PATCH] virtng.py, virt.sls: Extend libvirt_domain
12
13 Extend _modules/virtng.py, salt/control/virt.sls with support for:
14 - hw_firmware_type;
15 - virt_machine_model;
16 - cpu_model;
17
18 This functionality relies on the corresponding changes to be
19 implemented in libvirt_domain.jinja template.
20
21 These will later be leveraged via our reclass model with AArch64
22 specific values.
23
24 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
25 ---
26  .../0103-virtng-module-Extend-libvirt_domain.patch | 54 ++++++++++++++++++++++
27  ...4-salt-control-virt-Extend-libvirt_domain.patch | 51 ++++++++++++++++++++
28  mcp/patches/patches.list                           |  2 +
29  .../cluster/mcp-pike-common-ha/infra/kvm.yml       | 15 ++++++
30  .../cluster/mcp-pike-odl-ha/infra/kvm.yml.j2       |  3 ++
31  5 files changed, 125 insertions(+)
32  create mode 100644 mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch
33  create mode 100644 mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch
34
35 diff --git a/mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch b/mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch
36 new file mode 100644
37 index 00000000..706b67da
38 --- /dev/null
39 +++ b/mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch
40 @@ -0,0 +1,54 @@
41 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
42 +Date: Mon, 21 Aug 2017 02:03:01 +0200
43 +Subject: [PATCH] virtng: module: Extend libvirt_domain
44 +
45 +Extend virtng.py with support for passing down new params:
46 +- hw_firmware_type;
47 +- virt_machine_model;
48 +- cpu_model;
49 +
50 +This functionality relies on the corresponding changes to be
51 +implemented in libvirt_domain.jinja template.
52 +
53 +These will later be leveraged via salt virt formula with AArch64
54 +specific values.
55 +
56 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
57 +---
58 +
59 +diff --git a/_modules/virtng.py b/_modules/virtng.py
60 +--- a/_modules/virtng.py
61 ++++ b/_modules/virtng.py
62 +@@ -56,6 +56,10 @@
63 +
64 + VIRT_DEFAULT_HYPER = 'kvm'
65 +
66 ++DEFAULT_UEFI_LOADER_PATH = {
67 ++    "x86_64": "/usr/share/OVMF/OVMF_CODE.fd",
68 ++    "aarch64": "/usr/share/AAVMF/AAVMF_CODE.fd"
69 ++}
70 +
71 + def __virtual__():
72 +     if not HAS_ALL_IMPORTS:
73 +@@ -227,6 +231,21 @@
74 +         # TODO: make bus and model parameterized, this works for 64-bit Linux
75 +         context['controller_model'] = 'lsilogic'
76 +
77 ++    # TODO: limit cpu_model, hw_firmware_type, virt_machine_type to qemu/kvm
78 ++    # FIXME: parametrize hardcoded path for NVRAM storage
79 ++    if 'hw_firmware_type' in kwargs and kwargs['hw_firmware_type'] == 'uefi':
80 ++        context['os_loader_type'] = 'pflash'
81 ++        context['os_loader'] = DEFAULT_UEFI_LOADER_PATH[os.uname()[-1]]
82 ++        context['os_loader_nvram'] = '/var/lib/libvirt/qemu/nvram/{0}_VARS.fd'.format(name)
83 ++
84 ++    if 'virt_machine_model' in kwargs:
85 ++        context['custom_virt_machine'] = True
86 ++        context['virt_machine_model'] = kwargs['virt_machine_model']
87 ++
88 ++    if 'cpu_model' in kwargs:
89 ++        context['cpu_mode'] = 'custom'
90 ++        context['cpu_model'] = kwargs['cpu_model']
91 ++
92 +     if 'boot_dev' in kwargs:
93 +         context['boot_dev'] = []
94 +         for dev in kwargs['boot_dev'].split():
95 diff --git a/mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch b/mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch
96 new file mode 100644
97 index 00000000..78eb0bff
98 --- /dev/null
99 +++ b/mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch
100 @@ -0,0 +1,51 @@
101 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
102 +Date: Mon, 21 Aug 2017 02:03:01 +0200
103 +Subject: [PATCH] salt: control: virt: Extend libvirt_domain
104 +
105 +Extend salt/control/virt.sls with support for new params:
106 +- hw_firmware_type;
107 +- virt_machine_model;
108 +- cpu_model;
109 +
110 +This functionality relies on the corresponding changes to be
111 +implemented in libvirt_domain.jinja template, as well as in
112 +salt custom py module virtng.py.
113 +
114 +These will later be leveraged via reclass model with AArch64
115 +specific values.
116 +
117 +FIXME: Move all new params to different section, as "size" is
118 +definitely not the best choice.
119 +
120 +Example reclass model usage:
121 +salt:
122 +  control:
123 +    size:
124 +      openstack.example_vm_type:
125 +        hw_firmware_type: uefi
126 +        virt_machine_model: virt
127 +        cpu_model: host-passthrough
128 +
129 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
130 +---
131 +
132 +diff --git a/salt/control/virt.sls b/salt/control/virt.sls
133 +--- a/salt/control/virt.sls
134 ++++ b/salt/control/virt.sls
135 +@@ -44,6 +44,16 @@
136 +       {%- if node.img_dest is defined %}
137 +       img_dest: {{ node.img_dest }}
138 +       {%- endif %}
139 ++      # FIXME(armband): Move these 3 params to different section
140 ++      {%- if size.hw_firmware_type is defined %}
141 ++      hw_firmware_type: {{ size.hw_firmware_type }}
142 ++      {%- endif %}
143 ++      {%- if size.virt_machine_model is defined %}
144 ++      virt_machine_model: {{ size.virt_machine_model }}
145 ++      {%- endif %}
146 ++      {%- if size.cpu_model is defined %}
147 ++      cpu_model: {{ size.cpu_model }}
148 ++      {%- endif %}
149 +   - unless: virsh list --all --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
150 +
151 + #salt_control_seed_{{ cluster_name }}_{{ node_name }}:
152 diff --git a/mcp/patches/patches.list b/mcp/patches/patches.list
153 index 3632a92b..5bbacf56 100644
154 --- a/mcp/patches/patches.list
155 +++ b/mcp/patches/patches.list
156 @@ -18,3 +18,5 @@
157  /usr/share/salt-formulas/env: 0015-Set-ovs-bridges-as-L3-interfaces.patch
158  /usr/share/salt-formulas/env: 0016-Set-boot-source-selections.patch
159  /usr/share/salt-formulas/env: 0101-maas-Add-curtin_userdata_arm64_generic_xenial.patch
160 +/usr/share/salt-formulas/env: 0103-virtng-module-Extend-libvirt_domain.patch
161 +/usr/share/salt-formulas/env: 0104-salt-control-virt-Extend-libvirt_domain.patch
162 diff --git a/mcp/reclass/classes/cluster/mcp-pike-common-ha/infra/kvm.yml b/mcp/reclass/classes/cluster/mcp-pike-common-ha/infra/kvm.yml
163 index 5bbe0fe4..84b392e6 100644
164 --- a/mcp/reclass/classes/cluster/mcp-pike-common-ha/infra/kvm.yml
165 +++ b/mcp/reclass/classes/cluster/mcp-pike-common-ha/infra/kvm.yml
166 @@ -53,21 +53,33 @@ parameters:
167          openstack.control:
168            cpu: 4
169            ram: 12288
170 +          hw_firmware_type: uefi
171 +          virt_machine_model: virt
172 +          cpu_model: host-passthrough
173            disk_profile: small
174            net_profile: default
175          openstack.database:
176            cpu: 4
177            ram: 6144
178 +          hw_firmware_type: uefi
179 +          virt_machine_model: virt
180 +          cpu_model: host-passthrough
181            disk_profile: large
182            net_profile: default
183          openstack.message_queue:
184            cpu: 4
185            ram: 2048
186 +          hw_firmware_type: uefi
187 +          virt_machine_model: virt
188 +          cpu_model: host-passthrough
189            disk_profile: small
190            net_profile: default
191          openstack.telemetry:
192            cpu: 2
193            ram: 3072
194 +          hw_firmware_type: uefi
195 +          virt_machine_model: virt
196 +          cpu_model: host-passthrough
197            disk_profile: xxlarge
198            net_profile: default
199          # stacklight.log:
200 @@ -88,6 +100,9 @@ parameters:
201          openstack.proxy:
202            cpu: 2
203            ram: 2048
204 +          hw_firmware_type: uefi
205 +          virt_machine_model: virt
206 +          cpu_model: host-passthrough
207            disk_profile: small
208            net_profile: default_ext
209        cluster:
210 diff --git a/mcp/reclass/classes/cluster/mcp-pike-odl-ha/infra/kvm.yml.j2 b/mcp/reclass/classes/cluster/mcp-pike-odl-ha/infra/kvm.yml.j2
211 index 5fc4776d..b19789e3 100644
212 --- a/mcp/reclass/classes/cluster/mcp-pike-odl-ha/infra/kvm.yml.j2
213 +++ b/mcp/reclass/classes/cluster/mcp-pike-odl-ha/infra/kvm.yml.j2
214 @@ -19,6 +19,9 @@ parameters:
215          opendaylight.server:
216            cpu: 4
217            ram: 8192
218 +          hw_firmware_type: uefi
219 +          virt_machine_model: virt
220 +          cpu_model: host-passthrough
221            disk_profile: small
222            net_profile: default
223        cluster: