diff --git a/etc/providers.d/eisoo.conf b/etc/providers.d/eisoo.conf index 1eec9b84..cf41929b 100644 --- a/etc/providers.d/eisoo.conf +++ b/etc/providers.d/eisoo.conf @@ -5,6 +5,8 @@ id=e4008868-be97-492c-be41-44e50ef2e16f bank=karbor-swift-bank-plugin +enabled=False + [swift_client] swift_auth_url=http://127.0.0.1/identity swift_user=demo diff --git a/etc/providers.d/noop.conf b/etc/providers.d/noop.conf index d639b255..79a88cb6 100644 --- a/etc/providers.d/noop.conf +++ b/etc/providers.d/noop.conf @@ -6,6 +6,8 @@ id = b766f37c-d011-4026-8228-28730d734a3f plugin=karbor-noop-protection-plugin bank=karbor-swift-bank-plugin +enabled=True + [swift_client] swift_auth_url=http://127.0.0.1/identity swift_user=demo diff --git a/etc/providers.d/openstack-fs-bank.conf b/etc/providers.d/openstack-fs-bank.conf index 354dcccf..7bd375cd 100644 --- a/etc/providers.d/openstack-fs-bank.conf +++ b/etc/providers.d/openstack-fs-bank.conf @@ -8,5 +8,7 @@ plugin=karbor-image-protection-plugin plugin=karbor-server-protection-plugin bank=karbor-fs-bank-plugin +enabled=True + [file_system_bank_plugin] file_system_bank_path=/opt/stack/karbor_fs_bank diff --git a/etc/providers.d/openstack-infra-volume-snapshot.conf b/etc/providers.d/openstack-infra-volume-snapshot.conf index 758d8c7f..d942c288 100644 --- a/etc/providers.d/openstack-infra-volume-snapshot.conf +++ b/etc/providers.d/openstack-infra-volume-snapshot.conf @@ -6,6 +6,8 @@ id = 90d5bfea-a259-41e6-80c6-dcfcfcd9d827 plugin=karbor-volume-snapshot-plugin bank=karbor-swift-bank-plugin +enabled=True + [swift_client] swift_auth_url=http://127.0.0.1/identity swift_user=demo diff --git a/etc/providers.d/openstack-infra.conf b/etc/providers.d/openstack-infra.conf index 2bed4353..c62e36e5 100644 --- a/etc/providers.d/openstack-infra.conf +++ b/etc/providers.d/openstack-infra.conf @@ -10,6 +10,8 @@ plugin=karbor-share-protection-plugin plugin=karbor-network-protection-plugin bank=karbor-swift-bank-plugin +enabled=True + [swift_client] swift_auth_url=http://127.0.0.1/identity swift_user=demo diff --git a/karbor/services/protection/protectable_registry.py b/karbor/services/protection/protectable_registry.py index a21e719e..5e4bd594 100644 --- a/karbor/services/protection/protectable_registry.py +++ b/karbor/services/protection/protectable_registry.py @@ -11,12 +11,16 @@ # under the License. from karbor import exception +from karbor.exception import ListProtectableResourceFailed from karbor.i18n import _ from karbor.services.protection.graph import build_graph import six +from oslo_log import log as logging from stevedore import extension +LOG = logging.getLogger(__name__) + class ProtectablePluginLoadFailed(exception.KarborException): message = _("Could not load %(name)s: %(error)s") @@ -101,8 +105,14 @@ class ProtectableRegistry(object): protectable = self._get_protectable( context, plugin.get_resource_type()) - result.extend(protectable.get_dependent_resources(context, - resource)) + try: + protectable_resources = \ + protectable.get_dependent_resources(context, resource) + except ListProtectableResourceFailed as e: + LOG.error("List resources failed, so skip it. " + "Error: {0}".format(e)) + protectable_resources = [] + result.extend(protectable_resources) return result diff --git a/karbor/services/protection/provider.py b/karbor/services/protection/provider.py index 77eddefd..48e9a950 100644 --- a/karbor/services/protection/provider.py +++ b/karbor/services/protection/provider.py @@ -35,7 +35,10 @@ provider_opts = [ help='the name of provider'), cfg.StrOpt('id', default='', - help='the provider id') + help='the provider id'), + cfg.BoolOpt('enabled', + default=False, + help='enabled or not'), ] CONF = cfg.CONF @@ -172,6 +175,14 @@ class ProviderRegistry(object): provider_config = cfg.ConfigOpts() provider_config(args=['--config-file=' + config_path]) provider_config.register_opts(provider_opts, 'provider') + + provider_enabled = provider_config.provider.enabled + if not provider_enabled: + LOG.info('Provider {0} is not enabled'.format( + provider_config.provider.name) + ) + continue + try: provider = PluggableProtectionProvider(provider_config) except Exception as e: diff --git a/karbor/tests/unit/fake_providers/fake_provider1.conf b/karbor/tests/unit/fake_providers/fake_provider1.conf index be127140..4825d8ce 100644 --- a/karbor/tests/unit/fake_providers/fake_provider1.conf +++ b/karbor/tests/unit/fake_providers/fake_provider1.conf @@ -4,6 +4,7 @@ id = fake_id1 description = Test Provider 1 bank = karbor.tests.unit.fake_bank.FakeBankPlugin plugin = karbor.tests.unit.protection.fakes.FakeProtectionPlugin +enabled = True [fake_plugin] fake_user = user diff --git a/karbor/tests/unit/fake_providers/fake_provider2.conf b/karbor/tests/unit/fake_providers/fake_provider2.conf index 273ba599..9fe502de 100644 --- a/karbor/tests/unit/fake_providers/fake_provider2.conf +++ b/karbor/tests/unit/fake_providers/fake_provider2.conf @@ -2,3 +2,4 @@ name = fake_provider2 id = fake_id2 description = Test Provider 2 +enabled = True