Add --force option to OpenStack config update command
Both v1 and v2 clients are fixed Closes-bug: #1526871 Related-Bug: #1523131 Depends-on: I2ef06b7084b0cafa576172c9f2db40aa4ccd6db8 Change-Id: I5c9594f0ce65c893a5d7d2c7424533c7a36d4f2d
This commit is contained in:
@@ -36,6 +36,7 @@ class OpenstackConfigAction(Action):
|
||||
Args.get_single_role_arg("Node role"),
|
||||
Args.get_config_id_arg("Openstack config ID"),
|
||||
Args.get_deleted_arg("Get deleted configurations"),
|
||||
Args.get_force_arg("Force configuration update"),
|
||||
group(
|
||||
Args.get_list_arg("List openstack configurations"),
|
||||
Args.get_download_arg(
|
||||
@@ -131,12 +132,14 @@ class OpenstackConfigAction(Action):
|
||||
fuel openstack-config --execute --env 1
|
||||
fuel openstack-config --execute --env 1 --node 1
|
||||
fuel openstack-config --execute --env 1 --role controller
|
||||
fuel openstack-config --execute --env 1 --force
|
||||
"""
|
||||
node_id = getattr(params, 'node', None)
|
||||
node_role = getattr(params, 'role', None)
|
||||
force = getattr(params, 'force', False)
|
||||
task_result = OpenstackConfig.execute(
|
||||
cluster_id=params.env, node_id=node_id,
|
||||
node_role=node_role)
|
||||
node_role=node_role, force=force)
|
||||
if task_result['status'] == 'error':
|
||||
print(
|
||||
'Error applying openstack configuration: {0}.'.format(
|
||||
|
||||
@@ -61,6 +61,13 @@ class OpenstackConfigMixin(object):
|
||||
type=bool, default=False, help='Show deleted configurations.'
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def add_force_arg(parser):
|
||||
parser.add_argument(
|
||||
'-f', '--force',
|
||||
action='store_true', help='Force configuration update.'
|
||||
)
|
||||
|
||||
|
||||
class OpenstackConfigList(OpenstackConfigMixin, base.BaseCommand):
|
||||
"""List all openstack configurations.
|
||||
@@ -143,12 +150,14 @@ class OpenstackConfigExecute(OpenstackConfigMixin, base.BaseCommand):
|
||||
self.add_env_arg(parser)
|
||||
self.add_node_id_arg(parser)
|
||||
self.add_node_role_arg(parser)
|
||||
self.add_force_arg(parser)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, args):
|
||||
self.client.execute(
|
||||
cluster_id=args.env, node_id=args.node, node_role=args.role)
|
||||
cluster_id=args.env, node_id=args.node, node_role=args.role,
|
||||
force=args.force)
|
||||
|
||||
msg = "OpenStack configuration execution started.\n"
|
||||
self.app.stdout.write(msg)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import mock
|
||||
import yaml
|
||||
|
||||
@@ -133,6 +134,17 @@ class TestOpenstackConfigActions(base.UnitTestCase):
|
||||
json={'status': 'ready'})
|
||||
self.execute(['fuel', 'openstack-config', '--env', '42', '--execute'])
|
||||
self.assertTrue(m_put.called)
|
||||
self.assertEqual({"cluster_id": 42, "force": False},
|
||||
json.loads(m_put.last_request.text))
|
||||
|
||||
def test_config_force_execute(self):
|
||||
m_put = self.m_request.put('/api/v1/openstack-config/execute/',
|
||||
json={'status': 'ready'})
|
||||
self.execute(['fuel', 'openstack-config', '--env', '42', '--execute',
|
||||
'--force'])
|
||||
self.assertTrue(m_put.called)
|
||||
self.assertEqual({"cluster_id": 42, "force": True},
|
||||
json.loads(m_put.last_request.text))
|
||||
|
||||
def test_config_execute_fail(self):
|
||||
message = 'Some error'
|
||||
|
||||
@@ -111,4 +111,15 @@ class TestOpenstackConfig(test_engine.BaseCLITest):
|
||||
|
||||
self.m_get_client.assert_called_once_with('openstack-config', mock.ANY)
|
||||
self.m_client.execute.assert_called_once_with(
|
||||
cluster_id=self.CLUSTER_ID, node_id=self.NODE_ID, node_role=None)
|
||||
cluster_id=self.CLUSTER_ID, node_id=self.NODE_ID, node_role=None,
|
||||
force=False)
|
||||
|
||||
def test_config_force_execute(self):
|
||||
cmd = 'openstack-config execute --env {0} --node {1} --force' \
|
||||
''.format(self.CLUSTER_ID, self.NODE_ID)
|
||||
self.exec_command(cmd)
|
||||
|
||||
self.m_get_client.assert_called_once_with('openstack-config', mock.ANY)
|
||||
self.m_client.execute.assert_called_once_with(
|
||||
cluster_id=self.CLUSTER_ID, node_id=self.NODE_ID, node_role=None,
|
||||
force=True)
|
||||
|
||||
Reference in New Issue
Block a user