Initial Cookiecutter Commit.
This commit is contained in:
commit
d5ef76fbd7
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=./
|
7
requirements.txt
Normal file
7
requirements.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is managed centrally. If you find the need to modify this as a
|
||||
# one-off, please don't. Intead, consult #openstack-charms and ask about
|
||||
# requirements management in charms via bot-control. Thank you.
|
||||
#
|
||||
# Build requirements
|
||||
charm-tools>=2.4.4
|
||||
simplejson
|
19
src/README.md
Normal file
19
src/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
lvm Storage Backend for Cinder
|
||||
-------------------------------
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
This charm provides a lvm storage backend for use with the Cinder
|
||||
charm.
|
||||
|
||||
To use:
|
||||
|
||||
juju deploy cinder
|
||||
juju deploy cinder-lvm
|
||||
juju add-relation cinder-lvm cinder
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
See config.yaml for details of configuration options.
|
1
src/config.yaml
Normal file
1
src/config.yaml
Normal file
@ -0,0 +1 @@
|
||||
options:
|
12
src/layer.yaml
Normal file
12
src/layer.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
includes: ['layer:openstack', 'interface:cinder-backend']
|
||||
config:
|
||||
deletes:
|
||||
- debug
|
||||
- verbose
|
||||
- use-syslog
|
||||
- use-internal-endpoints
|
||||
- ssl_ca
|
||||
options:
|
||||
basic:
|
||||
use_venv: True
|
||||
repo: https://github.com/openstack-charmers/cinder-storage-backend-template
|
32
src/lib/charm/openstack/cinder_lvm.py
Normal file
32
src/lib/charm/openstack/cinder_lvm.py
Normal file
@ -0,0 +1,32 @@
|
||||
import charms_openstack.charm
|
||||
import charmhelpers.core.hookenv as ch_hookenv # noqa
|
||||
|
||||
charms_openstack.charm.use_defaults('charm.default-select-release')
|
||||
|
||||
|
||||
class CinderlvmCharm(
|
||||
charms_openstack.charm.CinderStoragePluginCharm):
|
||||
|
||||
name = 'cinder_lvm'
|
||||
version_package = 'cinder-volume'
|
||||
release = 'ocata'
|
||||
packages = [version_package]
|
||||
stateless = True
|
||||
# Specify any config that the user *must* set.
|
||||
mandatory_config = []
|
||||
|
||||
def cinder_configuration(self):
|
||||
volume_driver = ''
|
||||
driver_options = [
|
||||
('volume_driver', volume_driver),
|
||||
# Add config options that needs setting on cinder.conf
|
||||
]
|
||||
return driver_options
|
||||
|
||||
|
||||
class CinderlvmCharmRocky(CinderlvmCharm):
|
||||
|
||||
# Rocky needs py3 packages.
|
||||
release = 'rocky'
|
||||
version_package = 'cinder-volume'
|
||||
packages = [version_package]
|
24
src/metadata.yaml
Normal file
24
src/metadata.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
name: cinder-lvm
|
||||
summary: lvm 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 lvm backend for Cinder
|
||||
tags:
|
||||
- openstack
|
||||
- storage
|
||||
- file-servers
|
||||
- misc
|
||||
series:
|
||||
- xenial
|
||||
- bionic
|
||||
subordinate: true
|
||||
provides:
|
||||
storage-backend:
|
||||
interface: cinder-backend
|
||||
scope: container
|
||||
requires:
|
||||
juju-info:
|
||||
interface: juju-info
|
||||
scope: container
|
35
src/reactive/cinder_lvm_handlers.py
Normal file
35
src/reactive/cinder_lvm_handlers.py
Normal file
@ -0,0 +1,35 @@
|
||||
# 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',
|
||||
'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()
|
3
src/test-requirements.txt
Normal file
3
src/test-requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# zaza
|
||||
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-ocata.yaml
Normal file
50
src/tests/bundles/xenial-ocata.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-lvm: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-ocata
|
||||
to:
|
||||
- '1'
|
||||
cinder:
|
||||
charm: cs:~openstack-charmers-next/cinder
|
||||
num_units: 1
|
||||
options:
|
||||
openstack-origin: cloud:xenial-ocata
|
||||
to:
|
||||
- '2'
|
||||
cinder-lvm:
|
||||
series: xenial
|
||||
charm: cinder-lvm
|
||||
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-lvm
|
||||
tests:
|
||||
- tests.tests_cinder_lvm.CinderlvmTest
|
||||
configure:
|
||||
- zaza.openstack.charm_tests.keystone.setup.add_demo_user
|
||||
gate_bundles:
|
||||
- xenial-ocata
|
||||
smoke_bundles:
|
||||
- xenial-ocata
|
70
src/tests/tests_cinder_lvm.py
Normal file
70
src/tests/tests_cinder_lvm.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-lvm 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 CinderlvmTest(test_utils.OpenStackBaseTest):
|
||||
"""Encapsulate lvm tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Run class setup for running tests."""
|
||||
super(CinderlvmTest, 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('lvm')
|
||||
expected_contents = {
|
||||
'cinder-lvm': {
|
||||
'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-lvm')
|
||||
self.cinder_client.volumes.delete(vol_new)
|
35
src/tox.ini
Normal file
35
src/tox.ini
Normal file
@ -0,0 +1,35 @@
|
||||
[tox]
|
||||
envlist = pep8
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
PYTHONHASHSEED=0
|
||||
whitelist_externals = juju
|
||||
passenv = HOME TERM CS_API_* OS_* AMULET_*
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
install_command =
|
||||
pip install {opts} {packages}
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python3
|
||||
deps=charm-tools
|
||||
commands = charm-proof
|
||||
|
||||
[testenv:func-noop]
|
||||
basepython = python3
|
||||
commands =
|
||||
true
|
||||
|
||||
[testenv:func]
|
||||
basepython = python3
|
||||
commands =
|
||||
functest-run-suite --keep-model
|
||||
|
||||
[testenv:func-smoke]
|
||||
basepython = python3
|
||||
commands =
|
||||
functest-run-suite --keep-model --smoke
|
||||
|
||||
[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
|
7
test-requirements.txt
Normal file
7
test-requirements.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# Lint and unit test requirements
|
||||
flake8
|
||||
os-testr>=0.4.1
|
||||
charms.reactive
|
||||
mock>=1.2
|
||||
coverage>=3.6
|
||||
git+https://github.com/openstack/charms.openstack.git#egg=charms-openstack
|
61
tox.ini
Normal file
61
tox.ini
Normal file
@ -0,0 +1,61 @@
|
||||
# Source charm: ./tox.ini
|
||||
# This file is managed centrally by release-tools and should not be modified
|
||||
# within individual charm repos.
|
||||
[tox]
|
||||
skipsdist = True
|
||||
envlist = pep8,py34,py35,py36
|
||||
skip_missing_interpreters = True
|
||||
|
||||
[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
|
||||
install_command =
|
||||
pip install {opts} {packages}
|
||||
deps =
|
||||
-r{toxinidir}/requirements.txt
|
||||
|
||||
[testenv:build]
|
||||
basepython = python3
|
||||
commands =
|
||||
charm-build --log-level DEBUG -o {toxinidir}/build src {posargs}
|
||||
|
||||
[testenv:py27]
|
||||
basepython = python2.7
|
||||
# Reactive source charms are Python3-only, but a py27 unit test target
|
||||
# is required by OpenStack Governance. Remove this shim as soon as
|
||||
# permitted. https://governance.openstack.org/tc/reference/cti/python_cti.html
|
||||
whitelist_externals = true
|
||||
commands = true
|
||||
|
||||
[testenv:py34]
|
||||
basepython = python3.4
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:py35]
|
||||
basepython = python3.5
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:py36]
|
||||
basepython = python3.6
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python3
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = flake8 {posargs} src unit_tests
|
||||
|
||||
[testenv:venv]
|
||||
basepython = python3
|
||||
commands = {posargs}
|
||||
|
||||
[flake8]
|
||||
# E402 ignore necessary for path append before sys module import in actions
|
||||
ignore = E402
|
22
unit_tests/__init__.py
Normal file
22
unit_tests/__init__.py
Normal file
@ -0,0 +1,22 @@
|
||||
# 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()
|
49
unit_tests/test_lib_charm_openstack_cinder_lvm.py
Normal file
49
unit_tests/test_lib_charm_openstack_cinder_lvm.py
Normal file
@ -0,0 +1,49 @@
|
||||
# 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_lvm as cinder_lvm
|
||||
|
||||
import charms_openstack.test_utils as test_utils
|
||||
|
||||
|
||||
class TestCinderlvmCharm(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_lvm.CinderlvmCharm()
|
||||
return c
|
||||
|
||||
def test_cinder_base(self):
|
||||
charm = self._patch_config_and_charm({})
|
||||
self.assertEqual(charm.name, 'cinder_lvm')
|
||||
self.assertEqual(charm.version_package, 'cinder-volume')
|
||||
self.assertEqual(charm.packages, ['cinder-volume'])
|
||||
|
||||
def test_cinder_configuration(self):
|
||||
charm = self._patch_config_and_charm({'a': 'b'})
|
||||
config = charm.cinder_configuration() # noqa
|
||||
# Add check here that configuration is as expected.
|
||||
# self.assertEqual(config, {})
|
Loading…
Reference in New Issue
Block a user