From 82edb6cf3e3f36568772f1faa94388b74b29890e Mon Sep 17 00:00:00 2001 From: Narinder Gupta Date: Thu, 11 Jul 2019 15:32:04 -0500 Subject: [PATCH 1/3] lp1836108: Fixes bug where install and lint failed with unit test --- src/lib/charm/openstack/cinder_purestorage.py | 11 +++++------ src/reactive/cinder_purestorage_handlers.py | 6 +++--- tox.ini | 4 ++-- .../test_lib_charm_openstack_cinder_purestorage.py | 5 ++++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/lib/charm/openstack/cinder_purestorage.py b/src/lib/charm/openstack/cinder_purestorage.py index 6c93b96..5b6c720 100644 --- a/src/lib/charm/openstack/cinder_purestorage.py +++ b/src/lib/charm/openstack/cinder_purestorage.py @@ -1,5 +1,5 @@ import charms_openstack.charm -import charmhelpers.core.hookenv as ch_hookenv +import charmhelpers.core.hookenv as ch_hookenv # noqa charms_openstack.charm.use_defaults('charm.default-select-release') @@ -14,20 +14,19 @@ class CinderpurestorageCharm( stateless = True # Specify any config that the user *must* set. mandatory_config = [ - ('san_ip', self.config.get('san-ip')), - ('pure_api_token', self.config.get('pure-api-token')) - ] + 'san-ip', 'pure-api-token', 'protocol', 'volume-backend-name'] def cinder_configuration(self): drivers = { 'iscsi': 'cinder.volume.drivers.pure.PureISCSIDriver', 'fc': 'cinder.volume.drivers.pure.PureFCDriver', } - service = self.config.get('volume-backend-name') or service_name() + service = self.config.get('volume-backend-name') + volumedriver = drivers.get(self.config.get('protocol')) driver_options = [ ('san_ip', self.config.get('san-ip')), ('pure_api_token', self.config.get('pure-api-token')), - ('volume_driver', drivers[self.config.get('protocol').lower()]), + ('volume_driver', volumedriver), ('volume_backend_name', service)] return driver_options diff --git a/src/reactive/cinder_purestorage_handlers.py b/src/reactive/cinder_purestorage_handlers.py index 28ea684..bc62389 100644 --- a/src/reactive/cinder_purestorage_handlers.py +++ b/src/reactive/cinder_purestorage_handlers.py @@ -17,7 +17,7 @@ import charms.reactive # This charm's library contains all of the handler code associated with # this charm -- we need to import it to get the definitions for the charm. -import charm.openstack.cinder_purestorage +import charm.openstack.cinder_purestorage # noqa charms_openstack.charm.use_defaults( 'charm.installed', @@ -29,5 +29,5 @@ charms_openstack.charm.use_defaults( @charms.reactive.when('config.changed.driver-source') def reinstall(): - with charms_openstack.charm.provide_charm_instance() as charm: - charm.install() + with charms_openstack.charm.provide_charm_instance() as purestorage: + purestorage.install() diff --git a/tox.ini b/tox.ini index dffc82c..6ae35e9 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ envlist = pep8,py3 setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 TERM=linux - LAYER_PATH={toxinidir}/layers + CHARM_LAYERS_DIR={toxinidir}/layers JUJU_REPOSITORY={toxinidir}/build passenv = http_proxy https_proxy INTERFACE_PATH install_command = @@ -76,4 +76,4 @@ commands = {posargs} [flake8] # E402 ignore necessary for path append before sys module import in actions -ignore = E402 \ No newline at end of file +ignore = E402 diff --git a/unit_tests/test_lib_charm_openstack_cinder_purestorage.py b/unit_tests/test_lib_charm_openstack_cinder_purestorage.py index 9cbe919..680286e 100644 --- a/unit_tests/test_lib_charm_openstack_cinder_purestorage.py +++ b/unit_tests/test_lib_charm_openstack_cinder_purestorage.py @@ -46,4 +46,7 @@ class TestCinderpurestorageCharm(test_utils.PatchHelper): charm = self._patch_config_and_charm({'a': 'b'}) config = charm.cinder_configuration() # Add check here that configuration is as expected. - # self.assertEqual(config, {}) + self.assertEqual(config, [('san_ip', None), + ('pure_api_token', None), + ('volume_driver', None), + ('volume_backend_name', None)]) From 4e529644dbdeb97e8ec9102886c1ff1fb82ff981 Mon Sep 17 00:00:00 2001 From: Narinder Gupta Date: Thu, 11 Jul 2019 16:30:23 -0500 Subject: [PATCH 2/3] lp1836108: Removed noqa from the list --- src/lib/charm/openstack/cinder_purestorage.py | 1 - src/reactive/cinder_purestorage_handlers.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/charm/openstack/cinder_purestorage.py b/src/lib/charm/openstack/cinder_purestorage.py index 5b6c720..0f876e3 100644 --- a/src/lib/charm/openstack/cinder_purestorage.py +++ b/src/lib/charm/openstack/cinder_purestorage.py @@ -1,5 +1,4 @@ import charms_openstack.charm -import charmhelpers.core.hookenv as ch_hookenv # noqa charms_openstack.charm.use_defaults('charm.default-select-release') diff --git a/src/reactive/cinder_purestorage_handlers.py b/src/reactive/cinder_purestorage_handlers.py index bc62389..967c684 100644 --- a/src/reactive/cinder_purestorage_handlers.py +++ b/src/reactive/cinder_purestorage_handlers.py @@ -16,8 +16,10 @@ import charms_openstack.charm import charms.reactive # This charm's library contains all of the handler code associated with -# this charm -- we need to import it to get the definitions for the charm. -import charm.openstack.cinder_purestorage # noqa +# this charm -- we will use the auto-discovery feature of charms.openstack +# to get the definitions for the charm. +import charms_openstack.bus +charms_openstack.bus.discover() charms_openstack.charm.use_defaults( 'charm.installed', From 2ae76b658553574435c2128f5071905e7852d10b Mon Sep 17 00:00:00 2001 From: Narinder Gupta Date: Fri, 12 Jul 2019 09:55:24 -0500 Subject: [PATCH 3/3] lp1836108: Update README to include the driver source from PPA. --- README.md | 0 src/README.md | 5 ++++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/README.md b/src/README.md index bae298b..0dd0c53 100644 --- a/src/README.md +++ b/src/README.md @@ -10,9 +10,12 @@ charm. To use: juju deploy cinder - juju deploy cinder-purestorage + juju deploy cinder-purestorage --config driver-source="ppa:narindergupta/purestorage" juju add-relation cinder-purestorage cinder +Until purestorage packages went into Canonical repository plese use the driver +source from PPA narindergupta/purestorage. + Configuration =============