diff --git a/zaza/openstack/charm_tests/iscsi-connector/__init__.py b/zaza/openstack/charm_tests/iscsi-connector/__init__.py new file mode 100644 index 0000000..c0cf179 --- /dev/null +++ b/zaza/openstack/charm_tests/iscsi-connector/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2020 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. + +"""Collection of code for setting up and testing iscsi-connector charm.""" \ No newline at end of file diff --git a/zaza/openstack/charm_tests/iscsi-connector/setup.py b/zaza/openstack/charm_tests/iscsi-connector/setup.py new file mode 100644 index 0000000..f18a4ad --- /dev/null +++ b/zaza/openstack/charm_tests/iscsi-connector/setup.py @@ -0,0 +1,56 @@ +# Copyright 2020 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. + +"""Code for setting up iscsi-connector tests.""" + +# """ +# steps for testing without password: +# - deploy ubuntu for storage +# - deploy ubuntu for initiator +# configure that unit: +# - install tgt -y +# - configure iscsi target +# - need to know the initiator ip +# - restart tgt +# - configure ubuntu initiator with init dict, target, port +# """ + +import zaza.model +import zaza.openstack.utilities.openstack as openstack_utils + + +def basic_target_setup(): + """Run basic setup for iscsi guest.""" + unit = zaza.model.get_units('ubuntu-target')[0] + setup_cmds = [ + "apt install --yes tgt", + "systemctl start tgt",] + for cmd in setup_cmds: + zaza.model.run_on_unit( + unit.entity_id, + cmd) + +def configure_iscsi_target(): + lun = 'iqn.2020-07.canonical.com:lun1' + backing_store = 'dev/vdb' + initiator_address = zaza.model.get_app_ips('ubuntu')[0] + write_file = ( + """echo -e '\n\tbacking-store {}\n\tinitiator-address {}\n' | """ + """sudo tee /etc/tgt/conf.d/iscsi.conf""".format(lun, backing_store,initiator_address) + ) + zaza.model.run_on_unit('ubuntu-target/0', write_file) + # Restart tgt to load new config + restart_tgt = "systemctl restart tgt" + zaza.model.run_on_unit('ubuntu-target/0', restart_tgt) + diff --git a/zaza/openstack/charm_tests/iscsi-connector/tests.py b/zaza/openstack/charm_tests/iscsi-connector/tests.py new file mode 100644 index 0000000..c30f38c --- /dev/null +++ b/zaza/openstack/charm_tests/iscsi-connector/tests.py @@ -0,0 +1,15 @@ +# Copyright 2020 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 iscsi-connector testing.""" \ No newline at end of file