Browse Source

Upgrade with graph as default instead python based

Closes-bug: 1646112
Change-Id: I37365b134e10e429f82fbbaff341ed04b31030b9
stable/newton
Sergey Abramov 2 years ago
parent
commit
ed1b08b6f4

+ 17
- 12
octane/commands/osd_upgrade.py View File

@@ -262,27 +262,32 @@ class UpgradeOSDCommand(cmd.Command):
262 262
             type=int,
263 263
             metavar='SEED_ENV_ID',
264 264
             help="ID of seed environment")
265
-        parser.add_argument(
265
+        group = parser.add_argument_group()
266
+        group.add_argument(
266 267
             "--admin-password",
267 268
             type=str,
268 269
             action="store",
269 270
             dest="admin_password",
270
-            required=True,
271
-            help="Fuel admin password")
272
-        parser.add_argument(
273
-            '--with-graph', action='store_true',
274
-            help='EXPERIMENTAL: Use Fuel deployment graphs'
275
-                 ' instead of python-based commands.')
271
+            help="Fuel admin password",
272
+            required=False)
273
+        group.add_argument(
274
+            '--without-graph', action='store_true',
275
+            help='Use python-based commands'
276
+                 ' instead of Fuel deployment graphs.',
277
+            required=False)
276 278
         return parser
277 279
 
278 280
     def take_action(self, parsed_args):
279
-        if parsed_args.with_graph:
280
-            upgrade_osd_with_graph(
281
-                parsed_args.orig_env_id,
282
-                parsed_args.seed_env_id)
283
-        else:
281
+        if (bool(parsed_args.admin_password) != parsed_args.without_graph):
282
+            raise AssertionError(
283
+                'Admin password required only for not graph upgrade')
284
+        if parsed_args.without_graph:
284 285
             upgrade_osd(
285 286
                 parsed_args.orig_env_id,
286 287
                 parsed_args.seed_env_id,
287 288
                 'admin',
288 289
                 parsed_args.admin_password)
290
+        else:
291
+            upgrade_osd_with_graph(
292
+                parsed_args.orig_env_id,
293
+                parsed_args.seed_env_id)

+ 6
- 6
octane/commands/preupgrade_compute.py View File

@@ -154,14 +154,14 @@ class PreupgradeComputeCommand(cmd.Command):
154 154
             help="IDs of compute nodes to be preupgraded",
155 155
             nargs="+")
156 156
         parser.add_argument(
157
-            '--with-graph', action='store_true',
158
-            help='EXPERIMENTAL: Use Fuel deployment graphs'
159
-                 ' instead of python-based commands.')
157
+            '--without-graph', action='store_true',
158
+            help='Use python-based commands'
159
+                 ' instead of Fuel deployment graphs.')
160 160
         return parser
161 161
 
162 162
     def take_action(self, parsed_args):
163
-        if parsed_args.with_graph:
163
+        if parsed_args.without_graph:
164
+            preupgrade_compute(parsed_args.release_id, parsed_args.node_ids)
165
+        else:
164 166
             preupgrade_compute_with_graph(parsed_args.release_id,
165 167
                                           parsed_args.node_ids)
166
-        else:
167
-            preupgrade_compute(parsed_args.release_id, parsed_args.node_ids)

+ 6
- 6
octane/commands/upgrade_ceph.py View File

@@ -191,13 +191,13 @@ class UpgradeCephCommand(cmd.Command):
191 191
             'seed_id', type=int, metavar='SEED_ID',
192 192
             help="ID of seed environment")
193 193
         parser.add_argument(
194
-            '--with-graph', action='store_true',
195
-            help='EXPERIMENTAL: Use Fuel deployment graphs'
196
-                 ' instead of python-based commands.')
194
+            '--without-graph', action='store_true',
195
+            help='Use Fuel python-based commands'
196
+                 ' instead of deployment graphs.')
197 197
         return parser
198 198
 
199 199
     def take_action(self, parsed_args):
200
-        if parsed_args.with_graph:
201
-            upgrade_ceph_with_graph(parsed_args.orig_id, parsed_args.seed_id)
202
-        else:
200
+        if parsed_args.without_graph:
203 201
             upgrade_ceph(parsed_args.orig_id, parsed_args.seed_id)
