Merge "Add option to enable or disable providers"

This commit is contained in:
Jenkins 2017-07-20 08:33:36 +00:00 committed by Gerrit Code Review
commit fbab1ba09b
9 changed files with 36 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -2,3 +2,4 @@
name = fake_provider2
id = fake_id2
description = Test Provider 2
enabled = True