p/fuel: Retire OPNFV user
[armband.git] / patches / opnfv-fuel / 0002-mcp-salt-formulas-armband-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: Sun, 20 Aug 2017 22:41:26 +0200
11 Subject: [PATCH] mcp: salt-formulas: armband: Extend libvirt_domain
12
13 Add new state in armband salt formula that:
14 * extends salt's virt libvirt_domain.jinja template with support for:
15   - hw_firmware_type;
16   - virt_machine_model;
17   - cpu_model;
18   These will later be leveraged via salt virt formula with AArch64
19   specific values.
20 * to ensure compatibilty of `virt.purge` with NVRAM-enabled domains
21   at undefine time, pass down the proper flag to libvirt from virt.py.
22 * re-enable AArch64 bootstrap
23   Recent changes in salt bootstrap script from [1] whitelist a
24   fixed pool of known architectures. Add "arm64" to that list on the
25   fly, as part of `config.gather_bootstrap_script`.
26   NOTE: This change will be leveraged by passing a custom DEB repo to
27   the bootstrap script with `-R linux.enea.com/saltstack`.
28
29 NOTE: After running this new state, salt-minion should be restarted
30 to pick up the changes, so we'll run it before rebooting kvm nodes.
31
32 [1] http://bootstrap.saltstack.com
33
34 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
35 ---
36  mcp/config/states/baremetal_init              |  1 +
37  .../files/salt-minion-aarch64-rollup.diff     | 70 +++++++++++++++++++
38  mcp/salt-formulas/armband/salt_minion.sls     |  7 ++
39  3 files changed, 78 insertions(+)
40  create mode 100644 mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff
41  create mode 100644 mcp/salt-formulas/armband/salt_minion.sls
42
43 diff --git a/mcp/config/states/baremetal_init b/mcp/config/states/baremetal_init
44 index 358e1874..14d6a570 100755
45 --- a/mcp/config/states/baremetal_init
46 +++ b/mcp/config/states/baremetal_init
47 @@ -32,6 +32,7 @@ wait_for 5.0 "salt -C '${cluster_nodes_query}' state.apply salt.minion"
48  wait_for 5.0 "salt -C '${compute_nodes_query}' state.apply linux.system,linux.network"
49  wait_for 30.0 "salt -C '${cluster_nodes_query}' test.ping"
50
51 +salt -C "${control_nodes_query}" state.apply armband.salt_minion
52  salt -C "${cluster_nodes_query}" system.reboot
53  wait_for 90.0 "salt -C '${cluster_nodes_query}' test.ping"
54
55 diff --git a/mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff b/mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff
56 new file mode 100644
57 index 00000000..1a2e9a3c
58 --- /dev/null
59 +++ b/mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff
60 @@ -0,0 +1,70 @@
61 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
62 +Date: Sun Aug 20 18:18:53 2017 +0200
63 +Subject: [PATCH] libvirt_domain.jinja: Add AArch64 support
64 +
65 +Salt virt state relies on a Jinja template to create a libvirt
66 +XML definition for each new VM.
67 +This template needs to be extended with a few specific options
68 +for AArch64:
69 +- UEFI loader support (pflash);
70 +- custom machine model (e.g. 'virt-2.9'), since AArch64 defaults to
71 +  'integratorcp';
72 +- custom cpu model;
73 +
74 +Allow all these to be parametrized from the salt virt formula,
75 +which we will also adapt to allow the params to be passed via our
76 +reclass model.
77 +
78 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
79 +---
80 +
81 +diff --git a/salt/templates/virt/libvirt_domain.jinja b/salt/templates/virt/libvirt_domain.jinja
82 +--- a/salt/templates/virt/libvirt_domain.jinja
83 ++++ b/salt/templates/virt/libvirt_domain.jinja
84 +@@ -3,11 +3,22 @@
85 +         <vcpu>{{ cpu }}</vcpu>
86 +         <memory unit='KiB'>{{ mem }}</memory>
87 +         <os>
88 ++                {% if custom_virt_machine %}
89 ++                <type machine='{{ virt_machine_model }}'>hvm</type>
90 ++                {% else %}
91 +                 <type>hvm</type>
92 ++                {% endif %}
93 ++                {% if os_loader_type == 'pflash' %}
94 ++                <loader readonly='yes' type='{{ os_loader_type }}'>{{ os_loader }}</loader>
95 ++                <nvram>{{ os_loader_nvram }}</nvram>
96 ++                {% endif %}
97 +                 {% for dev in boot_dev %}
98 +                 <boot dev='{{ dev }}' />
99 +                 {% endfor %}
100 +         </os>
101 ++        {% if cpu_mode == 'custom' %}
102 ++        <cpu mode='{{ cpu_model }}' check='none'/>
103 ++        {% endif %}
104 +         <devices>
105 +                 {% for diskname, disk in disks.items() %}
106 +                 <disk type='file' device='disk'>
107 +--
108 +
109 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
110 +Date: Sun Nov 19 02:18:53 2017 +0200
111 +Subject: [PATCH] virt.py: undefine: NVRAM flag support
112 +
113 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
114 +---
115 +
116 +diff --git a/salt/modules/virt.py b/salt/modules/virt.py
117 +--- a/salt/modules/virt.py
118 ++++ b/salt/modules/virt.py
119 +@@ -1523,7 +1523,10 @@
120 +         salt '*' virt.undefine <domain>
121 +     '''
122 +     dom = _get_domain(vm_)
123 +-    return dom.undefine() == 0
124 ++    try:
125 ++        return dom.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_NVRAM) == 0
126 ++    except libvirt.libvirtError:
127 ++        return dom.undefine() == 0
128 +
129 +
130 + def purge(vm_, dirs=False):
131 diff --git a/mcp/salt-formulas/armband/salt_minion.sls b/mcp/salt-formulas/armband/salt_minion.sls
132 new file mode 100644
133 index 00000000..cc5c9242
134 --- /dev/null
135 +++ b/mcp/salt-formulas/armband/salt_minion.sls
136 @@ -0,0 +1,7 @@
137 +salt-minion-aarch64-rollup:
138 +  file.patch:
139 +  - name: /usr/lib/python2.7/dist-packages
140 +  - source: salt://armband/files/salt-minion-aarch64-rollup.diff
141 +  - hash: False
142 +  - options: '-p1'
143 +  - unless: 'test -f /var/cache/salt/minion/files/base/armband/files/salt-minion-aarch64-rollup.diff && cd /usr/lib/python2.7/dist-packages && patch -p1 -R --dry-run -r - < /var/cache/salt/minion/files/base/armband/files/salt-minion-aarch64-rollup.diff'