Browse Source

Remove nova storage aggregates

Remove the automated creation of storage host aggregates and host
population in inventory.

Story: 2004607
Task: 29068
Change-Id: I4a74a1ee1f8b3bc8dc6293a5c971d9c7ed1442b5
Signed-off-by: Jack Ding <jack.ding@windriver.com>
Jack Ding 3 months ago
parent
commit
9ececd7623

+ 0
- 15
inventory/inventory/inventory/common/k_host_agg.py View File

@@ -1,15 +0,0 @@
1
-#
2
-# Copyright (c) 2018 Wind River Systems, Inc.
3
-#
4
-# SPDX-License-Identifier: Apache-2.0
5
-#
6
-
7
-# Host Aggregate Constants
8
-
9
-# Storage: Host Aggregates Groups
10
-HOST_AGG_NAME_REMOTE = 'remote_storage_hosts'
11
-HOST_AGG_META_REMOTE = 'remote'
12
-HOST_AGG_NAME_LOCAL_LVM = 'local_storage_lvm_hosts'
13
-HOST_AGG_META_LOCAL_LVM = 'local_lvm'
14
-HOST_AGG_NAME_LOCAL_IMAGE = 'local_storage_image_hosts'
15
-HOST_AGG_META_LOCAL_IMAGE = 'local_image'

+ 8
- 171
inventory/inventory/inventory/conductor/openstack.py View File

@@ -15,8 +15,6 @@ from cinderclient.v2 import client as cinder_client_v2
15 15
 from inventory.common import constants
16 16
 from inventory.common import exception
17 17
 from inventory.common.i18n import _
18
-from inventory.common import k_host
19
-from inventory.common import k_host_agg
20 18
 from inventory.common.storage_backend_conf import StorageBackendConfig
21 19
 from keystoneclient.auth.identity import v3
22 20
 from keystoneclient import exceptions as identity_exc
@@ -24,7 +22,6 @@ from keystoneclient import session
24 22
 from keystoneclient.v3 import client as keystone_client
25 23
 from neutronclient.v2_0 import client as neutron_client_v2_0
26 24
 from novaclient.v2 import client as nova_client_v2
27
-from oslo_concurrency import lockutils
28 25
 from oslo_config import cfg
29 26
 from oslo_log import log
30 27
 from sqlalchemy.orm import exc
@@ -259,158 +256,6 @@ class OpenStackOperator(object):
259 256
 
260 257
         return interfaces
261 258
 
