diff --git a/.gitignore b/.gitignore index 18cac16..4e3756b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ .tox -.swp +**/*.swp __pycache__ .stestr/ lib/* !lib/README.txt +build +ceph-iscsi.charm + diff --git a/.gitmodules b/.gitmodules index 41ffcfc..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/build-requirements.txt b/build-requirements.txt index 1b770a7..1c2a91d 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1 +1 @@ -mod/charm-helpers +charmcraft==0.3.0 diff --git a/charm-init.sh b/charm-init.sh deleted file mode 100755 index 58e58bd..0000000 --- a/charm-init.sh +++ /dev/null @@ -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 diff --git a/hooks/install b/hooks/install deleted file mode 120000 index 25b1f68..0000000 --- a/hooks/install +++ /dev/null @@ -1 +0,0 @@ -../src/charm.py \ No newline at end of file diff --git a/lib/README.txt b/lib/README.txt deleted file mode 100644 index 7931d0d..0000000 --- a/lib/README.txt +++ /dev/null @@ -1 +0,0 @@ -Only generated files should be in here diff --git a/mod/charm-helpers b/mod/charm-helpers deleted file mode 160000 index 87fc7ee..0000000 --- a/mod/charm-helpers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 87fc7ee50662f14abe55d9fe0d02ec20d128379f diff --git a/mod/operator b/mod/operator deleted file mode 160000 index 59dd098..0000000 --- a/mod/operator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 59dd09875421668366ffcaff123bec34a0054ec3 diff --git a/mod/ops-interface-ceph-client b/mod/ops-interface-ceph-client deleted file mode 160000 index 088b68f..0000000 --- a/mod/ops-interface-ceph-client +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 088b68f5b36f76ac44056ccabbe93396c76de98d diff --git a/mod/ops-interface-tls-certificates b/mod/ops-interface-tls-certificates deleted file mode 160000 index f6e6ec1..0000000 --- a/mod/ops-interface-tls-certificates +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f6e6ec1b1d6a317aaeb2cb696e3ec7c1a7c3cd09 diff --git a/mod/ops-openstack b/mod/ops-openstack deleted file mode 160000 index 460b389..0000000 --- a/mod/ops-openstack +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 460b389811d25514c7ac280ff7c8b2f7c17dd790 diff --git a/requirements.txt b/requirements.txt index 8299f55..30a0797 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/src/charm.py b/src/charm.py index ab2f10b..53d81c1 100755 --- a/src/charm.py +++ b/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()) diff --git a/tests/bundles/focal.yaml b/tests/bundles/focal.yaml index 598a5ad..3c5b3e0 100644 --- a/tests/bundles/focal.yaml +++ b/tests/bundles/focal.yaml @@ -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 diff --git a/tests/bundles/overlays/local-charm-overlay.yaml.j2 b/tests/bundles/overlays/local-charm-overlay.yaml.j2 new file mode 100644 index 0000000..5cbfaf2 --- /dev/null +++ b/tests/bundles/overlays/local-charm-overlay.yaml.j2 @@ -0,0 +1,3 @@ +applications: + ceph-iscsi: + charm: ../../ceph-iscsi.charm diff --git a/tox.ini b/tox.ini index cf9f42d..ecb76c4 100644 --- a/tox.ini +++ b/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 diff --git a/unit_tests/test_ceph_iscsi_charm.py b/unit_tests/test_ceph_iscsi_charm.py index 43ed661..f8561f5 100644 --- a/unit_tests/test_ceph_iscsi_charm.py +++ b/unit_tests/test_ceph_iscsi_charm.py @@ -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( diff --git a/unit_tests/test_interface_ceph_iscsi_peer.py b/unit_tests/test_interface_ceph_iscsi_peer.py index f57b8b4..db00964 100644 --- a/unit_tests/test_interface_ceph_iscsi_peer.py +++ b/unit_tests/test_interface_ceph_iscsi_peer.py @@ -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,