From 7e1d537e8efad4e879d0e8291b39a7a3b73eaf5b Mon Sep 17 00:00:00 2001 From: Vitaly Kramskikh Date: Fri, 1 Apr 2016 10:58:11 +0000 Subject: [PATCH] Revert "Fix attribute type for hugepages for DPDK" UI doesn't support such type and became broken after merge of the original patch. Closes-Bug: #1564847 This reverts commit b04a2541febfd14b19379f5e73eaeeee2588e45e. Change-Id: I06417e0c48c9c1d24223b93c0c4c8b9d437b200c --- .../nailgun/api/v1/validators/json_schema/base_types.py | 4 +--- nailgun/nailgun/fixtures/openstack.yaml | 2 +- nailgun/nailgun/objects/node.py | 6 +++--- .../test/integration/test_cluster_changes_handler.py | 2 +- .../test/integration/test_orchestrator_serializer_90.py | 7 ++++--- nailgun/nailgun/test/unit/test_node_attributes.py | 6 +++--- .../nailgun/test/unit/test_node_attributes_validator.py | 4 ++-- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/nailgun/nailgun/api/v1/validators/json_schema/base_types.py b/nailgun/nailgun/api/v1/validators/json_schema/base_types.py index 8b36537b38..b16efca480 100644 --- a/nailgun/nailgun/api/v1/validators/json_schema/base_types.py +++ b/nailgun/nailgun/api/v1/validators/json_schema/base_types.py @@ -241,8 +241,7 @@ ATTRIBUTE_SCHEMA = { 'file', 'text_list', 'textarea_list', - 'custom_hugepages', - 'simple_hugepages' + 'custom_hugepages' ] }, # 'value': None, # custom validation depending on type @@ -322,7 +321,6 @@ ATTRIBUTE_TYPE_SCHEMAS = { 'radio': ALLOWED_VALUES_SCHEMA, 'select': ALLOWED_VALUES_SCHEMA, 'text': {'value': {'type': 'string'}}, - 'simple_hugepages': {'value': {'type': ['string', 'integer']}}, 'textarea': {'value': {'type': 'string'}}, 'text_list': MULTIPLE_TEXT_FIELDS_SCHEMA, 'textarea_list': MULTIPLE_TEXT_FIELDS_SCHEMA diff --git a/nailgun/nailgun/fixtures/openstack.yaml b/nailgun/nailgun/fixtures/openstack.yaml index 96f0c19f90..08cd6d0ac2 100644 --- a/nailgun/nailgun/fixtures/openstack.yaml +++ b/nailgun/nailgun/fixtures/openstack.yaml @@ -2160,7 +2160,7 @@ weight: 20 description: "DPDK Huge Pages per NUMA node in MB" label: "DPDK Huge Pages" - type: "simple_hugepages" + type: "text" value: "0" regex: source: '^\d+$' diff --git a/nailgun/nailgun/objects/node.py b/nailgun/nailgun/objects/node.py index 5fad010982..3bd5f83c60 100644 --- a/nailgun/nailgun/objects/node.py +++ b/nailgun/nailgun/objects/node.py @@ -1313,7 +1313,7 @@ class NodeAttributes(object): # FIXME(asvechnikov): remove this part, # after implementing of blueprint input-type-number in UI for attr in six.itervalues(hugepages): - if attr.get('type') == 'simple_hugepages': + if attr.get('type') == 'text': attr['value'] = int(attr['value']) elif attr.get('type') == 'custom_hugepages': for size in attr['value']: @@ -1412,7 +1412,7 @@ class NodeAttributes(object): value = attrs['value'] for size, count in six.iteritems(value): hugepages[size] += int(count) - elif attrs.get('type') == 'simple_hugepages': + elif attrs.get('type') == 'text': # type text means that value is the number of memory in MB # per NUMA node which should be converted to pages count count_per_numa_node = cls.pages_per_numa_node(attrs['value']) @@ -1482,7 +1482,7 @@ class NodeAttributes(object): components = {'all': [], 'any': []} for attrs in hugepages.values(): - if attrs.get('type') == 'simple_hugepages': + if attrs.get('type') == 'text': # type text means size of memory in MiB to allocate with # 2MiB pages, so we need to calculate pages count pages_count = cls.pages_per_numa_node(attrs['value']) diff --git a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py index f191a40021..cd2ff5caf2 100644 --- a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py +++ b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py @@ -1884,7 +1884,7 @@ class TestHandlers(BaseIntegrationTest): node = self.env.nodes[0] node.attributes['hugepages'] = { - 'dpdk': {'type': 'simple_hugepages', 'value': '1026'}, + 'dpdk': {'type': 'text', 'value': '1026'}, 'nova': {'type': 'custom_hugepages', 'value': {'2048': 1}} } diff --git a/nailgun/nailgun/test/integration/test_orchestrator_serializer_90.py b/nailgun/nailgun/test/integration/test_orchestrator_serializer_90.py index ee4d5f825f..034c3aef60 100644 --- a/nailgun/nailgun/test/integration/test_orchestrator_serializer_90.py +++ b/nailgun/nailgun/test/integration/test_orchestrator_serializer_90.py @@ -359,12 +359,13 @@ class TestDeploymentAttributesSerialization90( 'nova': { 'type': 'custom_hugepages', 'value': { - '2048': 512, + # FIXME make counts integer after appropriate UI fix + '2048': '512', } }, 'dpdk': { - 'type': 'simple_hugepages', - 'value': 512, + 'type': 'text', + 'value': '512', } } }) diff --git a/nailgun/nailgun/test/unit/test_node_attributes.py b/nailgun/nailgun/test/unit/test_node_attributes.py index d83bb09c80..55487261dd 100644 --- a/nailgun/nailgun/test/unit/test_node_attributes.py +++ b/nailgun/nailgun/test/unit/test_node_attributes.py @@ -71,7 +71,7 @@ class TestNodeAttributes(base.BaseUnitTest): '2048': 14, '1048576': '2'}}, 'comp2': { - 'type': 'simple_hugepages', + 'type': 'text', 'value': 20}}}, meta={'numa_topology': {'numa_nodes': [{'id': 0}]}}) expected = { @@ -90,7 +90,7 @@ class TestNodeAttributes(base.BaseUnitTest): 'value': { '1048576': 2}}, 'comp2': { - 'type': 'simple_hugepages', + 'type': 'text', 'value': '10'}}}, meta={'numa_topology': {'numa_nodes': [{'id': '0'}]}}) expected = " hugepagesz=2M hugepages=5 hugepagesz=1G hugepages=2" @@ -110,7 +110,7 @@ class TestNodeAttributes(base.BaseUnitTest): } }, 'comp2': { - 'type': 'simple_hugepages', + 'type': 'text', 'value': '512'}}}, meta={'numa_topology': {'numa_nodes': [ {'id': 0, 'memory': 2 ** 31}, diff --git a/nailgun/nailgun/test/unit/test_node_attributes_validator.py b/nailgun/nailgun/test/unit/test_node_attributes_validator.py index 91f613281e..36571b686b 100644 --- a/nailgun/nailgun/test/unit/test_node_attributes_validator.py +++ b/nailgun/nailgun/test/unit/test_node_attributes_validator.py @@ -45,7 +45,7 @@ class BaseNodeAttributeValidatorTest(base.BaseTestCase): 'value': {}, }, 'dpdk': { - 'type': 'simple_hugepages', + 'type': 'text', 'value': '0', }, }, @@ -81,7 +81,7 @@ class TestNodeAttributesValidatorHugepages(BaseNodeAttributeValidatorTest): }, }, 'dpdk': { - 'value': 2, + 'value': '2', }, } }