summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Zubkov <nzubkov@mirantis.com>2016-09-21 13:13:28 +0300
committerNikita Zubkov <nzubkov@mirantis.com>2016-09-21 18:35:09 +0300
commite7b127a308fd286f948bcd4960865eca73e08e14 (patch)
tree7386a37f064ef8e43589b0d6bea158d23d4b94dc
parent4150121e8a97ff76fc116596e8cd19e69c3ea279 (diff)
Add info about upgrade to deployment_info
This patch adds new data pipline for seed cluster that add to cluster deployment info attributes about upgrade Change-Id: I0630e75508552927b67065ff85cb6bac1bb88f61
Notes
Notes (review): Code-Review+2: Ilya Kharin <akscram@gmail.com> Workflow+1: Ilya Kharin <akscram@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 23 Sep 2016 22:25:06 +0000 Reviewed-on: https://review.openstack.org/373995 Project: openstack/fuel-nailgun-extension-cluster-upgrade Branch: refs/heads/master
-rw-r--r--cluster_upgrade/extension.py20
-rw-r--r--cluster_upgrade/handlers.py2
-rw-r--r--cluster_upgrade/tests/test_extension.py41
3 files changed, 60 insertions, 3 deletions
diff --git a/cluster_upgrade/extension.py b/cluster_upgrade/extension.py
index 79bdca4..ccda7a3 100644
--- a/cluster_upgrade/extension.py
+++ b/cluster_upgrade/extension.py
@@ -18,7 +18,21 @@ import os
18 18
19from nailgun import extensions 19from nailgun import extensions
20 20
21from . import handlers 21from cluster_upgrade import handlers
22
23
24class UpgradePipeline(extensions.BasePipeline):
25 @classmethod
26 def process_deployment_for_cluster(cls, cluster, cluster_data):
27 from cluster_upgrade.objects.relations import UpgradeRelationObject
28
29 relation = UpgradeRelationObject.get_cluster_relation(cluster.id)
30 cluster_data['upgrade'] = {
31 'relation_info': {
32 'orig_cluster_id': relation.orig_cluster_id,
33 'seed_cluster_id': relation.seed_cluster_id,
34 }
35 }
22 36
23 37
24class ClusterUpgradeExtension(extensions.BaseExtension): 38class ClusterUpgradeExtension(extensions.BaseExtension):
@@ -26,6 +40,10 @@ class ClusterUpgradeExtension(extensions.BaseExtension):
26 version = '0.0.1' 40 version = '0.0.1'
27 description = "Cluster Upgrade Extension" 41 description = "Cluster Upgrade Extension"
28 42
43 data_pipelines = [
44 UpgradePipeline,
45 ]
46
29 urls = [ 47 urls = [
30 {'uri': r'/clusters/(?P<cluster_id>\d+)/upgrade/clone/?$', 48 {'uri': r'/clusters/(?P<cluster_id>\d+)/upgrade/clone/?$',
31 'handler': handlers.ClusterUpgradeCloneHandler}, 49 'handler': handlers.ClusterUpgradeCloneHandler},
diff --git a/cluster_upgrade/handlers.py b/cluster_upgrade/handlers.py
index 22dd948..9c90312 100644
--- a/cluster_upgrade/handlers.py
+++ b/cluster_upgrade/handlers.py
@@ -19,6 +19,7 @@ import six
19 19
20from nailgun.api.v1.handlers import base 20from nailgun.api.v1.handlers import base
21from nailgun import errors 21from nailgun import errors
22from nailgun.extensions.manager import update_extensions_for_object
22from nailgun import objects 23from nailgun import objects
23from nailgun.task import manager 24from nailgun.task import manager
24 25
@@ -61,6 +62,7 @@ class ClusterUpgradeCloneHandler(base.BaseHandler):
61 raise errors.InvalidData("Network changes during upgrade" 62 raise errors.InvalidData("Network changes during upgrade"
62 " is not supported.") 63 " is not supported.")
63 64
65 update_extensions_for_object(new_cluster.cluster, ['cluster_upgrade'])
64 return new_cluster.to_dict() 66 return new_cluster.to_dict()
65 67
66 68
diff --git a/cluster_upgrade/tests/test_extension.py b/cluster_upgrade/tests/test_extension.py
index 92bff1d..39166ff 100644
--- a/cluster_upgrade/tests/test_extension.py
+++ b/cluster_upgrade/tests/test_extension.py
@@ -15,10 +15,16 @@
15# under the License. 15# under the License.
16 16
17import mock 17import mock
18from oslo_serialization import jsonutils
19
20from nailgun import objects
21from nailgun.orchestrator.deployment_serializers import DeploymentLCMSerializer
18from nailgun.test.base import BaseTestCase 22from nailgun.test.base import BaseTestCase
23from nailgun.utils import reverse
19 24
20from .. import extension 25from cluster_upgrade import extension
21from ..objects import relations 26from cluster_upgrade.objects import relations
27from cluster_upgrade.tests import base
22 28
23 29
24class TestExtension(BaseTestCase): 30class TestExtension(BaseTestCase):
@@ -27,3 +33,34 @@ class TestExtension(BaseTestCase):
27 cluster = mock.Mock(id=42) 33 cluster = mock.Mock(id=42)
28 extension.ClusterUpgradeExtension.on_cluster_delete(cluster) 34 extension.ClusterUpgradeExtension.on_cluster_delete(cluster)
29 mock_on_cluster_delete.assert_called_once_with(42) 35 mock_on_cluster_delete.assert_called_once_with(42)
36
37
38class TestPipeline(base.BaseCloneClusterTest):
39 def setUp(self):
40 super(TestPipeline, self).setUp()
41
42 resp = self.app.post(
43 reverse("ClusterUpgradeCloneHandler",
44 kwargs={"cluster_id": self.src_cluster_db.id}),
45 jsonutils.dumps(self.data),
46 headers=self.default_headers
47 ).json_body
48
49 self.dst_cluster_db = objects.Cluster.get_by_uid(resp['id'])
50
51 def test_upgrade_info(self):
52 deployment_info = DeploymentLCMSerializer().serialize(
53 self.dst_cluster_db, []
54 )
55
56 expected = {
57 'relation_info': {
58 'orig_cluster_id': self.src_cluster_db.id,
59 'seed_cluster_id': self.dst_cluster_db.id,
60 }
61 }
62
63 self.assertEqual(
64 deployment_info['common']['upgrade'],
65 expected,
66 )