Add option to enable or disable providers
1. Add configuration option in provider configuration file to enable or disable the provider. 2. Skip the protectable resources when get the dependent resources failed. Change-Id: Ie67fbacbebb887a76e57273c3dd36d1f333b615d Closes-Bug: #1702907
This commit is contained in:
parent
7d9f3f31b8
commit
e402bb9056
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
name = fake_provider2
|
||||
id = fake_id2
|
||||
description = Test Provider 2
|
||||
enabled = True
|
||||
|
|
Loading…
Reference in New Issue