Ensure that the actions use the configured admin user
Change-Id: I357b26fb585d68d2fbe9bbf21bbf9bfc52ac5050 Closes-Bug: #1893790
This commit is contained in:
parent
a0f71f6bc8
commit
7359b981d6
@ -6,28 +6,28 @@ import sys
|
||||
sys.path.append('hooks')
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
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('admin', backer_pool):
|
||||
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('admin', cache_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='admin', name=backer_pool)
|
||||
pool = Pool(service=user, name=backer_pool)
|
||||
try:
|
||||
pool.add_cache_tier(cache_pool=cache_pool, mode=cache_mode)
|
||||
except CalledProcessError as err:
|
||||
|
@ -18,28 +18,29 @@ _add_path(_root)
|
||||
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
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('admin', backer_pool):
|
||||
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('admin', cache_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='admin', name=backer_pool)
|
||||
pool = Pool(service=user, name=backer_pool)
|
||||
try:
|
||||
pool.add_cache_tier(cache_pool=cache_pool, mode=cache_mode)
|
||||
except CalledProcessError as err:
|
||||
|
@ -17,14 +17,14 @@ _add_path(_root)
|
||||
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import create_erasure_profile
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, log, action_fail
|
||||
|
||||
|
||||
def make_erasure_profile():
|
||||
name = action_get("name")
|
||||
plugin = action_get("plugin")
|
||||
failure_domain = action_get("failure-domain")
|
||||
|
||||
user = config('admin-user')
|
||||
# jerasure requires k+m
|
||||
# isa requires k+m
|
||||
# local requires k+m+l
|
||||
@ -34,7 +34,7 @@ def make_erasure_profile():
|
||||
k = action_get("data-chunks")
|
||||
m = action_get("coding-chunks")
|
||||
try:
|
||||
create_erasure_profile(service='admin',
|
||||
create_erasure_profile(service=user,
|
||||
erasure_plugin_name=plugin,
|
||||
profile_name=name,
|
||||
data_chunks=k,
|
||||
@ -48,7 +48,7 @@ def make_erasure_profile():
|
||||
k = action_get("data-chunks")
|
||||
m = action_get("coding-chunks")
|
||||
try:
|
||||
create_erasure_profile(service='admin',
|
||||
create_erasure_profile(service=user,
|
||||
erasure_plugin_name=plugin,
|
||||
profile_name=name,
|
||||
data_chunks=k,
|
||||
@ -63,7 +63,7 @@ def make_erasure_profile():
|
||||
m = action_get("coding-chunks")
|
||||
l = action_get("locality-chunks")
|
||||
try:
|
||||
create_erasure_profile(service='admin',
|
||||
create_erasure_profile(service=user,
|
||||
erasure_plugin_name=plugin,
|
||||
profile_name=name,
|
||||
data_chunks=k,
|
||||
@ -79,7 +79,7 @@ def make_erasure_profile():
|
||||
m = action_get("coding-chunks")
|
||||
c = action_get("durability-estimator")
|
||||
try:
|
||||
create_erasure_profile(service='admin',
|
||||
create_erasure_profile(service=user,
|
||||
erasure_plugin_name=plugin,
|
||||
profile_name=name,
|
||||
data_chunks=k,
|
||||
|
@ -15,18 +15,19 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from subprocess import CalledProcessError
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, 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")
|
||||
user = config('admin-user')
|
||||
try:
|
||||
if pool_type == "replicated":
|
||||
replicas = action_get("replicas")
|
||||
replicated_pool = ReplicatedPool(name=pool_name,
|
||||
service='admin',
|
||||
service=user,
|
||||
replicas=replicas)
|
||||
replicated_pool.create()
|
||||
|
||||
@ -34,7 +35,7 @@ def create_pool():
|
||||
crush_profile_name = action_get("erasure-profile-name")
|
||||
erasure_pool = ErasurePool(name=pool_name,
|
||||
erasure_code_profile=crush_profile_name,
|
||||
service='admin')
|
||||
service=user)
|
||||
erasure_pool.create()
|
||||
else:
|
||||
log("Unknown pool type of {}. Only erasure or replicated is "
|
||||
|
@ -18,14 +18,14 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import remove_erasure_profile
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, log, action_fail
|
||||
|
||||
|
||||
def delete_erasure_profile():
|
||||
name = action_get("name")
|
||||
|
||||
try:
|
||||
remove_erasure_profile(service='admin', profile_name=name)
|
||||
remove_erasure_profile(service=config('admin-user'), profile_name=name)
|
||||
except CalledProcessError as e:
|
||||
action_fail("Remove erasure profile failed with error: {}".format(
|
||||
e.message))
|
||||
|
@ -16,12 +16,12 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import get_erasure_profile
|
||||
from charmhelpers.core.hookenv import action_get, action_set
|
||||
from charmhelpers.core.hookenv import action_get, action_set, config
|
||||
|
||||
|
||||
def make_erasure_profile():
|
||||
name = action_get("name")
|
||||
out = get_erasure_profile(service='admin', name=name)
|
||||
out = get_erasure_profile(service=config('admin-user'), name=name)
|
||||
action_set({'message': out})
|
||||
|
||||
|
||||
|
@ -16,13 +16,13 @@ def _add_path(path):
|
||||
_add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from charmhelpers.core.hookenv import action_get, log, action_set, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, log, config, action_set, action_fail
|
||||
|
||||
if __name__ == '__main__':
|
||||
name = action_get("name")
|
||||
try:
|
||||
out = check_output(['ceph',
|
||||
'--id', 'admin',
|
||||
'--id', config('admin-user'),
|
||||
'osd',
|
||||
'erasure-code-profile',
|
||||
'ls']).decode('UTF-8')
|
||||
|
@ -16,11 +16,11 @@ def _add_path(path):
|
||||
_add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from charmhelpers.core.hookenv import log, action_set, action_fail
|
||||
from charmhelpers.core.hookenv import log, config, action_set, action_fail
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
out = check_output(['ceph', '--id', 'admin',
|
||||
out = check_output(['ceph', '--id', config('admin-user'),
|
||||
'osd', 'lspools']).decode('UTF-8')
|
||||
action_set({'message': out})
|
||||
except CalledProcessError as e:
|
||||
|
@ -16,13 +16,13 @@ def _add_path(path):
|
||||
_add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from charmhelpers.core.hookenv import log, action_set, action_get, action_fail
|
||||
from charmhelpers.core.hookenv import log, config, 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',
|
||||
out = check_output(['ceph', '--id', config('admin-user'),
|
||||
'osd', 'pool', 'get', name, key]).decode('UTF-8')
|
||||
action_set({'message': out})
|
||||
except CalledProcessError as e:
|
||||
|
@ -15,7 +15,7 @@ def _add_path(path):
|
||||
_add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, log, action_fail
|
||||
from ceph_broker import handle_set_pool_value
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -27,7 +27,7 @@ if __name__ == '__main__':
|
||||
'value': value}
|
||||
|
||||
try:
|
||||
handle_set_pool_value(service='admin', request=request)
|
||||
handle_set_pool_value(service=config('admin-user'), request=request)
|
||||
except CalledProcessError as e:
|
||||
log(str(e))
|
||||
action_fail("Setting pool key: {} and value: {} failed with "
|
||||
|
@ -15,11 +15,11 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from subprocess import check_output, CalledProcessError
|
||||
from charmhelpers.core.hookenv import log, action_set, action_fail
|
||||
from charmhelpers.core.hookenv import log, config, action_set, action_fail
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
out = check_output(['ceph', '--id', 'admin',
|
||||
out = check_output(['ceph', '--id', config('admin-user'),
|
||||
'df']).decode('UTF-8')
|
||||
action_set({'message': out})
|
||||
except CalledProcessError as e:
|
||||
|
@ -5,7 +5,7 @@ import sys
|
||||
sys.path.append('hooks')
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, log, action_fail
|
||||
|
||||
__author__ = 'chris'
|
||||
|
||||
@ -13,21 +13,22 @@ __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('admin', backer_pool):
|
||||
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('admin', cache_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='admin', name=backer_pool)
|
||||
pool = Pool(service=user, name=backer_pool)
|
||||
try:
|
||||
pool.remove_cache_tier(cache_pool=cache_pool)
|
||||
except CalledProcessError as err:
|
||||
|
@ -16,7 +16,7 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import Pool, pool_exists
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, log, action_fail
|
||||
|
||||
__author__ = 'chris'
|
||||
|
||||
@ -24,21 +24,21 @@ __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('admin', backer_pool):
|
||||
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('admin', cache_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='admin', name=backer_pool)
|
||||
pool = Pool(service=user, name=backer_pool)
|
||||
try:
|
||||
pool.remove_cache_tier(cache_pool=cache_pool)
|
||||
except CalledProcessError as err:
|
||||
|
@ -15,14 +15,14 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from subprocess import CalledProcessError
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, 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',
|
||||
remove_pool_snapshot(service=config('admin-user'),
|
||||
pool_name=name,
|
||||
snapshot_name=snapname)
|
||||
except CalledProcessError as e:
|
||||
|
@ -15,14 +15,14 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from subprocess import CalledProcessError
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, 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)
|
||||
rename_pool(service=config('admin-user'), old_name=name, new_name=new_name)
|
||||
except CalledProcessError as e:
|
||||
log(str(e))
|
||||
action_fail("Renaming pool failed with message: {}".format(str(e)))
|
||||
|
@ -15,14 +15,14 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from subprocess import CalledProcessError
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, 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)
|
||||
set_pool_quota(service=config('admin-user'), pool_name=name, max_bytes=max_bytes)
|
||||
except CalledProcessError as e:
|
||||
log(str(e))
|
||||
action_fail("Set pool quota failed with message: {}".format(str(e)))
|
||||
|
@ -15,14 +15,14 @@ _add_path(_hooks)
|
||||
_add_path(_root)
|
||||
|
||||
from subprocess import CalledProcessError
|
||||
from charmhelpers.core.hookenv import action_get, log, action_fail
|
||||
from charmhelpers.core.hookenv import action_get, config, 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',
|
||||
snapshot_pool(service=config('admin-user'),
|
||||
pool_name=name,
|
||||
snapshot_name=snapname)
|
||||
except CalledProcessError as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user