Initial Cookiecutter Commit.
This commit is contained in:
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
build
|
||||||
|
layers
|
||||||
|
.tox
|
||||||
|
interfaces
|
||||||
|
.testrepository
|
||||||
|
.stestr
|
||||||
|
*__pycache__*
|
||||||
|
*.pyc
|
3
.stestr.conf
Normal file
3
.stestr.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
test_path=./unit_tests
|
||||||
|
top_dir=./
|
18
pip.sh
Executable file
18
pip.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# This file is managed centrally by release-tools and should not be modified
|
||||||
|
# within individual charm repos. See the 'global' dir contents for available
|
||||||
|
# choices of tox.ini for OpenStack Charms:
|
||||||
|
# https://github.com/openstack-charmers/release-tools
|
||||||
|
#
|
||||||
|
# setuptools 58.0 dropped the support for use_2to3=true which is needed to
|
||||||
|
# install blessings (an indirect dependency of charm-tools).
|
||||||
|
#
|
||||||
|
# More details on the beahvior of tox and virtualenv creation can be found at
|
||||||
|
# https://github.com/tox-dev/tox/issues/448
|
||||||
|
#
|
||||||
|
# This script is wrapper to force the use of the pinned versions early in the
|
||||||
|
# process when the virtualenv was created and upgraded before installing the
|
||||||
|
# depedencies declared in the target.
|
||||||
|
pip install 'pip<20.3' 'setuptools<50.0.0'
|
||||||
|
pip "$@"
|
22
requirements.txt
Normal file
22
requirements.txt
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# This file is managed centrally by release-tools and should not be modified
|
||||||
|
# within individual charm repos. See the 'global' dir contents for available
|
||||||
|
# choices of *requirements.txt files for OpenStack Charms:
|
||||||
|
# https://github.com/openstack-charmers/release-tools
|
||||||
|
#
|
||||||
|
# NOTE(lourot): This might look like a duplication of test-requirements.txt but
|
||||||
|
# some tox targets use only test-requirements.txt whereas charm-build uses only
|
||||||
|
# requirements.txt
|
||||||
|
setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85
|
||||||
|
|
||||||
|
# Build requirements
|
||||||
|
charm-tools==2.8.3
|
||||||
|
|
||||||
|
simplejson
|
||||||
|
|
||||||
|
# Newer versions use keywords that didn't exist in python 3.5 yet (e.g.
|
||||||
|
# "ModuleNotFoundError")
|
||||||
|
# NOTE(lourot): This might look like a duplication of test-requirements.txt but
|
||||||
|
# some tox targets use only test-requirements.txt whereas charm-build uses only
|
||||||
|
# requirements.txt
|
||||||
|
importlib-metadata<3.0.0; python_version < '3.6'
|
||||||
|
importlib-resources<3.0.0; python_version < '3.6'
|
19
src/README.md
Normal file
19
src/README.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
DellEMCPowerStore Storage Backend for Cinder
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
Overview
|
||||||
|
========
|
||||||
|
|
||||||
|
This charm provides a DellEMCPowerStore storage backend for use with the Cinder
|
||||||
|
charm.
|
||||||
|
|
||||||
|
To use:
|
||||||
|
|
||||||
|
juju deploy cinder
|
||||||
|
juju deploy cinder-dell_emc_powerstore
|
||||||
|
juju add-relation cinder-dell_emc_powerstore cinder
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
See config.yaml for details of configuration options.
|
19
src/config.yaml
Normal file
19
src/config.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
options:
|
||||||
|
volume-backend-name:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
description: |
|
||||||
|
Volume backend name for the backend. The default value is the
|
||||||
|
application name in the Juju model.
|
||||||
|
use-multipath:
|
||||||
|
type: boolean
|
||||||
|
default: True
|
||||||
|
description: |
|
||||||
|
Whether to use a multipath connection for iSCSI or FC in Cinder
|
||||||
|
volume service. Enabling multipath for VMs is managed by the
|
||||||
|
"use-multipath" option in the nova-compute charm.
|
||||||
|
protocol:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
description: |
|
||||||
|
SAN protocol to use. Choose between iscsi or fc.
|
17
src/layer.yaml
Normal file
17
src/layer.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
includes:
|
||||||
|
- layer:openstack
|
||||||
|
- interface:cinder-backend
|
||||||
|
config:
|
||||||
|
deletes:
|
||||||
|
- debug
|
||||||
|
- verbose
|
||||||
|
- use-syslog
|
||||||
|
- use-internal-endpoints
|
||||||
|
- ssl_cert
|
||||||
|
- ssl_key
|
||||||
|
- ssl_ca
|
||||||
|
options:
|
||||||
|
basic:
|
||||||
|
use_venv: True
|
||||||
|
include_system_packages: False
|
||||||
|
repo: https://github.com/openstack-charmers/cinder-storage-backend-template
|
66
src/lib/charm/openstack/cinder_dell_emc_powerstore.py
Normal file
66
src/lib/charm/openstack/cinder_dell_emc_powerstore.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import charms_openstack.charm
|
||||||
|
import charmhelpers.core.hookenv as ch_hookenv # noqa
|
||||||
|
|
||||||
|
charms_openstack.charm.use_defaults("charm.default-select-release")
|
||||||
|
|
||||||
|
MULTIPATH_PACKAGES = [
|
||||||
|
"multipath-tools", # installed by default for disco+
|
||||||
|
"sysfsutils", # LP: #1947063
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class CinderDellEMCPowerStoreCharm(
|
||||||
|
charms_openstack.charm.CinderStoragePluginCharm
|
||||||
|
):
|
||||||
|
|
||||||
|
# The name of the charm
|
||||||
|
name = "cinder_dell_emc_powerstore"
|
||||||
|
|
||||||
|
# Package to determine application version. Use "cinder-common" when
|
||||||
|
# the driver is in-tree of Cinder upstream.
|
||||||
|
version_package = "cinder-common"
|
||||||
|
|
||||||
|
# Package to determine OpenStack release name
|
||||||
|
release_pkg = "cinder-common"
|
||||||
|
|
||||||
|
# this is the first release in which this charm works
|
||||||
|
release = "victoria"
|
||||||
|
|
||||||
|
# List of packages to install
|
||||||
|
packages = [""]
|
||||||
|
|
||||||
|
# make sure multipath related packages are installed
|
||||||
|
packages.extend(MULTIPATH_PACKAGES)
|
||||||
|
|
||||||
|
stateless = True
|
||||||
|
|
||||||
|
# Specify any config that the user *must* set.
|
||||||
|
mandatory_config = ["protocol"]
|
||||||
|
|
||||||
|
def cinder_configuration(self):
|
||||||
|
mandatory_config_values = map(self.config.get, self.mandatory_config)
|
||||||
|
if not all(list(mandatory_config_values)):
|
||||||
|
return []
|
||||||
|
|
||||||
|
if self.config.get("volume-backend-name"):
|
||||||
|
volume_backend_name = self.config.get("volume-backend-name")
|
||||||
|
else:
|
||||||
|
volume_backend_name = self.service_name
|
||||||
|
|
||||||
|
volume_driver = ""
|
||||||
|
|
||||||
|
driver_options = [
|
||||||
|
("volume_backend_name", volume_backend_name),
|
||||||
|
("volume_driver", volume_driver),
|
||||||
|
# Add config options that needs setting on cinder.conf
|
||||||
|
]
|
||||||
|
|
||||||
|
if self.config.get("use-multipath"):
|
||||||
|
driver_options.extend(
|
||||||
|
[
|
||||||
|
("use_multipath_for_image_xfer", True),
|
||||||
|
("enforce_multipath_for_image_xfer", True),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
return driver_options
|
23
src/metadata.yaml
Normal file
23
src/metadata.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: cinder-dell_emc_powerstore
|
||||||
|
summary: DellEMCPowerStore integration for OpenStack Block Storage
|
||||||
|
maintainer: OpenStack Charmers <openstack-charmers@lists.ubuntu.com>
|
||||||
|
description: |
|
||||||
|
Cinder is the block storage service for the Openstack project.
|
||||||
|
.
|
||||||
|
This charm provides a DellEMCPowerStore backend for Cinder
|
||||||
|
tags:
|
||||||
|
- openstack
|
||||||
|
- storage
|
||||||
|
- file-servers
|
||||||
|
- misc
|
||||||
|
series:
|
||||||
|
- focal
|
||||||
|
subordinate: true
|
||||||
|
provides:
|
||||||
|
storage-backend:
|
||||||
|
interface: cinder-backend
|
||||||
|
scope: container
|
||||||
|
requires:
|
||||||
|
juju-info:
|
||||||
|
interface: juju-info
|
||||||
|
scope: container
|
37
src/reactive/cinder_dell_emc_powerstore_handlers.py
Normal file
37
src/reactive/cinder_dell_emc_powerstore_handlers.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Copyright 2019
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import charms_openstack.charm
|
||||||
|
import charms.reactive
|
||||||
|
|
||||||
|
# This charm's library contains all of the handler code associated with
|
||||||
|
# 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",
|
||||||
|
"config.changed",
|
||||||
|
"update-status",
|
||||||
|
"upgrade-charm",
|
||||||
|
"storage-backend.connected",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@charms.reactive.when("config.changed.driver-source")
|
||||||
|
def reinstall():
|
||||||
|
with charms_openstack.charm.provide_charm_instance() as charm:
|
||||||
|
charm.install()
|
9
src/test-requirements.txt
Normal file
9
src/test-requirements.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# This file is managed centrally by release-tools and should not be modified
|
||||||
|
# within individual charm repos. See the 'global' dir contents for available
|
||||||
|
# choices of *requirements.txt files for OpenStack Charms:
|
||||||
|
# https://github.com/openstack-charmers/release-tools
|
||||||
|
#
|
||||||
|
|
||||||
|
# Functional Test Requirements (let Zaza's dependencies solve all dependencies here!)
|
||||||
|
git+https://github.com/openstack-charmers/zaza.git#egg=zaza
|
||||||
|
git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack
|
50
src/tests/bundles/xenial-victoria.yaml
Normal file
50
src/tests/bundles/xenial-victoria.yaml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
series: xenial
|
||||||
|
comment:
|
||||||
|
- 'machines section to decide order of deployment. database sooner = faster'
|
||||||
|
machines:
|
||||||
|
'0':
|
||||||
|
constraints: mem=3072M
|
||||||
|
'1':
|
||||||
|
'2':
|
||||||
|
'3':
|
||||||
|
relations:
|
||||||
|
- - keystone:shared-db
|
||||||
|
- mysql:shared-db
|
||||||
|
- - cinder:shared-db
|
||||||
|
- mysql:shared-db
|
||||||
|
- - cinder:identity-service
|
||||||
|
- keystone:identity-service
|
||||||
|
- - cinder:amqp
|
||||||
|
- rabbitmq-server:amqp
|
||||||
|
- - cinder:storage-backend
|
||||||
|
- cinder-dell_emc_powerstore:storage-backend
|
||||||
|
applications:
|
||||||
|
mysql:
|
||||||
|
charm: cs:~openstack-charmers-next/percona-cluster
|
||||||
|
num_units: 1
|
||||||
|
to:
|
||||||
|
- '0'
|
||||||
|
keystone:
|
||||||
|
charm: cs:~openstack-charmers-next/keystone
|
||||||
|
num_units: 1
|
||||||
|
options:
|
||||||
|
openstack-origin: cloud:xenial-victoria
|
||||||
|
to:
|
||||||
|
- '1'
|
||||||
|
cinder:
|
||||||
|
charm: cs:~openstack-charmers-next/cinder
|
||||||
|
num_units: 1
|
||||||
|
options:
|
||||||
|
openstack-origin: cloud:xenial-victoria
|
||||||
|
to:
|
||||||
|
- '2'
|
||||||
|
cinder-dell_emc_powerstore:
|
||||||
|
series: xenial
|
||||||
|
charm: cinder-dell_emc_powerstore
|
||||||
|
options:
|
||||||
|
# Add config options here
|
||||||
|
rabbitmq-server:
|
||||||
|
charm: cs:~openstack-charmers-next/rabbitmq-server
|
||||||
|
num_units: 1
|
||||||
|
to:
|
||||||
|
- '3'
|
9
src/tests/tests.yaml
Normal file
9
src/tests/tests.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
charm_name: cinder-dell_emc_powerstore
|
||||||
|
tests:
|
||||||
|
- tests.tests_cinder_dell_emc_powerstore.CinderDellEMCPowerStoreTest
|
||||||
|
configure:
|
||||||
|
- zaza.openstack.charm_tests.keystone.setup.add_demo_user
|
||||||
|
gate_bundles:
|
||||||
|
- xenial-victoria
|
||||||
|
smoke_bundles:
|
||||||
|
- xenial-victoria
|
70
src/tests/tests_cinder_dell_emc_powerstore.py
Normal file
70
src/tests/tests_cinder_dell_emc_powerstore.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright 2019 Canonical Ltd.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
"""Encapsulate cinder-dell_emc_powerstore testing."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import zaza.model
|
||||||
|
import zaza.openstack.charm_tests.test_utils as test_utils
|
||||||
|
import zaza.openstack.utilities.openstack as openstack_utils
|
||||||
|
|
||||||
|
|
||||||
|
class CinderDellEMCPowerStoreTest(test_utils.OpenStackBaseTest):
|
||||||
|
"""Encapsulate DellEMCPowerStore tests."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
"""Run class setup for running tests."""
|
||||||
|
super(CinderDellEMCPowerStoreTest, cls).setUpClass()
|
||||||
|
cls.keystone_session = openstack_utils.get_overcloud_keystone_session()
|
||||||
|
cls.model_name = zaza.model.get_juju_model()
|
||||||
|
cls.cinder_client = openstack_utils.get_cinder_session_client(
|
||||||
|
cls.keystone_session)
|
||||||
|
|
||||||
|
def test_cinder_config(self):
|
||||||
|
logging.info('dell_emc_powerstore')
|
||||||
|
expected_contents = {
|
||||||
|
'cinder-dell_emc_powerstore': {
|
||||||
|
'iscsi_helper': ['tgtadm'],
|
||||||
|
'volume_dd_blocksize': ['512']}}
|
||||||
|
|
||||||
|
zaza.model.run_on_leader(
|
||||||
|
'cinder',
|
||||||
|
'sudo cp /etc/cinder/cinder.conf /tmp/',
|
||||||
|
model_name=self.model_name)
|
||||||
|
zaza.model.block_until_oslo_config_entries_match(
|
||||||
|
'cinder',
|
||||||
|
'/tmp/cinder.conf',
|
||||||
|
expected_contents,
|
||||||
|
model_name=self.model_name,
|
||||||
|
timeout=2)
|
||||||
|
|
||||||
|
def test_create_volume(self):
|
||||||
|
test_vol_name = "zaza{}".format(uuid.uuid1().fields[0])
|
||||||
|
vol_new = self.cinder_client.volumes.create(
|
||||||
|
name=test_vol_name,
|
||||||
|
size=2)
|
||||||
|
openstack_utils.resource_reaches_status(
|
||||||
|
self.cinder_client.volumes,
|
||||||
|
vol_new.id,
|
||||||
|
expected_status='available')
|
||||||
|
test_vol = self.cinder_client.volumes.find(name=test_vol_name)
|
||||||
|
self.assertEqual(
|
||||||
|
getattr(test_vol, 'os-vol-host-attr:host').split('#')[0],
|
||||||
|
'cinder@cinder-dell_emc_powerstore')
|
||||||
|
self.cinder_client.volumes.delete(vol_new)
|
61
src/tox.ini
Normal file
61
src/tox.ini
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# Source charm (with zaza): ./src/tox.ini
|
||||||
|
# This file is managed centrally by release-tools and should not be modified
|
||||||
|
# within individual charm repos. See the 'global' dir contents for available
|
||||||
|
# choices of tox.ini for OpenStack Charms:
|
||||||
|
# https://github.com/openstack-charmers/release-tools
|
||||||
|
|
||||||
|
[tox]
|
||||||
|
envlist = pep8
|
||||||
|
skipsdist = True
|
||||||
|
# NOTE: Avoid build/test env pollution by not enabling sitepackages.
|
||||||
|
sitepackages = False
|
||||||
|
# NOTE: Avoid false positives by not skipping missing interpreters.
|
||||||
|
skip_missing_interpreters = False
|
||||||
|
# NOTES:
|
||||||
|
# * We avoid the new dependency resolver by pinning pip < 20.3, see
|
||||||
|
# https://github.com/pypa/pip/issues/9187
|
||||||
|
# * Pinning dependencies requires tox >= 3.2.0, see
|
||||||
|
# https://tox.readthedocs.io/en/latest/config.html#conf-requires
|
||||||
|
# * It is also necessary to pin virtualenv as a newer virtualenv would still
|
||||||
|
# lead to fetching the latest pip in the func* tox targets, see
|
||||||
|
# https://stackoverflow.com/a/38133283
|
||||||
|
requires = pip < 20.3
|
||||||
|
virtualenv < 20.0
|
||||||
|
# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci
|
||||||
|
minversion = 3.18.0
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
|
PYTHONHASHSEED=0
|
||||||
|
allowlist_externals = juju
|
||||||
|
passenv = HOME TERM CS_* OS_* TEST_*
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
install_command =
|
||||||
|
pip install {opts} {packages}
|
||||||
|
|
||||||
|
[testenv:pep8]
|
||||||
|
basepython = python3
|
||||||
|
commands = charm-proof
|
||||||
|
|
||||||
|
[testenv:func-noop]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
functest-run-suite --help
|
||||||
|
|
||||||
|
[testenv:func]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
functest-run-suite --keep-model
|
||||||
|
|
||||||
|
[testenv:func-smoke]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
functest-run-suite --keep-model --smoke
|
||||||
|
|
||||||
|
[testenv:func-target]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
functest-run-suite --keep-model --bundle {posargs}
|
||||||
|
|
||||||
|
[testenv:venv]
|
||||||
|
commands = {posargs}
|
2
src/wheelhouse.txt
Normal file
2
src/wheelhouse.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#layer-basic uses wheelhouse to install python dependencies
|
||||||
|
psutil
|
51
test-requirements.txt
Normal file
51
test-requirements.txt
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# This file is managed centrally by release-tools and should not be modified
|
||||||
|
# within individual charm repos. See the 'global' dir contents for available
|
||||||
|
# choices of *requirements.txt files for OpenStack Charms:
|
||||||
|
# https://github.com/openstack-charmers/release-tools
|
||||||
|
#
|
||||||
|
setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85
|
||||||
|
|
||||||
|
stestr>=2.2.0
|
||||||
|
|
||||||
|
# Dependency of stestr. Workaround for
|
||||||
|
# https://github.com/mtreinish/stestr/issues/145
|
||||||
|
cliff<3.0.0
|
||||||
|
|
||||||
|
# Dependencies of stestr. Newer versions use keywords that didn't exist in
|
||||||
|
# python 3.5 yet (e.g. "ModuleNotFoundError")
|
||||||
|
importlib-metadata<3.0.0; python_version < '3.6'
|
||||||
|
importlib-resources<3.0.0; python_version < '3.6'
|
||||||
|
|
||||||
|
# Some Zuul nodes sometimes pull newer versions of these dependencies which
|
||||||
|
# dropped support for python 3.5:
|
||||||
|
osprofiler<2.7.0;python_version<'3.6'
|
||||||
|
stevedore<1.31.0;python_version<'3.6'
|
||||||
|
debtcollector<1.22.0;python_version<'3.6'
|
||||||
|
oslo.utils<=3.41.0;python_version<'3.6'
|
||||||
|
|
||||||
|
requests>=2.18.4
|
||||||
|
charms.reactive
|
||||||
|
|
||||||
|
# Newer mock seems to have some syntax which is newer than python3.5 (e.g.
|
||||||
|
# f'{something}'
|
||||||
|
mock>=1.2,<4.0.0; python_version < '3.6'
|
||||||
|
mock>=1.2; python_version >= '3.6'
|
||||||
|
|
||||||
|
nose>=1.3.7
|
||||||
|
coverage>=3.6
|
||||||
|
git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack
|
||||||
|
#
|
||||||
|
# Revisit for removal / mock improvement:
|
||||||
|
#
|
||||||
|
# NOTE(lourot): newer versions of cryptography require a Rust compiler to build,
|
||||||
|
# see
|
||||||
|
# * https://github.com/openstack-charmers/zaza/issues/421
|
||||||
|
# * https://mail.python.org/pipermail/cryptography-dev/2021-January/001003.html
|
||||||
|
#
|
||||||
|
netifaces # vault
|
||||||
|
psycopg2-binary # vault
|
||||||
|
tenacity # vault
|
||||||
|
pbr==5.6.0 # vault
|
||||||
|
cryptography<3.4 # vault, keystone-saml-mellon
|
||||||
|
lxml # keystone-saml-mellon
|
||||||
|
hvac # vault, barbican-vault
|
118
tox.ini
Normal file
118
tox.ini
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
# Source charm: ./tox.ini
|
||||||
|
# This file is managed centrally by release-tools and should not be modified
|
||||||
|
# within individual charm repos. See the 'global' dir contents for available
|
||||||
|
# choices of tox.ini for OpenStack Charms:
|
||||||
|
# https://github.com/openstack-charmers/release-tools
|
||||||
|
|
||||||
|
[tox]
|
||||||
|
skipsdist = True
|
||||||
|
envlist = pep8,py3
|
||||||
|
# NOTE: Avoid build/test env pollution by not enabling sitepackages.
|
||||||
|
sitepackages = False
|
||||||
|
# NOTE: Avoid false positives by not skipping missing interpreters.
|
||||||
|
skip_missing_interpreters = False
|
||||||
|
# NOTES:
|
||||||
|
# * We avoid the new dependency resolver by pinning pip < 20.3, see
|
||||||
|
# https://github.com/pypa/pip/issues/9187
|
||||||
|
# * Pinning dependencies requires tox >= 3.2.0, see
|
||||||
|
# https://tox.readthedocs.io/en/latest/config.html#conf-requires
|
||||||
|
# * It is also necessary to pin virtualenv as a newer virtualenv would still
|
||||||
|
# lead to fetching the latest pip in the func* tox targets, see
|
||||||
|
# https://stackoverflow.com/a/38133283
|
||||||
|
requires =
|
||||||
|
pip < 20.3
|
||||||
|
virtualenv < 20.0
|
||||||
|
setuptools<50.0.0
|
||||||
|
|
||||||
|
# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci
|
||||||
|
minversion = 3.18.0
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
|
PYTHONHASHSEED=0
|
||||||
|
TERM=linux
|
||||||
|
LAYER_PATH={toxinidir}/layers
|
||||||
|
INTERFACE_PATH={toxinidir}/interfaces
|
||||||
|
JUJU_REPOSITORY={toxinidir}/build
|
||||||
|
passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH JUJU_REPOSITORY
|
||||||
|
install_command =
|
||||||
|
{toxinidir}/pip.sh install {opts} {packages}
|
||||||
|
deps =
|
||||||
|
-r{toxinidir}/requirements.txt
|
||||||
|
|
||||||
|
[testenv:build]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
charm-build --log-level DEBUG --use-lock-file-branches -o {toxinidir}/build/builds src {posargs}
|
||||||
|
|
||||||
|
[testenv:add-build-lock-file]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
charm-build --log-level DEBUG --write-lock-file -o {toxinidir}/build/builds src {posargs}
|
||||||
|
|
||||||
|
[testenv:py3]
|
||||||
|
basepython = python3
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
|
[testenv:py35]
|
||||||
|
basepython = python3.5
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
|
[testenv:py36]
|
||||||
|
basepython = python3.6
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
|
[testenv:py37]
|
||||||
|
basepython = python3.7
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
|
[testenv:py38]
|
||||||
|
basepython = python3.8
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
|
[testenv:pep8]
|
||||||
|
basepython = python3
|
||||||
|
deps = flake8==3.9.2
|
||||||
|
charm-tools==2.8.3
|
||||||
|
commands = flake8 {posargs} src unit_tests
|
||||||
|
|
||||||
|
[testenv:cover]
|
||||||
|
# Technique based heavily upon
|
||||||
|
# https://github.com/openstack/nova/blob/master/tox.ini
|
||||||
|
basepython = python3
|
||||||
|
deps = -r{toxinidir}/requirements.txt
|
||||||
|
-r{toxinidir}/test-requirements.txt
|
||||||
|
setenv =
|
||||||
|
{[testenv]setenv}
|
||||||
|
PYTHON=coverage run
|
||||||
|
commands =
|
||||||
|
coverage erase
|
||||||
|
stestr run --slowest {posargs}
|
||||||
|
coverage combine
|
||||||
|
coverage html -d cover
|
||||||
|
coverage xml -o cover/coverage.xml
|
||||||
|
coverage report
|
||||||
|
|
||||||
|
[coverage:run]
|
||||||
|
branch = True
|
||||||
|
concurrency = multiprocessing
|
||||||
|
parallel = True
|
||||||
|
source =
|
||||||
|
.
|
||||||
|
omit =
|
||||||
|
.tox/*
|
||||||
|
*/charmhelpers/*
|
||||||
|
unit_tests/*
|
||||||
|
|
||||||
|
[testenv:venv]
|
||||||
|
basepython = python3
|
||||||
|
commands = {posargs}
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
# E402 ignore necessary for path append before sys module import in actions
|
||||||
|
ignore = E402,W503,W504
|
23
unit_tests/__init__.py
Normal file
23
unit_tests/__init__.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Copyright 2016 Canonical Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append("src")
|
||||||
|
sys.path.append("src/lib")
|
||||||
|
|
||||||
|
# Mock out charmhelpers so that we can test without it.
|
||||||
|
import charms_openstack.test_mocks # noqa
|
||||||
|
|
||||||
|
charms_openstack.test_mocks.mock_charmhelpers()
|
@@ -0,0 +1,108 @@
|
|||||||
|
# Copyright 2016 Canonical Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import charmhelpers
|
||||||
|
|
||||||
|
import charm.openstack.cinder_dell_emc_powerstore as cinder_dell_emc_powerstore
|
||||||
|
|
||||||
|
import charms_openstack.test_utils as test_utils
|
||||||
|
|
||||||
|
|
||||||
|
class TestCinderDellEMCPowerStoreCharm(test_utils.PatchHelper):
|
||||||
|
def _patch_config_and_charm(self, config):
|
||||||
|
self.patch_object(charmhelpers.core.hookenv, "config")
|
||||||
|
|
||||||
|
def cf(key=None):
|
||||||
|
if key is not None:
|
||||||
|
return config[key]
|
||||||
|
return config
|
||||||
|
|
||||||
|
self.config.side_effect = cf
|
||||||
|
c = cinder_dell_emc_powerstore.CinderDellEMCPowerStoreCharm()
|
||||||
|
return c
|
||||||
|
|
||||||
|
def test_cinder_base(self):
|
||||||
|
charm = self._patch_config_and_charm({})
|
||||||
|
self.assertEqual(charm.name, "cinder_dell_emc_powerstore")
|
||||||
|
self.assertEqual(charm.version_package, "cinder-common")
|
||||||
|
self.assertEqual(charm.packages, ["", "multipath-tools", "sysfsutils"])
|
||||||
|
|
||||||
|
def test_cinder_configuration(self):
|
||||||
|
charm = self._patch_config_and_charm(
|
||||||
|
{
|
||||||
|
"volume-backend-name": "my_backend_name",
|
||||||
|
"protocol": "iscsi",
|
||||||
|
# more options to test
|
||||||
|
}
|
||||||
|
)
|
||||||
|
config = charm.cinder_configuration()
|
||||||
|
# Add check here that configuration is as expected.
|
||||||
|
self.assertEqual(
|
||||||
|
config,
|
||||||
|
[
|
||||||
|
("volume_backend_name", "my_backend_name"),
|
||||||
|
("volume_driver", ""),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_cinder_configuration_missing_mandatory_config(self):
|
||||||
|
self.patch_object(charmhelpers.core.hookenv, "service_name")
|
||||||
|
self.service_name.return_value = "cinder-myapp-name"
|
||||||
|
charm = self._patch_config_and_charm(
|
||||||
|
{
|
||||||
|
"protocol": None,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
config = charm.cinder_configuration()
|
||||||
|
self.assertEqual(config, [])
|
||||||
|
|
||||||
|
def test_cinder_configuration_no_explicit_backend_name(self):
|
||||||
|
self.patch_object(charmhelpers.core.hookenv, "service_name")
|
||||||
|
self.service_name.return_value = "cinder-myapp-name"
|
||||||
|
charm = self._patch_config_and_charm(
|
||||||
|
{
|
||||||
|
"protocol": "iscsi",
|
||||||
|
"volume-backend-name": None,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
config = charm.cinder_configuration()
|
||||||
|
self.assertEqual(
|
||||||
|
config,
|
||||||
|
[
|
||||||
|
("volume_backend_name", "cinder-myapp-name"),
|
||||||
|
("volume_driver", ""),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_cinder_configuration_use_multipath(self):
|
||||||
|
charm = self._patch_config_and_charm(
|
||||||
|
{
|
||||||
|
"volume-backend-name": "my_backend_name",
|
||||||
|
"use-multipath": True,
|
||||||
|
"protocol": "iscsi",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
config = charm.cinder_configuration()
|
||||||
|
self.assertEqual(
|
||||||
|
config,
|
||||||
|
[
|
||||||
|
("volume_backend_name", "my_backend_name"),
|
||||||
|
("volume_driver", ""),
|
||||||
|
("use_multipath_for_image_xfer", True),
|
||||||
|
("enforce_multipath_for_image_xfer", True),
|
||||||
|
],
|
||||||
|
)
|
Reference in New Issue
Block a user