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;
+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`.
-These will later be leveraged via salt virt formula with AArch64
-specific values.
+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/virtual_control_plane | 1 +
- .../armband/files/libvirt_domain.jinja.diff | 46 ++++++++++++++++++++++
- .../armband/libvirt_domain_template.sls | 4 ++
- 3 files changed, 51 insertions(+)
- create mode 100644 mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff
- create mode 100644 mcp/salt-formulas/armband/libvirt_domain_template.sls
+ mcp/config/states/virtual_control_plane | 1 +
+ .../armband/files/salt-minion-aarch64-rollup.diff | 101 +++++++++++++++++++++
+ mcp/salt-formulas/armband/salt_minion.sls | 7 ++
+ 3 files changed, 109 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/virtual_control_plane b/mcp/config/states/virtual_control_plane
-index 99fb517..abf46ce 100755
+index 99fb517..88a4488 100755
--- a/mcp/config/states/virtual_control_plane
+++ b/mcp/config/states/virtual_control_plane
-@@ -47,6 +47,7 @@ wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
- salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
-
- salt -C 'kvm*' state.sls armband || true
-+salt -C 'kvm*' state.sls armband.libvirt_domain_template || true
- wait_for 5 "salt -C 'kvm*' state.sls libvirt"
-
- salt -C '* and not cfg01* and not mas01*' state.apply salt
-diff --git a/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff b/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff
+@@ -40,6 +40,7 @@ salt -C 'kvm*' pkg.install bridge-utils
+ salt -C 'kvm*' state.apply linux.network
+ salt -C 'cmp*' state.apply linux.system
+ salt -C 'cmp*' state.apply linux.network || true
++salt -C 'kvm*' state.apply armband.salt_minion || true
+ salt -C 'kvm* or cmp*' system.reboot
+ wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
+ "tee /dev/stderr | grep -Fq 'Not connected'"
+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 0000000..4e7fad5
+index 0000000..9e74c24
--- /dev/null
-+++ b/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff
-@@ -0,0 +1,46 @@
++++ b/mcp/salt-formulas/armband/files/salt-minion-aarch64-rollup.diff
+@@ -0,0 +1,101 @@
++From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
++Date: Sun Aug 20 18:18:53 2017 +0200
++Subject: [PATCH] cloud.py: Allow AArch64 arch in salt 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`.
++
++[1] http://bootstrap.saltstack.com
++
++Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
++---
++
++diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py
++--- a/salt/utils/cloud.py
+++++ b/salt/utils/cloud.py
++@@ -2772,6 +2772,9 @@
++ if not script_content:
++ raise ValueError('No content in bootstrap script !')
++
+++ # NOTE(armband): edit bootstrap script on the fly to allow AArch64
+++ script_content = script_content.replace('"amd64")', '"amd64"|"arm64")')
+++
++ # Get the path to the built-in deploy scripts directory
++ builtin_deploy_dir = os.path.join(
++ os.path.dirname(__file__),
++--
++
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Sun Aug 20 18:18:53 2017 +0200
+Subject: [PATCH] libvirt_domain.jinja: Add AArch64 support
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+---
+
-+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
-+--- 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
++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>
+ <devices>
+ {% for diskname, disk in disks.items() %}
+ <disk type='file' device='disk'>
-diff --git a/mcp/salt-formulas/armband/libvirt_domain_template.sls b/mcp/salt-formulas/armband/libvirt_domain_template.sls
++--
++
++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 0000000..7cc8e22
+index 0000000..9cce636
--- /dev/null
-+++ b/mcp/salt-formulas/armband/libvirt_domain_template.sls
-@@ -0,0 +1,4 @@
-+/usr/lib/python2.7/dist-packages/salt/templates/virt/libvirt_domain.jinja:
++++ b/mcp/salt-formulas/armband/salt_minion.sls
+@@ -0,0 +1,7 @@
++salt-minion-aarch64-rollup:
+ file.patch:
-+ - source: salt://armband/files/libvirt_domain.jinja.diff
-+ - hash: "9d02cd8aa04497c2d75c72840a5c6c41"
++ - 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 /var/cache/salt/minion/files/base/armband/files/salt-minion-aarch64-rollup.diff'
+++ /dev/null
-::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-: Copyright (c) 2017 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: Mon, 21 Aug 2017 20:53:03 +0200
-Subject: [PATCH] mcp: salt-formulas: armband: 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/virtual_control_plane | 1 +
- .../armband/bootstrap_script_arm64.sls | 4 +++
- mcp/salt-formulas/armband/files/cloud.py.diff | 29 ++++++++++++++++++++++
- 3 files changed, 34 insertions(+)
- create mode 100644 mcp/salt-formulas/armband/bootstrap_script_arm64.sls
- create mode 100644 mcp/salt-formulas/armband/files/cloud.py.diff
-
-diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
-index abf46ce..1657d3c 100755
---- a/mcp/config/states/virtual_control_plane
-+++ b/mcp/config/states/virtual_control_plane
-@@ -40,6 +40,7 @@ salt -C 'kvm*' pkg.install bridge-utils
- salt -C 'kvm*' state.apply linux.network
- salt -C 'cmp*' state.apply linux.system
- salt -C 'cmp*' state.apply linux.network || true
-+salt -C 'kvm*' state.apply armband.bootstrap_script_arm64 || true
- salt -C 'kvm* or cmp*' system.reboot
- wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
- "tee /dev/stderr | grep -Fq 'Not connected'"
-diff --git a/mcp/salt-formulas/armband/bootstrap_script_arm64.sls b/mcp/salt-formulas/armband/bootstrap_script_arm64.sls
-new file mode 100644
-index 0000000..845dedd
---- /dev/null
-+++ b/mcp/salt-formulas/armband/bootstrap_script_arm64.sls
-@@ -0,0 +1,4 @@
-+/usr/lib/python2.7/dist-packages/salt/utils/cloud.py:
-+ file.patch:
-+ - source: salt://armband/files/cloud.py.diff
-+ - hash: "ecd450b187156c1f6a91ea272fd668b0"
-diff --git a/mcp/salt-formulas/armband/files/cloud.py.diff b/mcp/salt-formulas/armband/files/cloud.py.diff
-new file mode 100644
-index 0000000..75c3281
---- /dev/null
-+++ b/mcp/salt-formulas/armband/files/cloud.py.diff
-@@ -0,0 +1,29 @@
-+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
-+Date: Sun Aug 20 18:18:53 2017 +0200
-+Subject: [PATCH] cloud.py: Allow AArch64 arch in salt 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`.
-+
-+[1] http://bootstrap.saltstack.com
-+
-+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
-+---
-+
-+diff --git a//usr/lib/python2.7/dist-packages/salt/utils/cloud.py b//usr/lib/python2.7/dist-packages/salt/utils/cloud.py
-+--- a//usr/lib/python2.7/dist-packages/salt/utils/cloud.py
-++++ b//usr/lib/python2.7/dist-packages/salt/utils/cloud.py
-+@@ -2772,6 +2772,9 @@
-+ if not script_content:
-+ raise ValueError('No content in bootstrap script !')
-+
-++ # NOTE(armband): edit bootstrap script on the fly to allow AArch64
-++ script_content = script_content.replace('"amd64")', '"amd64"|"arm64")')
-++
-+ # Get the path to the built-in deploy scripts directory
-+ builtin_deploy_dir = os.path.join(
-+ os.path.dirname(__file__),
--- /dev/null
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+: Copyright (c) 2017 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: Mon, 21 Aug 2017 20:42:00 +0200
+Subject: [PATCH] seedng: module: Add AArch64 repo
+
+salt custom py module seedng.py should use custom repo arg
+"-R linux.enea.com/saltstack" on AArch64 nodes.
+
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+---
+ mcp/patches/0009-seedng-module-Sync-salt-version.patch | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/mcp/patches/0009-seedng-module-Sync-salt-version.patch b/mcp/patches/0009-seedng-module-Sync-salt-version.patch
+index d116c81..20233a9 100644
+--- a/mcp/patches/0009-seedng-module-Sync-salt-version.patch
++++ b/mcp/patches/0009-seedng-module-Sync-salt-version.patch
+@@ -8,23 +8,29 @@
+ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+ Date: Mon, 21 Aug 2017 02:03:01 +0200
+-Subject: [PATCH] seedng: module: Sync salt version
++Subject: [PATCH] seedng: module: Sync salt version, AArch64 repo
+
+ salt custom py module seedng.py should use the same Salt version
+ when preinstalling minion for salt-controlled VMs via bootstrap
+ script.
+
++While at it, add AArch64 repo. This used to be a separate patch, but
++we'll squash it in, so reverse-apply checks still work:
++- salt custom py module seedng.py should use custom repo arg
++ "-R linux.enea.com/saltstack" on AArch64 nodes.
++
+ Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+ ---
+
+ diff --git a/_modules/seedng.py b/_modules/seedng.py
+ --- a/_modules/seedng.py
+ +++ b/_modules/seedng.py
+-@@ -256,8 +256,10 @@
++@@ -256,8 +256,11 @@
+ boot_, tmppath = (prep_bootstrap(mpt)
+ or salt.syspaths.BOOTSTRAP)
+ # Exec the chroot command
+-+ arg = 'stable {0}'.format('.'.join(salt.version.__version__.split('.')[:2]))
+++ arg = '-R linux.enea.com/saltstack ' if os.uname()[-1] == 'aarch64' else ''
+++ arg += 'stable {0}'.format('.'.join(salt.version.__version__.split('.')[:2]))
+ cmd = 'if type salt-minion; then exit 0; '
+ - cmd += 'else sh {0} -c /tmp; fi'.format(os.path.join(tmppath, 'bootstrap-salt.sh'))
+ + cmd += 'else sh {0} -c /tmp {1}; fi'.format(
+++ /dev/null
-::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-: Copyright (c) 2017 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: Mon, 21 Aug 2017 20:42:00 +0200
-Subject: [PATCH] seedng: module: Add AArch64 repo
-
-salt custom py module seedng.py should use custom repo arg
-"-R linux.enea.com/saltstack" on AArch64 nodes.
-
-Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
----
- .../0105-seedng-module-Add-AArch64-repo.patch | 22 ++++++++++++++++++++++
- mcp/patches/patches.list | 1 +
- 2 files changed, 23 insertions(+)
- create mode 100644 mcp/patches/0105-seedng-module-Add-AArch64-repo.patch
-
-diff --git a/mcp/patches/0105-seedng-module-Add-AArch64-repo.patch b/mcp/patches/0105-seedng-module-Add-AArch64-repo.patch
-new file mode 100644
-index 0000000..d40e63b
---- /dev/null
-+++ b/mcp/patches/0105-seedng-module-Add-AArch64-repo.patch
-@@ -0,0 +1,22 @@
-+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
-+Date: Mon, 21 Aug 2017 02:03:01 +0200
-+Subject: [PATCH] seedng: module: Add AArch64 repo
-+
-+salt custom py module seedng.py should use custom repo arg
-+"-R linux.enea.com/saltstack" on AArch64 nodes.
-+
-+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
-+---
-+
-+diff --git a/_modules/seedng.py b/_modules/seedng.py
-+--- a/_modules/seedng.py
-++++ b/_modules/seedng.py
-+@@ -257,6 +257,7 @@
-+ or salt.syspaths.BOOTSTRAP)
-+ # Exec the chroot command
-+- arg = 'stable {0}'.format('.'.join(salt.version.__version__.split('.')[:2]))
-++ arg = '-R linux.enea.com/saltstack ' if os.uname()[-1] == 'aarch64' else ''
-++ arg += 'stable {0}'.format('.'.join(salt.version.__version__.split('.')[:2]))
-+ cmd = 'if type salt-minion; then exit 0; '
-+ cmd += 'else sh {0} -c /tmp {1}; fi'.format(
-+ os.path.join(tmppath, 'bootstrap-salt.sh'), arg)
-diff --git a/mcp/patches/patches.list b/mcp/patches/patches.list
-index e618d57..62e3cc6 100644
---- a/mcp/patches/patches.list
-+++ b/mcp/patches/patches.list
-@@ -22,3 +22,4 @@
- /usr/share/salt-formulas/env: 0102-libvirt-unix_sock_group-s-libvirtd-libvirt.patch
- /usr/share/salt-formulas/env: 0103-virtng-module-Extend-libvirt_domain.patch
- /usr/share/salt-formulas/env: 0104-salt-control-virt-Extend-libvirt_domain.patch
-+/usr/share/salt-formulas/env: 0105-seedng-module-Add-AArch64-repo.patch
create mode 100644 mcp/salt-formulas/opnfv/adduser.sls
diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
-index 1657d3c..4b3ec42 100755
+index 88a4488..298a9de 100755
--- a/mcp/config/states/virtual_control_plane
+++ b/mcp/config/states/virtual_control_plane
@@ -37,6 +37,7 @@ salt -C 'kvm* or cmp*' file.replace $debian_ip_source \
salt -C 'kvm*' state.apply linux.network
salt -C 'cmp*' state.apply linux.system
salt -C 'cmp*' state.apply linux.network || true
-@@ -67,6 +68,7 @@ while [ $rc -ne 0 ] && [ ${attempt} -lt ${total_attempts} ]; do
+@@ -66,6 +67,7 @@ while [ $rc -ne 0 ] && [ ${attempt} -lt ${total_attempts} ]; do
rc=0
for node in $vcp_nodes; do
salt "$node" test.ping 2>/dev/null || { rc=$?; break; };
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
-index 4b3ec42..ad8218e 100755
+index 298a9de..c07d342 100755
--- a/mcp/config/states/virtual_control_plane
+++ b/mcp/config/states/virtual_control_plane
@@ -39,9 +39,12 @@ salt -C 'kvm* or cmp*' file.replace $debian_ip_source \
-salt -C 'cmp*' state.apply linux.system
+salt -C 'kvm* or cmp*' state.apply linux.system
salt -C 'cmp*' state.apply linux.network || true
- salt -C 'kvm*' state.apply armband.bootstrap_script_arm64 || true
+ salt -C 'kvm*' state.apply armband.salt_minion || true
+# NOTE(armband): Should be later moved to reclass as system.kernel.version
+salt -C 'kvm* or cmp*' pkg.install \
+ linux-image-generic-hwe-16.04-edge,linux-headers-generic-hwe-16.04-edge
salt -C 'kvm* or cmp*' system.reboot
wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
"tee /dev/stderr | grep -Fq 'Not connected'"
-@@ -85,3 +88,10 @@ wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_US
+@@ -84,3 +87,10 @@ wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_US
# Disable proxy dhcp routes after installation
salt -C 'prx*' file.write /etc/dhcp/dhclient-enter-hooks.d/no-default-route \
args='unset new_routers'