c-h sync - restore proxy env vars for add-apt-repository
Change-Id: I2233fb9a3a0aa9b91b01d7808f8a1039f50cbe31
This commit is contained in:
parent
f79e3303c9
commit
f845822b1b
|
@ -46,9 +46,13 @@ class ServiceEvent():
|
|||
self.service = service
|
||||
self.reason = reason
|
||||
self.action = action
|
||||
if not policy_requestor_name:
|
||||
if policy_requestor_name:
|
||||
self.policy_requestor_name = policy_requestor_name
|
||||
else:
|
||||
self.policy_requestor_name = hookenv.service_name()
|
||||
if not policy_requestor_type:
|
||||
if policy_requestor_type:
|
||||
self.policy_requestor_type = policy_requestor_type
|
||||
else:
|
||||
self.policy_requestor_type = 'charm'
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -99,7 +103,9 @@ def read_event_file(file_name):
|
|||
contents['timestamp'],
|
||||
contents['service'],
|
||||
contents['reason'],
|
||||
contents['action'])
|
||||
contents['action'],
|
||||
policy_requestor_name=contents.get('policy_requestor_name'),
|
||||
policy_requestor_type=contents.get('policy_requestor_type'))
|
||||
return event
|
||||
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ from charmhelpers.core.hookenv import (
|
|||
relation_id,
|
||||
relation_ids,
|
||||
relation_set,
|
||||
service_name as ch_service_name,
|
||||
status_set,
|
||||
hook_name,
|
||||
application_version_set,
|
||||
|
@ -1089,8 +1090,12 @@ def _determine_os_workload_status(
|
|||
try:
|
||||
if config(POLICYD_CONFIG_NAME):
|
||||
message = "{} {}".format(policyd_status_message_prefix(), message)
|
||||
# Get deferred restarts events that have been triggered by a policy
|
||||
# written by this charm.
|
||||
deferred_restarts = list(set(
|
||||
[e.service for e in deferred_events.get_deferred_restarts()]))
|
||||
[e.service
|
||||
for e in deferred_events.get_deferred_restarts()
|
||||
if e.policy_requestor_name == ch_service_name()]))
|
||||
if deferred_restarts:
|
||||
svc_msg = "Services queued for restart: {}".format(
|
||||
', '.join(sorted(deferred_restarts)))
|
||||
|
|
|
@ -658,17 +658,11 @@ def _add_apt_repository(spec):
|
|||
:param spec: the parameter to pass to add_apt_repository
|
||||
:type spec: str
|
||||
"""
|
||||
series = get_distrib_codename()
|
||||
if '{series}' in spec:
|
||||
series = get_distrib_codename()
|
||||
spec = spec.replace('{series}', series)
|
||||
# software-properties package for bionic properly reacts to proxy settings
|
||||
# set via apt.conf (see lp:1433761), however this is not the case for LTS
|
||||
# and non-LTS releases before bionic.
|
||||
if series in ('trusty', 'xenial'):
|
||||
_run_with_retries(['add-apt-repository', '--yes', spec],
|
||||
cmd_env=env_proxy_settings(['https', 'http']))
|
||||
else:
|
||||
_run_with_retries(['add-apt-repository', '--yes', spec])
|
||||
_run_with_retries(['add-apt-repository', '--yes', spec],
|
||||
cmd_env=env_proxy_settings(['https', 'http']))
|
||||
|
||||
|
||||
def _add_cloud_pocket(pocket):
|
||||
|
|
|
@ -79,9 +79,9 @@ class Crushmap(object):
|
|||
stdin=crush.stdout)
|
||||
.decode('UTF-8'))
|
||||
except CalledProcessError as e:
|
||||
log("Error occured while loading and decompiling CRUSH map:"
|
||||
log("Error occurred while loading and decompiling CRUSH map:"
|
||||
"{}".format(e), ERROR)
|
||||
raise "Failed to read CRUSH map"
|
||||
raise
|
||||
|
||||
def ensure_bucket_is_present(self, bucket_name):
|
||||
if bucket_name not in [bucket.name for bucket in self.buckets()]:
|
||||
|
@ -111,7 +111,7 @@ class Crushmap(object):
|
|||
return ceph_output
|
||||
except CalledProcessError as e:
|
||||
log("save error: {}".format(e))
|
||||
raise "Failed to save CRUSH map."
|
||||
raise
|
||||
|
||||
def build_crushmap(self):
|
||||
"""Modifies the current CRUSH map to include the new buckets"""
|
||||
|
|
|
@ -24,6 +24,7 @@ import subprocess
|
|||
import sys
|
||||
import time
|
||||
import uuid
|
||||
import functools
|
||||
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime
|
||||
|
@ -3271,13 +3272,14 @@ def determine_packages():
|
|||
def determine_packages_to_remove():
|
||||
"""Determines packages for removal
|
||||
|
||||
Note: if in a container, then the CHRONY_PACKAGE is removed.
|
||||
|
||||
:returns: list of packages to be removed
|
||||
:rtype: List[str]
|
||||
"""
|
||||
rm_packages = REMOVE_PACKAGES.copy()
|
||||
if is_container():
|
||||
install_list = filter_missing_packages(CHRONY_PACKAGE)
|
||||
if not install_list:
|
||||
rm_packages.append(CHRONY_PACKAGE)
|
||||
rm_packages.extend(filter_missing_packages([CHRONY_PACKAGE]))
|
||||
return rm_packages
|
||||
|
||||
|
||||
|
@ -3376,3 +3378,132 @@ def apply_osd_settings(settings):
|
|||
level=ERROR)
|
||||
raise OSDConfigSetError
|
||||
return True
|
||||
|
||||
|
||||
def enabled_manager_modules():
|
||||
"""Return a list of enabled manager modules.
|
||||
|
||||
:rtype: List[str]
|
||||
"""
|
||||
cmd = ['ceph', 'mgr', 'module', 'ls']
|
||||
try:
|
||||
modules = subprocess.check_output(cmd).decode('UTF-8')
|
||||
except subprocess.CalledProcessError as e:
|
||||
log("Failed to list ceph modules: {}".format(e), WARNING)
|
||||
return []
|
||||
modules = json.loads(modules)
|
||||
return modules['enabled_modules']
|
||||
|
||||
|
||||
def is_mgr_module_enabled(module):
|
||||
"""Is a given manager module enabled.
|
||||
|
||||
:param module:
|
||||
:type module: str
|
||||
:returns: Whether the named module is enabled
|
||||
:rtype: bool
|
||||
"""
|
||||
return module in enabled_manager_modules()
|
||||
|
||||
|
||||
is_dashboard_enabled = functools.partial(is_mgr_module_enabled, 'dashboard')
|
||||
|
||||
|
||||
def mgr_enable_module(module):
|
||||
"""Enable a Ceph Manager Module.
|
||||
|
||||
:param module: The module name to enable
|
||||
:type module: str
|
||||
|
||||
:raises: subprocess.CalledProcessError
|
||||
"""
|
||||
if not is_mgr_module_enabled(module):
|
||||
subprocess.check_call(['ceph', 'mgr', 'module', 'enable', module])
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
mgr_enable_dashboard = functools.partial(mgr_enable_module, 'dashboard')
|
||||
|
||||
|
||||
def mgr_disable_module(module):
|
||||
"""Enable a Ceph Manager Module.
|
||||
|
||||
:param module: The module name to enable
|
||||
:type module: str
|
||||
|
||||
:raises: subprocess.CalledProcessError
|
||||
"""
|
||||
if is_mgr_module_enabled(module):
|
||||
subprocess.check_call(['ceph', 'mgr', 'module', 'disable', module])
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
mgr_disable_dashboard = functools.partial(mgr_disable_module, 'dashboard')
|
||||
|
||||
|
||||
def ceph_config_set(name, value, who):
|
||||
"""Set a ceph config option
|
||||
|
||||
:param name: key to set
|
||||
:type name: str
|
||||
:param value: value corresponding to key
|
||||
:type value: str
|
||||
:param who: Config area the key is associated with (e.g. 'dashboard')
|
||||
:type who: str
|
||||
|
||||
:raises: subprocess.CalledProcessError
|
||||
"""
|
||||
subprocess.check_call(['ceph', 'config', 'set', who, name, value])
|
||||
|
||||
|
||||
mgr_config_set = functools.partial(ceph_config_set, who='mgr')
|
||||
|
||||
|
||||
def ceph_config_get(name, who):
|
||||
"""Retrieve the value of a ceph config option
|
||||
|
||||
:param name: key to lookup
|
||||
:type name: str
|
||||
:param who: Config area the key is associated with (e.g. 'dashboard')
|
||||
:type who: str
|
||||
:returns: Value associated with key
|
||||
:rtype: str
|
||||
:raises: subprocess.CalledProcessError
|
||||
"""
|
||||
return subprocess.check_output(
|
||||
['ceph', 'config', 'get', who, name]).decode('UTF-8')
|
||||
|
||||
|
||||
mgr_config_get = functools.partial(ceph_config_get, who='mgr')
|
||||
|
||||
|
||||
def _dashboard_set_ssl_artifact(path, artifact_name, hostname=None):
|
||||
"""Set SSL dashboard config option.
|
||||
|
||||
:param path: Path to file
|
||||
:type path: str
|
||||
:param artifact_name: Option name for setting the artifact
|
||||
:type artifact_name: str
|
||||
:param hostname: If hostname is set artifact will only be associated with
|
||||
the dashboard on that host.
|
||||
:type hostname: str
|
||||
:raises: subprocess.CalledProcessError
|
||||
"""
|
||||
cmd = ['ceph', 'dashboard', artifact_name]
|
||||
if hostname:
|
||||
cmd.append(hostname)
|
||||
cmd.extend(['-i', path])
|
||||
log(cmd, level=DEBUG)
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
|
||||
dashboard_set_ssl_certificate = functools.partial(
|
||||
_dashboard_set_ssl_artifact,
|
||||
artifact_name='set-ssl-certificate')
|
||||
|
||||
|
||||
dashboard_set_ssl_certificate_key = functools.partial(
|
||||
_dashboard_set_ssl_artifact,
|
||||
artifact_name='set-ssl-certificate-key')
|
||||
|
|
Loading…
Reference in New Issue