From 1d27ca64b96d040722b2650b774dbb5af983dc08 Mon Sep 17 00:00:00 2001 From: Chris Holcombe Date: Wed, 29 Jun 2016 16:01:38 -0700 Subject: [PATCH] Symlink Actions This change symlinks the python actions files so that tox can properly test the code. Change-Id: Ib6d070555535dc202735124afdafa8dd401350df --- actions/create-cache-tier | 2 +- actions/create-erasure-profile | 90 +------------------------------ actions/create-erasure-profile.py | 89 ++++++++++++++++++++++++++++++ actions/create-pool | 39 +------------- actions/create-pool.py | 38 +++++++++++++ actions/delete-erasure-profile | 25 +-------- actions/delete-erasure-profile.py | 26 +++++++++ actions/delete-pool | 29 +--------- actions/delete-pool.py | 28 ++++++++++ actions/get-erasure-profile | 19 +------ actions/get-erasure-profile.py | 18 +++++++ actions/list-erasure-profiles | 23 +------- actions/list-erasure-profiles.py | 22 ++++++++ actions/list-pools | 18 +------ actions/list-pools.py | 17 ++++++ actions/pool-get | 20 +------ actions/pool-get.py | 19 +++++++ actions/pool-set | 24 +-------- actions/pool-set.py | 23 ++++++++ actions/pool-statistics | 16 +----- actions/pool-statistics.py | 15 ++++++ actions/remove-cache-tier | 2 +- actions/remove-pool-snapshot | 20 +------ actions/remove-pool-snapshot.py | 19 +++++++ actions/rename-pool | 17 +----- actions/rename-pool.py | 16 ++++++ actions/set-pool-max-bytes | 17 +----- actions/set-pool-max-bytes.py | 16 ++++++ actions/snapshot-pool | 19 +------ actions/snapshot-pool.py | 18 +++++++ 30 files changed, 380 insertions(+), 364 deletions(-) mode change 100755 => 120000 actions/create-erasure-profile create mode 100755 actions/create-erasure-profile.py mode change 100755 => 120000 actions/create-pool create mode 100755 actions/create-pool.py mode change 100755 => 120000 actions/delete-erasure-profile create mode 100755 actions/delete-erasure-profile.py mode change 100755 => 120000 actions/delete-pool create mode 100755 actions/delete-pool.py mode change 100755 => 120000 actions/get-erasure-profile create mode 100755 actions/get-erasure-profile.py mode change 100755 => 120000 actions/list-erasure-profiles create mode 100755 actions/list-erasure-profiles.py mode change 100755 => 120000 actions/list-pools create mode 100755 actions/list-pools.py mode change 100755 => 120000 actions/pool-get create mode 100755 actions/pool-get.py mode change 100755 => 120000 actions/pool-set create mode 100755 actions/pool-set.py mode change 100755 => 120000 actions/pool-statistics create mode 100755 actions/pool-statistics.py mode change 100755 => 120000 actions/remove-pool-snapshot create mode 100755 actions/remove-pool-snapshot.py mode change 100755 => 120000 actions/rename-pool create mode 100755 actions/rename-pool.py mode change 100755 => 120000 actions/set-pool-max-bytes create mode 100755 actions/set-pool-max-bytes.py mode change 100755 => 120000 actions/snapshot-pool create mode 100755 actions/snapshot-pool.py diff --git a/actions/create-cache-tier b/actions/create-cache-tier index 2a7e4346..5b049bef 120000 --- a/actions/create-cache-tier +++ b/actions/create-cache-tier @@ -1 +1 @@ -create-cache-tier.py \ No newline at end of file +./create-cache-tier.py \ No newline at end of file diff --git a/actions/create-erasure-profile b/actions/create-erasure-profile deleted file mode 100755 index 2b00b588..00000000 --- a/actions/create-erasure-profile +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/python -from subprocess import CalledProcessError -import sys - -sys.path.append('hooks') - -from charmhelpers.contrib.storage.linux.ceph import create_erasure_profile -from charmhelpers.core.hookenv import action_get, log, action_fail - - -def make_erasure_profile(): - name = action_get("name") - plugin = action_get("plugin") - failure_domain = action_get("failure-domain") - - # jerasure requires k+m - # isa requires k+m - # local requires k+m+l - # shec requires k+m+c - - if plugin == "jerasure": - k = action_get("data-chunks") - m = action_get("coding-chunks") - try: - create_erasure_profile(service='admin', - erasure_plugin_name=plugin, - profile_name=name, - data_chunks=k, - coding_chunks=m, - failure_domain=failure_domain) - except CalledProcessError as e: - log(e) - action_fail("Create erasure profile failed with " - "message: {}".format(e.message)) - elif plugin == "isa": - k = action_get("data-chunks") - m = action_get("coding-chunks") - try: - create_erasure_profile(service='admin', - erasure_plugin_name=plugin, - profile_name=name, - data_chunks=k, - coding_chunks=m, - failure_domain=failure_domain) - except CalledProcessError as e: - log(e) - action_fail("Create erasure profile failed with " - "message: {}".format(e.message)) - elif plugin == "local": - k = action_get("data-chunks") - m = action_get("coding-chunks") - l = action_get("locality-chunks") - try: - create_erasure_profile(service='admin', - erasure_plugin_name=plugin, - profile_name=name, - data_chunks=k, - coding_chunks=m, - locality=l, - failure_domain=failure_domain) - except CalledProcessError as e: - log(e) - action_fail("Create erasure profile failed with " - "message: {}".format(e.message)) - elif plugin == "shec": - k = action_get("data-chunks") - m = action_get("coding-chunks") - c = action_get("durability-estimator") - try: - create_erasure_profile(service='admin', - erasure_plugin_name=plugin, - profile_name=name, - data_chunks=k, - coding_chunks=m, - durability_estimator=c, - failure_domain=failure_domain) - except CalledProcessError as e: - log(e) - action_fail("Create erasure profile failed with " - "message: {}".format(e.message)) - else: - # Unknown erasure plugin - action_fail("Unknown erasure-plugin type of {}. " - "Only jerasure, isa, local or shec is " - "allowed".format(plugin)) - - -if __name__ == '__main__': - make_erasure_profile() diff --git a/actions/create-erasure-profile b/actions/create-erasure-profile new file mode 120000 index 00000000..2e8dba41 --- /dev/null +++ b/actions/create-erasure-profile @@ -0,0 +1 @@ +./create-erasure-profile.py \ No newline at end of file diff --git a/actions/create-erasure-profile.py b/actions/create-erasure-profile.py new file mode 100755 index 00000000..2b00b588 --- /dev/null +++ b/actions/create-erasure-profile.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +from subprocess import CalledProcessError +import sys + +sys.path.append('hooks') + +from charmhelpers.contrib.storage.linux.ceph import create_erasure_profile +from charmhelpers.core.hookenv import action_get, log, action_fail + + +def make_erasure_profile(): + name = action_get("name") + plugin = action_get("plugin") + failure_domain = action_get("failure-domain") + + # jerasure requires k+m + # isa requires k+m + # local requires k+m+l + # shec requires k+m+c + + if plugin == "jerasure": + k = action_get("data-chunks") + m = action_get("coding-chunks") + try: + create_erasure_profile(service='admin', + erasure_plugin_name=plugin, + profile_name=name, + data_chunks=k, + coding_chunks=m, + failure_domain=failure_domain) + except CalledProcessError as e: + log(e) + action_fail("Create erasure profile failed with " + "message: {}".format(e.message)) + elif plugin == "isa": + k = action_get("data-chunks") + m = action_get("coding-chunks") + try: + create_erasure_profile(service='admin', + erasure_plugin_name=plugin, + profile_name=name, + data_chunks=k, + coding_chunks=m, + failure_domain=failure_domain) + except CalledProcessError as e: + log(e) + action_fail("Create erasure profile failed with " + "message: {}".format(e.message)) + elif plugin == "local": + k = action_get("data-chunks") + m = action_get("coding-chunks") + l = action_get("locality-chunks") + try: + create_erasure_profile(service='admin', + erasure_plugin_name=plugin, + profile_name=name, + data_chunks=k, + coding_chunks=m, + locality=l, + failure_domain=failure_domain) + except CalledProcessError as e: + log(e) + action_fail("Create erasure profile failed with " + "message: {}".format(e.message)) + elif plugin == "shec": + k = action_get("data-chunks") + m = action_get("coding-chunks") + c = action_get("durability-estimator") + try: + create_erasure_profile(service='admin', + erasure_plugin_name=plugin, + profile_name=name, + data_chunks=k, + coding_chunks=m, + durability_estimator=c, + failure_domain=failure_domain) + except CalledProcessError as e: + log(e) + action_fail("Create erasure profile failed with " + "message: {}".format(e.message)) + else: + # Unknown erasure plugin + action_fail("Unknown erasure-plugin type of {}. " + "Only jerasure, isa, local or shec is " + "allowed".format(plugin)) + + +if __name__ == '__main__': + make_erasure_profile() diff --git a/actions/create-pool b/actions/create-pool deleted file mode 100755 index 4d1d2148..00000000 --- a/actions/create-pool +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python -import sys - -sys.path.append('hooks') -from subprocess import CalledProcessError -from charmhelpers.core.hookenv import action_get, log, action_fail -from charmhelpers.contrib.storage.linux.ceph import ErasurePool, ReplicatedPool - - -def create_pool(): - pool_name = action_get("name") - pool_type = action_get("pool-type") - try: - if pool_type == "replicated": - replicas = action_get("replicas") - replicated_pool = ReplicatedPool(name=pool_name, - service='admin', - replicas=replicas) - replicated_pool.create() - - elif pool_type == "erasure": - crush_profile_name = action_get("erasure-profile-name") - erasure_pool = ErasurePool(name=pool_name, - erasure_code_profile=crush_profile_name, - service='admin') - erasure_pool.create() - else: - log("Unknown pool type of {}. Only erasure or replicated is " - "allowed".format(pool_type)) - action_fail("Unknown pool type of {}. Only erasure or replicated " - "is allowed".format(pool_type)) - except CalledProcessError as e: - action_fail("Pool creation failed because of a failed process. " - "Ret Code: {} Message: {}".format(e.returncode, e.message)) - - -if __name__ == '__main__': - create_pool() diff --git a/actions/create-pool b/actions/create-pool new file mode 120000 index 00000000..4956f568 --- /dev/null +++ b/actions/create-pool @@ -0,0 +1 @@ +./create-pool.py \ No newline at end of file diff --git a/actions/create-pool.py b/actions/create-pool.py new file mode 100755 index 00000000..4d1d2148 --- /dev/null +++ b/actions/create-pool.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +import sys + +sys.path.append('hooks') +from subprocess import CalledProcessError +from charmhelpers.core.hookenv import action_get, log, action_fail +from charmhelpers.contrib.storage.linux.ceph import ErasurePool, ReplicatedPool + + +def create_pool(): + pool_name = action_get("name") + pool_type = action_get("pool-type") + try: + if pool_type == "replicated": + replicas = action_get("replicas") + replicated_pool = ReplicatedPool(name=pool_name, + service='admin', + replicas=replicas) + replicated_pool.create() + + elif pool_type == "erasure": + crush_profile_name = action_get("erasure-profile-name") + erasure_pool = ErasurePool(name=pool_name, + erasure_code_profile=crush_profile_name, + service='admin') + erasure_pool.create() + else: + log("Unknown pool type of {}. Only erasure or replicated is " + "allowed".format(pool_type)) + action_fail("Unknown pool type of {}. Only erasure or replicated " + "is allowed".format(pool_type)) + except CalledProcessError as e: + action_fail("Pool creation failed because of a failed process. " + "Ret Code: {} Message: {}".format(e.returncode, e.message)) + + +if __name__ == '__main__': + create_pool() diff --git a/actions/delete-erasure-profile b/actions/delete-erasure-profile deleted file mode 100755 index 075c410e..00000000 --- a/actions/delete-erasure-profile +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -from subprocess import CalledProcessError - -__author__ = 'chris' -import sys - -sys.path.append('hooks') - -from charmhelpers.contrib.storage.linux.ceph import remove_erasure_profile -from charmhelpers.core.hookenv import action_get, log, action_fail - - -def delete_erasure_profile(): - name = action_get("name") - - try: - remove_erasure_profile(service='admin', profile_name=name) - except CalledProcessError as e: - action_fail("Remove erasure profile failed with error: {}".format( - e.message)) - - -if __name__ == '__main__': - delete_erasure_profile() diff --git a/actions/delete-erasure-profile b/actions/delete-erasure-profile new file mode 120000 index 00000000..a31aaba5 --- /dev/null +++ b/actions/delete-erasure-profile @@ -0,0 +1 @@ +./delete-erasure-profile.py \ No newline at end of file diff --git a/actions/delete-erasure-profile.py b/actions/delete-erasure-profile.py new file mode 100755 index 00000000..1773eb82 --- /dev/null +++ b/actions/delete-erasure-profile.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +from subprocess import CalledProcessError + +__author__ = 'chris' +import sys + +sys.path.append('hooks') + +from charmhelpers.contrib.storage.linux.ceph import remove_erasure_profile +from charmhelpers.core.hookenv import action_get, log, action_fail + + +def delete_erasure_profile(): + name = action_get("name") + + try: + remove_erasure_profile(service='admin', profile_name=name) + except CalledProcessError as e: + log("Remove erasure profile failed with error {}".format(e.message), + level="ERROR") + action_fail("Remove erasure profile failed with error: {}".format( + e.message)) + + +if __name__ == '__main__': + delete_erasure_profile() diff --git a/actions/delete-pool b/actions/delete-pool deleted file mode 100755 index 3d655076..00000000 --- a/actions/delete-pool +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python -import sys - -sys.path.append('hooks') - -import rados -from ceph_ops import connect -from charmhelpers.core.hookenv import action_get, log, action_fail - - -def remove_pool(): - try: - pool_name = action_get("name") - cluster = connect() - log("Deleting pool: {}".format(pool_name)) - cluster.delete_pool(str(pool_name)) # Convert from unicode - cluster.shutdown() - except (rados.IOError, - rados.ObjectNotFound, - rados.NoData, - rados.NoSpace, - rados.PermissionError) as e: - log(e) - action_fail(e) - - -if __name__ == '__main__': - remove_pool() diff --git a/actions/delete-pool b/actions/delete-pool new file mode 120000 index 00000000..7b239cb5 --- /dev/null +++ b/actions/delete-pool @@ -0,0 +1 @@ +./delete-pool.py \ No newline at end of file diff --git a/actions/delete-pool.py b/actions/delete-pool.py new file mode 100755 index 00000000..3d655076 --- /dev/null +++ b/actions/delete-pool.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +import sys + +sys.path.append('hooks') + +import rados +from ceph_ops import connect +from charmhelpers.core.hookenv import action_get, log, action_fail + + +def remove_pool(): + try: + pool_name = action_get("name") + cluster = connect() + log("Deleting pool: {}".format(pool_name)) + cluster.delete_pool(str(pool_name)) # Convert from unicode + cluster.shutdown() + except (rados.IOError, + rados.ObjectNotFound, + rados.NoData, + rados.NoSpace, + rados.PermissionError) as e: + log(e) + action_fail(e) + + +if __name__ == '__main__': + remove_pool() diff --git a/actions/get-erasure-profile b/actions/get-erasure-profile deleted file mode 100755 index 29ece59d..00000000 --- a/actions/get-erasure-profile +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python -__author__ = 'chris' -import sys - -sys.path.append('hooks') - -from charmhelpers.contrib.storage.linux.ceph import get_erasure_profile -from charmhelpers.core.hookenv import action_get, action_set - - -def make_erasure_profile(): - name = action_get("name") - out = get_erasure_profile(service='admin', name=name) - action_set({'message': out}) - - -if __name__ == '__main__': - make_erasure_profile() diff --git a/actions/get-erasure-profile b/actions/get-erasure-profile new file mode 120000 index 00000000..a604d843 --- /dev/null +++ b/actions/get-erasure-profile @@ -0,0 +1 @@ +./get-erasure-profile.py \ No newline at end of file diff --git a/actions/get-erasure-profile.py b/actions/get-erasure-profile.py new file mode 100755 index 00000000..29ece59d --- /dev/null +++ b/actions/get-erasure-profile.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +__author__ = 'chris' +import sys + +sys.path.append('hooks') + +from charmhelpers.contrib.storage.linux.ceph import get_erasure_profile +from charmhelpers.core.hookenv import action_get, action_set + + +def make_erasure_profile(): + name = action_get("name") + out = get_erasure_profile(service='admin', name=name) + action_set({'message': out}) + + +if __name__ == '__main__': + make_erasure_profile() diff --git a/actions/list-erasure-profiles b/actions/list-erasure-profiles deleted file mode 100755 index cf6dfa09..00000000 --- a/actions/list-erasure-profiles +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python -__author__ = 'chris' -import sys -from subprocess import check_output, CalledProcessError - -sys.path.append('hooks') - -from charmhelpers.core.hookenv import action_get, log, action_set, action_fail - -if __name__ == '__main__': - name = action_get("name") - try: - out = check_output(['ceph', - '--id', 'admin', - 'osd', - 'erasure-code-profile', - 'ls']).decode('UTF-8') - action_set({'message': out}) - except CalledProcessError as e: - log(e) - action_fail("Listing erasure profiles failed with error: {}".format( - e.message)) diff --git a/actions/list-erasure-profiles b/actions/list-erasure-profiles new file mode 120000 index 00000000..e8ad6605 --- /dev/null +++ b/actions/list-erasure-profiles @@ -0,0 +1 @@ +./list-erasure-profiles.py \ No newline at end of file diff --git a/actions/list-erasure-profiles.py b/actions/list-erasure-profiles.py new file mode 100755 index 00000000..cf6dfa09 --- /dev/null +++ b/actions/list-erasure-profiles.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +__author__ = 'chris' +import sys +from subprocess import check_output, CalledProcessError + +sys.path.append('hooks') + +from charmhelpers.core.hookenv import action_get, log, action_set, action_fail + +if __name__ == '__main__': + name = action_get("name") + try: + out = check_output(['ceph', + '--id', 'admin', + 'osd', + 'erasure-code-profile', + 'ls']).decode('UTF-8') + action_set({'message': out}) + except CalledProcessError as e: + log(e) + action_fail("Listing erasure profiles failed with error: {}".format( + e.message)) diff --git a/actions/list-pools b/actions/list-pools deleted file mode 100755 index 102667cf..00000000 --- a/actions/list-pools +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python -__author__ = 'chris' -import sys -from subprocess import check_output, CalledProcessError - -sys.path.append('hooks') - -from charmhelpers.core.hookenv import log, action_set, action_fail - -if __name__ == '__main__': - try: - out = check_output(['ceph', '--id', 'admin', - 'osd', 'lspools']).decode('UTF-8') - action_set({'message': out}) - except CalledProcessError as e: - log(e) - action_fail("List pools failed with error: {}".format(e.message)) diff --git a/actions/list-pools b/actions/list-pools new file mode 120000 index 00000000..ac972184 --- /dev/null +++ b/actions/list-pools @@ -0,0 +1 @@ +./list-pools.py \ No newline at end of file diff --git a/actions/list-pools.py b/actions/list-pools.py new file mode 100755 index 00000000..102667cf --- /dev/null +++ b/actions/list-pools.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +__author__ = 'chris' +import sys +from subprocess import check_output, CalledProcessError + +sys.path.append('hooks') + +from charmhelpers.core.hookenv import log, action_set, action_fail + +if __name__ == '__main__': + try: + out = check_output(['ceph', '--id', 'admin', + 'osd', 'lspools']).decode('UTF-8') + action_set({'message': out}) + except CalledProcessError as e: + log(e) + action_fail("List pools failed with error: {}".format(e.message)) diff --git a/actions/pool-get b/actions/pool-get deleted file mode 100755 index e4f924b9..00000000 --- a/actions/pool-get +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/python -__author__ = 'chris' -import sys -from subprocess import check_output, CalledProcessError - -sys.path.append('hooks') - -from charmhelpers.core.hookenv import log, action_set, action_get, action_fail - -if __name__ == '__main__': - name = action_get('pool-name') - key = action_get('key') - try: - out = check_output(['ceph', '--id', 'admin', - 'osd', 'pool', 'get', name, key]).decode('UTF-8') - action_set({'message': out}) - except CalledProcessError as e: - log(e) - action_fail("Pool get failed with message: {}".format(e.message)) diff --git a/actions/pool-get b/actions/pool-get new file mode 120000 index 00000000..57a93cc7 --- /dev/null +++ b/actions/pool-get @@ -0,0 +1 @@ +./pool-get.py \ No newline at end of file diff --git a/actions/pool-get.py b/actions/pool-get.py new file mode 100755 index 00000000..e4f924b9 --- /dev/null +++ b/actions/pool-get.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +__author__ = 'chris' +import sys +from subprocess import check_output, CalledProcessError + +sys.path.append('hooks') + +from charmhelpers.core.hookenv import log, action_set, action_get, action_fail + +if __name__ == '__main__': + name = action_get('pool-name') + key = action_get('key') + try: + out = check_output(['ceph', '--id', 'admin', + 'osd', 'pool', 'get', name, key]).decode('UTF-8') + action_set({'message': out}) + except CalledProcessError as e: + log(e) + action_fail("Pool get failed with message: {}".format(e.message)) diff --git a/actions/pool-set b/actions/pool-set deleted file mode 100755 index 1f6e13b8..00000000 --- a/actions/pool-set +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python -from subprocess import CalledProcessError -import sys - -sys.path.append('hooks') - -from charmhelpers.core.hookenv import action_get, log, action_fail -from ceph_broker import handle_set_pool_value - -if __name__ == '__main__': - name = action_get("pool-name") - key = action_get("key") - value = action_get("value") - request = {'name': name, - 'key': key, - 'value': value} - - try: - handle_set_pool_value(service='admin', request=request) - except CalledProcessError as e: - log(e.message) - action_fail("Setting pool key: {} and value: {} failed with " - "message: {}".format(key, value, e.message)) diff --git a/actions/pool-set b/actions/pool-set new file mode 120000 index 00000000..6dcb8466 --- /dev/null +++ b/actions/pool-set @@ -0,0 +1 @@ +./pool-set.py \ No newline at end of file diff --git a/actions/pool-set.py b/actions/pool-set.py new file mode 100755 index 00000000..1f6e13b8 --- /dev/null +++ b/actions/pool-set.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +from subprocess import CalledProcessError +import sys + +sys.path.append('hooks') + +from charmhelpers.core.hookenv import action_get, log, action_fail +from ceph_broker import handle_set_pool_value + +if __name__ == '__main__': + name = action_get("pool-name") + key = action_get("key") + value = action_get("value") + request = {'name': name, + 'key': key, + 'value': value} + + try: + handle_set_pool_value(service='admin', request=request) + except CalledProcessError as e: + log(e.message) + action_fail("Setting pool key: {} and value: {} failed with " + "message: {}".format(key, value, e.message)) diff --git a/actions/pool-statistics b/actions/pool-statistics deleted file mode 100755 index 536c889a..00000000 --- a/actions/pool-statistics +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/python -import sys - -sys.path.append('hooks') -from subprocess import check_output, CalledProcessError -from charmhelpers.core.hookenv import log, action_set, action_fail - -if __name__ == '__main__': - try: - out = check_output(['ceph', '--id', 'admin', - 'df']).decode('UTF-8') - action_set({'message': out}) - except CalledProcessError as e: - log(e) - action_fail("ceph df failed with message: {}".format(e.message)) diff --git a/actions/pool-statistics b/actions/pool-statistics new file mode 120000 index 00000000..2e9a80e0 --- /dev/null +++ b/actions/pool-statistics @@ -0,0 +1 @@ +./pool-statistics.py \ No newline at end of file diff --git a/actions/pool-statistics.py b/actions/pool-statistics.py new file mode 100755 index 00000000..536c889a --- /dev/null +++ b/actions/pool-statistics.py @@ -0,0 +1,15 @@ +#!/usr/bin/python +import sys + +sys.path.append('hooks') +from subprocess import check_output, CalledProcessError +from charmhelpers.core.hookenv import log, action_set, action_fail + +if __name__ == '__main__': + try: + out = check_output(['ceph', '--id', 'admin', + 'df']).decode('UTF-8') + action_set({'message': out}) + except CalledProcessError as e: + log(e) + action_fail("ceph df failed with message: {}".format(e.message)) diff --git a/actions/remove-cache-tier b/actions/remove-cache-tier index 136c0f06..efbda4fa 120000 --- a/actions/remove-cache-tier +++ b/actions/remove-cache-tier @@ -1 +1 @@ -remove-cache-tier.py \ No newline at end of file +./remove-cache-tier.py \ No newline at end of file diff --git a/actions/remove-pool-snapshot b/actions/remove-pool-snapshot deleted file mode 100755 index 387849ea..00000000 --- a/actions/remove-pool-snapshot +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/python -import sys - -sys.path.append('hooks') -from subprocess import CalledProcessError -from charmhelpers.core.hookenv import action_get, log, action_fail -from charmhelpers.contrib.storage.linux.ceph import remove_pool_snapshot - -if __name__ == '__main__': - name = action_get("pool-name") - snapname = action_get("snapshot-name") - try: - remove_pool_snapshot(service='admin', - pool_name=name, - snapshot_name=snapname) - except CalledProcessError as e: - log(e) - action_fail("Remove pool snapshot failed with message: {}".format( - e.message)) diff --git a/actions/remove-pool-snapshot b/actions/remove-pool-snapshot new file mode 120000 index 00000000..ea226fff --- /dev/null +++ b/actions/remove-pool-snapshot @@ -0,0 +1 @@ +./remove-pool-snapshot.py \ No newline at end of file diff --git a/actions/remove-pool-snapshot.py b/actions/remove-pool-snapshot.py new file mode 100755 index 00000000..387849ea --- /dev/null +++ b/actions/remove-pool-snapshot.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import sys + +sys.path.append('hooks') +from subprocess import CalledProcessError +from charmhelpers.core.hookenv import action_get, log, action_fail +from charmhelpers.contrib.storage.linux.ceph import remove_pool_snapshot + +if __name__ == '__main__': + name = action_get("pool-name") + snapname = action_get("snapshot-name") + try: + remove_pool_snapshot(service='admin', + pool_name=name, + snapshot_name=snapname) + except CalledProcessError as e: + log(e) + action_fail("Remove pool snapshot failed with message: {}".format( + e.message)) diff --git a/actions/rename-pool b/actions/rename-pool deleted file mode 100755 index 6fe088ec..00000000 --- a/actions/rename-pool +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python -import sys - -sys.path.append('hooks') -from subprocess import CalledProcessError -from charmhelpers.core.hookenv import action_get, log, action_fail -from charmhelpers.contrib.storage.linux.ceph import rename_pool - -if __name__ == '__main__': - name = action_get("pool-name") - new_name = action_get("new-name") - try: - rename_pool(service='admin', old_name=name, new_name=new_name) - except CalledProcessError as e: - log(e) - action_fail("Renaming pool failed with message: {}".format(e.message)) diff --git a/actions/rename-pool b/actions/rename-pool new file mode 120000 index 00000000..c7e4e7a6 --- /dev/null +++ b/actions/rename-pool @@ -0,0 +1 @@ +./rename-pool.py \ No newline at end of file diff --git a/actions/rename-pool.py b/actions/rename-pool.py new file mode 100755 index 00000000..6fe088ec --- /dev/null +++ b/actions/rename-pool.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +import sys + +sys.path.append('hooks') +from subprocess import CalledProcessError +from charmhelpers.core.hookenv import action_get, log, action_fail +from charmhelpers.contrib.storage.linux.ceph import rename_pool + +if __name__ == '__main__': + name = action_get("pool-name") + new_name = action_get("new-name") + try: + rename_pool(service='admin', old_name=name, new_name=new_name) + except CalledProcessError as e: + log(e) + action_fail("Renaming pool failed with message: {}".format(e.message)) diff --git a/actions/set-pool-max-bytes b/actions/set-pool-max-bytes deleted file mode 100755 index 86360885..00000000 --- a/actions/set-pool-max-bytes +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python -import sys - -sys.path.append('hooks') -from subprocess import CalledProcessError -from charmhelpers.core.hookenv import action_get, log, action_fail -from charmhelpers.contrib.storage.linux.ceph import set_pool_quota - -if __name__ == '__main__': - max_bytes = action_get("max") - name = action_get("pool-name") - try: - set_pool_quota(service='admin', pool_name=name, max_bytes=max_bytes) - except CalledProcessError as e: - log(e) - action_fail("Set pool quota failed with message: {}".format(e.message)) diff --git a/actions/set-pool-max-bytes b/actions/set-pool-max-bytes new file mode 120000 index 00000000..34d4d9b5 --- /dev/null +++ b/actions/set-pool-max-bytes @@ -0,0 +1 @@ +./set-pool-max-bytes.py \ No newline at end of file diff --git a/actions/set-pool-max-bytes.py b/actions/set-pool-max-bytes.py new file mode 100755 index 00000000..86360885 --- /dev/null +++ b/actions/set-pool-max-bytes.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +import sys + +sys.path.append('hooks') +from subprocess import CalledProcessError +from charmhelpers.core.hookenv import action_get, log, action_fail +from charmhelpers.contrib.storage.linux.ceph import set_pool_quota + +if __name__ == '__main__': + max_bytes = action_get("max") + name = action_get("pool-name") + try: + set_pool_quota(service='admin', pool_name=name, max_bytes=max_bytes) + except CalledProcessError as e: + log(e) + action_fail("Set pool quota failed with message: {}".format(e.message)) diff --git a/actions/snapshot-pool b/actions/snapshot-pool deleted file mode 100755 index a02619bf..00000000 --- a/actions/snapshot-pool +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python -import sys - -sys.path.append('hooks') -from subprocess import CalledProcessError -from charmhelpers.core.hookenv import action_get, log, action_fail -from charmhelpers.contrib.storage.linux.ceph import snapshot_pool - -if __name__ == '__main__': - name = action_get("pool-name") - snapname = action_get("snapshot-name") - try: - snapshot_pool(service='admin', - pool_name=name, - snapshot_name=snapname) - except CalledProcessError as e: - log(e) - action_fail("Snapshot pool failed with message: {}".format(e.message)) diff --git a/actions/snapshot-pool b/actions/snapshot-pool new file mode 120000 index 00000000..6e3eccc9 --- /dev/null +++ b/actions/snapshot-pool @@ -0,0 +1 @@ +./snapshot-pool.py \ No newline at end of file diff --git a/actions/snapshot-pool.py b/actions/snapshot-pool.py new file mode 100755 index 00000000..a02619bf --- /dev/null +++ b/actions/snapshot-pool.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +import sys + +sys.path.append('hooks') +from subprocess import CalledProcessError +from charmhelpers.core.hookenv import action_get, log, action_fail +from charmhelpers.contrib.storage.linux.ceph import snapshot_pool + +if __name__ == '__main__': + name = action_get("pool-name") + snapname = action_get("snapshot-name") + try: + snapshot_pool(service='admin', + pool_name=name, + snapshot_name=snapname) + except CalledProcessError as e: + log(e) + action_fail("Snapshot pool failed with message: {}".format(e.message))