202
+        else:
203
+            upgrade_ceph_with_graph(parsed_args.orig_id, parsed_args.seed_id)

+ 6
- 6
octane/commands/upgrade_controlplane.py View File

@@ -139,15 +139,15 @@ class UpgradeControlPlaneCommand(cmd.Command):
139 139
             'seed_id', type=int, metavar='SEED_ID',
140 140
             help="ID of seed environment")
141 141
         parser.add_argument(
142
-            '--with-graph', action='store_true',
143
-            help='EXPERIMENTAL: Use Fuel deployment graphs'
144
-                 ' instead of python-based commands.')
142
+            '--without-graph', action='store_true',
143
+            help='Use python-based commands'
144
+                 ' instead of Fuel deployment graphs.')
145 145
         return parser
146 146
 
147 147
     def take_action(self, parsed_args):
148
-        if parsed_args.with_graph:
148
+        if parsed_args.without_graph:
149
+            upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id)
150
+        else:
149 151
             upgrade_control_plane_with_graph(
150 152
                 parsed_args.orig_id,
151 153
                 parsed_args.seed_id)
152
-        else:
153
-            upgrade_control_plane(parsed_args.orig_id, parsed_args.seed_id)

+ 7
- 8
octane/commands/upgrade_db.py View File

@@ -117,22 +117,21 @@ class UpgradeDBCommand(cmd.Command):
117 117
             'seed_id', type=int, metavar='SEED_ID',
118 118
             help="ID of seed environment")
119 119
 
120
-        group = parser.add_mutually_exclusive_group()
120
+        group = parser.add_argument_group()
121 121
         group.add_argument(
122 122
             '--db_role_name', type=str, metavar='DB_ROLE_NAME',
123 123
             default="controller", help="Set not standard role name for DB "
124 124
                                        "(default controller).")
125 125
         group.add_argument(
126
-            '--with-graph', action='store_true',
127
-            help="EXPERIMENTAL: Use Fuel deployment graphs"
128
-                 " instead of python-based commands.")
126
+            '--without-graph', action='store_true',
127
+            help="Use python-based commands"
128
+                 " instead of Fuel deployment graphs.")
129 129
 
130 130
         return parser
131 131
 
132 132
     def take_action(self, parsed_args):
133
-        # Execute alternative approach if requested
134
-        if parsed_args.with_graph:
135
-            upgrade_db_with_graph(parsed_args.orig_id, parsed_args.seed_id)
136
-        else:
133
+        if parsed_args.without_graph:
137 134
             upgrade_db(parsed_args.orig_id, parsed_args.seed_id,
138 135
                        parsed_args.db_role_name)
136
+        else:
137
+            upgrade_db_with_graph(parsed_args.orig_id, parsed_args.seed_id)

+ 15
- 6
octane/tests/test_osd_upgrade.py View File

@@ -22,9 +22,13 @@ from octane.util import ssh
22 22
 @pytest.mark.parametrize("orig_env_id", [None, 1])
23 23
 @pytest.mark.parametrize("seed_env_id", [None, 2])
24 24
 @pytest.mark.parametrize("admin_pswd", [None, "pswd"])
25
-def test_osd_cmd_upgrade(
26
-        mocker, octane_app, orig_env_id, seed_env_id, admin_pswd):
27
-    upgrade_osd_mock = mocker.patch("octane.commands.osd_upgrade.upgrade_osd")
25
+@pytest.mark.parametrize("without_graph", [True, False])
26
+def test_osd_cmd_upgrade(mocker, octane_app, orig_env_id, seed_env_id,
27
+                         admin_pswd, without_graph):
28
+    upgrade_osd_mock = mocker.patch(
29
+        "octane.commands.osd_upgrade.upgrade_osd_with_graph")
30
+    upgrade_osd_mock_without_graph = mocker.patch(
31
+        "octane.commands.osd_upgrade.upgrade_osd")
28 32
     params = ["upgrade-osd"]
29 33
     if admin_pswd:
30 34
         params += ["--admin-password", admin_pswd]
