diff --git a/nova/rc_fields.py b/nova/rc_fields.py index 7eb434c73311..ab410860cc81 100644 --- a/nova/rc_fields.py +++ b/nova/rc_fields.py @@ -41,12 +41,19 @@ class ResourceClass(fields.StringField): IPV4_ADDRESS = 'IPV4_ADDRESS' VGPU = 'VGPU' VGPU_DISPLAY_HEAD = 'VGPU_DISPLAY_HEAD' + # Standard resource class for network bandwidth egress measured in + # kilobits per second. + NET_BW_EGR_KILOBIT_PER_SEC = 'NET_BW_EGR_KILOBIT_PER_SEC' + # Standard resource class for network bandwidth ingress measured in + # kilobits per second. + NET_BW_IGR_KILOBIT_PER_SEC = 'NET_BW_IGR_KILOBIT_PER_SEC' # The ordering here is relevant. If you must add a value, only # append. STANDARD = (VCPU, MEMORY_MB, DISK_GB, PCI_DEVICE, SRIOV_NET_VF, NUMA_SOCKET, NUMA_CORE, NUMA_THREAD, NUMA_MEMORY_MB, - IPV4_ADDRESS, VGPU, VGPU_DISPLAY_HEAD) + IPV4_ADDRESS, VGPU, VGPU_DISPLAY_HEAD, + NET_BW_EGR_KILOBIT_PER_SEC, NET_BW_IGR_KILOBIT_PER_SEC) @classmethod def normalize_name(cls, rc_name): diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-policy.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-policy.yaml index 51f14b4336e0..1d90db0d6f3a 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-policy.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-policy.yaml @@ -16,7 +16,7 @@ tests: - name: list resource classes GET: /resource_classes response_json_paths: - $.resource_classes.`len`: 12 # Number of standard resource classes + $.resource_classes.`len`: 14 # Number of standard resource classes - name: create resource class POST: /resource_classes diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml index f77b1280b30c..638b03a33c7c 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml @@ -51,7 +51,7 @@ tests: GET: /resource_classes response_json_paths: response_json_paths: - $.resource_classes.`len`: 12 # Number of standard resource classes + $.resource_classes.`len`: 14 # Number of standard resource classes $.resource_classes[0].name: VCPU - name: non admin forbidden @@ -138,9 +138,9 @@ tests: - name: list resource classes after addition of custom res class GET: /resource_classes response_json_paths: - $.resource_classes.`len`: 13 # 12 standard plus 1 custom - $.resource_classes[12].name: $ENVIRON['CUSTOM_RES_CLASS'] - $.resource_classes[12].links[?rel = "self"].href: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS'] + $.resource_classes.`len`: 15 # 14 standard plus 1 custom + $.resource_classes[14].name: $ENVIRON['CUSTOM_RES_CLASS'] + $.resource_classes[14].links[?rel = "self"].href: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS'] - name: update standard resource class bad json PUT: /resource_classes/VCPU diff --git a/nova/tests/unit/objects/test_fields.py b/nova/tests/unit/objects/test_fields.py index f65974b26310..e98b65b23d0d 100644 --- a/nova/tests/unit/objects/test_fields.py +++ b/nova/tests/unit/objects/test_fields.py @@ -337,20 +337,10 @@ class TestResourceClass(TestString): def setUp(self): super(TestResourceClass, self).setUp() self.field = rc_fields.ResourceClassField() - self.coerce_good_values = [ - ('VCPU', 'VCPU'), - ('MEMORY_MB', 'MEMORY_MB'), - ('DISK_GB', 'DISK_GB'), - ('PCI_DEVICE', 'PCI_DEVICE'), - ('SRIOV_NET_VF', 'SRIOV_NET_VF'), - ('NUMA_SOCKET', 'NUMA_SOCKET'), - ('NUMA_CORE', 'NUMA_CORE'), - ('NUMA_THREAD', 'NUMA_THREAD'), - ('NUMA_MEMORY_MB', 'NUMA_MEMORY_MB'), - ('IPV4_ADDRESS', 'IPV4_ADDRESS'), - ('VGPU', 'VGPU'), - ('VGPU_DISPLAY_HEAD', 'VGPU_DISPLAY_HEAD'), - ] + # NOTE(gibi): We assume that the input value of a STANDARD RC is always + # the same as the coerced value + self.coerce_good_values = [(v, v) for v in + rc_fields.ResourceClass.STANDARD] self.coerce_bad_values = [object(), dict()] self.to_primitive_values = self.coerce_good_values[0:1] self.from_primitive_values = self.coerce_good_values[0:1]