p/fuel: salt-formulas: Enable Armband formula
[armband.git] / patches / opnfv-fuel / 0008-mcp-salt-formulas-Add-enable-armband-formula.patch
1 From: Guillermo Herrero <Guillermo.Herrero@enea.com>
2 Date: Tue, 25 Jul 2017 00:58:32 +0200
3 Subject: [PATCH] mcp: salt-formulas: Add & enable armband formula
4
5 FIXME: Re-enable apparmor.
6 FIXME: Detect baremetal and re-enable acceleration.
7
8 - install qemu-efi;
9 - install vgabios;
10 - disable apparmor as security driver for libvirt (temporary);
11 - fix missing link for vgabios binary blob;
12 - nova: virt_type=qemu (temporary, until we support baremetal too);
13 - nova: pointer_model=ps2mouse since AArch64 has no USB tablet;
14 - nova: cpu_model=cortex-a57;
15 - nova: libvirt driver: Add ttyAMA0 by default on AArch64;
16 - nova: libvirt driver: Use VGA video type by default on AArch64;
17
18 Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
19 Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com>
20 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
21 ---
22  mcp/config/states/openstack                        |  2 +
23  .../armband/files/nova-libvirt-driver.diff         | 48 ++++++++++++++++++++++
24  mcp/salt-formulas/armband/init.sls                 |  6 +++
25  mcp/salt-formulas/armband/libvirt_driver.sls       |  5 +++
26  mcp/salt-formulas/armband/nova.sls                 | 24 +++++++++++
27  mcp/salt-formulas/armband/qemu.sls                 |  7 ++++
28  mcp/salt-formulas/armband/vgabios.sls              |  6 +++
29  7 files changed, 98 insertions(+)
30  create mode 100644 mcp/salt-formulas/armband/files/nova-libvirt-driver.diff
31  create mode 100644 mcp/salt-formulas/armband/init.sls
32  create mode 100644 mcp/salt-formulas/armband/libvirt_driver.sls
33  create mode 100644 mcp/salt-formulas/armband/nova.sls
34  create mode 100644 mcp/salt-formulas/armband/qemu.sls
35  create mode 100644 mcp/salt-formulas/armband/vgabios.sls
36
37 diff --git a/mcp/config/states/openstack b/mcp/config/states/openstack
38 index 57ca585..23aaf72 100755
39 --- a/mcp/config/states/openstack
40 +++ b/mcp/config/states/openstack
41 @@ -23,3 +23,5 @@ salt -I 'neutron:gateway' state.sls neutron
42  salt -I 'nova:compute' state.sls nova
43
44  salt -I 'horizon:server' state.sls horizon
45 +
46 +salt -I 'nova:compute' state.sls armband
47 diff --git a/mcp/salt-formulas/armband/files/nova-libvirt-driver.diff b/mcp/salt-formulas/armband/files/nova-libvirt-driver.diff
48 new file mode 100644
49 index 0000000..a5b08da
50 --- /dev/null
51 +++ b/mcp/salt-formulas/armband/files/nova-libvirt-driver.diff
52 @@ -0,0 +1,48 @@
53 +From: Stanislaw Kardach <stanislaw.kardach@cavium.com>
54 +Date: Tue, 22 Mar 2016 12:05:09 +0100
55 +Subject: [PATCH] nova: Update vga, console defaults for armv7, aarch64
56 +
57 +Nova hardcodes default options for both video=cirrus and console.
58 +armv7 and aarch64 VMs require video=vga, and since most applications
59 +use PL011 serial driver for guests, adding console=ttyAMA0 is also
60 +a nice UX addition.
61 +
62 +Signed-off-by: Stanislaw Kardach <stanislaw.kardach@cavium.com>
63 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
64 +Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
65 +
66 +---
67 + usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py | 10 +++++++++-
68 + 1 file changed, 9 insertions(+), 1 deletion(-)
69 +
70 +diff --git a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
71 +index bba9b00..99e86be 100644
72 +--- a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
73 ++++ b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
74 +@@ -4179,7 +4179,12 @@ class LibvirtDriver(driver.ComputeDriver):
75 +         if virt_type == "xen":
76 +             guest.os_cmdline = "ro root=%s" % root_device_name
77 +         else:
78 ++            guestarch = libvirt_utils.get_arch(image_meta)
79 +             guest.os_cmdline = ("root=%s %s" % (root_device_name, CONSOLE))
80 ++            if guestarch in (fields.Architecture.ARMV7,
81 ++                             fields.Architecture.AARCH64):
82 ++                # NOTE(armband): ARM v7/v8 use PL011 drv, add ttyAMA0 console
83 ++                guest.os_cmdline += " console=ttyAMA0"
84 +             if virt_type == "qemu":
85 +                 guest.os_cmdline += " no_timer_check"
86 +         if instance.ramdisk_id:
87 +@@ -4288,9 +4293,12 @@ class LibvirtDriver(driver.ComputeDriver):
88 +             video.type = 'xen'
89 +         elif CONF.libvirt.virt_type == 'parallels':
90 +             video.type = 'vga'
91 +-        elif guestarch in (fields.Architecture.PPC,
92 ++        elif guestarch in (fields.Architecture.ARMV7,
93 ++                           fields.Architecture.AARCH64,
94 ++                           fields.Architecture.PPC,
95 +                            fields.Architecture.PPC64,
96 +                            fields.Architecture.PPC64LE):
97 ++            # NOTE(armband): Added ARM v7/v8, same as on PPC.
98 +             # NOTE(ldbragst): PowerKVM doesn't support 'cirrus' be default
99 +             # so use 'vga' instead when running on Power hardware.
100 +             video.type = 'vga'
101 diff --git a/mcp/salt-formulas/armband/init.sls b/mcp/salt-formulas/armband/init.sls
102 new file mode 100644
103 index 0000000..6e7b6ad
104 --- /dev/null
105 +++ b/mcp/salt-formulas/armband/init.sls
106 @@ -0,0 +1,6 @@
107 +include:
108 + - armband.qemu
109 + - armband.vgabios
110 + - armband.nova
111 + - armband.libvirt_driver
112 +
113 diff --git a/mcp/salt-formulas/armband/libvirt_driver.sls b/mcp/salt-formulas/armband/libvirt_driver.sls
114 new file mode 100644
115 index 0000000..c309035
116 --- /dev/null
117 +++ b/mcp/salt-formulas/armband/libvirt_driver.sls
118 @@ -0,0 +1,5 @@
119 +/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py:
120 +  file.patch:
121 +  - source:  salt://armband/files/nova-libvirt-driver.diff
122 +  - hash: "668641080c6a77a9205d0f71d510ad5f"
123 +
124 diff --git a/mcp/salt-formulas/armband/nova.sls b/mcp/salt-formulas/armband/nova.sls
125 new file mode 100644
126 index 0000000..994d505
127 --- /dev/null
128 +++ b/mcp/salt-formulas/armband/nova.sls
129 @@ -0,0 +1,24 @@
130 +nova_virt_type:
131 +  file.replace:
132 +    - name: "/etc/nova/nova.conf"
133 +    - pattern: ^virt_type =.*$
134 +    - repl: "virt_type = qemu"
135 +nova_pointer_model:
136 +  file.replace:
137 +    - name: "/etc/nova/nova.conf"
138 +    - pattern: ^#pointer_model=.*$
139 +    - repl: "pointer_model=ps2mouse"
140 +nova_cpu_mode:
141 +  file.replace:
142 +    - name: "/etc/nova/nova.conf"
143 +    - pattern: "^cpu_mode = host-passthrough"
144 +    - repl: "cpu_mode=custom"
145 +nova_cpu_model:
146 +  file.replace:
147 +    - name: "/etc/nova/nova.conf"
148 +    - pattern: ^#cpu_model=.*$
149 +    - repl: "cpu_model=cortex-a57"
150 +restart_nova-compute:
151 +  cmd:
152 +    - run
153 +    - name: "service nova-compute restart"
154 diff --git a/mcp/salt-formulas/armband/qemu.sls b/mcp/salt-formulas/armband/qemu.sls
155 new file mode 100644
156 index 0000000..4760114
157 --- /dev/null
158 +++ b/mcp/salt-formulas/armband/qemu.sls
159 @@ -0,0 +1,7 @@
160 +qemu-efi:
161 +  pkg.installed
162 +/etc/libvirt/qemu.conf:
163 +  file.replace:
164 +    - pattern: ^#security_driver =.*$
165 +    - repl: "security_driver = none"
166 +
167 diff --git a/mcp/salt-formulas/armband/vgabios.sls b/mcp/salt-formulas/armband/vgabios.sls
168 new file mode 100644
169 index 0000000..a31eafa
170 --- /dev/null
171 +++ b/mcp/salt-formulas/armband/vgabios.sls
172 @@ -0,0 +1,6 @@
173 +vgabios:
174 +  pkg.installed
175 +/usr/share/qemu/vgabios-stdvga.bin:
176 +  file.symlink:
177 +    - target: "/usr/share/vgabios/vgabios.bin"
178 +