diff options
author | Nate Potter <nathaniel.potteR@intel.com> | 2018-03-27 07:59:02 -0700 |
---|---|---|
committer | Nate Potter <nathaniel.potteR@intel.com> | 2018-03-27 07:59:02 -0700 |
commit | d5660966bce0bf724f124cd80f812da21700466b (patch) | |
tree | c3dc0cc467c28af940f54ea9d159b2023f82b698 /newton | |
parent | a3b7ac14b562270157bf6fe7a91666449244d126 (diff) |
Add SRIOV HPA fetching
Change-Id: I9b9307278293da8e579aac8cf01f7cfb6b725d6b
Signed-off-by: Nathaniel Potter <nathaniel.potter@intel.com>
Issue-ID: MULTICLOUD-179
Diffstat (limited to 'newton')
-rw-r--r-- | newton/newton/registration/tests/test_registration.py | 1 | ||||
-rw-r--r-- | newton/newton/registration/views/registration.py | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/newton/newton/registration/tests/test_registration.py b/newton/newton/registration/tests/test_registration.py index 0e9be29f..e603e4e8 100644 --- a/newton/newton/registration/tests/test_registration.py +++ b/newton/newton/registration/tests/test_registration.py @@ -56,6 +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", "hw:mem_page_size": "1GB" } } diff --git a/newton/newton/registration/views/registration.py b/newton/newton/registration/views/registration.py index e446a3b8..9ed811b8 100644 --- a/newton/newton/registration/views/registration.py +++ b/newton/newton/registration/views/registration.py @@ -194,12 +194,45 @@ class Registry(newton_registration.Registry): { 'hpa-attribute-key': 'pciDeviceId', 'hpa-attribute-value': '{{\"value\":\"{0}\"}}'.format(device_id) + }, + { + 'hpa-attribute-key': 'functionType', + 'hpa-attribute-value': 'PCI-PASSTHROUGH' + } + ] + + capability['hpa-features-attributes'] = attributes + capabilities.append(capability) + + # SRIOV Devices + sriov_devices = [spec for spec in extra_specs if spec.startswith("aggregate_instance_extra_spec:sriov-device")] + 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] + + attributes = [ + { + 'hpa-attribute-key': 'pciVendorId', + 'hpa-attribute-value': '{{\"value\":\"{0}\"}}'.format(vendor_id) + }, + { + 'hpa-attribute-key': 'pciDeviceId', + 'hpa-attribute-value': '{{\"value\":\"{0}\"}}'.format(device_id) + }, + { + 'hpa-attribute-key': 'functionType', + 'hpa-attribute-value': 'SRIOV' } ] capability['hpa-features-attributes'] = attributes capabilities.append(capability) + # OVS DPDK if cloud_extra_info: cloud_dpdk_info = cloud_extra_info.get('ovsDpdk') |