Remove 'nodes' key from serializer for 10.0

'nodes' data is deprecated so must be removed from 10.0 version
serializer output. The change was moved to separate serializer class in
order to maintain compatibility with previously deployed 9.0 clusters
after upgrade to 10.0.

Change-Id: I8fef591908cd8b1e4ace5502bb1e80cb37786c6e
Related-Bug: #1531128
This commit is contained in:
Artem Roma 2016-05-17 15:21:25 +03:00
parent 4a1f7cd08d
commit 80d7188700
4 changed files with 47 additions and 22 deletions

View File

@ -552,10 +552,6 @@ class DeploymentHASerializer90(DeploymentHASerializer80):
node_attrs['nova_hugepages_enabled'] = (
objects.NodeAttributes.is_nova_hugepages_enabled(node))
# we don't need nodes in serialized data for 9.0 environments
# https://bugs.launchpad.net/fuel/+bug/1531128
attrs.pop('nodes')
return attrs
@classmethod
@ -638,6 +634,18 @@ class DeploymentHASerializer90(DeploymentHASerializer80):
hugepages)
class DeploymentHASerializer10(DeploymentHASerializer90):
def get_common_attrs(self, cluster):
attrs = super(DeploymentHASerializer10, self).get_common_attrs(cluster)
# we don't need nodes in serialized data for 10.0 environments
# https://bugs.launchpad.net/fuel/+bug/1531128
attrs.pop('nodes')
return attrs
class DeploymentLCMSerializer(DeploymentHASerializer90):
_configs = None
_priorities = {
@ -799,7 +807,10 @@ def get_serializer_for_cluster(cluster):
},
'9.0': {
'ha': DeploymentHASerializer90,
}
},
'10.0': {
'ha': DeploymentHASerializer10,
},
}
env_mode = 'ha' if cluster.is_ha_mode else 'multinode'

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from nailgun.test.integration import test_orchestrator_serializer_90
class TestDeploymentHASerializer100(
test_orchestrator_serializer_90.TestDeploymentHASerializer90):
env_version = 'newton-10.0'
def test_remove_nodes_from_common_attrs(self):
cluster_db = self.env.clusters[0]
serializer = self.create_serializer(cluster_db)
common_attrs = serializer.get_common_attrs(cluster_db)
self.assertNotIn('nodes', common_attrs)

View File

@ -18,7 +18,6 @@ import mock
import six
from oslo_serialization import jsonutils
import unittest2
from nailgun import consts
from nailgun import objects
@ -634,13 +633,6 @@ class TestDeploymentHASerializer90(
for item in serialized:
self.assertIn(item, cust_serialized)
def test_remove_nodes_from_common_attrs(self):
cluster_db = self.env.clusters[0]
serializer = self.create_serializer(cluster_db)
common_attrs = serializer.get_common_attrs(cluster_db)
self.assertNotIn('nodes', common_attrs)
class TestDeploymentTasksSerialization90(
TestSerializer90Mixin,
@ -709,14 +701,6 @@ class TestNetworkTemplateSerializer90CompatibleWith80(
self.assertEqual(node_attrs['swift_zone'], node.uid)
self.assertEqual(node_attrs['nova_cpu_pinning_enabled'], False)
@unittest2.skip(
"'nodes' key was removed from 9.0 version serializer output, "
"thus test bound to this data (that exists in parent test case class) "
"must be skipped"
)
def test_network_not_mapped_to_nics_w_template(self):
pass
class TestNetworkTemplateSerializer90(
TestSerializer90Mixin,

View File

@ -97,4 +97,4 @@ class TestGetSerializer(BaseUnitTest):
cluster.release.environment_version = '9999.0'
self.assertIs(
ds.get_serializer_for_cluster(cluster),
ds.DeploymentHASerializer90)
ds.DeploymentHASerializer10)