diff options
author | Nate Potter <nathaniel.potteR@intel.com> | 2018-03-30 04:11:52 -0700 |
---|---|---|
committer | Nate Potter <nathaniel.potteR@intel.com> | 2018-03-30 04:13:15 -0700 |
commit | 181c53c3dc4d7ec3c603e60d78358d9ba16deccc (patch) | |
tree | dca18ead6898248f9a796ff8496e63107bd4e914 /newton | |
parent | cf244aca09697228f76fd033d1fd5e02f8124ef8 (diff) |
Fix SRIOV count fetching
Update the logic for SRIOV HPA fetching to get a count
value from the true or false that is provided.
Change-Id: I314a491a3b33bcfb445a85df8213203a436e03d1
Signed-off-by: Nathaniel Potter <nathaniel.potter@intel.com>
Issue-ID: MULTICLOUD-208
Diffstat (limited to 'newton')
-rw-r--r-- | newton/newton/registration/tests/test_registration.py | 2 | ||||
-rw-r--r-- | newton/newton/registration/views/registration.py | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/newton/newton/registration/tests/test_registration.py b/newton/newton/registration/tests/test_registration.py index e603e4e8..d5be81de 100644 --- a/newton/newton/registration/tests/test_registration.py +++ b/newton/newton/registration/tests/test_registration.py @@ -56,7 +56,7 @@ MOCK_GET_EXTRA_SPECS_RESPONSE = { "hw:numa_cpus.1": [0, 1], "hw:numa_mem.1": 2, "pci_passthrough:alias": "mycrypto-8086-0443:4", - "aggregate_instance_extra_spec:sriov-device-intel": "1832-9475", + "aggregate_instance_extra_spec:sriov-device-intel-1832-9475": "true", "hw:mem_page_size": "1GB" } } diff --git a/newton/newton/registration/views/registration.py b/newton/newton/registration/views/registration.py index 3a9c5acd..cc97e048 100644 --- a/newton/newton/registration/views/registration.py +++ b/newton/newton/registration/views/registration.py @@ -205,17 +205,23 @@ class Registry(newton_registration.Registry): capabilities.append(capability) # SRIOV Devices - sriov_devices = [spec for spec in extra_specs if spec.startswith("aggregate_instance_extra_spec:sriov-device")] + sriov_devices = [spec for spec in extra_specs if spec.startswith("aggregate_instance_extra_spec:sriov")] for device in sriov_devices: capability = hpa_dict['pciePassthrough']['info'] capability['hpa-capability-id'] = str(uuid.uuid4()) - # device will be in the form aggregate_instance_extra_specs:sriov-device-<name>="<Vendor ID>-<Device ID>", - device_info = extra_specs[device] - vendor_id = device_info.split("-")[0] - device_id = device_info.split("-")[1] + # device will be in the form aggregate_instance_extra_specs:sriov-device-<NAME>=<true/false>, + # NAME is expected to be in the form <NAME>-<VENDOR_ID>-<DEVICE_ID> + enabled = extra_specs[device] + count = 1 if enabled == "true" else 0 + vendor_id = device.split(":")[1].split("-")[3] + device_id = device.split(":")[1].split("-")[4] attributes = [ { + 'hpa-attribute-key': 'pciCount', + 'hpa-attribute-value': '{{\"value\":\"{0}\"}}'.format(count) + }, + { 'hpa-attribute-key': 'pciVendorId', 'hpa-attribute-value': '{{\"value\":\"{0}\"}}'.format(vendor_id) }, |