From 2cf0d9fbc60d63768e51196af07f04a13b4f7940 Mon Sep 17 00:00:00 2001 From: miaohb Date: Mon, 7 Nov 2016 12:55:42 +0800 Subject: [PATCH] Policy binding attach cannot work The value of args.enabled must be changed from string to bool Closed-Bug: 1639692 Change-Id: I657eeeb44a14f484aef7cc52157876c7daf653c8 --- senlinclient/tests/unit/v1/test_shell.py | 8 ++++---- senlinclient/v1/shell.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/senlinclient/tests/unit/v1/test_shell.py b/senlinclient/tests/unit/v1/test_shell.py index 1c2a197..1be4874 100644 --- a/senlinclient/tests/unit/v1/test_shell.py +++ b/senlinclient/tests/unit/v1/test_shell.py @@ -1260,11 +1260,11 @@ class ShellTest(testtools.TestCase): args = { 'id': 'C1', 'policy': 'P1', - 'enabled': 'True', + 'enabled': True, } args = self._make_args(args) kwargs = { - 'enabled': 'True', + 'enabled': True, } service.cluster_attach_policy.return_value = {'action': 'action_id'} sh.do_cluster_policy_attach(service, args) @@ -1288,11 +1288,11 @@ class ShellTest(testtools.TestCase): args = { 'id': 'C1', 'policy': 'policy1', - 'enabled': 'True', + 'enabled': True, } args = self._make_args(args) kwargs = { - 'enabled': 'True', + 'enabled': True, } service.cluster_update_policy.return_value = {'action': 'action_id'} diff --git a/senlinclient/v1/shell.py b/senlinclient/v1/shell.py index 742b66d..b28a036 100644 --- a/senlinclient/v1/shell.py +++ b/senlinclient/v1/shell.py @@ -16,6 +16,7 @@ import threading import time from openstack import exceptions as sdk_exc +from oslo_utils import strutils import six from senlinclient.common import exc @@ -1052,7 +1053,7 @@ def do_cluster_policy_update(service, args): show_deprecated('senlin cluster-policy-update', 'openstack cluster policy binding update') kwargs = { - 'enabled': args.enabled, + 'enabled': strutils.bool_from_string(args.enabled, strict=True), } resp = service.cluster_update_policy(args.id, args.policy, **kwargs)