diff options
author | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2017-08-21 01:27:43 +0200 |
---|---|---|
committer | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2017-08-21 01:33:47 +0200 |
commit | a75f48f6376c5887a97758a16241080ead8f785f (patch) | |
tree | 0bec9d3ff287d113d7fb411f7a017fa5d27a3a42 /patches | |
parent | ff2eea6750b3fdf049686a00bea5567c4d76ee71 (diff) |
salt: virt: Extend libvirt_domain
Extend salt virt modelling capabilities with support for:
- hw_firmware_type;
- virt_machine_model;
- cpu_model;
This requires extending/patching:
- libvirt_domain.jinja template (part of salt package, handled via
armband.libvirt_domain_template new state);
- _modules/virtng.py custom module;
- salt/control/virt.sls;
The new support is leveraged via our reclass model with AArch64
specific values.
Change-Id: I34bdb235cb7765ecdde365761dbd2c942f699039
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Diffstat (limited to 'patches')
-rw-r--r-- | patches/opnfv-fuel/0015-mcp-salt-formulas-armband-Extend-libvirt_domain.patch | 97 | ||||
-rw-r--r-- | patches/opnfv-fuel/0016-virtng.py-virt.sls-Extend-libvirt_domain.patch | 198 |
2 files changed, 295 insertions, 0 deletions
diff --git a/patches/opnfv-fuel/0015-mcp-salt-formulas-armband-Extend-libvirt_domain.patch b/patches/opnfv-fuel/0015-mcp-salt-formulas-armband-Extend-libvirt_domain.patch new file mode 100644 index 00000000..7bdb14b9 --- /dev/null +++ b/patches/opnfv-fuel/0015-mcp-salt-formulas-armband-Extend-libvirt_domain.patch @@ -0,0 +1,97 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +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; + +These will later be leveraged via salt virt formula with AArch64 +specific values. + +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +--- + mcp/config/states/maas | 2 +- + .../armband/files/libvirt_domain.jinja.diff | 46 ++++++++++++++++++++++ + .../armband/libvirt_domain_template.sls | 4 ++ + 3 files changed, 51 insertions(+), 1 deletion(-) + create mode 100644 mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff + create mode 100644 mcp/salt-formulas/armband/libvirt_domain_template.sls + +diff --git a/mcp/config/states/maas b/mcp/config/states/maas +index 4b306af..d99dfc4 100755 +--- a/mcp/config/states/maas ++++ b/mcp/config/states/maas +@@ -48,7 +48,7 @@ wait_for "! salt '*' test.ping | tee /dev/stderr | fgrep -q 'Not connected'" + + salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp + +-salt -C 'kvm*' state.sls armband ++salt -C 'kvm*' state.sls armband,armband.libvirt_domain_template + 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 +new file mode 100644 +index 0000000..4e7fad5 +--- /dev/null ++++ b/mcp/salt-formulas/armband/files/libvirt_domain.jinja.diff +@@ -0,0 +1,46 @@ ++From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> ++Date: Sun Aug 20 18:18:53 2017 +0200 ++Subject: [PATCH] libvirt_domain.jinja: Add AArch64 support ++ ++Salt virt state relies on a Jinja template to create a libvirt ++XML definition for each new VM. ++This template needs to be extended with a few specific options ++for AArch64: ++- UEFI loader support (pflash); ++- custom machine model (e.g. 'virt-2.9'), since AArch64 defaults to ++ 'integratorcp'; ++- custom cpu model; ++ ++Allow all these to be parametrized from the salt virt formula, ++which we will also adapt to allow the params to be passed via our ++reclass model. ++ ++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 ++@@ -3,11 +3,22 @@ ++ <vcpu>{{ cpu }}</vcpu> ++ <memory unit='KiB'>{{ mem }}</memory> ++ <os> +++ {% if custom_virt_machine %} +++ <type machine='{{ virt_machine_model }}'>hvm</type> +++ {% else %} ++ <type>hvm</type> +++ {% endif %} +++ {% if os_loader_type == 'pflash' %} +++ <loader readonly='yes' type='{{ os_loader_type }}'>{{ os_loader }}</loader> +++ <nvram>{{ os_loader_nvram }}</nvram> +++ {% endif %} ++ {% for dev in boot_dev %} ++ <boot dev='{{ dev }}' /> ++ {% endfor %} ++ </os> +++ {% if cpu_mode == 'custom' %} +++ <cpu mode='{{ cpu_model }}' check='none'/> +++ {% endif %} ++ <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 +new file mode 100644 +index 0000000..7cc8e22 +--- /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: ++ file.patch: ++ - source: salt://armband/files/libvirt_domain.jinja.diff ++ - hash: "9d02cd8aa04497c2d75c72840a5c6c41" diff --git a/patches/opnfv-fuel/0016-virtng.py-virt.sls-Extend-libvirt_domain.patch b/patches/opnfv-fuel/0016-virtng.py-virt.sls-Extend-libvirt_domain.patch new file mode 100644 index 00000000..ec1c6afe --- /dev/null +++ b/patches/opnfv-fuel/0016-virtng.py-virt.sls-Extend-libvirt_domain.patch @@ -0,0 +1,198 @@ +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +Date: Mon, 21 Aug 2017 01:10:16 +0200 +Subject: [PATCH] virtng.py, virt.sls: Extend libvirt_domain + +Extend _modules/virtng.py, salt/control/virt.sls with support for: +- hw_firmware_type; +- virt_machine_model; +- cpu_model; + +This functionality relies on the corresponding changes to be +implemented in libvirt_domain.jinja template. + +These will later be leveraged via our reclass model with AArch64 +specific values. + +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> +--- + .../0103-virtng-module-Extend-libvirt_domain.patch | 54 ++++++++++++++++++++++ + ...4-salt-control-virt-Extend-libvirt_domain.patch | 51 ++++++++++++++++++++ + mcp/patches/patches.list | 2 + + .../baremetal-mcp-ocata-ovs-ha/infra/kvm.yml | 15 ++++++ + 4 files changed, 122 insertions(+) + create mode 100644 mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch + create mode 100644 mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch + +diff --git a/mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch b/mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch +new file mode 100644 +index 0000000..706b67d +--- /dev/null ++++ b/mcp/patches/0103-virtng-module-Extend-libvirt_domain.patch +@@ -0,0 +1,54 @@ ++From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> ++Date: Mon, 21 Aug 2017 02:03:01 +0200 ++Subject: [PATCH] virtng: module: Extend libvirt_domain ++ ++Extend virtng.py with support for passing down new params: ++- hw_firmware_type; ++- virt_machine_model; ++- cpu_model; ++ ++This functionality relies on the corresponding changes to be ++implemented in libvirt_domain.jinja template. ++ ++These will later be leveraged via salt virt formula with AArch64 ++specific values. ++ ++Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> ++--- ++ ++diff --git a/_modules/virtng.py b/_modules/virtng.py ++--- a/_modules/virtng.py +++++ b/_modules/virtng.py ++@@ -56,6 +56,10 @@ ++ ++ VIRT_DEFAULT_HYPER = 'kvm' ++ +++DEFAULT_UEFI_LOADER_PATH = { +++ "x86_64": "/usr/share/OVMF/OVMF_CODE.fd", +++ "aarch64": "/usr/share/AAVMF/AAVMF_CODE.fd" +++} ++ ++ def __virtual__(): ++ if not HAS_ALL_IMPORTS: ++@@ -227,6 +231,21 @@ ++ # TODO: make bus and model parameterized, this works for 64-bit Linux ++ context['controller_model'] = 'lsilogic' ++ +++ # TODO: limit cpu_model, hw_firmware_type, virt_machine_type to qemu/kvm +++ # FIXME: parametrize hardcoded path for NVRAM storage +++ if 'hw_firmware_type' in kwargs and kwargs['hw_firmware_type'] == 'uefi': +++ context['os_loader_type'] = 'pflash' +++ context['os_loader'] = DEFAULT_UEFI_LOADER_PATH[os.uname()[-1]] +++ context['os_loader_nvram'] = '/var/lib/libvirt/qemu/nvram/{0}_VARS.fd'.format(name) +++ +++ if 'virt_machine_model' in kwargs: +++ context['custom_virt_machine'] = True +++ context['virt_machine_model'] = kwargs['virt_machine_model'] +++ +++ if 'cpu_model' in kwargs: +++ context['cpu_mode'] = 'custom' +++ context['cpu_model'] = kwargs['cpu_model'] +++ ++ if 'boot_dev' in kwargs: ++ context['boot_dev'] = [] ++ for dev in kwargs['boot_dev'].split(): +diff --git a/mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch b/mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch +new file mode 100644 +index 0000000..a9fe11b +--- /dev/null ++++ b/mcp/patches/0104-salt-control-virt-Extend-libvirt_domain.patch +@@ -0,0 +1,51 @@ ++From: Alexandru Avadanii <Alexandru.Avadanii@enea.com> ++Date: Mon, 21 Aug 2017 02:03:01 +0200 ++Subject: [PATCH] salt: control: virt: Extend libvirt_domain ++ ++Extend salt/control/virt.sls with support for new params: ++- hw_firmware_type; ++- virt_machine_model; ++- cpu_model; ++ ++This functionality relies on the corresponding changes to be ++implemented in libvirt_domain.jinja template, as well as in ++salt custom py module virtng.py. ++ ++These will later be leveraged via reclass model with AArch64 ++specific values. ++ ++FIXME: Move all new params to different section, as "size" is ++definitely not the best choice. ++ ++Example reclass model usage: ++salt: ++ control: ++ size: ++ openstack.example_vm_type: ++ hw_firmware_type: uefi ++ virt_machine_model: virt ++ cpu_model: host-passthrough ++ ++Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> ++--- ++ ++diff --git a/salt/control/virt.sls b/salt/control/virt.sls ++--- a/salt/control/virt.sls +++++ b/salt/control/virt.sls ++@@ -44,6 +44,16 @@ ++ seed: True ++ serial_type: pty ++ console: True +++ # FIXME(armband): Move these 3 params to different section +++ {%- if size.hw_firmware_type is defined %} +++ hw_firmware_type: {{ size.hw_firmware_type }} +++ {%- endif %} +++ {%- if size.virt_machine_model is defined %} +++ virt_machine_model: {{ size.virt_machine_model }} +++ {%- endif %} +++ {%- if size.cpu_model is defined %} +++ cpu_model: {{ size.cpu_model }} +++ {%- endif %} ++ - unless: virsh list --all --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$" ++ ++ #salt_control_seed_{{ cluster_name }}_{{ node_name }}: +diff --git a/mcp/patches/patches.list b/mcp/patches/patches.list +index a42f513..67b9c82 100644 +--- a/mcp/patches/patches.list ++++ b/mcp/patches/patches.list +@@ -7,3 +7,5 @@ + /usr/share/salt-formulas/env: 0007-linux.network.interface-noifupdown-support.patch + /usr/share/salt-formulas/env: 0101-maas-Add-curtin_userdata_arm64_generic_xenial.patch + /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 +diff --git a/mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-ha/infra/kvm.yml b/mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-ha/infra/kvm.yml +index 8b09e76..ff06a15 100644 +--- a/mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-ha/infra/kvm.yml ++++ b/mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-ha/infra/kvm.yml +@@ -34,26 +34,41 @@ parameters: + openstack.control: + cpu: 6 + ram: 8192 ++ hw_firmware_type: uefi ++ virt_machine_model: virt ++ cpu_model: host-passthrough + disk_profile: small + net_profile: default + openstack.database: + cpu: 6 + ram: 8192 ++ hw_firmware_type: uefi ++ virt_machine_model: virt ++ cpu_model: host-passthrough + disk_profile: large + net_profile: default + openstack.message_queue: + cpu: 6 + ram: 8192 ++ hw_firmware_type: uefi ++ virt_machine_model: virt ++ cpu_model: host-passthrough + disk_profile: small + net_profile: default + openstack.telemetry: + cpu: 4 + ram: 4096 ++ hw_firmware_type: uefi ++ virt_machine_model: virt ++ cpu_model: host-passthrough + disk_profile: xxlarge + net_profile: default + openstack.proxy: + cpu: 4 + ram: 4096 ++ hw_firmware_type: uefi ++ virt_machine_model: virt ++ cpu_model: host-passthrough + disk_profile: small + net_profile: default + # stacklight.log: |