Merge "Check node status before do cluster-recover action"
This commit is contained in:
commit
79a9a760b0
@ -780,12 +780,13 @@ class TestClusterRecover(TestCluster):
|
||||
return_value=self.response)
|
||||
|
||||
def test_cluster_recover(self):
|
||||
arglist = ['cluster1', 'cluster2', 'cluster3']
|
||||
arglist = ['cluster1', 'cluster2', 'cluster3', '--check', 'false']
|
||||
kwargs = {'check': False}
|
||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.mock_client.recover_cluster.assert_has_calls(
|
||||
[mock.call('cluster1'), mock.call('cluster2'),
|
||||
mock.call('cluster3')]
|
||||
[mock.call('cluster1', **kwargs), mock.call('cluster2', **kwargs),
|
||||
mock.call('cluster3', **kwargs)]
|
||||
)
|
||||
|
||||
def test_cluster_recover_not_found(self):
|
||||
|
@ -1374,13 +1374,20 @@ class ShellTest(testtools.TestCase):
|
||||
|
||||
def test_do_cluster_recover(self):
|
||||
service = mock.Mock()
|
||||
args = self._make_args({'id': ['cluster1']})
|
||||
args = {
|
||||
'id': ['cluster1'],
|
||||
'check': 'false'
|
||||
}
|
||||
args = self._make_args(args)
|
||||
params = {
|
||||
'check': False
|
||||
}
|
||||
service.recover_cluster = mock.Mock()
|
||||
service.recover_cluster.return_value = {'action': 'action_id'}
|
||||
|
||||
sh.do_cluster_recover(service, args)
|
||||
|
||||
service.recover_cluster.assert_called_once_with('cluster1')
|
||||
service.recover_cluster.assert_called_once_with('cluster1', **params)
|
||||
|
||||
def test_do_cluster_collect(self):
|
||||
service = mock.Mock()
|
||||
|
@ -831,14 +831,28 @@ class RecoverCluster(command.Command):
|
||||
nargs='+',
|
||||
help=_('ID or name of cluster(s) to operate on.')
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--check',
|
||||
metavar='<boolean>',
|
||||
default=False,
|
||||
help=_("Whether the cluster should check it's nodes status before "
|
||||
"doing cluster recover. Default is false")
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
senlin_client = self.app.client_manager.clustering
|
||||
|
||||
params = {
|
||||
'check': strutils.bool_from_string(parsed_args.check, strict=True)
|
||||
}
|
||||
|
||||
for cid in parsed_args.cluster:
|
||||
try:
|
||||
resp = senlin_client.recover_cluster(cid)
|
||||
resp = senlin_client.recover_cluster(cid, **params)
|
||||
except sdk_exc.ResourceNotFound:
|
||||
raise exc.CommandError(_('Cluster not found: %s') % cid)
|
||||
print('Cluster recover request on cluster %(cid)s is accepted by '
|
||||
|
@ -1166,13 +1166,21 @@ def do_cluster_check(service, args):
|
||||
'action %(action)s.' % {'cid': cid, 'action': resp['action']})
|
||||
|
||||
|
||||
@utils.arg('-c', '--check', metavar='<BOOLEAN>', default=False,
|
||||
help=_("Whether the cluster should check it's nodes status before "
|
||||
"doing cluster recover. Default is false"))
|
||||
@utils.arg('id', metavar='<CLUSTER>', nargs='+',
|
||||
help=_('ID or name of cluster(s) to operate on.'))
|
||||
def do_cluster_recover(service, args):
|
||||
"""Recover the cluster(s)."""
|
||||
show_deprecated('senlin cluster-recover', 'openstack cluster recover')
|
||||
|
||||
params = {
|
||||
'check': strutils.bool_from_string(args.check, strict=True)
|
||||
}
|
||||
|
||||
for cid in args.id:
|
||||
resp = service.recover_cluster(cid)
|
||||
resp = service.recover_cluster(cid, **params)
|
||||
print('Cluster recover request on cluster %(cid)s is accepted by '
|
||||
'action %(action)s.' % {'cid': cid, 'action': resp['action']})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user