Sync charm libraries
Change-Id: Ic2916be468271eb3ff37b305429f3e4133e734c5
This commit is contained in:
parent
213d1055b0
commit
0962f230a1
|
@ -158,15 +158,19 @@ def get_osd_settings(relation_name):
|
||||||
return _order_dict_by_key(osd_settings)
|
return _order_dict_by_key(osd_settings)
|
||||||
|
|
||||||
|
|
||||||
def send_application_name(relid=None):
|
def send_application_name(relid=None, app_name=None):
|
||||||
"""Send the application name down the relation.
|
"""Send the application name down the relation.
|
||||||
|
|
||||||
:param relid: Relation id to set application name in.
|
:param relid: Relation id to set application name in.
|
||||||
:type relid: str
|
:type relid: str
|
||||||
|
:param app_name: Application name to send in the relation.
|
||||||
|
:type app_name: str
|
||||||
"""
|
"""
|
||||||
|
if app_name is None:
|
||||||
|
app_name = application_name()
|
||||||
relation_set(
|
relation_set(
|
||||||
relation_id=relid,
|
relation_id=relid,
|
||||||
relation_settings={'application-name': application_name()})
|
relation_settings={'application-name': app_name})
|
||||||
|
|
||||||
|
|
||||||
def send_osd_settings():
|
def send_osd_settings():
|
||||||
|
|
|
@ -151,6 +151,7 @@ import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -521,6 +522,42 @@ _KV = None
|
||||||
|
|
||||||
def kv():
|
def kv():
|
||||||
global _KV
|
global _KV
|
||||||
|
|
||||||
|
# If we are running unit tests, it is useful to go into memory-backed KV store to
|
||||||
|
# avoid concurrency issues when running multiple tests. This is not a
|
||||||
|
# problem when juju is running normally.
|
||||||
|
|
||||||
|
env_var = os.environ.get("CHARM_HELPERS_TESTMODE", "auto").lower()
|
||||||
|
if env_var not in ["auto", "no", "yes"]:
|
||||||
|
logging.warning("Unknown value for CHARM_HELPERS_TESTMODE '%s'"
|
||||||
|
", assuming 'no'", env_var)
|
||||||
|
env_var = "no"
|
||||||
|
|
||||||
|
if env_var == "no":
|
||||||
|
in_memory_db = False
|
||||||
|
elif env_var == "yes":
|
||||||
|
in_memory_db = True
|
||||||
|
elif env_var == "auto":
|
||||||
|
# If UNIT_STATE_DB is set, respect this request
|
||||||
|
if "UNIT_STATE_DB" in os.environ:
|
||||||
|
in_memory_db = False
|
||||||
|
# Autodetect normal juju execution by looking for juju variables
|
||||||
|
elif "JUJU_CHARM_DIR" in os.environ or "JUJU_UNIT_NAME" in os.environ:
|
||||||
|
in_memory_db = False
|
||||||
|
else:
|
||||||
|
# We are probably running in unit test mode
|
||||||
|
logging.warning("Auto-detected unit test environment for KV store.")
|
||||||
|
in_memory_db = True
|
||||||
|
else:
|
||||||
|
# Help the linter realise that in_memory_db is always set
|
||||||
|
raise Exception("Cannot reach this line")
|
||||||
|
|
||||||
if _KV is None:
|
if _KV is None:
|
||||||
_KV = Storage()
|
if in_memory_db:
|
||||||
|
_KV = Storage(":memory:")
|
||||||
|
else:
|
||||||
|
_KV = Storage()
|
||||||
|
else:
|
||||||
|
if in_memory_db and _KV.db_path != ":memory:":
|
||||||
|
logging.warning("Running with in_memory_db and KV is not set to :memory:")
|
||||||
return _KV
|
return _KV
|
||||||
|
|
|
@ -52,7 +52,7 @@ def _snap_exec(commands):
|
||||||
:param commands: List commands
|
:param commands: List commands
|
||||||
:return: Integer exit code
|
:return: Integer exit code
|
||||||
"""
|
"""
|
||||||
assert type(commands) == list
|
assert isinstance(commands, list)
|
||||||
|
|
||||||
retry_count = 0
|
retry_count = 0
|
||||||
return_code = None
|
return_code = None
|
||||||
|
|
|
@ -907,7 +907,7 @@ def process_requests_v1(reqs):
|
||||||
log(msg, level=ERROR)
|
log(msg, level=ERROR)
|
||||||
return {'exit-code': 1, 'stderr': msg}
|
return {'exit-code': 1, 'stderr': msg}
|
||||||
|
|
||||||
if type(ret) == dict and 'exit-code' in ret:
|
if isinstance(ret, dict) and 'exit-code' in ret:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
return {'exit-code': 0}
|
return {'exit-code': 0}
|
||||||
|
|
|
@ -1223,6 +1223,11 @@ def get_upgrade_key():
|
||||||
return get_named_key('upgrade-osd', _upgrade_caps)
|
return get_named_key('upgrade-osd', _upgrade_caps)
|
||||||
|
|
||||||
|
|
||||||
|
def is_internal_client(name):
|
||||||
|
keys = ('osd-upgrade', 'osd-removal', 'admin', 'rbd-mirror', 'mds')
|
||||||
|
return any(name.startswith(key) for key in keys)
|
||||||
|
|
||||||
|
|
||||||
def get_named_key(name, caps=None, pool_list=None):
|
def get_named_key(name, caps=None, pool_list=None):
|
||||||
"""Retrieve a specific named cephx key.
|
"""Retrieve a specific named cephx key.
|
||||||
|
|
||||||
|
@ -1236,7 +1241,8 @@ def get_named_key(name, caps=None, pool_list=None):
|
||||||
|
|
||||||
key = ceph_auth_get(key_name)
|
key = ceph_auth_get(key_name)
|
||||||
if key:
|
if key:
|
||||||
upgrade_key_caps(key_name, caps)
|
if is_internal_client(name):
|
||||||
|
upgrade_key_caps(key_name, caps)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
log("Creating new key for {}".format(name), level=DEBUG)
|
log("Creating new key for {}".format(name), level=DEBUG)
|
||||||
|
@ -3225,6 +3231,7 @@ UPGRADE_PATHS = collections.OrderedDict([
|
||||||
('nautilus', 'octopus'),
|
('nautilus', 'octopus'),
|
||||||
('octopus', 'pacific'),
|
('octopus', 'pacific'),
|
||||||
('pacific', 'quincy'),
|
('pacific', 'quincy'),
|
||||||
|
('quincy', 'reef'),
|
||||||
])
|
])
|
||||||
|
|
||||||
# Map UCA codenames to Ceph codenames
|
# Map UCA codenames to Ceph codenames
|
||||||
|
@ -3248,7 +3255,7 @@ UCA_CODENAME_MAP = {
|
||||||
'yoga': 'quincy',
|
'yoga': 'quincy',
|
||||||
'zed': 'quincy',
|
'zed': 'quincy',
|
||||||
'antelope': 'quincy',
|
'antelope': 'quincy',
|
||||||
'bobcat': 'quincy',
|
'bobcat': 'reef',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue