Switch charm to use charmcraft for building
Switch charm to use charmcraft for building, which involved: * Remove git submodules * Define charms runtime requirements in requirements.txt and pin to specific hashes. * Update .gitignore to ignore zip charm created by build process. * ops-openstack and ops interfaces were refactored so src/charm.py was updated accordingly. * Point functional test bundles at zip file. * Remove old charm build method (charm-init.sh)
This commit is contained in:
parent
7569f3e598
commit
224b5df30c
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,6 +1,9 @@
|
||||
.tox
|
||||
.swp
|
||||
**/*.swp
|
||||
__pycache__
|
||||
.stestr/
|
||||
lib/*
|
||||
!lib/README.txt
|
||||
build
|
||||
ceph-iscsi.charm
|
||||
|
||||
|
15
.gitmodules
vendored
15
.gitmodules
vendored
@ -1,15 +0,0 @@
|
||||
[submodule "mod/operator"]
|
||||
path = mod/operator
|
||||
url = https://github.com/canonical/operator
|
||||
[submodule "mod/ops-interface-ceph-client"]
|
||||
path = mod/ops-interface-ceph-client
|
||||
url = https://github.com/openstack-charmers/ops-interface-ceph-client.git
|
||||
[submodule "mod/ops-openstack"]
|
||||
path = mod/ops-openstack
|
||||
url = https://github.com/openstack-charmers/ops-openstack.git
|
||||
[submodule "mod/charm-helpers"]
|
||||
path = mod/charm-helpers
|
||||
url = https://github.com/juju/charm-helpers.git
|
||||
[submodule "mod/ops-interface-tls-certificates"]
|
||||
path = mod/ops-interface-tls-certificates
|
||||
url = https://github.com/openstack-charmers/ops-interface-tls-certificates.git
|
@ -1 +1 @@
|
||||
mod/charm-helpers
|
||||
charmcraft==0.3.0
|
||||
|
@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
UPDATE=""
|
||||
while getopts ":u" opt; do
|
||||
case $opt in
|
||||
u) UPDATE=true;;
|
||||
esac
|
||||
done
|
||||
|
||||
git submodule update --init
|
||||
|
||||
# pbr seems unable to detect the current tag when installing
|
||||
# from a local checkout using a git submodule. To work around this
|
||||
# manually set the version.
|
||||
export PBR_VERSION=$(cd mod/charm-helpers; git describe --tags)
|
||||
|
||||
if [[ -z "$UPDATE" ]]; then
|
||||
pip install -t lib -r build-requirements.txt
|
||||
else
|
||||
git -C mod/operator pull origin master
|
||||
git -C mod/ops-openstack pull origin master
|
||||
git -C mod/ops-interface-ceph-client pull origin master
|
||||
git -C mod/ops-interface-tls-certificates pull origin master
|
||||
git -C mod/charm-helpers pull origin master
|
||||
pip install -t lib -r build-requirements.txt --upgrade
|
||||
fi
|
||||
|
||||
ln -f -t lib -s ../mod/operator/ops
|
||||
ln -f -t lib -s ../mod/ops-interface-ceph-client/interface_ceph_client.py
|
||||
ln -f -t lib -s ../mod/ops-openstack/ops_openstack.py
|
||||
ln -f -t lib -s ../mod/ops-openstack/adapters.py
|
||||
ln -f -t lib -s ../mod/ops-interface-tls-certificates/ca_client.py
|
@ -1 +0,0 @@
|
||||
../src/charm.py
|
@ -1 +0,0 @@
|
||||
Only generated files should be in here
|
@ -1 +0,0 @@
|
||||
Subproject commit 87fc7ee50662f14abe55d9fe0d02ec20d128379f
|
@ -1 +0,0 @@
|
||||
Subproject commit 59dd09875421668366ffcaff123bec34a0054ec3
|
@ -1 +0,0 @@
|
||||
Subproject commit 088b68f5b36f76ac44056ccabbe93396c76de98d
|
@ -1 +0,0 @@
|
||||
Subproject commit f6e6ec1b1d6a317aaeb2cb696e3ec7c1a7c3cd09
|
@ -1 +0,0 @@
|
||||
Subproject commit 460b389811d25514c7ac280ff7c8b2f7c17dd790
|
@ -1 +1,6 @@
|
||||
# requirements
|
||||
git+https://github.com/juju/charm-helpers.git@87fc7ee5#egg=charmhelpers
|
||||
git+https://github.com/canonical/operator.git@169794cdd#egg=ops
|
||||
git+https://github.com/openstack-charmers/ops-interface-ceph-client@cc10f29d4#egg=interface_ceph_client
|
||||
git+https://github.com/openstack-charmers/ops-openstack@ea51b43e#egg=ops_openstack
|
||||
git+https://github.com/openstack-charmers/ops-interface-tls-certificates@2ec41b60#egg=ca_client
|
||||
|
28
src/charm.py
28
src/charm.py
@ -18,18 +18,18 @@ from ops.main import main
|
||||
import ops.model
|
||||
import charmhelpers.core.host as ch_host
|
||||
import charmhelpers.core.templating as ch_templating
|
||||
import interface_ceph_client
|
||||
import interface_ceph_client.ceph_client as ceph_client
|
||||
import interface_ceph_iscsi_peer
|
||||
import ca_client
|
||||
import interface_tls_certificates.ca_client as ca_client
|
||||
|
||||
import adapters
|
||||
import ops_openstack
|
||||
import ops_openstack.adapters
|
||||
import ops_openstack.core
|
||||
import gwcli_client
|
||||
import cryptography.hazmat.primitives.serialization as serialization
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CephClientAdapter(adapters.OpenStackOperRelationAdapter):
|
||||
class CephClientAdapter(ops_openstack.adapters.OpenStackOperRelationAdapter):
|
||||
|
||||
def __init__(self, relation):
|
||||
super(CephClientAdapter, self).__init__(relation)
|
||||
@ -48,7 +48,7 @@ class CephClientAdapter(adapters.OpenStackOperRelationAdapter):
|
||||
return self.relation.get_relation_data()['key']
|
||||
|
||||
|
||||
class PeerAdapter(adapters.OpenStackOperRelationAdapter):
|
||||
class PeerAdapter(ops_openstack.adapters.OpenStackOperRelationAdapter):
|
||||
|
||||
def __init__(self, relation):
|
||||
super(PeerAdapter, self).__init__(relation)
|
||||
@ -71,7 +71,8 @@ class GatewayClientPeerAdapter(PeerAdapter):
|
||||
return ' '.join(sorted(ips))
|
||||
|
||||
|
||||
class TLSCertificatesAdapter(adapters.OpenStackOperRelationAdapter):
|
||||
class TLSCertificatesAdapter(
|
||||
ops_openstack.adapters.OpenStackOperRelationAdapter):
|
||||
|
||||
def __init__(self, relation):
|
||||
super(TLSCertificatesAdapter, self).__init__(relation)
|
||||
@ -84,7 +85,8 @@ class TLSCertificatesAdapter(adapters.OpenStackOperRelationAdapter):
|
||||
return False
|
||||
|
||||
|
||||
class CephISCSIGatewayAdapters(adapters.OpenStackRelationAdapters):
|
||||
class CephISCSIGatewayAdapters(
|
||||
ops_openstack.adapters.OpenStackRelationAdapters):
|
||||
|
||||
relation_adapters = {
|
||||
'ceph-client': CephClientAdapter,
|
||||
@ -93,7 +95,7 @@ class CephISCSIGatewayAdapters(adapters.OpenStackRelationAdapters):
|
||||
}
|
||||
|
||||
|
||||
class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm):
|
||||
class CephISCSIGatewayCharmBase(ops_openstack.core.OSBaseCharm):
|
||||
|
||||
state = StoredState()
|
||||
PACKAGES = ['ceph-iscsi', 'tcmu-runner', 'ceph-common']
|
||||
@ -136,7 +138,7 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm):
|
||||
self.state.set_default(
|
||||
target_created=False,
|
||||
enable_tls=False)
|
||||
self.ceph_client = interface_ceph_client.CephClientRequires(
|
||||
self.ceph_client = ceph_client.CephClientRequires(
|
||||
self,
|
||||
'ceph-client')
|
||||
self.peers = interface_ceph_iscsi_peer.CephISCSIGatewayPeers(
|
||||
@ -345,18 +347,18 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm):
|
||||
event.set_results({'iqn': target})
|
||||
|
||||
|
||||
@ops_openstack.charm_class
|
||||
@ops_openstack.core.charm_class
|
||||
class CephISCSIGatewayCharmJewel(CephISCSIGatewayCharmBase):
|
||||
|
||||
state = StoredState()
|
||||
release = 'jewel'
|
||||
|
||||
|
||||
@ops_openstack.charm_class
|
||||
@ops_openstack.core.charm_class
|
||||
class CephISCSIGatewayCharmOcto(CephISCSIGatewayCharmBase):
|
||||
|
||||
state = StoredState()
|
||||
release = 'octopus'
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(ops_openstack.get_charm_class_for_release())
|
||||
main(ops_openstack.core.get_charm_class_for_release())
|
||||
|
@ -1,3 +1,4 @@
|
||||
local_overlay_enabled: False
|
||||
series: focal
|
||||
machines:
|
||||
'0':
|
||||
@ -22,7 +23,7 @@ applications:
|
||||
to:
|
||||
- '7'
|
||||
ceph-iscsi:
|
||||
charm: ../../
|
||||
charm: ../../ceph-iscsi.charm
|
||||
num_units: 2
|
||||
options:
|
||||
rbd-metadata-pool: tmbtil
|
||||
|
3
tests/bundles/overlays/local-charm-overlay.yaml.j2
Normal file
3
tests/bundles/overlays/local-charm-overlay.yaml.j2
Normal file
@ -0,0 +1,3 @@
|
||||
applications:
|
||||
ceph-iscsi:
|
||||
charm: ../../ceph-iscsi.charm
|
4
tox.ini
4
tox.ini
@ -82,9 +82,9 @@ commands = {posargs}
|
||||
|
||||
[testenv:build]
|
||||
basepython = python3
|
||||
deps =
|
||||
deps = -r{toxinidir}/build-requirements.txt
|
||||
commands =
|
||||
./charm-init.sh
|
||||
charmcraft build
|
||||
|
||||
[testenv:update-deps]
|
||||
basepython = python3
|
||||
|
@ -159,7 +159,6 @@ class TestCephISCSIGatewayCharmBase(CharmTestCase):
|
||||
self.harness._backend = _TestingOPSModelBackend(
|
||||
self.harness._unit_name, self.harness._meta)
|
||||
self.harness._model = model.Model(
|
||||
self.harness._unit_name,
|
||||
self.harness._meta,
|
||||
self.harness._backend)
|
||||
self.harness._framework = framework.Framework(
|
||||
|
@ -52,7 +52,7 @@ class TestCephISCSIGatewayPeers(unittest.TestCase):
|
||||
|
||||
receiver = TestReceiver(self.harness.framework, 'receiver')
|
||||
self.harness.framework.observe(self.peers.on.ready_peers,
|
||||
receiver)
|
||||
receiver.on_ready_peers)
|
||||
relation_id = self.harness.add_relation('cluster', 'ceph-iscsi')
|
||||
self.harness.add_relation_unit(
|
||||
relation_id,
|
||||
|
Loading…
Reference in New Issue
Block a user