aboutsummaryrefslogtreecommitdiffstats
path: root/patches/opnfv-fuel/0002-mcp-salt-formulas-armband-Extend-libvirt_domain.patch
blob: 998a5aba7a032ea83a77d72acae97b2fd51e7cf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: Copyright (c) 2018 Enea AB and others.
:
: All rights reserved. This program and the accompanying materials
: are made available under the terms of the Apache License, Version 2.0
: which accompanies this distribution, and is available at
: http://www.apache.org/licenses/LICENSE-2.0
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Date: Sun, 20 Aug 2017 22:41:26 +0200
Subject: [PATCH] mcp: salt-formulas: armband: Extend libvirt_domain

Add new state in armband salt formula that:
* extends salt's virt libvirt_domain.jinja template with support for:
  - hw_firmware_type;
  - virt_machine_model;
  - cpu_model;
  These will later be leveraged via salt virt formula with AArch64
  specific values.
* to ensure compatibilty of `virt.purge` with NVRAM-enabled domains
  at undefine time, pass down the proper flag to libvirt from virt.py.
* re-enable AArch64 bootstrap
  Recent changes in salt bootstrap script from [1] whitelist a
  fixed pool of known architectures. Add "arm64" to that list on the
  fly, as part of `config.gather_bootstrap_script`.
  NOTE: This change will be leveraged by passing a custom DEB repo to
  the bootstrap script with `-R linux.enea.com/saltstack`.

NOTE: After running this new state, salt-minion should be restarted
to pick up the changes, so we'll run it before rebooting kvm nodes.

[1] http://bootstrap.saltstack.com

Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
---
 mcp/config/states/baremetal_init              |  1 +
 .../files/salt-minion-aarch64-rollup.diff     | 70 +++++++++++++++++++
 mcp/salt-formulas/armband/salt_minion.sls     |  7 ++
 3 files changed, 78 insertions(+)
 create mode 100644 mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff
 create mode 100644 mcp/salt-formulas/armband/salt_minion.sls

diff --git a/mcp/config/states/baremetal_init b/mcp/config/states/baremetal_init
index 358e1874..14d6a570 100755
--- a/mcp/config/states/baremetal_init
+++ b/mcp/config/states/baremetal_init
@@ -32,6 +32,7 @@ wait_for 5.0 "salt -C '${cluster_nodes_query}' state.apply salt.minion"
 wait_for 5.0 "salt -C '${compute_nodes_query}' state.apply linux.system,linux.network"
 wait_for 30.0 "salt -C '${cluster_nodes_query}' test.ping"

+salt -C "${control_nodes_query}" state.apply armband.salt_minion
 salt -C "${cluster_nodes_query}" system.reboot
 wait_for 90.0 "salt -C '${cluster_nodes_query}' test.ping"

diff --git a/mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff b/mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff
new file mode 100644
index 00000000..1a2e9a3c
--- /dev/null
+++ b/mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff
@@ -0,0 +1,70 @@
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Sun Aug 20 18:18:53 2017 +0200
+Subject: [PATCH] libvirt_domain.jinja: Add AArch64 support
+
+Salt virt state relies on a Jinja template to create a libvirt
+XML definition for each new VM.
+This template needs to be extended with a few specific options
+for AArch64:
+- UEFI loader support (pflash);
+- custom machine model (e.g. 'virt-2.9'), since AArch64 defaults to
+  'integratorcp';
+- custom cpu model;
+
+Allow all these to be parametrized from the salt virt formula,
+which we will also adapt to allow the params to be passed via our
+reclass model.
+
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+---
+
+diff --git a/salt/templates/virt/libvirt_domain.jinja b/salt/templates/virt/libvirt_domain.jinja
+--- a/salt/templates/virt/libvirt_domain.jinja
++++ b/salt/templates/virt/libvirt_domain.jinja
+@@ -3,11 +3,22 @@
+         <vcpu>{{ cpu }}</vcpu>
+         <memory unit='KiB'>{{ mem }}</memory>
+         <os>
++                {% if custom_virt_machine %}
++                <type machine='{{ virt_machine_model }}'>hvm</type>
++                {% else %}
+                 <type>hvm</type>
++                {% endif %}
++                {% if os_loader_type == 'pflash' %}
++                <loader readonly='yes' type='{{ os_loader_type }}'>{{ os_loader }}</loader>
++                <nvram>{{ os_loader_nvram }}</nvram>
++                {% endif %}
+                 {% for dev in boot_dev %}
+                 <boot dev='{{ dev }}' />
+                 {% endfor %}
+         </os>
++        {% if cpu_mode == 'custom' %}
++        <cpu mode='{{ cpu_model }}' check='none'/>
++        {% endif %}
+         <devices>
+                 {% for diskname, disk in disks.items() %}
+                 <disk type='file' device='disk'>
+--
+
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Sun Nov 19 02:18:53 2017 +0200
+Subject: [PATCH] virt.py: undefine: NVRAM flag support
+
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+---
+
+diff --git a/salt/modules/virt.py b/salt/modules/virt.py
+--- a/salt/modules/virt.py
++++ b/salt/modules/virt.py
+@@ -1523,7 +1523,10 @@
+         salt '*' virt.undefine <domain>
+     '''
+     dom = _get_domain(vm_)
+-    return dom.undefine() == 0
++    try:
++        return dom.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_NVRAM) == 0
++    except libvirt.libvirtError:
++        return dom.undefine() == 0
+
+
+ def purge(vm_, dirs=False):
diff --git a/mcp/salt-formulas/armband/salt_minion.sls b/mcp/salt-formulas/armband/salt_minion.sls
new file mode 100644
index 00000000..cc5c9242
--- /dev/null
+++ b/mcp/salt-formulas/armband/salt_minion.sls
@@ -0,0 +1,7 @@
+salt-minion-aarch64-rollup:
+  file.patch:
+  - name: /usr/lib/python2.7/dist-packages
+  - source: salt://armband/files/salt-minion-aarch64-rollup.diff
+  - hash: False
+  - options: '-p1'
+  - 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'