diff --git a/octane/commands/osd_upgrade.py b/octane/commands/osd_upgrade.py index b581acb2..641828ed 100644 --- a/octane/commands/osd_upgrade.py +++ b/octane/commands/osd_upgrade.py @@ -262,27 +262,32 @@ class UpgradeOSDCommand(cmd.Command): type=int, metavar='SEED_ENV_ID', help="ID of seed environment") - parser.add_argument( + group = parser.add_argument_group() + group.add_argument( "--admin-password", type=str, action="store", dest="admin_password", - required=True, - help="Fuel admin password") - parser.add_argument( - '--with-graph', action='store_true', - help='EXPERIMENTAL: Use Fuel deployment graphs' - ' instead of python-based commands.') + help="Fuel admin password", + required=False) + group.add_argument( + '--without-graph', action='store_true', + help='Use python-based commands' + ' instead of Fuel deployment graphs.', + required=False) return parser def take_action(self, parsed_args): - if parsed_args.with_graph: - upgrade_osd_with_graph( - parsed_args.orig_env_id, - parsed_args.seed_env_id) - else: + if (bool(parsed_args.admin_password) != parsed_args.without_graph): + raise AssertionError( + 'Admin password required only for not graph upgrade') + if parsed_args.without_graph: upgrade_osd( parsed_args.orig_env_id, parsed_args.seed_env_id, 'admin', parsed_args.admin_password) + else: + upgrade_osd_with_graph( + parsed_args.orig_env_id, + parsed_args.seed_env_id) diff --git a/octane/commands/preupgrade_compute.py b/octane/commands/preupgrade_compute.py index ba09180e..848d1c63 100644 --- a/octane/commands/preupgrade_compute.py +++ b/octane/commands/preupgrade_compute.py @@ -154,14 +154,14 @@ class PreupgradeComputeCommand(cmd.Command): help="IDs of compute nodes to be preupgraded", nargs="+") parser.add_argument( - '--with-graph', action='store_true', - help='EXPERIMENTAL: Use Fuel deployment graphs' - ' instead of python-based commands.') + '--without-graph', action='store_true', + help='Use python-based commands' + ' instead of Fuel deployment graphs.') return parser def take_action(self, parsed_args): - if parsed_args.with_graph: + if parsed_args.without_graph: + preupgrade_compute(parsed_args.release_id, parsed_args.node_ids) + else: preupgrade_compute_with_graph(parsed_args.release_id, parsed_args.node_ids) - else: - preupgrade_compute(parsed_args.release_id, parsed_args.node_ids) diff --git a/octane/commands/upgrade_ceph.py b/octane/commands/upgrade_ceph.py index 95b3f735..eaab14ac 100644 --- a/octane/commands/upgrade_ceph.py +++ b/octane/commands/upgrade_ceph.py @@ -191,13 +191,13 @@ class UpgradeCephCommand(cmd.Command): 'seed_id', type=int, metavar='SEED_ID', help="ID of seed environment") parser.add_argument( - '--with-graph', action='store_true', - help='EXPERIMENTAL: Use Fuel deployment graphs' - ' instead of python-based commands.') + '--without-graph', action='store_true', + help='Use Fuel python-based commands' + ' instead of deployment graphs.') return parser def take_action(self, parsed_args): - if parsed_args.with_graph: - upgrade_ceph_with_graph(parsed_args.orig_id, parsed_args.seed_id) - else: + if parsed_args.without_graph: upgrade_ceph(parsed_args.orig_id, parsed_args.seed_id) + else: + upgrade_ceph_with_graph(parsed_args.orig_id, parsed_args.seed_id) diff --git a/octane/commands/upgrade_controlplane.py b/octane/commands/upgrade_controlplane.py index d3bca738..bd3c4e1b 100644 --- a/octane/commands/upgrade_controlplane.py +++ b/octane/commands/upgrade_controlplane.py @@ -139,15 +139,15 @@ class UpgradeControlPlaneCommand(cmd.Command): 'seed_id', type=int, metavar='SEED_ID', help="ID of seed environment") parser.add_argument( - '--with-graph', action='store_true', - help='EXPERIMENTAL: Use Fuel deployment graphs' - ' instead of python-based commands.') + '--without-graph', action='store_true', + help='Use python-based commands' + ' instead of Fuel deployment graphs.') return parser def take_action(self, parsed_args): - if parsed_args.with_graph: + if parsed_args.without_graph: + upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id) + else: upgrade_control_plane_with_graph( parsed_args.orig_id, parsed_args.seed_id) - else: - upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id) diff --git a/octane/commands/upgrade_db.py b/octane/commands/upgrade_db.py index 8c131e68..ac17de9d 100644 --- a/octane/commands/upgrade_db.py +++ b/octane/commands/upgrade_db.py @@ -117,22 +117,21 @@ class UpgradeDBCommand(cmd.Command): 'seed_id', type=int, metavar='SEED_ID', help="ID of seed environment") - group = parser.add_mutually_exclusive_group() + group = parser.add_argument_group() group.add_argument( '--db_role_name', type=str, metavar='DB_ROLE_NAME', default="controller", help="Set not standard role name for DB " "(default controller).") group.add_argument( - '--with-graph', action='store_true', - help="EXPERIMENTAL: Use Fuel deployment graphs" - " instead of python-based commands.") + '--without-graph', action='store_true', + help="Use python-based commands" + " instead of Fuel deployment graphs.") return parser def take_action(self, parsed_args): - # Execute alternative approach if requested - if parsed_args.with_graph: - upgrade_db_with_graph(parsed_args.orig_id, parsed_args.seed_id) - else: + if parsed_args.without_graph: upgrade_db(parsed_args.orig_id, parsed_args.seed_id, parsed_args.db_role_name) + else: + upgrade_db_with_graph(parsed_args.orig_id, parsed_args.seed_id) diff --git a/octane/tests/test_osd_upgrade.py b/octane/tests/test_osd_upgrade.py index e658805d..85b37b4e 100644 --- a/octane/tests/test_osd_upgrade.py +++ b/octane/tests/test_osd_upgrade.py @@ -22,9 +22,13 @@ from octane.util import ssh @pytest.mark.parametrize("orig_env_id", [None, 1]) @pytest.mark.parametrize("seed_env_id", [None, 2]) @pytest.mark.parametrize("admin_pswd", [None, "pswd"]) -def test_osd_cmd_upgrade( - mocker, octane_app, orig_env_id, seed_env_id, admin_pswd): - upgrade_osd_mock = mocker.patch("octane.commands.osd_upgrade.upgrade_osd") +@pytest.mark.parametrize("without_graph", [True, False]) +def test_osd_cmd_upgrade(mocker, octane_app, orig_env_id, seed_env_id, + admin_pswd, without_graph): + upgrade_osd_mock = mocker.patch( + "octane.commands.osd_upgrade.upgrade_osd_with_graph") + upgrade_osd_mock_without_graph = mocker.patch( + "octane.commands.osd_upgrade.upgrade_osd") params = ["upgrade-osd"] if admin_pswd: params += ["--admin-password", admin_pswd] @@ -32,10 +36,15 @@ def test_osd_cmd_upgrade( params += [str(orig_env_id)] if seed_env_id: params += [str(seed_env_id)] - if orig_env_id and seed_env_id and admin_pswd: + if without_graph: + params += ['--without-graph'] + if orig_env_id and seed_env_id and (bool(admin_pswd) == without_graph): octane_app.run(params) - upgrade_osd_mock.assert_called_once_with( - orig_env_id, seed_env_id, "admin", admin_pswd) + if without_graph: + upgrade_osd_mock_without_graph.assert_called_once_with( + orig_env_id, seed_env_id, "admin", admin_pswd) + else: + upgrade_osd_mock.assert_called_once_with(orig_env_id, seed_env_id) return with pytest.raises(AssertionError): octane_app.run(params) diff --git a/octane/tests/test_preupgrade_compute.py b/octane/tests/test_preupgrade_compute.py index 3168175a..f60de97a 100644 --- a/octane/tests/test_preupgrade_compute.py +++ b/octane/tests/test_preupgrade_compute.py @@ -22,7 +22,8 @@ from octane import magic_consts (["preupgrade-compute", "1", "1"], 1, [1]), ]) def test_parser(mocker, octane_app, cmd, release_id, node_ids): - m = mocker.patch("octane.commands.preupgrade_compute.preupgrade_compute") + m = mocker.patch( + "octane.commands.preupgrade_compute.preupgrade_compute_with_graph") octane_app.run(cmd) assert not octane_app.stdout.getvalue() assert not octane_app.stderr.getvalue() diff --git a/octane/tests/test_upgrade_ceph.py b/octane/tests/test_upgrade_ceph.py index 9d67fe5c..dafb024d 100644 --- a/octane/tests/test_upgrade_ceph.py +++ b/octane/tests/test_upgrade_ceph.py @@ -18,7 +18,7 @@ from octane.handlers.upgrade import ceph_osd def test_parser(mocker, octane_app): - m = mocker.patch('octane.commands.upgrade_ceph.upgrade_ceph') + m = mocker.patch('octane.commands.upgrade_ceph.upgrade_ceph_with_graph') octane_app.run(["upgrade-ceph", "1", "2"]) assert not octane_app.stdout.getvalue() assert not octane_app.stderr.getvalue() diff --git a/octane/tests/test_upgrade_db.py b/octane/tests/test_upgrade_db.py index bb4dd775..0d9b302b 100644 --- a/octane/tests/test_upgrade_db.py +++ b/octane/tests/test_upgrade_db.py @@ -18,7 +18,8 @@ from octane.commands import upgrade_db def test_parser(mocker, octane_app): m = mocker.patch('octane.commands.upgrade_db.upgrade_db') - octane_app.run(["upgrade-db", "1", "2", "--db_role_name", "3"]) + octane_app.run([ + "upgrade-db", "--without-graph", "1", "2", "--db_role_name", "3"]) assert not octane_app.stdout.getvalue() assert not octane_app.stderr.getvalue() m.assert_called_once_with(1, 2, '3') @@ -26,20 +27,12 @@ def test_parser(mocker, octane_app): def test_parser_with_graph(mocker, octane_app): m = mocker.patch("octane.commands.upgrade_db.upgrade_db_with_graph") - octane_app.run(["upgrade-db", "--with-graph", "1", "2"]) + octane_app.run(["upgrade-db", "1", "2"]) assert not octane_app.stdout.getvalue() assert not octane_app.stderr.getvalue() m.assert_called_once_with(1, 2) -def test_parser_exclusive_group(mocker, octane_app): - mocker.patch("octane.commands.upgrade_db.upgrade_db") - mocker.patch("octane.commands.upgrade_db.upgrade_db_with_graph") - with pytest.raises(AssertionError): - octane_app.run(["upgrade-db", "--with-graph", "--db_role_name", "db", - "1", "2"]) - - @pytest.mark.parametrize(("calls", "graph_names", "catch"), [ # Orig is fine, seed is fine and there is no need to rollback. (