summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Abramov <sabramov@mirantis.com>2016-08-25 18:44:27 +0300
committerSergey Abramov <sabramov@mirantis.com>2016-08-29 14:35:41 +0300
commit8147718cf776dc287b4952cb24f067f0c47991ac (patch)
treec3ccf3278ab7f5dc220f1b2b5c61cf4f17c5f64e
parent0ae07c813ee42191caa24edf45b52b3e91f85182 (diff)
Fixes in CreateUpgradeReleaseHandler
* add deployment_tasks in clone release * fix typo * copy net_roles_metadata on src releases Change-Id: Ia3b29f3f6d36442d5980e9fdff951bfcc3ad814f Closes-bug: 1617247
Notes
Notes (review): Code-Review+1: Nikita Zubkov <nzubkov@mirantis.com> Code-Review+2: Ilya Kharin <akscram@gmail.com> Code-Review+2: Yuriy Taraday <yorik.sar@gmail.com> Workflow+1: Yuriy Taraday <yorik.sar@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 29 Aug 2016 14:38:57 +0000 Reviewed-on: https://review.openstack.org/360645 Project: openstack/fuel-nailgun-extension-cluster-upgrade Branch: refs/heads/master
-rw-r--r--cluster_upgrade/handlers.py17
-rw-r--r--cluster_upgrade/tests/test_handlers.py16
2 files changed, 26 insertions, 7 deletions
diff --git a/cluster_upgrade/handlers.py b/cluster_upgrade/handlers.py
index d4b7f71..9e79952 100644
--- a/cluster_upgrade/handlers.py
+++ b/cluster_upgrade/handlers.py
@@ -14,6 +14,7 @@
14# License for the specific language governing permissions and limitations 14# License for the specific language governing permissions and limitations
15# under the License. 15# under the License.
16 16
17import copy
17import six 18import six
18 19
19from nailgun.api.v1.handlers import base 20from nailgun.api.v1.handlers import base
@@ -152,13 +153,14 @@ class CreateUpgradeReleaseHandler(base.BaseHandler):
152 153
153 Overwrite base default_mapping by orig default_maping values. 154 Overwrite base default_mapping by orig default_maping values.
154 """ 155 """
156 base_nets = copy.deepcopy(base_nets)
157 orig_nets = copy.deepcopy(orig_nets)
155 orig_network_dict = {n['id']: n for n in orig_nets} 158 orig_network_dict = {n['id']: n for n in orig_nets}
156 for base_net in base_nets: 159 for base_net in base_nets:
157 orig_net = orig_network_dict.get(base_net['id']) 160 orig_net = orig_network_dict.get(base_net['id'])
158 if orig_net is None: 161 if orig_net is not None:
159 orig_net = base_net 162 base_net['default_mapping'] = orig_net['default_mapping']
160 base_net['default_mapping'] = orig_net['default_mapping'] 163 return base_nets
161 return base_net
162 164
163 @base.serialize 165 @base.serialize
164 def POST(self, cluster_id, release_id): 166 def POST(self, cluster_id, release_id):
@@ -174,14 +176,15 @@ class CreateUpgradeReleaseHandler(base.BaseHandler):
174 base_release = self.get_object_or_404(objects.Release, release_id) 176 base_release = self.get_object_or_404(objects.Release, release_id)
175 orig_cluster = self.get_object_or_404(objects.Cluster, cluster_id) 177 orig_cluster = self.get_object_or_404(objects.Cluster, cluster_id)
176 orig_release = orig_cluster.release 178 orig_release = orig_cluster.release
177
178 network_metadata = self.merge_network_roles( 179 network_metadata = self.merge_network_roles(
179 base_release.network_roles_metadata, 180 base_release.network_roles_metadata,
180 orig_release.network_roles_metadata) 181 orig_release.network_roles_metadata)
181 data = objects.Release.to_dict(base_release) 182 data = dict(base_release)
182 data['network_roles_metadata'] = network_metadata 183 data['network_roles_metadata'] = network_metadata
183 data['name'] = '{0} Upgrade ({1})'.format( 184 data['name'] = '{0} Upgrade ({1})'.format(
184 base_release.name, orig_release.id) 185 base_release.name, orig_release.id)
186 deployment_tasks = objects.Release.get_deployment_tasks(base_release)
187 data['deployment_tasks'] = deployment_tasks
185 del data['id'] 188 del data['id']
186 new_release = objects.Release.create(data) 189 new_release = objects.Release.create(data)
187 return new_release.to_dict() 190 return objects.Release.to_dict(new_release)
diff --git a/cluster_upgrade/tests/test_handlers.py b/cluster_upgrade/tests/test_handlers.py
index ad7239a..819a1fc 100644
--- a/cluster_upgrade/tests/test_handlers.py
+++ b/cluster_upgrade/tests/test_handlers.py
@@ -247,3 +247,19 @@ class TestCopyVipsHandler(base.BaseIntegrationTest):
247 247
248 self.assertEqual(resp.status_code, 200) 248 self.assertEqual(resp.status_code, 200)
249 self.assertTrue(copy_vips_mc.called) 249 self.assertTrue(copy_vips_mc.called)
250
251
252class TestCreateUpgradeReleaseHandler(base.BaseIntegrationTest):
253
254 def test_clone_release(self):
255 new_cluster = self.env.create_cluster(api=False)
256 release = self.env.create_release(
257 operating_system=consts.RELEASE_OS.ubuntu, version="new_version")
258 uri = reverse(
259 'CreateUpgradeReleaseHandler',
260 kwargs={'cluster_id': new_cluster.id, 'release_id': release.id})
261 resp = self.app.post(uri, headers=self.default_headers)
262 self.assertEqual(resp.status_code, 200)
263 self.assertEqual(
264 '{0} Upgrade ({1})'.format(release.name, new_cluster.release.id),
265 resp.json_body['name'])