Upgrade with graph as default instead python based

Closes-bug: 1646112
Change-Id: I37365b134e10e429f82fbbaff341ed04b31030b9
This commit is contained in:
Sergey Abramov 2016-11-29 12:24:46 +03:00
parent 678d7ea1ef
commit ed1b08b6f4
9 changed files with 63 additions and 56 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -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()

View File

@ -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.
(