Remove duplicated action files

Closes-Bug #1894600

Change-Id: I74c737480c6ad56d5691689caeb84bca7154be38
This commit is contained in:
Chris MacNaughton 2020-09-07 09:12:42 +02:00
parent 7359b981d6
commit 5e59db8fee
No known key found for this signature in database
GPG Key ID: 74BAF13D12E6A841
4 changed files with 30 additions and 113 deletions

View File

@ -1,9 +1,21 @@
#!/usr/bin/python
#!/usr/bin/env python3
__author__ = 'chris'
import os
from subprocess import CalledProcessError
import sys
sys.path.append('hooks')
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
_root = os.path.abspath(os.path.join(_path, '..'))
def _add_path(path):
if path not in sys.path:
sys.path.insert(1, path)
_add_path(_hooks)
_add_path(_root)
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
from charmhelpers.core.hookenv import action_get, config, log, action_fail
@ -14,6 +26,7 @@ def make_cache_tier():
cache_pool = action_get("cache-pool")
cache_mode = action_get("cache-mode")
user = config('admin-user')
# Pre flight checks
if not pool_exists(user, backer_pool):
log("Please create {} pool before calling create-cache-tier".format(

View File

@ -1,54 +0,0 @@
#!/usr/bin/env python3
__author__ = 'chris'
import os
from subprocess import CalledProcessError
import sys
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
_root = os.path.abspath(os.path.join(_path, '..'))
def _add_path(path):
if path not in sys.path:
sys.path.insert(1, path)
_add_path(_hooks)
_add_path(_root)
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
from charmhelpers.core.hookenv import action_get, config, log, action_fail
def make_cache_tier():
backer_pool = action_get("backer-pool")
cache_pool = action_get("cache-pool")
cache_mode = action_get("cache-mode")
user = config('admin-user')
# Pre flight checks
if not pool_exists(user, backer_pool):
log("Please create {} pool before calling create-cache-tier".format(
backer_pool))
action_fail("create-cache-tier failed. Backer pool {} must exist "
"before calling this".format(backer_pool))
if not pool_exists(user, cache_pool):
log("Please create {} pool before calling create-cache-tier".format(
cache_pool))
action_fail("create-cache-tier failed. Cache pool {} must exist "
"before calling this".format(cache_pool))
pool = Pool(service=user, name=backer_pool)
try:
pool.add_cache_tier(cache_pool=cache_pool, mode=cache_mode)
except CalledProcessError as err:
log("Add cache tier failed with message: {}".format(
err.message))
action_fail("create-cache-tier failed. Add cache tier failed with "
"message: {}".format(err.message))
if __name__ == '__main__':
make_cache_tier()

View File

@ -1,8 +1,19 @@
#!/usr/bin/python
#!/usr/bin/env python3
import os
from subprocess import CalledProcessError
import sys
sys.path.append('hooks')
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
_root = os.path.abspath(os.path.join(_path, '..'))
def _add_path(path):
if path not in sys.path:
sys.path.insert(1, path)
_add_path(_hooks)
_add_path(_root)
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
from charmhelpers.core.hookenv import action_get, config, log, action_fail
@ -14,7 +25,6 @@ def delete_cache_tier():
backer_pool = action_get("backer-pool")
cache_pool = action_get("cache-pool")
user = config('admin-user')
# Pre flight checks
if not pool_exists(user, backer_pool):
log("Backer pool {} must exist before calling this".format(
@ -33,9 +43,9 @@ def delete_cache_tier():
pool.remove_cache_tier(cache_pool=cache_pool)
except CalledProcessError as err:
log("Removing the cache tier failed with message: {}".format(
err.message))
str(err)))
action_fail("remove-cache-tier failed. Removing the cache tier failed "
"with message: {}".format(err.message))
"with message: {}".format(str(err)))
if __name__ == '__main__':

View File

@ -1,52 +0,0 @@
#!/usr/bin/env python3
import os
from subprocess import CalledProcessError
import sys
_path = os.path.dirname(os.path.realpath(__file__))
_hooks = os.path.abspath(os.path.join(_path, '../hooks'))
_root = os.path.abspath(os.path.join(_path, '..'))
def _add_path(path):
if path not in sys.path:
sys.path.insert(1, path)
_add_path(_hooks)
_add_path(_root)
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
from charmhelpers.core.hookenv import action_get, config, log, action_fail
__author__ = 'chris'
def delete_cache_tier():
backer_pool = action_get("backer-pool")
cache_pool = action_get("cache-pool")
user = config('admin-user')
# Pre flight checks
if not pool_exists(user, backer_pool):
log("Backer pool {} must exist before calling this".format(
backer_pool))
action_fail("remove-cache-tier failed. Backer pool {} must exist "
"before calling this".format(backer_pool))
if not pool_exists(user, cache_pool):
log("Cache pool {} must exist before calling this".format(
cache_pool))
action_fail("remove-cache-tier failed. Cache pool {} must exist "
"before calling this".format(cache_pool))
pool = Pool(service=user, name=backer_pool)
try:
pool.remove_cache_tier(cache_pool=cache_pool)
except CalledProcessError as err:
log("Removing the cache tier failed with message: {}".format(
str(err)))
action_fail("remove-cache-tier failed. Removing the cache tier failed "
"with message: {}".format(str(err)))
if __name__ == '__main__':
delete_cache_tier()