diff --git a/actions.yaml b/actions.yaml index 860ca087..749a17f5 100644 --- a/actions.yaml +++ b/actions.yaml @@ -229,3 +229,7 @@ crushmap-update: show-disk-free: description: Show disk utilization by host and OSD. additionalProperties: false +set-noout: + description: Set ceph noout across the cluster. +unset-noout: + description: Unset ceph noout across the cluster. diff --git a/actions/set-noout b/actions/set-noout new file mode 120000 index 00000000..d2ac02d8 --- /dev/null +++ b/actions/set-noout @@ -0,0 +1 @@ +set_noout.py \ No newline at end of file diff --git a/actions/set_noout.py b/actions/set_noout.py new file mode 100755 index 00000000..97aa3841 --- /dev/null +++ b/actions/set_noout.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +# +# Copyright 2017 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('hooks') +from charmhelpers.core.hookenv import action_set, action_fail +sys.path.append('lib') +from ceph.utils import osd_noout + +if __name__ == '__main__': + result = osd_noout(True) + if result: + action_set({'message': 'Ceph osd noout has been set'}) + else: + action_fail('Ceph osd noout failed to set') diff --git a/actions/unset-noout b/actions/unset-noout new file mode 120000 index 00000000..807c18a7 --- /dev/null +++ b/actions/unset-noout @@ -0,0 +1 @@ +unset_noout.py \ No newline at end of file diff --git a/actions/unset_noout.py b/actions/unset_noout.py new file mode 100755 index 00000000..8ae9a393 --- /dev/null +++ b/actions/unset_noout.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +# +# Copyright 2017 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('hooks') +from charmhelpers.core.hookenv import action_set, action_fail +sys.path.append('lib') +from ceph.utils import osd_noout + +if __name__ == '__main__': + result = osd_noout(False) + if result: + action_set({'message': 'Ceph osd noout has been unset'}) + else: + action_fail('Ceph osd noout failed to unset') diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 67091164..15397c74 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -568,6 +568,27 @@ class CephBasicDeployment(OpenStackAmuletDeployment): assert "cache_mode" not in pool_line, \ "cache_mode is still enabled on cache pool" + def test_404_set_noout_actions(self): + """Verify that set/unset noout works""" + u.log.debug("Testing set noout") + cmd = "ceph -s" + + sentry_unit = self.ceph0_sentry + action_id = u.run_action(sentry_unit, 'set-noout') + assert u.wait_on_action(action_id), "Set noout action failed." + + output, code = sentry_unit.run(cmd) + if 'noout' not in output: + amulet.raise_status(amulet.FAIL, msg="Missing noout") + + u.log.debug("Testing unset noout") + action_id = u.run_action(sentry_unit, 'unset-noout') + assert u.wait_on_action(action_id), "Unset noout action failed." + + output, code = sentry_unit.run(cmd) + if 'noout' in output: + amulet.raise_status(amulet.FAIL, msg="Still has noout") + def test_410_ceph_cinder_vol_create(self): """Create and confirm a ceph-backed cinder volume, and inspect ceph cinder pool object count as the volume is created