1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 Enea AB and others.
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
13 Add new state in armband salt formula that extends salt's virt
14 libvirt_domain.jinja template with support for:
19 These will later be leveraged via salt virt formula with AArch64
22 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
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
31 diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
32 index 5a99aef..2163069 100755
33 --- a/mcp/config/states/virtual_control_plane
34 +++ b/mcp/config/states/virtual_control_plane
35 @@ -28,6 +28,7 @@ wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
36 salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
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"
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
45 index 0000000..4e7fad5
47 +++ b/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff
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
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
57 +- UEFI loader support (pflash);
58 +- custom machine model (e.g. 'virt-2.9'), since AArch64 defaults to
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
66 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
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
73 + <vcpu>{{ cpu }}</vcpu>
74 + <memory unit='KiB'>{{ mem }}</memory>
76 ++ {% if custom_virt_machine %}
77 ++ <type machine='{{ virt_machine_model }}'>hvm</type>
81 ++ {% if os_loader_type == 'pflash' %}
82 ++ <loader readonly='yes' type='{{ os_loader_type }}'>{{ os_loader }}</loader>
83 ++ <nvram>{{ os_loader_nvram }}</nvram>
85 + {% for dev in boot_dev %}
86 + <boot dev='{{ dev }}' />
89 ++ {% if cpu_mode == 'custom' %}
90 ++ <cpu mode='{{ cpu_model }}' check='none'/>
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
97 index 0000000..7cc8e22
99 +++ b/mcp/salt-formulas/armband/libvirt_domain_template.sls
101 +/usr/lib/python2.7/dist-packages/salt/templates/virt/libvirt_domain.jinja:
103 + - source: salt://armband/files/libvirt_domain.jinja.diff
104 + - hash: "9d02cd8aa04497c2d75c72840a5c6c41"