From e01394344f5652020faee7c98b95d8832164b0cb Mon Sep 17 00:00:00 2001 From: xu-haiwei Date: Thu, 1 Dec 2016 06:28:39 +0000 Subject: [PATCH] Fix resource update issues Currently when updating a resource, the 'id' is not allowed to be in the request body, openstacksdk is can not checking whether 'ID' is legal or not. So pass an object to openstacksdk to get through. Change-Id: I3b52ef9ceaa75ab28c3bb52a314b044fa51e6dda --- senlinclient/tests/unit/v1/test_shell.py | 8 ++++---- senlinclient/v1/shell.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/senlinclient/tests/unit/v1/test_shell.py b/senlinclient/tests/unit/v1/test_shell.py index a924828b..6c89eb7c 100644 --- a/senlinclient/tests/unit/v1/test_shell.py +++ b/senlinclient/tests/unit/v1/test_shell.py @@ -262,7 +262,7 @@ class ShellTest(testtools.TestCase): 'name': 'stack_spec', 'metadata': {'user': 'demo'}, } - service.update_profile.assert_called_once_with(profile_id, **params) + service.update_profile.assert_called_once_with(profile, **params) mock_show.assert_called_once_with(service, profile_id) @mock.patch.object(utils, 'format_parameters') @@ -662,7 +662,7 @@ class ShellTest(testtools.TestCase): sh.do_policy_update(service, args) service.get_policy.assert_called_once_with('policy_id') service.update_policy.assert_called_once_with( - 'policy_id', **params) + policy, **params) mock_show(service, policy_id=policy.id) def test_do_policy_delete(self): @@ -972,7 +972,7 @@ class ShellTest(testtools.TestCase): sh.do_cluster_update(service, args) service.get_cluster.assert_called_once_with('CID') - service.update_cluster.assert_called_once_with('CID', **attrs) + service.update_cluster.assert_called_once_with(cluster, **attrs) mock_show.assert_called_once_with(service, 'CID') @mock.patch.object(sh, '_show_cluster') @@ -1537,7 +1537,7 @@ class ShellTest(testtools.TestCase): service.get_node.return_value = node sh.do_node_update(service, args) service.get_node.assert_called_once_with('node_id') - service.update_node.assert_called_once_with('node_id', **attrs) + service.update_node.assert_called_once_with(node, **attrs) mock_show.assert_called_once_with(service, 'node_id') @mock.patch.object(utils, 'print_list') diff --git a/senlinclient/v1/shell.py b/senlinclient/v1/shell.py index ff93e254..38214aed 100644 --- a/senlinclient/v1/shell.py +++ b/senlinclient/v1/shell.py @@ -217,7 +217,7 @@ def do_profile_update(service, args): profile = service.get_profile(args.id) except sdk_exc.ResourceNotFound: raise exc.CommandError(_('Profile not found: %s') % args.id) - service.update_profile(profile.id, **params) + service.update_profile(profile, **params) _show_profile(service, profile.id) @@ -408,7 +408,7 @@ def do_policy_update(service, args): policy = service.get_policy(args.id) if policy is not None: - service.update_policy(policy.id, **params) + service.update_policy(policy, **params) _show_policy(service, policy_id=policy.id) @@ -768,7 +768,7 @@ def do_cluster_update(service, args): 'timeout': args.timeout, } - service.update_cluster(cluster.id, **attrs) + service.update_cluster(cluster, **attrs) _show_cluster(service, cluster.id) @@ -1247,7 +1247,7 @@ def do_node_update(service, args): 'metadata': utils.format_parameters(args.metadata), } - service.update_node(args.id, **attrs) + service.update_node(node, **attrs) _show_node(service, node.id)