262
-    @lockutils.synchronized('update_nova_local_aggregates', 'inventory-')
263
-    def update_nova_local_aggregates(self, ihost_uuid, aggregates=None):
264
-        """
265
-        Update nova_local aggregates for a host
266
-        """
267
-        availability_zone = None
268
-
269
-        if not aggregates:
270
-            try:
271
-                aggregates = self._get_novaclient().aggregates.list()
272
-            except Exception:
273
-                self.nova_client = None  # password may have updated
274
-                aggregates = self._get_novaclient().aggregates.list()
275
-
276
-        nova_aggset_provider = set()
277
-        for aggregate in aggregates:
278
-            nova_aggset_provider.add(aggregate.name)
279
-
280
-        aggset_storage = set([
281
-            k_host_agg.HOST_AGG_NAME_LOCAL_LVM,
282
-            k_host_agg.HOST_AGG_NAME_LOCAL_IMAGE,
283
-            k_host_agg.HOST_AGG_NAME_REMOTE])
284
-        agglist_missing = list(aggset_storage - nova_aggset_provider)
285
-        LOG.debug("AGG Storage agglist_missing = %s." % agglist_missing)
286
-
287
-        # Only add the ones that don't exist
288
-        for agg_name in agglist_missing:
289
-            # Create the aggregate
290
-            try:
291
-                aggregate = self._get_novaclient().aggregates.create(
292
-                    agg_name, availability_zone)
293
-                LOG.info("AGG-AS Storage aggregate= %s created. " % (
294
-                    aggregate))
295
-            except Exception:
296
-                LOG.error("AGG-AS EXCEPTION Storage aggregate "
297
-                          "agg_name=%s not created" % (agg_name))
298
-                raise
299
-
300
-            # Add the metadata
301
-            try:
302
-                if agg_name == k_host_agg.HOST_AGG_NAME_LOCAL_LVM:
303
-                    metadata = {'storage': k_host_agg.HOST_AGG_META_LOCAL_LVM}
304
-                elif agg_name == k_host_agg.HOST_AGG_NAME_LOCAL_IMAGE:
305
-                    metadata = \
306
-                        {'storage': k_host_agg.HOST_AGG_META_LOCAL_IMAGE}
307
-                else:
308
-                    metadata = {'storage': k_host_agg.HOST_AGG_META_REMOTE}
309
-                LOG.debug("AGG-AS storage aggregate metadata = %s." % metadata)
310
-                aggregate = self._get_novaclient().aggregates.set_metadata(
311
-                    aggregate.id, metadata)
312
-            except Exception:
313
-                LOG.error("AGG-AS EXCEPTION Storage aggregate "
314
-                          "=%s metadata not added" % aggregate)
315
-                raise
316
-
317
-        # refresh the aggregate list
318
-        try:
319
-            aggregates = dict([(agg.name, agg) for agg in
320
-                               self._get_novaclient().aggregates.list()])
321
-        except Exception:
322
-            self.nova_client = None  # password may have updated
323
-            aggregates = dict([(agg.name, agg) for agg in
324
-                               self._get_novaclient().aggregates.list()])
325
-
326
-        # Add the host to the local or remote aggregate group
327
-        # determine if this host is configured for local storage
328
-        host_has_lvg = False
329
-        lvg_backing = False
330
-        try:
331
-            ilvgs = self.dbapi.ilvg_get_by_ihost(ihost_uuid)
332
-            for lvg in ilvgs:
333
-                if lvg.lvm_vg_name == constants.LVG_NOVA_LOCAL and \
334
-                   lvg.vg_state == k_host.PROVISIONED:
335
-                    host_has_lvg = True
336
-                    lvg_backing = lvg.capabilities.get(
337
-                        constants.LVG_NOVA_PARAM_BACKING)
338
-                    break
339
-                else:
340
-                    LOG.debug("AGG-AS Found LVG %s with state %s "
341
-                              "for host %s." % (
342
-                                  lvg.lvm_vg_name,
343
-                                  lvg.vg_state,
344
-                                  ihost_uuid))
345
-        except Exception:
346
-            LOG.error("AGG-AS ilvg_get_by_ihost failed "
347
-                      "for %s." % ihost_uuid)
348
-            raise
349
-
350
-        LOG.debug("AGG-AS ihost (%s) %s in a local storage configuration." %
351
-                  (ihost_uuid,
352
-                   "is not"
353
-                   if (lvg_backing == constants.LVG_NOVA_BACKING_REMOTE) else
354
-                   "is"))
355
-
356
-        # Select the appropriate aggregate id based on the presence of an LVG
357
-        #
358
-        agg_add_to = ""
359
-        if host_has_lvg:
360
-            agg_add_to = {
361
-                constants.LVG_NOVA_BACKING_IMAGE:
362
-                k_host_agg.HOST_AGG_NAME_LOCAL_IMAGE,
363
-                constants.LVG_NOVA_BACKING_LVM:
364
-                k_host_agg.HOST_AGG_NAME_LOCAL_LVM,
365
-                constants.LVG_NOVA_BACKING_REMOTE:
366
-                k_host_agg.HOST_AGG_NAME_REMOTE
367
-            }.get(lvg_backing)
368
-
369
-        if not agg_add_to:
370
-            LOG.error("The nova-local LVG for host: %s has an invalid "
371
-                      "instance backing: " % (ihost_uuid, agg_add_to))
372
-
373
-        ihost = self.dbapi.ihost_get(ihost_uuid)
374
-        for aggregate in aggregates.values():
375
-            if aggregate.name not in aggset_storage \
376
-               or aggregate.name == agg_add_to:
377
-                continue
378
-            if hasattr(aggregate, 'hosts') \
379
-               and ihost.hostname in aggregate.hosts:
380
-                try:
381
-                    self._get_novaclient().aggregates.remove_host(
382
-                        aggregate.id,
383
-                        ihost.hostname)
384
-                    LOG.info("AGG-AS remove ihost = %s from aggregate = %s." %
385
-                             (ihost.hostname, aggregate.name))
386
-                except Exception:
387
-                    LOG.error(("AGG-AS EXCEPTION remove ihost= %s "
388
-                               "from aggregate = %s.") % (
389
-                                   ihost.hostname,
390
-                                   aggregate.name))
391
-                    raise
392
-            else:
393
-                LOG.info("skip removing host=%s not in storage "
394
-                         "aggregate id=%s" % (
395
-                             ihost.hostname,
396
-                             aggregate))
397
-        if hasattr(aggregates[agg_add_to], 'hosts') \
398
-           and ihost.hostname in aggregates[agg_add_to].hosts:
399
-            LOG.info(("skip adding host=%s already in storage "
400
-                      "aggregate id=%s") % (
401
-                          ihost.hostname,
402
-                          agg_add_to))
403
-        else:
404
-            try:
405
-                self._get_novaclient().aggregates.add_host(
406
-                    aggregates[agg_add_to].id, ihost.hostname)
407
-                LOG.info("AGG-AS add ihost = %s to aggregate = %s." % (
408
-                    ihost.hostname, agg_add_to))
409
-            except Exception:
410
-                LOG.error("AGG-AS EXCEPTION add ihost= %s to aggregate = %s." %
411
-                          (ihost.hostname, agg_add_to))
412
-                raise
413
-
414 259
     def nova_host_available(self, ihost_uuid):
