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