@@ -32,10 +36,15 @@ def test_osd_cmd_upgrade(
32 36
         params += [str(orig_env_id)]
33 37
     if seed_env_id:
34 38
         params += [str(seed_env_id)]
35
-    if orig_env_id and seed_env_id and admin_pswd:
39
+    if without_graph:
40
+        params += ['--without-graph']
41
+    if orig_env_id and seed_env_id and (bool(admin_pswd) == without_graph):
36 42
         octane_app.run(params)
37
-        upgrade_osd_mock.assert_called_once_with(
38
-            orig_env_id, seed_env_id, "admin", admin_pswd)
43
+        if without_graph:
44
+            upgrade_osd_mock_without_graph.assert_called_once_with(
45
+                orig_env_id, seed_env_id, "admin", admin_pswd)
46
+        else:
47
+            upgrade_osd_mock.assert_called_once_with(orig_env_id, seed_env_id)
39 48
         return
40 49
     with pytest.raises(AssertionError):
41 50
         octane_app.run(params)

+ 2
- 1
octane/tests/test_preupgrade_compute.py View File

@@ -22,7 +22,8 @@ from octane import magic_consts
22 22
     (["preupgrade-compute", "1", "1"], 1, [1]),
23 23
 ])
24 24
 def test_parser(mocker, octane_app, cmd, release_id, node_ids):
25
-    m = mocker.patch("octane.commands.preupgrade_compute.preupgrade_compute")
25
+    m = mocker.patch(
26
+        "octane.commands.preupgrade_compute.preupgrade_compute_with_graph")
26 27
     octane_app.run(cmd)
27 28
     assert not octane_app.stdout.getvalue()
28 29
     assert not octane_app.stderr.getvalue()

+ 1
- 1
octane/tests/test_upgrade_ceph.py View File

@@ -18,7 +18,7 @@ from octane.handlers.upgrade import ceph_osd
18 18
 
19 19
 
20 20
 def test_parser(mocker, octane_app):
21
-    m = mocker.patch('octane.commands.upgrade_ceph.upgrade_ceph')
21
+    m = mocker.patch('octane.commands.upgrade_ceph.upgrade_ceph_with_graph')
22 22
     octane_app.run(["upgrade-ceph", "1", "2"])
23 23
     assert not octane_app.stdout.getvalue()
24 24
     assert not octane_app.stderr.getvalue()

+ 3
- 10
octane/tests/test_upgrade_db.py View File

@@ -18,7 +18,8 @@ from octane.commands import upgrade_db
18 18
 
19 19
 def test_parser(mocker, octane_app):
20 20
     m = mocker.patch('octane.commands.upgrade_db.upgrade_db')
21
-    octane_app.run(["upgrade-db", "1", "2", "--db_role_name", "3"])
21
+    octane_app.run([
22
+        "upgrade-db", "--without-graph", "1", "2", "--db_role_name", "3"])
22 23
     assert not octane_app.stdout.getvalue()
23 24
     assert not octane_app.stderr.getvalue()
24 25
     m.assert_called_once_with(1, 2, '3')
@@ -26,20 +27,12 @@ def test_parser(mocker, octane_app):
26 27
 
27 28
 def test_parser_with_graph(mocker, octane_app):
28 29
     m = mocker.patch("octane.commands.upgrade_db.upgrade_db_with_graph")
29
-    octane_app.run(["upgrade-db", "--with-graph", "1", "2"])
30
+    octane_app.run(["upgrade-db", "1", "2"])
30 31
     assert not octane_app.stdout.getvalue()
31 32
     assert not octane_app.stderr.getvalue()
32 33
     m.assert_called_once_with(1, 2)
33 34
 
34 35
 
35
-def test_parser_exclusive_group(mocker, octane_app):
36
-    mocker.patch("octane.commands.upgrade_db.upgrade_db")
37
-    mocker.patch("octane.commands.upgrade_db.upgrade_db_with_graph")
38
-    with pytest.raises(AssertionError):
39
-        octane_app.run(["upgrade-db", "--with-graph", "--db_role_name", "db",
40
-                        "1", "2"])
41
-
42
-
43 36
 @pytest.mark.parametrize(("calls", "graph_names", "catch"), [
44 37
     # Orig is fine, seed is fine and there is no need to rollback.
45 38
     (

Loading…
Cancel
Save