415 260
         """
416 261
         Perform inventory driven nova operations for an available ihost
@@ -623,12 +468,6 @@ class OpenStackOperator(object):
623 468
         else:
624 469
             LOG.debug("AGG ihost_providernets empty %s." % ihost_uuid)
625 470
 
626
-        # setup the valid set of storage aggregates for host removal
627
-        aggset_storage = set([
628
-            k_host_agg.HOST_AGG_NAME_LOCAL_LVM,
629
-            k_host_agg.HOST_AGG_NAME_LOCAL_IMAGE,
630
-            k_host_agg.HOST_AGG_NAME_REMOTE])
631
-
632 471
         # Remove aggregates from provider network. Anything with host in list.
633 472
         # 4. nova aggregate-remove-host provider_physnet0 compute-0
634 473
         #    cs.aggregates.remove_host(aggregate.id, args.host)
@@ -636,16 +475,14 @@ class OpenStackOperator(object):
636 475
         ihost = self.dbapi.ihost_get(ihost_uuid)
637 476
 
638 477
         for aggregate in aggregates:
639
-            if aggregate.name in ihost_providernets or \
640
-               aggregate.name in aggset_storage:  # or just do it for all aggs
641
-                try:
642
-                    LOG.debug("AGG10 remove aggregate id = %s ihost= %s." %
643
-                              (aggregate.id, ihost.hostname))
644
-                    self._get_novaclient().aggregates.remove_host(
645
-                        aggregate.id, ihost.hostname)
646
-                except Exception:
647
-                    LOG.debug("AGG10 EXCEPTION remove aggregate")
648
-                    pass
478
+            try:
479
+                LOG.debug("AGG10 remove aggregate id = %s ihost= %s." %
480
+                          (aggregate.id, ihost.hostname))
481
+                self._get_novaclient().aggregates.remove_host(
482
+                    aggregate.id, ihost.hostname)
483
+            except Exception:
484
+                LOG.debug("AGG10 EXCEPTION remove aggregate")
485
+                pass
649 486
 
650 487
         return True
651 488
 

Loading…
Cancel
Save