Support redfish emulation and run the keystone jobs with redfish

Prepare for UEFI support that will be finished in follow-up patches.

Change-Id: I18d034239edd3d49ceedf281b48a650e6011bab4
This commit is contained in:
Dmitry Tantsur 2020-08-03 11:00:56 +02:00
parent 82dd2ea5cc
commit 02fb11fcc7
17 changed files with 109 additions and 8 deletions

View File

@ -122,6 +122,7 @@ def cmd_testenv(args):
test_vm_memory_size=args.memory, test_vm_memory_size=args.memory,
test_vm_disk_gib=args.disk, test_vm_disk_gib=args.disk,
test_vm_domain_type=args.domain_type, test_vm_domain_type=args.domain_type,
test_vm_node_driver=args.driver,
baremetal_json_file=os.path.abspath(args.inventory), baremetal_json_file=os.path.abspath(args.inventory),
baremetal_nodes_json=os.path.abspath(args.output), baremetal_nodes_json=os.path.abspath(args.output),
extra_vars=args.extra_vars, extra_vars=args.extra_vars,
@ -198,6 +199,9 @@ def parse_args():
testenv.add_argument('--inventory', default='baremetal-inventory.json', testenv.add_argument('--inventory', default='baremetal-inventory.json',
help='output file with the inventory for using ' help='output file with the inventory for using '
'with dynamic playbooks') 'with dynamic playbooks')
testenv.add_argument('--driver', default='ipmi',
choices=['ipmi', 'redfish'],
help='driver for testing nodes')
testenv.add_argument('-e', '--extra-vars', action='append', testenv.add_argument('-e', '--extra-vars', action='append',
help='additional vars to pass to ansible') help='additional vars to pass to ansible')
testenv.add_argument('-o', '--output', default='baremetal-nodes.json', testenv.add_argument('-o', '--output', default='baremetal-nodes.json',

View File

@ -14,3 +14,4 @@
ENABLE_VENV: "{{ use_venv | default(true) | bool | lower }}" ENABLE_VENV: "{{ use_venv | default(true) | bool | lower }}"
ZUUL_BRANCH: "{{ zuul.branch }}" ZUUL_BRANCH: "{{ zuul.branch }}"
BOOT_MODE: "{{ boot_mode | default('') }}" BOOT_MODE: "{{ boot_mode | default('') }}"
TEST_VM_NODE_DRIVER: "{{ test_driver | default('ipmi') }}"

View File

@ -15,6 +15,11 @@ test_vm_disk_cache: "{{ lookup('env', 'VM_DISK_CACHE') | default('writeback', tr
test_vm_node_name_base: "{{ lookup('env', 'NODEBASE') | default('testvm', true) }}" test_vm_node_name_base: "{{ lookup('env', 'NODEBASE') | default('testvm', true) }}"
test_vm_node_names: "{{ lookup('env', 'TEST_VM_NODE_NAMES').split() }}" test_vm_node_names: "{{ lookup('env', 'TEST_VM_NODE_NAMES').split() }}"
test_vm_node_driver: ipmi
redfish_emulator_host: localhost
redfish_emulator_port: 9132
# NOTE(pas-ha) name and default are chosen to be the same # NOTE(pas-ha) name and default are chosen to be the same
# as in 'bifrost-ironic-install' role # as in 'bifrost-ironic-install' role
network_interface: "virbr0" network_interface: "virbr0"

View File

@ -22,5 +22,6 @@ required_packages:
- pkgconfig - pkgconfig
- libvirt-devel - libvirt-devel
- trousers - trousers
- edk2-ovmf
test_vm_emulator: "/usr/libexec/qemu-kvm" test_vm_emulator: "/usr/libexec/qemu-kvm"
test_vm_machine: "pc" test_vm_machine: "pc"

View File

@ -12,5 +12,6 @@ required_packages:
- sgabios - sgabios
- pkg-config - pkg-config
- libvirt-dev - libvirt-dev
- ovmf
- ebtables - ebtables
- dnsmasq - dnsmasq

View File

@ -12,3 +12,4 @@ required_packages:
- pkgconfig - pkgconfig
- libvirt-devel - libvirt-devel
- python3-libselinux - python3-libselinux
- edk2-ovmf

View File

@ -16,3 +16,4 @@ required_packages:
- libvirt-devel - libvirt-devel
- libxslt-devel - libxslt-devel
- libxml2-devel - libxml2-devel
- edk2-ovmf

View File

@ -14,5 +14,6 @@ required_packages:
- libxml2-devel - libxml2-devel
- pkg-config - pkg-config
- libvirt-devel - libvirt-devel
- qemu-ovmf-x86_64
- ebtables - ebtables
- dnsmasq - dnsmasq

View File

@ -12,5 +12,6 @@ required_packages:
- qemu-system-data - qemu-system-data
- pkg-config - pkg-config
- libvirt-dev - libvirt-dev
- ovmf
- ebtables - ebtables
- dnsmasq - dnsmasq

View File

@ -136,13 +136,17 @@
name: "{{ vm_name }}" name: "{{ vm_name }}"
uuid: "{{ vm_name | to_uuid }}" uuid: "{{ vm_name | to_uuid }}"
host_groups: "{{ vm_host_group }}" host_groups: "{{ vm_host_group }}"
driver: "{{ test_vm_node_driver|default('ipmi') }}" driver: "{{ test_vm_node_driver }}"
driver_info: driver_info:
power: power:
ipmi_address: "192.168.122.1" ipmi_address: "192.168.122.1"
ipmi_port: "{{ virtual_ipmi_port }}" ipmi_port: "{{ virtual_ipmi_port }}"
ipmi_username: "admin" ipmi_username: "admin"
ipmi_password: "password" ipmi_password: "password"
redfish_address: "http://{{ redfish_emulator_host }}:{{ redfish_emulator_port }}"
redfish_system_id: "/redfish/v1/Systems/{{ vm_name }}"
redfish_username: "admin"
redfish_password: "password"
nics: nics:
- mac: "{{ vm_mac }}" - mac: "{{ vm_mac }}"
ansible_ssh_host: "192.168.122.{{ testvm_json_data | length + 2 }}" ansible_ssh_host: "192.168.122.{{ testvm_json_data | length + 2 }}"
@ -155,12 +159,16 @@
node_entry: node_entry:
name: "{{ vm_name }}" name: "{{ vm_name }}"
uuid: "{{ vm_name | to_uuid }}" uuid: "{{ vm_name | to_uuid }}"
driver: "{{ test_vm_node_driver|default('ipmi') }}" driver: "{{ test_vm_node_driver }}"
driver_info: driver_info:
ipmi_address: "192.168.122.1" ipmi_address: "192.168.122.1"
ipmi_port: "{{ virtual_ipmi_port }}" ipmi_port: "{{ virtual_ipmi_port }}"
ipmi_username: "admin" ipmi_username: "admin"
ipmi_password: "password" ipmi_password: "password"
redfish_address: "http://{{ redfish_emulator_host }}:{{ redfish_emulator_port }}"
redfish_system_id: "/redfish/v1/Systems/{{ vm_name }}"
redfish_username: "admin"
redfish_password: "password"
ports: ports:
- address: "{{ vm_mac }}" - address: "{{ vm_mac }}"
properties: properties:

View File

@ -15,18 +15,14 @@
# Setup libvirt - ensure network and storage pool are defined and active, # Setup libvirt - ensure network and storage pool are defined and active,
# prepare dir for vm logs # prepare dir for vm logs
--- ---
- name: set virtualenv_command - name: install libvirt-python, gunicorn and lxml
set_fact:
venv_command: "python3 -m venv"
when: enable_venv
- name: install libvirt-python and lxml
include_role: include_role:
name: bifrost-pip-install name: bifrost-pip-install
vars: vars:
package: "{{ item }}" package: "{{ item }}"
loop: loop:
- libvirt-python - libvirt-python
- gunicorn
- lxml - lxml
- name: configure libvirt log filters for qemu - name: configure libvirt log filters for qemu
@ -198,3 +194,45 @@
state: started state: started
daemon_reload: "{{ vbmcd_service_file.changed }}" daemon_reload: "{{ vbmcd_service_file.changed }}"
become: true become: true
- name: install sushy-tools
include_role:
name: bifrost-pip-install
vars:
package: sushy-tools
- name: ensure Redfish Emulator systemd service is configured
template:
src: redfish-emulator.service.j2
dest: /etc/systemd/system/redfish-emulator.service
owner: root
group: root
mode: 0644
become: true
register: redfish_emulator_service_file
- name: find OVMF firmware
set_fact:
efi_loader_path: "{{ item }}"
with_first_found:
- /usr/share/OVMF/OVMF_CODE.secboot.fd
- /usr/share/OVMF/OVMF_CODE.fd
- /usr/share/qemu/ovmf-x86_64-code.bin
- name: write Redfish Emulator configuration file
template:
src: redfish-emulator.conf.j2
dest: /etc/redfish-emulator.conf
owner: root
group: root
mode: 0600
become: true
register: redfish_emulator_config_file
- name: ensure Redfish Emulator systemd service is started and enabled
systemd:
name: redfish-emulator
enabled: yes
state: "{{ 'restarted' if redfish_emulator_config_file.changed else 'started' }}"
daemon_reload: "{{ redfish_emulator_service_file.changed }}"
become: true

View File

@ -0,0 +1,11 @@
SUSHY_EMULATOR_BOOT_LOADER_MAP = {
'UEFI': {
'x86_64': '{{ efi_loader_path }}'
},
'Legacy': {
'x86_64': None
}
}
SUSHY_EMULATOR_LISTEN_IP = '{{ redfish_emulator_host }}'
SUSHY_EMULATOR_LISTEN_PORT = {{ redfish_emulator_port }}

View File

@ -0,0 +1,15 @@
{% if enable_venv | bool %}
{% set gunicorn = bifrost_venv_dir ~ '/bin/gunicorn' %}
{% else %}
{% set gunicorn = '/usr/local/bin/gunicorn' %}
{% endif %}
[Unit]
Description=Sushy Redfish Emulator
[Service]
Type=simple
Restart=on-failure
ExecStart={{ gunicorn }} sushy_tools.emulator.main:app \
--bind {{ redfish_emulator_host }}:{{ redfish_emulator_port }} \
--env SUSHY_EMULATOR_CONFIG=/etc/redfish-emulator.conf \
--env FLASK_DEBUG=1 --workers 2 --threads 2 --timeout 90

View File

@ -0,0 +1,9 @@
---
features:
- |
The ``bifrost-create-vm-nodes`` role now supports redfish emulation, set
``test_vm_node_driver=redfish`` (or ``--driver=redfish`` for
``bifrost-cli testenv``) to use.
- |
The new parameter ``default_boot_mode`` allows specifying the default boot
mode: ``uefi`` or ``bios``.

View File

@ -62,6 +62,7 @@ sudo journalctl -u ironic-conductor &> ${LOG_LOCATION}/ironic-conductor.log
sudo journalctl -u ironic-inspector &> ${LOG_LOCATION}/ironic-inspector.log sudo journalctl -u ironic-inspector &> ${LOG_LOCATION}/ironic-inspector.log
sudo journalctl -u dnsmasq &> ${LOG_LOCATION}/dnsmasq.log sudo journalctl -u dnsmasq &> ${LOG_LOCATION}/dnsmasq.log
sudo journalctl -u vbmcd &> ${LOG_LOCATION}/vbmcd.log sudo journalctl -u vbmcd &> ${LOG_LOCATION}/vbmcd.log
sudo journalctl -u redfish-emulator &> ${LOG_LOCATION}/redfish-emulator.log
sudo journalctl -u uwsgi &> ${LOG_LOCATION}/uwsgi.log sudo journalctl -u uwsgi &> ${LOG_LOCATION}/uwsgi.log
# Copy PXE information # Copy PXE information

View File

@ -132,6 +132,7 @@ done
--memory ${VM_MEMORY_SIZE:-512} \ --memory ${VM_MEMORY_SIZE:-512} \
--disk ${VM_DISK:-5} \ --disk ${VM_DISK:-5} \
--inventory "${BAREMETAL_DATA_FILE}" \ --inventory "${BAREMETAL_DATA_FILE}" \
--driver ${TEST_VM_NODE_DRIVER:-ipmi} \
--extra-vars git_url_root="${WORKSPACE:-https://opendev.org}" \ --extra-vars git_url_root="${WORKSPACE:-https://opendev.org}" \
${VM_SETUP_EXTRA:-} \ ${VM_SETUP_EXTRA:-} \
${BIFROST_CLI_EXTRA:-} ${BIFROST_CLI_EXTRA:-}

View File

@ -80,6 +80,7 @@
- openstack/keystone - openstack/keystone
vars: vars:
enable_keystone: true enable_keystone: true
test_driver: redfish
- job: - job:
name: bifrost-cli-ubuntu-bionic name: bifrost-cli-ubuntu-bionic
@ -105,6 +106,7 @@
- openstack/keystone - openstack/keystone
vars: vars:
enable_keystone: true enable_keystone: true
test_driver: redfish
- job: - job:
name: bifrost-integration-tinyipa-debian-buster name: bifrost-integration-tinyipa-debian-buster