73a0a786265ddbb06da7ae73ad2c1e3e702c8f14
[armband.git] / patches / opnfv-fuel / 0008-mcp-salt-formulas-armband-Extend-libvirt_domain.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 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 extends salt's virt
14 libvirt_domain.jinja template with support for:
15 - hw_firmware_type;
16 - virt_machine_model;
17 - cpu_model;
18
19 These will later be leveraged via salt virt formula with AArch64
20 specific values.
21
22 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
23 ---
24  mcp/config/states/virtual_control_plane            |  2 +-
25  .../armband/files/libvirt_domain.jinja.diff        | 46 ++++++++++++++++++++++
26  .../armband/libvirt_domain_template.sls            |  4 ++
27  3 files changed, 51 insertions(+), 1 deletion(-)
28  create mode 100644 mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff
29  create mode 100644 mcp/salt-formulas/armband/libvirt_domain_template.sls
30
31 diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
32 index 79ad880..327b159 100755
33 --- a/mcp/config/states/virtual_control_plane
34 +++ b/mcp/config/states/virtual_control_plane
35 @@ -12,7 +12,7 @@ wait_for 90 "! salt 'kvm*' test.ping | tee /dev/stderr | grep -Fq 'Not connected
36
37  salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
38
39 -salt -C 'kvm*' state.sls armband
40 +salt -C 'kvm*' state.sls armband,armband.libvirt_domain_template
41  salt -C 'kvm*' state.sls libvirt
42
43  salt -C '* and not cfg01* and not mas01*' state.apply salt
44 diff --git a/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff b/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff
45 new file mode 100644
46 index 0000000..4e7fad5
47 --- /dev/null
48 +++ b/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff
49 @@ -0,0 +1,46 @@
50 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
51 +Date: Sun Aug 20 18:18:53 2017 +0200
52 +Subject: [PATCH] libvirt_domain.jinja: Add AArch64 support
53 +
54 +Salt virt state relies on a Jinja template to create a libvirt
55 +XML definition for each new VM.
56 +This template needs to be extended with a few specific options
57 +for AArch64:
58 +- UEFI loader support (pflash);
59 +- custom machine model (e.g. 'virt-2.9'), since AArch64 defaults to
60 +  'integratorcp';
61 +- custom cpu model;
62 +
63 +Allow all these to be parametrized from the salt virt formula,
64 +which we will also adapt to allow the params to be passed via our
65 +reclass model.
66 +
67 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
68 +---
69 +
70 +diff --git a/usr/lib/python2.7/dist-packages/salt/templates/virt/libvirt_domain.jinja b/usr/lib/python2.7/dist-packages/salt/templates/virt/libvirt_domain.jinja
71 +--- a/usr/lib/python2.7/dist-packages/salt/templates/virt/libvirt_domain.jinja
72 ++++ b/usr/lib/python2.7/dist-packages/salt/templates/virt/libvirt_domain.jinja
73 +@@ -3,11 +3,22 @@
74 +         <vcpu>{{ cpu }}</vcpu>
75 +         <memory unit='KiB'>{{ mem }}</memory>
76 +         <os>
77 ++                {% if custom_virt_machine %}
78 ++                <type machine='{{ virt_machine_model }}'>hvm</type>
79 ++                {% else %}
80 +                 <type>hvm</type>
81 ++                {% endif %}
82 ++                {% if os_loader_type == 'pflash' %}
83 ++                <loader readonly='yes' type='{{ os_loader_type }}'>{{ os_loader }}</loader>
84 ++                <nvram>{{ os_loader_nvram }}</nvram>
85 ++                {% endif %}
86 +                 {% for dev in boot_dev %}
87 +                 <boot dev='{{ dev }}' />
88 +                 {% endfor %}
89 +         </os>
90 ++        {% if cpu_mode == 'custom' %}
91 ++        <cpu mode='{{ cpu_model }}' check='none'/>
92 ++        {% endif %}
93 +         <devices>
94 +                 {% for diskname, disk in disks.items() %}
95 +                 <disk type='file' device='disk'>
96 diff --git a/mcp/salt-formulas/armband/libvirt_domain_template.sls b/mcp/salt-formulas/armband/libvirt_domain_template.sls
97 new file mode 100644
98 index 0000000..7cc8e22
99 --- /dev/null
100 +++ b/mcp/salt-formulas/armband/libvirt_domain_template.sls
101 @@ -0,0 +1,4 @@
102 +/usr/lib/python2.7/dist-packages/salt/templates/virt/libvirt_domain.jinja:
103 +  file.patch:
104 +  - source:  salt://armband/files/libvirt_domain.jinja.diff
105 +  - hash: "9d02cd8aa04497c2d75c72840a5c6c41"