Configuring emulators¶
Running emulators in the background¶
The emulators run as interactive processes attached to the terminal by default.
You can create systemd services to run the emulators in the background.
For each emulator, create a systemd unit file, and update <full-path>
to the
sushy-static
or sushy-emulator
binary, and adjust the arguments as
necessary, for example:
[Unit]
Description=Sushy Libvirt emulator
After=syslog.target
[Service]
Type=simple
ExecStart=/<full-path>/sushy-emulator --port 8000 --libvirt-uri "qemu:///system"
StandardOutput=syslog
StandardError=syslog
If you want to run the emulators with different configurations, for example, the
sushy-static
emulator with different mockup files, then create a new systemd
unit file.
You can also use gunicorn
to run sushy-emulator
, for example:
ExecStart=/usr/bin/gunicorn sushy_tools.emulator.main:app
Using configuration file¶
Besides command-line options, sushy-emulator can be configured via a configuration file. This tool uses the Flask application configuration infrastructure. Emulator-specific configuration options are prefixed with SUSHY_EMULATOR_ to make sure that they don’t collide with Flask’s own configuration options.
The configuration file itself can be specified through the SUSHY_EMULATOR_CONFIG environment variable.
The full list of supported options and their meanings can be found in the sample configuration file:
# sushy emulator configuration file built on top of Flask application
# configuration infrastructure: http://flask.pocoo.org/docs/config/
# Listen on all local IP interfaces
SUSHY_EMULATOR_LISTEN_IP = u''
# Bind to TCP port 8000
SUSHY_EMULATOR_LISTEN_PORT = 8000
# Serve this SSL certificate to the clients
SUSHY_EMULATOR_SSL_CERT = None
# If SSL certificate is being served, this is its RSA private key
SUSHY_EMULATOR_SSL_KEY = None
# If authentication is desired, set this to an htpasswd file.
SUSHY_EMULATOR_AUTH_FILE = None
# The OpenStack cloud ID to use. This option enables OpenStack driver.
SUSHY_EMULATOR_OS_CLOUD = None
# The OpenStack cloud ID to use for Ironic. This option enables Ironic driver.
SUSHY_EMULATOR_IRONIC_CLOUD = None
# The libvirt URI to use. This option enables libvirt driver.
SUSHY_EMULATOR_LIBVIRT_URI = u'qemu:///system'
# Instruct the libvirt driver to ignore any instructions to set the boot device,
# allowing the UEFI firmware to instead rely on the EFI Boot Manager.
# Note: This sets the legacy boot element to dev="fd" and relies on the floppy
# not existing. It likely won't work if your VM has a floppy drive.
SUSHY_EMULATOR_IGNORE_BOOT_DEVICE = False
# The map of firmware loaders dependent on the boot mode and system
# architecture. Ideally the x86_64 loader will be capable of secure boot or not
# based on the chosen nvram.
SUSHY_EMULATOR_BOOT_LOADER_MAP = {
'UEFI': {
'x86_64': u'/usr/share/OVMF/OVMF_CODE.secboot.fd',
'aarch64': u'/usr/share/AAVMF/AAVMF_CODE.fd'
},
'Legacy': {
'x86_64': None,
'aarch64': None
}
}
# nvram templates to use on x86_64 to enable or disable secure boot
SUSHY_EMULATOR_SECURE_BOOT_ENABLED_NVRAM = '/usr/share/OVMF/OVMF_VARS.secboot.fd'
SUSHY_EMULATOR_SECURE_BOOT_DISABLED_NVRAM = '/usr/share/OVMF/OVMF_VARS.fd'
# This map contains statically configured Redfish Chassis linked up with the
# Systems and Managers enclosed into this Chassis.
#
# The first chassis in the list will contain all other resources.
#
# If this map is not present in the configuration, a single default Chassis is
# configured automatically to enclose all available Systems and Managers.
SUSHY_EMULATOR_CHASSIS = [
{
u'Id': u'Chassis',
u'Name': u'Chassis',
u'UUID': u'48295861-2522-3561-6729-621118518810'
}
]
# This map contains statically configured Redfish IndicatorLED resource state
# ('Lit', 'Off', 'Blinking'), keyed by UUIDs of System and Chassis resources.
#
# If this map is not present in the configuration, each System and Chassis will
# have their IndicatorLED `Lit` by default.
#
# The Redfish client can change IndicatorLED state. The new state is volatile,
# i.e. it's maintained in process memory.
SUSHY_EMULATOR_INDICATOR_LEDS = {
# u'48295861-2522-3561-6729-621118518810': u'Blinking'
}
# This map contains statically configured virtual media resources.
# These devices ('Cd', 'Floppy', 'USBStick') will be exposed by the Manager(s)
# and possibly used by the System(s) if system emulation backend supports boot
# image configuration.
#
# This value is ignored by the OpenStack driver, which only supports the 'Cd'
# device. If this map is not present in the configuration, the following
# configuration is used for other drivers:
SUSHY_EMULATOR_VMEDIA_DEVICES = {
u'Cd': {
u'Name': 'Virtual CD',
u'MediaTypes': [
u'CD',
u'DVD'
]
},
u'Floppy': {
u'Name': u'Virtual Removable Media',
u'MediaTypes': [
u'Floppy',
u'USBStick'
]
}
}
# Instruct the virtual media insertion to not verify the SSL certificate when
# retrieving the image.
SUSHY_EMULATOR_VMEDIA_VERIFY_SSL = False
# This map contains statically configured Redfish Storage resources linked up
# with the Systems resources, keyed by the UUIDs of the Systems.
SUSHY_EMULATOR_STORAGE = {
"da69abcc-dae0-4913-9a7b-d344043097c0": [
{
"Id": "1",
"Name": "Local Storage Controller",
"StorageControllers": [
{
"MemberId": "0",
"Name": "Contoso Integrated RAID",
"SpeedGbps": 12
}
],
"Drives": [
"32ADF365C6C1B7BD"
]
}
]
}
# This map contains statically configured Redfish Drives resources. The Drive
# objects are keyed in a composite fashion using a tuple of the form
# (System_UUID, Storage_ID) referring to the UUID of the System and Id of the
# Storage resource, respectively, to which the Drive belongs.
SUSHY_EMULATOR_DRIVES = {
("da69abcc-dae0-4913-9a7b-d344043097c0", "1"): [
{
"Id": "32ADF365C6C1B7BD",
"Name": "Drive Sample",
"CapacityBytes": 899527000000,
"Protocol": "SAS"
}
]
}
# This map contains dynamically configured Redfish Volume resources backed by
# the libvirt virtualization backend of the dynamic Redfish emulator.
# The Volume objects are keyed in a composite fashion using a tuple of the form
# (System_UUID, Storage_ID) referring to the UUID of the System and ID of the
# Storage resource, respectively, to which the Volume belongs.
#
# Only the Volumes specified in the map or created via a POST request are
# allowed to be emulated upon by the emulator. Volumes other than these can
# neither be listed nor deleted.
#
# The Volumes in the map missing from the libvirt backend will be created
# dynamically in the pool name specified (provided the pool exists in the
# backend). If the pool name is not specified, the Volume will be created
# automatically in a pool named 'default'.
SUSHY_EMULATOR_VOLUMES = {
('da69abcc-dae0-4913-9a7b-d344043097c0', '1'): [
{
"libvirtPoolName": "sushyPool",
"libvirtVolName": "testVol",
"Id": "1",
"Name": "Sample Volume 1",
"VolumeType": "Mirrored",
"CapacityBytes": 23748
},
{
"libvirtPoolName": "sushyPool",
"libvirtVolName": "testVol1",
"Id": "2",
"Name": "Sample Volume 2",
"VolumeType": "StripedWithParity",
"CapacityBytes": 48395
}
]
}
# This list contains the identities of instances that the driver will filter by.
# It is useful in a tenant environment where only some instances represent
# virtual bare metal.
SUSHY_EMULATOR_ALLOWED_INSTANCES = [
"437XR1138R2",
"1",
"529QB9450R6",
"529QB9451R6",
"529QB9452R6",
"529QB9453R6"
]
# Disable the ability to power off the node, in line with NCSI enablement in
# Ironic
SUSHY_EMULATOR_DISABLE_POWER_OFF = False