Browse Source

Python part for osd-upgrade with graph

Change-Id: I7896e705fbb2911fe3446c59d25fd70c5d808c7a
changes/63/383663/10
Dmitry Nikishov 2 years ago
parent
commit
064ed577d4
2 changed files with 51 additions and 5 deletions
  1. 47
    5
      octane/commands/osd_upgrade.py
  2. 4
    0
      octane/magic_consts.py

+ 47
- 5
octane/commands/osd_upgrade.py View File

@@ -20,10 +20,12 @@ import time
20 20
 from cliff import command as cmd
21 21
 
22 22
 from fuelclient.objects import environment as env_obj
23
+from fuelclient.objects import release as rel_obj
23 24
 
24 25
 from octane.handlers import backup_restore
25 26
 from octane import magic_consts
26 27
 from octane.util import apt
28
+from octane.util import deployment as deploy
27 29
 from octane.util import env
28 30
 from octane.util import fuel_client
29 31
 from octane.util import ssh
@@ -183,6 +185,17 @@ def get_repos_for_upgrade(orig_env, seed_env):
183 185
     return results
184 186
 
185 187
 
188
+def add_upgrade_attrs_to_settings(env, repos, ceph_rel, hosts):
189
+    attrs = env.get_settings_data()
190
+    attrs['editable']['repo_setup']['upgrade_osd'] = {'value': repos,
191
+                                                      'type': 'hidden'}
192
+    attrs['editable']['common']['ceph_upgrade_release'] = {'value': ceph_rel,
193
+                                                           'type': 'hidden'}
194
+    attrs['editable']['common']['ceph_upgrade_hostnames'] = {'value': hosts,
195
+                                                             'type': 'hidden'}
196
+    env.set_settings_data(attrs)
197
+
198
+
186 199
 def upgrade_osd(orig_env_id, seed_env_id, user, password):
187 200
     with fuel_client.set_auth_context(
188 201
             backup_restore.NailgunCredentialsContext(user, password)):
@@ -214,6 +227,26 @@ def upgrade_osd(orig_env_id, seed_env_id, user, password):
214 227
         raise Exception(msg)
215 228
 
216 229
 
230
+def upgrade_osd_with_graph(orig_env_id, seed_env_id):
231
+    orig_env = env_obj.Environment(orig_env_id)
232
+    seed_env = env_obj.Environment(seed_env_id)
233
+    seed_repos = get_repos_for_upgrade(orig_env, seed_env)
234
+    seed_rel = rel_obj.Release(seed_env.data['release_id'])
235
+    ceph_rel = magic_consts.CEPH_RELEASES.get(seed_rel.data['version'])
236
+    osd_nodes = list(env.get_nodes(orig_env, ["ceph-osd"]))
237
+    hostnames = [n.data['hostname'] for n in osd_nodes]
238
+
239
+    add_upgrade_attrs_to_settings(orig_env, seed_repos, ceph_rel, hostnames)
240
+    add_upgrade_attrs_to_settings(seed_env, seed_repos, ceph_rel, hostnames)
241
+
242
+    deploy.upload_graph(orig_env_id, 'orig')
243
+    deploy.upload_graph(seed_env_id, 'seed')
244
+
245
+    deploy.execute_graph_and_wait('upgrade-osd-pre', orig_env_id)
246
+    deploy.execute_graph_and_wait('upgrade-osd', seed_env_id)
247
+    deploy.execute_graph_and_wait('upgrade-osd-post', orig_env_id)
248
+
249
+
217 250
 class UpgradeOSDCommand(cmd.Command):
218 251
     """Upgrade osd servers"""
219 252
 
@@ -236,11 +269,20 @@ class UpgradeOSDCommand(cmd.Command):
236 269
             dest="admin_password",
237 270
             required=True,
238 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.')
239 276
         return parser
240 277
 
241 278
     def take_action(self, parsed_args):
242
-        upgrade_osd(
243
-            parsed_args.orig_env_id,
244
-            parsed_args.seed_env_id,
245
-            'admin',
246
-            parsed_args.admin_password)
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:
284
+            upgrade_osd(
285
+                parsed_args.orig_env_id,
286
+                parsed_args.seed_env_id,
287
+                'admin',
288
+                parsed_args.admin_password)

+ 4
- 0
octane/magic_consts.py View File

@@ -169,3 +169,7 @@ COMPUTE_PREUPGRADE_PACKAGES = {
169 169
 
170 170
 ASTUTE_YAML = "/etc/fuel/astute.yaml"
171 171
 CINDER_CONF = "/etc/cinder/cinder.conf"
172
+
173
+CEPH_RELEASES = {'kilo-7.0': 'firefly',
174
+                 'liberty-8.0': 'hammer',
175
+                 'mitaka-9.0': 'hammer'}

Loading…
Cancel
Save