Reduced cluster and release information in deployment_info

Reduced cluster and release attributes which are added to
deployment_info on serialization

Change-Id: I98a960ad4b4c1ac12f25059e9b429fdca97cffb4
Closes-Bug: 1618002
This commit is contained in:
Bulat Gaifullin 2016-08-29 15:43:49 +03:00
parent 5a89e0370b
commit 3073c61361
2 changed files with 26 additions and 19 deletions

View File

@ -677,8 +677,15 @@ class DeploymentLCMSerializer(DeploymentHASerializer90):
attrs = super(DeploymentLCMSerializer, self).get_common_attrs(
cluster
)
attrs['cluster'] = objects.Cluster.to_dict(cluster)
attrs['release'] = objects.Release.to_dict(cluster.release)
attrs['cluster'] = objects.Cluster.to_dict(
cluster, fields=("id", "name", "fuel_version", "status", "mode")
)
attrs['release'] = objects.Release.to_dict(
cluster.release, fields=('name', 'version', 'operating_system')
)
# the ReleaseSerializer adds this attribute certainly
attrs['release'].pop('is_deployable', None)
provision = attrs.setdefault('provision', {})
utils.dict_update(
provision,

View File

@ -523,24 +523,25 @@ class TestDeploymentLCMSerialization90(
def test_cluster_attributes_in_serialized(self):
objects.Cluster.prepare_for_deployment(self.cluster_db)
serialized = self.serializer.serialize(self.cluster_db, [self.node])
release = self.cluster_db.release
release_info = {
'name': release.name,
'version': release.version,
'operating_system': release.operating_system,
}
cluster_info = {
"id": self.cluster_db.id,
"name": self.cluster_db.name,
"fuel_version": self.cluster_db.fuel_version,
"status": self.cluster_db.status,
"mode": self.cluster_db.mode
}
for node_info in serialized:
self.assertEqual(
objects.Cluster.to_dict(self.cluster_db),
node_info['cluster']
)
self.assertEqual(
objects.Release.to_dict(self.cluster_db.release),
node_info['release']
)
self.assertEqual(cluster_info, node_info['cluster'])
self.assertEqual(release_info, node_info['release'])
self.assertEqual(
['compute'],
serialized[0]['roles']
)
self.assertEqual(
[consts.TASK_ROLES.master],
serialized[1]['roles']
)
self.assertEqual(['compute'], serialized[0]['roles'])
self.assertEqual([consts.TASK_ROLES.master], serialized[1]['roles'])
@mock.patch.object(
plugins.adapters.PluginAdapterBase, 'repo_files',
@ -618,7 +619,6 @@ class TestDeploymentLCMSerialization90(
if item['uid'] != consts.MASTER_NODE_UID:
self.assertIn(item, cust_serialized)
else:
item['cluster']['is_customized'] = True
self.assertIn(item, cust_serialized)
def test_provision_info_serialized(self):