id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
12,400
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.service_restarted
def service_restarted(self, sentry_unit, service, filename, pgrep_full=None, sleep_time=20): """Check if service was restarted. Compare a service's start time vs a file's last modification time (such as a config file for that service) to determine if the service ...
python
def service_restarted(self, sentry_unit, service, filename, pgrep_full=None, sleep_time=20): """Check if service was restarted. Compare a service's start time vs a file's last modification time (such as a config file for that service) to determine if the service ...
[ "def", "service_restarted", "(", "self", ",", "sentry_unit", ",", "service", ",", "filename", ",", "pgrep_full", "=", "None", ",", "sleep_time", "=", "20", ")", ":", "# /!\\ DEPRECATION WARNING (beisner):", "# This method is prone to races in that no before-time is known.",...
Check if service was restarted. Compare a service's start time vs a file's last modification time (such as a config file for that service) to determine if the service has been restarted.
[ "Check", "if", "service", "was", "restarted", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L294-L318
12,401
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.service_restarted_since
def service_restarted_since(self, sentry_unit, mtime, service, pgrep_full=None, sleep_time=20, retry_count=30, retry_sleep_time=10): """Check if service was been started after a given time. Args: sentry_unit (sentry): The sentry ...
python
def service_restarted_since(self, sentry_unit, mtime, service, pgrep_full=None, sleep_time=20, retry_count=30, retry_sleep_time=10): """Check if service was been started after a given time. Args: sentry_unit (sentry): The sentry ...
[ "def", "service_restarted_since", "(", "self", ",", "sentry_unit", ",", "mtime", ",", "service", ",", "pgrep_full", "=", "None", ",", "sleep_time", "=", "20", ",", "retry_count", "=", "30", ",", "retry_sleep_time", "=", "10", ")", ":", "# NOTE(beisner) pgrep_f...
Check if service was been started after a given time. Args: sentry_unit (sentry): The sentry unit to check for the service on mtime (float): The epoch time to check against service (string): service name to look for in process table pgrep_full: [Deprecated] Use full comm...
[ "Check", "if", "service", "was", "been", "started", "after", "a", "given", "time", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L320-L378
12,402
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.config_updated_since
def config_updated_since(self, sentry_unit, filename, mtime, sleep_time=20, retry_count=30, retry_sleep_time=10): """Check if file was modified after a given time. Args: sentry_unit (sentry): The sentry unit to check the file mtime on ...
python
def config_updated_since(self, sentry_unit, filename, mtime, sleep_time=20, retry_count=30, retry_sleep_time=10): """Check if file was modified after a given time. Args: sentry_unit (sentry): The sentry unit to check the file mtime on ...
[ "def", "config_updated_since", "(", "self", ",", "sentry_unit", ",", "filename", ",", "mtime", ",", "sleep_time", "=", "20", ",", "retry_count", "=", "30", ",", "retry_sleep_time", "=", "10", ")", ":", "unit_name", "=", "sentry_unit", ".", "info", "[", "'u...
Check if file was modified after a given time. Args: sentry_unit (sentry): The sentry unit to check the file mtime on filename (string): The file to check mtime of mtime (float): The epoch time to check against sleep_time (int): Initial sleep time (s) before looking for ...
[ "Check", "if", "file", "was", "modified", "after", "a", "given", "time", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L380-L431
12,403
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.validate_service_config_changed
def validate_service_config_changed(self, sentry_unit, mtime, service, filename, pgrep_full=None, sleep_time=20, retry_count=30, retry_sleep_time=10): """Check service and file were updated af...
python
def validate_service_config_changed(self, sentry_unit, mtime, service, filename, pgrep_full=None, sleep_time=20, retry_count=30, retry_sleep_time=10): """Check service and file were updated af...
[ "def", "validate_service_config_changed", "(", "self", ",", "sentry_unit", ",", "mtime", ",", "service", ",", "filename", ",", "pgrep_full", "=", "None", ",", "sleep_time", "=", "20", ",", "retry_count", "=", "30", ",", "retry_sleep_time", "=", "10", ")", ":...
Check service and file were updated after mtime Args: sentry_unit (sentry): The sentry unit to check for the service on mtime (float): The epoch time to check against service (string): service name to look for in process table filename (string): The file to check mtime o...
[ "Check", "service", "and", "file", "were", "updated", "after", "mtime" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L433-L485
12,404
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.file_to_url
def file_to_url(self, file_rel_path): """Convert a relative file path to a file URL.""" _abs_path = os.path.abspath(file_rel_path) return urlparse.urlparse(_abs_path, scheme='file').geturl()
python
def file_to_url(self, file_rel_path): """Convert a relative file path to a file URL.""" _abs_path = os.path.abspath(file_rel_path) return urlparse.urlparse(_abs_path, scheme='file').geturl()
[ "def", "file_to_url", "(", "self", ",", "file_rel_path", ")", ":", "_abs_path", "=", "os", ".", "path", ".", "abspath", "(", "file_rel_path", ")", "return", "urlparse", ".", "urlparse", "(", "_abs_path", ",", "scheme", "=", "'file'", ")", ".", "geturl", ...
Convert a relative file path to a file URL.
[ "Convert", "a", "relative", "file", "path", "to", "a", "file", "URL", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L504-L507
12,405
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.check_commands_on_units
def check_commands_on_units(self, commands, sentry_units): """Check that all commands in a list exit zero on all sentry units in a list. :param commands: list of bash commands :param sentry_units: list of sentry unit pointers :returns: None if successful; Failure message other...
python
def check_commands_on_units(self, commands, sentry_units): """Check that all commands in a list exit zero on all sentry units in a list. :param commands: list of bash commands :param sentry_units: list of sentry unit pointers :returns: None if successful; Failure message other...
[ "def", "check_commands_on_units", "(", "self", ",", "commands", ",", "sentry_units", ")", ":", "self", ".", "log", ".", "debug", "(", "'Checking exit codes for {} commands on {} '", "'sentry units...'", ".", "format", "(", "len", "(", "commands", ")", ",", "len", ...
Check that all commands in a list exit zero on all sentry units in a list. :param commands: list of bash commands :param sentry_units: list of sentry unit pointers :returns: None if successful; Failure message otherwise
[ "Check", "that", "all", "commands", "in", "a", "list", "exit", "zero", "on", "all", "sentry", "units", "in", "a", "list", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L509-L531
12,406
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.get_unit_process_ids
def get_unit_process_ids( self, unit_processes, expect_success=True, pgrep_full=False): """Construct a dict containing unit sentries, process names, and process IDs. :param unit_processes: A dictionary of Amulet sentry instance to list of process names. :param ex...
python
def get_unit_process_ids( self, unit_processes, expect_success=True, pgrep_full=False): """Construct a dict containing unit sentries, process names, and process IDs. :param unit_processes: A dictionary of Amulet sentry instance to list of process names. :param ex...
[ "def", "get_unit_process_ids", "(", "self", ",", "unit_processes", ",", "expect_success", "=", "True", ",", "pgrep_full", "=", "False", ")", ":", "pid_dict", "=", "{", "}", "for", "sentry_unit", ",", "process_list", "in", "six", ".", "iteritems", "(", "unit_...
Construct a dict containing unit sentries, process names, and process IDs. :param unit_processes: A dictionary of Amulet sentry instance to list of process names. :param expect_success: if False expect the processes to not be running, raise if they are. :returns:...
[ "Construct", "a", "dict", "containing", "unit", "sentries", "process", "names", "and", "process", "IDs", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L558-L578
12,407
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.validate_unit_process_ids
def validate_unit_process_ids(self, expected, actual): """Validate process id quantities for services on units.""" self.log.debug('Checking units for running processes...') self.log.debug('Expected PIDs: {}'.format(expected)) self.log.debug('Actual PIDs: {}'.format(actual)) if l...
python
def validate_unit_process_ids(self, expected, actual): """Validate process id quantities for services on units.""" self.log.debug('Checking units for running processes...') self.log.debug('Expected PIDs: {}'.format(expected)) self.log.debug('Actual PIDs: {}'.format(actual)) if l...
[ "def", "validate_unit_process_ids", "(", "self", ",", "expected", ",", "actual", ")", ":", "self", ".", "log", ".", "debug", "(", "'Checking units for running processes...'", ")", "self", ".", "log", ".", "debug", "(", "'Expected PIDs: {}'", ".", "format", "(", ...
Validate process id quantities for services on units.
[ "Validate", "process", "id", "quantities", "for", "services", "on", "units", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L580-L636
12,408
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.validate_list_of_identical_dicts
def validate_list_of_identical_dicts(self, list_of_dicts): """Check that all dicts within a list are identical.""" hashes = [] for _dict in list_of_dicts: hashes.append(hash(frozenset(_dict.items()))) self.log.debug('Hashes: {}'.format(hashes)) if len(set(hashes)) ==...
python
def validate_list_of_identical_dicts(self, list_of_dicts): """Check that all dicts within a list are identical.""" hashes = [] for _dict in list_of_dicts: hashes.append(hash(frozenset(_dict.items()))) self.log.debug('Hashes: {}'.format(hashes)) if len(set(hashes)) ==...
[ "def", "validate_list_of_identical_dicts", "(", "self", ",", "list_of_dicts", ")", ":", "hashes", "=", "[", "]", "for", "_dict", "in", "list_of_dicts", ":", "hashes", ".", "append", "(", "hash", "(", "frozenset", "(", "_dict", ".", "items", "(", ")", ")", ...
Check that all dicts within a list are identical.
[ "Check", "that", "all", "dicts", "within", "a", "list", "are", "identical", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L638-L650
12,409
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.get_unit_hostnames
def get_unit_hostnames(self, units): """Return a dict of juju unit names to hostnames.""" host_names = {} for unit in units: host_names[unit.info['unit_name']] = \ str(unit.file_contents('/etc/hostname').strip()) self.log.debug('Unit host names: {}'.format(hos...
python
def get_unit_hostnames(self, units): """Return a dict of juju unit names to hostnames.""" host_names = {} for unit in units: host_names[unit.info['unit_name']] = \ str(unit.file_contents('/etc/hostname').strip()) self.log.debug('Unit host names: {}'.format(hos...
[ "def", "get_unit_hostnames", "(", "self", ",", "units", ")", ":", "host_names", "=", "{", "}", "for", "unit", "in", "units", ":", "host_names", "[", "unit", ".", "info", "[", "'unit_name'", "]", "]", "=", "str", "(", "unit", ".", "file_contents", "(", ...
Return a dict of juju unit names to hostnames.
[ "Return", "a", "dict", "of", "juju", "unit", "names", "to", "hostnames", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L669-L676
12,410
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.run_cmd_unit
def run_cmd_unit(self, sentry_unit, cmd): """Run a command on a unit, return the output and exit code.""" output, code = sentry_unit.run(cmd) if code == 0: self.log.debug('{} `{}` command returned {} ' '(OK)'.format(sentry_unit.info['unit_name'], ...
python
def run_cmd_unit(self, sentry_unit, cmd): """Run a command on a unit, return the output and exit code.""" output, code = sentry_unit.run(cmd) if code == 0: self.log.debug('{} `{}` command returned {} ' '(OK)'.format(sentry_unit.info['unit_name'], ...
[ "def", "run_cmd_unit", "(", "self", ",", "sentry_unit", ",", "cmd", ")", ":", "output", ",", "code", "=", "sentry_unit", ".", "run", "(", "cmd", ")", "if", "code", "==", "0", ":", "self", ".", "log", ".", "debug", "(", "'{} `{}` command returned {} '", ...
Run a command on a unit, return the output and exit code.
[ "Run", "a", "command", "on", "a", "unit", "return", "the", "output", "and", "exit", "code", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L678-L690
12,411
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.file_exists_on_unit
def file_exists_on_unit(self, sentry_unit, file_name): """Check if a file exists on a unit.""" try: sentry_unit.file_stat(file_name) return True except IOError: return False except Exception as e: msg = 'Error checking file {}: {}'.format(f...
python
def file_exists_on_unit(self, sentry_unit, file_name): """Check if a file exists on a unit.""" try: sentry_unit.file_stat(file_name) return True except IOError: return False except Exception as e: msg = 'Error checking file {}: {}'.format(f...
[ "def", "file_exists_on_unit", "(", "self", ",", "sentry_unit", ",", "file_name", ")", ":", "try", ":", "sentry_unit", ".", "file_stat", "(", "file_name", ")", "return", "True", "except", "IOError", ":", "return", "False", "except", "Exception", "as", "e", ":...
Check if a file exists on a unit.
[ "Check", "if", "a", "file", "exists", "on", "a", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L692-L701
12,412
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.file_contents_safe
def file_contents_safe(self, sentry_unit, file_name, max_wait=60, fatal=False): """Get file contents from a sentry unit. Wrap amulet file_contents with retry logic to address races where a file checks as existing, but no longer exists by the time file_contents is call...
python
def file_contents_safe(self, sentry_unit, file_name, max_wait=60, fatal=False): """Get file contents from a sentry unit. Wrap amulet file_contents with retry logic to address races where a file checks as existing, but no longer exists by the time file_contents is call...
[ "def", "file_contents_safe", "(", "self", ",", "sentry_unit", ",", "file_name", ",", "max_wait", "=", "60", ",", "fatal", "=", "False", ")", ":", "unit_name", "=", "sentry_unit", ".", "info", "[", "'unit_name'", "]", "file_contents", "=", "False", "tries", ...
Get file contents from a sentry unit. Wrap amulet file_contents with retry logic to address races where a file checks as existing, but no longer exists by the time file_contents is called. Return None if file not found. Optionally raise if fatal is True.
[ "Get", "file", "contents", "from", "a", "sentry", "unit", ".", "Wrap", "amulet", "file_contents", "with", "retry", "logic", "to", "address", "races", "where", "a", "file", "checks", "as", "existing", "but", "no", "longer", "exists", "by", "the", "time", "f...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L703-L728
12,413
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.port_knock_tcp
def port_knock_tcp(self, host="localhost", port=22, timeout=15): """Open a TCP socket to check for a listening sevice on a host. :param host: host name or IP address, default to localhost :param port: TCP port number, default to 22 :param timeout: Connect timeout, default to 15 seconds ...
python
def port_knock_tcp(self, host="localhost", port=22, timeout=15): """Open a TCP socket to check for a listening sevice on a host. :param host: host name or IP address, default to localhost :param port: TCP port number, default to 22 :param timeout: Connect timeout, default to 15 seconds ...
[ "def", "port_knock_tcp", "(", "self", ",", "host", "=", "\"localhost\"", ",", "port", "=", "22", ",", "timeout", "=", "15", ")", ":", "# Resolve host name if possible", "try", ":", "connect_host", "=", "socket", ".", "gethostbyname", "(", "host", ")", "host_...
Open a TCP socket to check for a listening sevice on a host. :param host: host name or IP address, default to localhost :param port: TCP port number, default to 22 :param timeout: Connect timeout, default to 15 seconds :returns: True if successful, False if connect failed
[ "Open", "a", "TCP", "socket", "to", "check", "for", "a", "listening", "sevice", "on", "a", "host", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L730-L761
12,414
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.port_knock_units
def port_knock_units(self, sentry_units, port=22, timeout=15, expect_success=True): """Open a TCP socket to check for a listening sevice on each listed juju unit. :param sentry_units: list of sentry unit pointers :param port: TCP port number, default to 22 ...
python
def port_knock_units(self, sentry_units, port=22, timeout=15, expect_success=True): """Open a TCP socket to check for a listening sevice on each listed juju unit. :param sentry_units: list of sentry unit pointers :param port: TCP port number, default to 22 ...
[ "def", "port_knock_units", "(", "self", ",", "sentry_units", ",", "port", "=", "22", ",", "timeout", "=", "15", ",", "expect_success", "=", "True", ")", ":", "for", "unit", "in", "sentry_units", ":", "host", "=", "unit", ".", "info", "[", "'public-addres...
Open a TCP socket to check for a listening sevice on each listed juju unit. :param sentry_units: list of sentry unit pointers :param port: TCP port number, default to 22 :param timeout: Connect timeout, default to 15 seconds :expect_success: True by default, set False to invert ...
[ "Open", "a", "TCP", "socket", "to", "check", "for", "a", "listening", "sevice", "on", "each", "listed", "juju", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L763-L780
12,415
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.wait_on_action
def wait_on_action(self, action_id, _check_output=subprocess.check_output): """Wait for a given action, returning if it completed or not. action_id a string action uuid _check_output parameter is no longer used """ data = amulet.actions.get_action_output(action_id, full_output=T...
python
def wait_on_action(self, action_id, _check_output=subprocess.check_output): """Wait for a given action, returning if it completed or not. action_id a string action uuid _check_output parameter is no longer used """ data = amulet.actions.get_action_output(action_id, full_output=T...
[ "def", "wait_on_action", "(", "self", ",", "action_id", ",", "_check_output", "=", "subprocess", ".", "check_output", ")", ":", "data", "=", "amulet", ".", "actions", ".", "get_action_output", "(", "action_id", ",", "full_output", "=", "True", ")", "return", ...
Wait for a given action, returning if it completed or not. action_id a string action uuid _check_output parameter is no longer used
[ "Wait", "for", "a", "given", "action", "returning", "if", "it", "completed", "or", "not", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L804-L811
12,416
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.status_get
def status_get(self, unit): """Return the current service status of this unit.""" raw_status, return_code = unit.run( "status-get --format=json --include-data") if return_code != 0: return ("unknown", "") status = json.loads(raw_status) return (status["sta...
python
def status_get(self, unit): """Return the current service status of this unit.""" raw_status, return_code = unit.run( "status-get --format=json --include-data") if return_code != 0: return ("unknown", "") status = json.loads(raw_status) return (status["sta...
[ "def", "status_get", "(", "self", ",", "unit", ")", ":", "raw_status", ",", "return_code", "=", "unit", ".", "run", "(", "\"status-get --format=json --include-data\"", ")", "if", "return_code", "!=", "0", ":", "return", "(", "\"unknown\"", ",", "\"\"", ")", ...
Return the current service status of this unit.
[ "Return", "the", "current", "service", "status", "of", "this", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L813-L820
12,417
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.execute
def execute(self, sql): """Execute arbitary SQL against the database.""" cursor = self.connection.cursor() try: cursor.execute(sql) finally: cursor.close()
python
def execute(self, sql): """Execute arbitary SQL against the database.""" cursor = self.connection.cursor() try: cursor.execute(sql) finally: cursor.close()
[ "def", "execute", "(", "self", ",", "sql", ")", ":", "cursor", "=", "self", ".", "connection", ".", "cursor", "(", ")", "try", ":", "cursor", ".", "execute", "(", "sql", ")", "finally", ":", "cursor", ".", "close", "(", ")" ]
Execute arbitary SQL against the database.
[ "Execute", "arbitary", "SQL", "against", "the", "database", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L160-L166
12,418
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.select
def select(self, sql): """ Execute arbitrary SQL select query against the database and return the results. :param sql: SQL select query to execute :type sql: string :returns: SQL select query result :rtype: list of lists :raises: MySQLdb.Error """...
python
def select(self, sql): """ Execute arbitrary SQL select query against the database and return the results. :param sql: SQL select query to execute :type sql: string :returns: SQL select query result :rtype: list of lists :raises: MySQLdb.Error """...
[ "def", "select", "(", "self", ",", "sql", ")", ":", "cursor", "=", "self", ".", "connection", ".", "cursor", "(", ")", "try", ":", "cursor", ".", "execute", "(", "sql", ")", "results", "=", "[", "list", "(", "i", ")", "for", "i", "in", "cursor", ...
Execute arbitrary SQL select query against the database and return the results. :param sql: SQL select query to execute :type sql: string :returns: SQL select query result :rtype: list of lists :raises: MySQLdb.Error
[ "Execute", "arbitrary", "SQL", "select", "query", "against", "the", "database", "and", "return", "the", "results", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L168-L185
12,419
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.migrate_passwords_to_leader_storage
def migrate_passwords_to_leader_storage(self, excludes=None): """Migrate any passwords storage on disk to leader storage.""" if not is_leader(): log("Skipping password migration as not the lead unit", level=DEBUG) return dirname = os.path.dirname(self.root...
python
def migrate_passwords_to_leader_storage(self, excludes=None): """Migrate any passwords storage on disk to leader storage.""" if not is_leader(): log("Skipping password migration as not the lead unit", level=DEBUG) return dirname = os.path.dirname(self.root...
[ "def", "migrate_passwords_to_leader_storage", "(", "self", ",", "excludes", "=", "None", ")", ":", "if", "not", "is_leader", "(", ")", ":", "log", "(", "\"Skipping password migration as not the lead unit\"", ",", "level", "=", "DEBUG", ")", "return", "dirname", "=...
Migrate any passwords storage on disk to leader storage.
[ "Migrate", "any", "passwords", "storage", "on", "disk", "to", "leader", "storage", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L187-L212
12,420
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.get_mysql_password_on_disk
def get_mysql_password_on_disk(self, username=None, password=None): """Retrieve, generate or store a mysql password for the provided username on disk.""" if username: template = self.user_passwd_file_template passwd_file = template.format(username) else: ...
python
def get_mysql_password_on_disk(self, username=None, password=None): """Retrieve, generate or store a mysql password for the provided username on disk.""" if username: template = self.user_passwd_file_template passwd_file = template.format(username) else: ...
[ "def", "get_mysql_password_on_disk", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "username", ":", "template", "=", "self", ".", "user_passwd_file_template", "passwd_file", "=", "template", ".", "format", "(", "usern...
Retrieve, generate or store a mysql password for the provided username on disk.
[ "Retrieve", "generate", "or", "store", "a", "mysql", "password", "for", "the", "provided", "username", "on", "disk", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L214-L243
12,421
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.passwd_keys
def passwd_keys(self, username): """Generator to return keys used to store passwords in peer store. NOTE: we support both legacy and new format to support mysql charm prior to refactor. This is necessary to avoid LP 1451890. """ keys = [] if username == 'mysql': ...
python
def passwd_keys(self, username): """Generator to return keys used to store passwords in peer store. NOTE: we support both legacy and new format to support mysql charm prior to refactor. This is necessary to avoid LP 1451890. """ keys = [] if username == 'mysql': ...
[ "def", "passwd_keys", "(", "self", ",", "username", ")", ":", "keys", "=", "[", "]", "if", "username", "==", "'mysql'", ":", "log", "(", "\"Bad username '%s'\"", "%", "(", "username", ")", ",", "level", "=", "WARNING", ")", "if", "username", ":", "# IM...
Generator to return keys used to store passwords in peer store. NOTE: we support both legacy and new format to support mysql charm prior to refactor. This is necessary to avoid LP 1451890.
[ "Generator", "to", "return", "keys", "used", "to", "store", "passwords", "in", "peer", "store", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L245-L263
12,422
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.get_mysql_password
def get_mysql_password(self, username=None, password=None): """Retrieve, generate or store a mysql password for the provided username using peer relation cluster.""" excludes = [] # First check peer relation. try: for key in self.passwd_keys(username): ...
python
def get_mysql_password(self, username=None, password=None): """Retrieve, generate or store a mysql password for the provided username using peer relation cluster.""" excludes = [] # First check peer relation. try: for key in self.passwd_keys(username): ...
[ "def", "get_mysql_password", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "excludes", "=", "[", "]", "# First check peer relation.", "try", ":", "for", "key", "in", "self", ".", "passwd_keys", "(", "username", ")", ":"...
Retrieve, generate or store a mysql password for the provided username using peer relation cluster.
[ "Retrieve", "generate", "or", "store", "a", "mysql", "password", "for", "the", "provided", "username", "using", "peer", "relation", "cluster", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L265-L293
12,423
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.set_mysql_password
def set_mysql_password(self, username, password): """Update a mysql password for the provided username changing the leader settings To update root's password pass `None` in the username """ if username is None: username = 'root' # get root password via lead...
python
def set_mysql_password(self, username, password): """Update a mysql password for the provided username changing the leader settings To update root's password pass `None` in the username """ if username is None: username = 'root' # get root password via lead...
[ "def", "set_mysql_password", "(", "self", ",", "username", ",", "password", ")", ":", "if", "username", "is", "None", ":", "username", "=", "'root'", "# get root password via leader-get, it may be that in the past (when", "# changes to root-password were not supported) the user...
Update a mysql password for the provided username changing the leader settings To update root's password pass `None` in the username
[ "Update", "a", "mysql", "password", "for", "the", "provided", "username", "changing", "the", "leader", "settings" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L299-L370
12,424
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.get_allowed_units
def get_allowed_units(self, database, username, relation_id=None): """Get list of units with access grants for database with username. This is typically used to provide shared-db relations with a list of which units have been granted access to the given database. """ self.connec...
python
def get_allowed_units(self, database, username, relation_id=None): """Get list of units with access grants for database with username. This is typically used to provide shared-db relations with a list of which units have been granted access to the given database. """ self.connec...
[ "def", "get_allowed_units", "(", "self", ",", "database", ",", "username", ",", "relation_id", "=", "None", ")", ":", "self", ".", "connect", "(", "password", "=", "self", ".", "get_mysql_root_password", "(", ")", ")", "allowed_units", "=", "set", "(", ")"...
Get list of units with access grants for database with username. This is typically used to provide shared-db relations with a list of which units have been granted access to the given database.
[ "Get", "list", "of", "units", "with", "access", "grants", "for", "database", "with", "username", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L387-L426
12,425
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
MySQLHelper.configure_db
def configure_db(self, hostname, database, username, admin=False): """Configure access to database for username from hostname.""" self.connect(password=self.get_mysql_root_password()) if not self.database_exists(database): self.create_database(database) remote_ip = self.norm...
python
def configure_db(self, hostname, database, username, admin=False): """Configure access to database for username from hostname.""" self.connect(password=self.get_mysql_root_password()) if not self.database_exists(database): self.create_database(database) remote_ip = self.norm...
[ "def", "configure_db", "(", "self", ",", "hostname", ",", "database", ",", "username", ",", "admin", "=", "False", ")", ":", "self", ".", "connect", "(", "password", "=", "self", ".", "get_mysql_root_password", "(", ")", ")", "if", "not", "self", ".", ...
Configure access to database for username from hostname.
[ "Configure", "access", "to", "database", "for", "username", "from", "hostname", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L428-L443
12,426
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
PerconaClusterHelper.human_to_bytes
def human_to_bytes(self, human): """Convert human readable configuration options to bytes.""" num_re = re.compile('^[0-9]+$') if num_re.match(human): return human factors = { 'K': 1024, 'M': 1048576, 'G': 1073741824, 'T': 10995...
python
def human_to_bytes(self, human): """Convert human readable configuration options to bytes.""" num_re = re.compile('^[0-9]+$') if num_re.match(human): return human factors = { 'K': 1024, 'M': 1048576, 'G': 1073741824, 'T': 10995...
[ "def", "human_to_bytes", "(", "self", ",", "human", ")", ":", "num_re", "=", "re", ".", "compile", "(", "'^[0-9]+$'", ")", "if", "num_re", ".", "match", "(", "human", ")", ":", "return", "human", "factors", "=", "{", "'K'", ":", "1024", ",", "'M'", ...
Convert human readable configuration options to bytes.
[ "Convert", "human", "readable", "configuration", "options", "to", "bytes", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L470-L494
12,427
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
PerconaClusterHelper.sys_mem_limit
def sys_mem_limit(self): """Determine the default memory limit for the current service unit.""" if platform.machine() in ['armv7l']: _mem_limit = self.human_to_bytes('2700M') # experimentally determined else: # Limit for x86 based 32bit systems _mem_limit = s...
python
def sys_mem_limit(self): """Determine the default memory limit for the current service unit.""" if platform.machine() in ['armv7l']: _mem_limit = self.human_to_bytes('2700M') # experimentally determined else: # Limit for x86 based 32bit systems _mem_limit = s...
[ "def", "sys_mem_limit", "(", "self", ")", ":", "if", "platform", ".", "machine", "(", ")", "in", "[", "'armv7l'", "]", ":", "_mem_limit", "=", "self", ".", "human_to_bytes", "(", "'2700M'", ")", "# experimentally determined", "else", ":", "# Limit for x86 base...
Determine the default memory limit for the current service unit.
[ "Determine", "the", "default", "memory", "limit", "for", "the", "current", "service", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L503-L511
12,428
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
PerconaClusterHelper.get_mem_total
def get_mem_total(self): """Calculate the total memory in the current service unit.""" with open('/proc/meminfo') as meminfo_file: for line in meminfo_file: key, mem = line.split(':', 2) if key == 'MemTotal': mtot, modifier = mem.strip().sp...
python
def get_mem_total(self): """Calculate the total memory in the current service unit.""" with open('/proc/meminfo') as meminfo_file: for line in meminfo_file: key, mem = line.split(':', 2) if key == 'MemTotal': mtot, modifier = mem.strip().sp...
[ "def", "get_mem_total", "(", "self", ")", ":", "with", "open", "(", "'/proc/meminfo'", ")", "as", "meminfo_file", ":", "for", "line", "in", "meminfo_file", ":", "key", ",", "mem", "=", "line", ".", "split", "(", "':'", ",", "2", ")", "if", "key", "==...
Calculate the total memory in the current service unit.
[ "Calculate", "the", "total", "memory", "in", "the", "current", "service", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L513-L520
12,429
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
PerconaClusterHelper.parse_config
def parse_config(self): """Parse charm configuration and calculate values for config files.""" config = config_get() mysql_config = {} if 'max-connections' in config: mysql_config['max_connections'] = config['max-connections'] if 'wait-timeout' in config: ...
python
def parse_config(self): """Parse charm configuration and calculate values for config files.""" config = config_get() mysql_config = {} if 'max-connections' in config: mysql_config['max_connections'] = config['max-connections'] if 'wait-timeout' in config: ...
[ "def", "parse_config", "(", "self", ")", ":", "config", "=", "config_get", "(", ")", "mysql_config", "=", "{", "}", "if", "'max-connections'", "in", "config", ":", "mysql_config", "[", "'max_connections'", "]", "=", "config", "[", "'max-connections'", "]", "...
Parse charm configuration and calculate values for config files.
[ "Parse", "charm", "configuration", "and", "calculate", "values", "for", "config", "files", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L522-L577
12,430
juju/charm-helpers
charmhelpers/contrib/storage/linux/loopback.py
create_loopback
def create_loopback(file_path): ''' Create a loopback device for a given backing file. :returns: str: Full path to new loopback device (eg, /dev/loop0) ''' file_path = os.path.abspath(file_path) check_call(['losetup', '--find', file_path]) for d, f in six.iteritems(loopback_devices()): ...
python
def create_loopback(file_path): ''' Create a loopback device for a given backing file. :returns: str: Full path to new loopback device (eg, /dev/loop0) ''' file_path = os.path.abspath(file_path) check_call(['losetup', '--find', file_path]) for d, f in six.iteritems(loopback_devices()): ...
[ "def", "create_loopback", "(", "file_path", ")", ":", "file_path", "=", "os", ".", "path", ".", "abspath", "(", "file_path", ")", "check_call", "(", "[", "'losetup'", ",", "'--find'", ",", "file_path", "]", ")", "for", "d", ",", "f", "in", "six", ".", ...
Create a loopback device for a given backing file. :returns: str: Full path to new loopback device (eg, /dev/loop0)
[ "Create", "a", "loopback", "device", "for", "a", "given", "backing", "file", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/loopback.py#L48-L58
12,431
juju/charm-helpers
charmhelpers/contrib/storage/linux/loopback.py
ensure_loopback_device
def ensure_loopback_device(path, size): ''' Ensure a loopback device exists for a given backing file path and size. If it a loopback device is not mapped to file, a new one will be created. TODO: Confirm size of found loopback device. :returns: str: Full path to the ensured loopback device (eg, /d...
python
def ensure_loopback_device(path, size): ''' Ensure a loopback device exists for a given backing file path and size. If it a loopback device is not mapped to file, a new one will be created. TODO: Confirm size of found loopback device. :returns: str: Full path to the ensured loopback device (eg, /d...
[ "def", "ensure_loopback_device", "(", "path", ",", "size", ")", ":", "for", "d", ",", "f", "in", "six", ".", "iteritems", "(", "loopback_devices", "(", ")", ")", ":", "if", "f", "==", "path", ":", "return", "d", "if", "not", "os", ".", "path", ".",...
Ensure a loopback device exists for a given backing file path and size. If it a loopback device is not mapped to file, a new one will be created. TODO: Confirm size of found loopback device. :returns: str: Full path to the ensured loopback device (eg, /dev/loop0)
[ "Ensure", "a", "loopback", "device", "exists", "for", "a", "given", "backing", "file", "path", "and", "size", ".", "If", "it", "a", "loopback", "device", "is", "not", "mapped", "to", "file", "a", "new", "one", "will", "be", "created", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/loopback.py#L61-L78
12,432
juju/charm-helpers
charmhelpers/contrib/peerstorage/__init__.py
leader_get
def leader_get(attribute=None, rid=None): """Wrapper to ensure that settings are migrated from the peer relation. This is to support upgrading an environment that does not support Juju leadership election to one that does. If a setting is not extant in the leader-get but is on the relation-get pee...
python
def leader_get(attribute=None, rid=None): """Wrapper to ensure that settings are migrated from the peer relation. This is to support upgrading an environment that does not support Juju leadership election to one that does. If a setting is not extant in the leader-get but is on the relation-get pee...
[ "def", "leader_get", "(", "attribute", "=", "None", ",", "rid", "=", "None", ")", ":", "migration_key", "=", "'__leader_get_migrated_settings__'", "if", "not", "is_leader", "(", ")", ":", "return", "_leader_get", "(", "attribute", "=", "attribute", ")", "setti...
Wrapper to ensure that settings are migrated from the peer relation. This is to support upgrading an environment that does not support Juju leadership election to one that does. If a setting is not extant in the leader-get but is on the relation-get peer rel, it is migrated and marked as such so that ...
[ "Wrapper", "to", "ensure", "that", "settings", "are", "migrated", "from", "the", "peer", "relation", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L60-L122
12,433
juju/charm-helpers
charmhelpers/contrib/peerstorage/__init__.py
relation_set
def relation_set(relation_id=None, relation_settings=None, **kwargs): """Attempt to use leader-set if supported in the current version of Juju, otherwise falls back on relation-set. Note that we only attempt to use leader-set if the provided relation_id is a peer relation id or no relation id is provid...
python
def relation_set(relation_id=None, relation_settings=None, **kwargs): """Attempt to use leader-set if supported in the current version of Juju, otherwise falls back on relation-set. Note that we only attempt to use leader-set if the provided relation_id is a peer relation id or no relation id is provid...
[ "def", "relation_set", "(", "relation_id", "=", "None", ",", "relation_settings", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "if", "relation_id", "in", "relation_ids", "(", "'cluster'", ")", ":", "return", "leader_set", "(", "settings", "=...
Attempt to use leader-set if supported in the current version of Juju, otherwise falls back on relation-set. Note that we only attempt to use leader-set if the provided relation_id is a peer relation id or no relation id is provided (in which case we assume we are within the peer relation context).
[ "Attempt", "to", "use", "leader", "-", "set", "if", "supported", "in", "the", "current", "version", "of", "Juju", "otherwise", "falls", "back", "on", "relation", "-", "set", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L125-L140
12,434
juju/charm-helpers
charmhelpers/contrib/peerstorage/__init__.py
relation_get
def relation_get(attribute=None, unit=None, rid=None): """Attempt to use leader-get if supported in the current version of Juju, otherwise falls back on relation-get. Note that we only attempt to use leader-get if the provided rid is a peer relation id or no relation id is provided (in which case we as...
python
def relation_get(attribute=None, unit=None, rid=None): """Attempt to use leader-get if supported in the current version of Juju, otherwise falls back on relation-get. Note that we only attempt to use leader-get if the provided rid is a peer relation id or no relation id is provided (in which case we as...
[ "def", "relation_get", "(", "attribute", "=", "None", ",", "unit", "=", "None", ",", "rid", "=", "None", ")", ":", "try", ":", "if", "rid", "in", "relation_ids", "(", "'cluster'", ")", ":", "return", "leader_get", "(", "attribute", ",", "rid", ")", "...
Attempt to use leader-get if supported in the current version of Juju, otherwise falls back on relation-get. Note that we only attempt to use leader-get if the provided rid is a peer relation id or no relation id is provided (in which case we assume we are within the peer relation context).
[ "Attempt", "to", "use", "leader", "-", "get", "if", "supported", "in", "the", "current", "version", "of", "Juju", "otherwise", "falls", "back", "on", "relation", "-", "get", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L143-L157
12,435
juju/charm-helpers
charmhelpers/contrib/peerstorage/__init__.py
peer_retrieve
def peer_retrieve(key, relation_name='cluster'): """Retrieve a named key from peer relation `relation_name`.""" cluster_rels = relation_ids(relation_name) if len(cluster_rels) > 0: cluster_rid = cluster_rels[0] return relation_get(attribute=key, rid=cluster_rid, u...
python
def peer_retrieve(key, relation_name='cluster'): """Retrieve a named key from peer relation `relation_name`.""" cluster_rels = relation_ids(relation_name) if len(cluster_rels) > 0: cluster_rid = cluster_rels[0] return relation_get(attribute=key, rid=cluster_rid, u...
[ "def", "peer_retrieve", "(", "key", ",", "relation_name", "=", "'cluster'", ")", ":", "cluster_rels", "=", "relation_ids", "(", "relation_name", ")", "if", "len", "(", "cluster_rels", ")", ">", "0", ":", "cluster_rid", "=", "cluster_rels", "[", "0", "]", "...
Retrieve a named key from peer relation `relation_name`.
[ "Retrieve", "a", "named", "key", "from", "peer", "relation", "relation_name", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L160-L169
12,436
juju/charm-helpers
charmhelpers/contrib/peerstorage/__init__.py
peer_echo
def peer_echo(includes=None, force=False): """Echo filtered attributes back onto the same relation for storage. This is a requirement to use the peerstorage module - it needs to be called from the peer relation's changed hook. If Juju leader support exists this will be a noop unless force is True. ...
python
def peer_echo(includes=None, force=False): """Echo filtered attributes back onto the same relation for storage. This is a requirement to use the peerstorage module - it needs to be called from the peer relation's changed hook. If Juju leader support exists this will be a noop unless force is True. ...
[ "def", "peer_echo", "(", "includes", "=", "None", ",", "force", "=", "False", ")", ":", "try", ":", "is_leader", "(", ")", "except", "NotImplementedError", ":", "pass", "else", ":", "if", "not", "force", ":", "return", "# NOOP if leader-election is supported",...
Echo filtered attributes back onto the same relation for storage. This is a requirement to use the peerstorage module - it needs to be called from the peer relation's changed hook. If Juju leader support exists this will be a noop unless force is True.
[ "Echo", "filtered", "attributes", "back", "onto", "the", "same", "relation", "for", "storage", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L204-L237
12,437
juju/charm-helpers
charmhelpers/contrib/peerstorage/__init__.py
peer_store_and_set
def peer_store_and_set(relation_id=None, peer_relation_name='cluster', peer_store_fatal=False, relation_settings=None, delimiter='_', **kwargs): """Store passed-in arguments both in argument relation and in peer storage. It functions like doing relation_set() and p...
python
def peer_store_and_set(relation_id=None, peer_relation_name='cluster', peer_store_fatal=False, relation_settings=None, delimiter='_', **kwargs): """Store passed-in arguments both in argument relation and in peer storage. It functions like doing relation_set() and p...
[ "def", "peer_store_and_set", "(", "relation_id", "=", "None", ",", "peer_relation_name", "=", "'cluster'", ",", "peer_store_fatal", "=", "False", ",", "relation_settings", "=", "None", ",", "delimiter", "=", "'_'", ",", "*", "*", "kwargs", ")", ":", "relation_...
Store passed-in arguments both in argument relation and in peer storage. It functions like doing relation_set() and peer_store() at the same time, with the same data. @param relation_id: the id of the relation to store the data on. Defaults to the current relation. @param peer_...
[ "Store", "passed", "-", "in", "arguments", "both", "in", "argument", "relation", "and", "in", "peer", "storage", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L240-L267
12,438
juju/charm-helpers
charmhelpers/core/files.py
sed
def sed(filename, before, after, flags='g'): """ Search and replaces the given pattern on filename. :param filename: relative or absolute file path. :param before: expression to be replaced (see 'man sed') :param after: expression to replace with (see 'man sed') :param flags: sed-compatible reg...
python
def sed(filename, before, after, flags='g'): """ Search and replaces the given pattern on filename. :param filename: relative or absolute file path. :param before: expression to be replaced (see 'man sed') :param after: expression to replace with (see 'man sed') :param flags: sed-compatible reg...
[ "def", "sed", "(", "filename", ",", "before", ",", "after", ",", "flags", "=", "'g'", ")", ":", "expression", "=", "r's/{0}/{1}/{2}'", ".", "format", "(", "before", ",", "after", ",", "flags", ")", "return", "subprocess", ".", "check_call", "(", "[", "...
Search and replaces the given pattern on filename. :param filename: relative or absolute file path. :param before: expression to be replaced (see 'man sed') :param after: expression to replace with (see 'man sed') :param flags: sed-compatible regex flags in example, to make the search and replace ...
[ "Search", "and", "replaces", "the", "given", "pattern", "on", "filename", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/files.py#L24-L43
12,439
juju/charm-helpers
charmhelpers/contrib/hardening/ssh/checks/config.py
SSHConfigContext.get_listening
def get_listening(self, listen=['0.0.0.0']): """Returns a list of addresses SSH can list on Turns input into a sensible list of IPs SSH can listen on. Input must be a python list of interface names, IPs and/or CIDRs. :param listen: list of IPs, CIDRs, interface names :returns:...
python
def get_listening(self, listen=['0.0.0.0']): """Returns a list of addresses SSH can list on Turns input into a sensible list of IPs SSH can listen on. Input must be a python list of interface names, IPs and/or CIDRs. :param listen: list of IPs, CIDRs, interface names :returns:...
[ "def", "get_listening", "(", "self", ",", "listen", "=", "[", "'0.0.0.0'", "]", ")", ":", "if", "listen", "==", "[", "'0.0.0.0'", "]", ":", "return", "listen", "value", "=", "[", "]", "for", "network", "in", "listen", ":", "try", ":", "ip", "=", "g...
Returns a list of addresses SSH can list on Turns input into a sensible list of IPs SSH can listen on. Input must be a python list of interface names, IPs and/or CIDRs. :param listen: list of IPs, CIDRs, interface names :returns: list of IPs available on the host
[ "Returns", "a", "list", "of", "addresses", "SSH", "can", "list", "on" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/ssh/checks/config.py#L135-L163
12,440
juju/charm-helpers
charmhelpers/contrib/openstack/templating.py
get_loader
def get_loader(templates_dir, os_release): """ Create a jinja2.ChoiceLoader containing template dirs up to and including os_release. If directory template directory is missing at templates_dir, it will be omitted from the loader. templates_dir is added to the bottom of the search list as a base ...
python
def get_loader(templates_dir, os_release): """ Create a jinja2.ChoiceLoader containing template dirs up to and including os_release. If directory template directory is missing at templates_dir, it will be omitted from the loader. templates_dir is added to the bottom of the search list as a base ...
[ "def", "get_loader", "(", "templates_dir", ",", "os_release", ")", ":", "tmpl_dirs", "=", "[", "(", "rel", ",", "os", ".", "path", ".", "join", "(", "templates_dir", ",", "rel", ")", ")", "for", "rel", "in", "six", ".", "itervalues", "(", "OPENSTACK_CO...
Create a jinja2.ChoiceLoader containing template dirs up to and including os_release. If directory template directory is missing at templates_dir, it will be omitted from the loader. templates_dir is added to the bottom of the search list as a base loading dir. A charm may also ship a templates di...
[ "Create", "a", "jinja2", ".", "ChoiceLoader", "containing", "template", "dirs", "up", "to", "and", "including", "os_release", ".", "If", "directory", "template", "directory", "is", "missing", "at", "templates_dir", "it", "will", "be", "omitted", "from", "the", ...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/templating.py#L43-L88
12,441
juju/charm-helpers
charmhelpers/contrib/openstack/templating.py
OSConfigTemplate.complete_contexts
def complete_contexts(self): ''' Return a list of interfaces that have satisfied contexts. ''' if self._complete_contexts: return self._complete_contexts self.context() return self._complete_contexts
python
def complete_contexts(self): ''' Return a list of interfaces that have satisfied contexts. ''' if self._complete_contexts: return self._complete_contexts self.context() return self._complete_contexts
[ "def", "complete_contexts", "(", "self", ")", ":", "if", "self", ".", "_complete_contexts", ":", "return", "self", ".", "_complete_contexts", "self", ".", "context", "(", ")", "return", "self", ".", "_complete_contexts" ]
Return a list of interfaces that have satisfied contexts.
[ "Return", "a", "list", "of", "interfaces", "that", "have", "satisfied", "contexts", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/templating.py#L121-L128
12,442
juju/charm-helpers
charmhelpers/contrib/openstack/templating.py
OSConfigRenderer.write
def write(self, config_file): """ Write a single config file, raises if config file is not registered. """ if config_file not in self.templates: log('Config not registered: %s' % config_file, level=ERROR) raise OSConfigException _out = self.render(config_...
python
def write(self, config_file): """ Write a single config file, raises if config file is not registered. """ if config_file not in self.templates: log('Config not registered: %s' % config_file, level=ERROR) raise OSConfigException _out = self.render(config_...
[ "def", "write", "(", "self", ",", "config_file", ")", ":", "if", "config_file", "not", "in", "self", ".", "templates", ":", "log", "(", "'Config not registered: %s'", "%", "config_file", ",", "level", "=", "ERROR", ")", "raise", "OSConfigException", "_out", ...
Write a single config file, raises if config file is not registered.
[ "Write", "a", "single", "config", "file", "raises", "if", "config", "file", "is", "not", "registered", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/templating.py#L313-L328
12,443
juju/charm-helpers
charmhelpers/contrib/openstack/templating.py
OSConfigRenderer.write_all
def write_all(self): """ Write out all registered config files. """ [self.write(k) for k in six.iterkeys(self.templates)]
python
def write_all(self): """ Write out all registered config files. """ [self.write(k) for k in six.iterkeys(self.templates)]
[ "def", "write_all", "(", "self", ")", ":", "[", "self", ".", "write", "(", "k", ")", "for", "k", "in", "six", ".", "iterkeys", "(", "self", ".", "templates", ")", "]" ]
Write out all registered config files.
[ "Write", "out", "all", "registered", "config", "files", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/templating.py#L330-L334
12,444
juju/charm-helpers
charmhelpers/contrib/openstack/templating.py
OSConfigRenderer.set_release
def set_release(self, openstack_release): """ Resets the template environment and generates a new template loader based on a the new openstack release. """ self._tmpl_env = None self.openstack_release = openstack_release self._get_tmpl_env()
python
def set_release(self, openstack_release): """ Resets the template environment and generates a new template loader based on a the new openstack release. """ self._tmpl_env = None self.openstack_release = openstack_release self._get_tmpl_env()
[ "def", "set_release", "(", "self", ",", "openstack_release", ")", ":", "self", ".", "_tmpl_env", "=", "None", "self", ".", "openstack_release", "=", "openstack_release", "self", ".", "_get_tmpl_env", "(", ")" ]
Resets the template environment and generates a new template loader based on a the new openstack release.
[ "Resets", "the", "template", "environment", "and", "generates", "a", "new", "template", "loader", "based", "on", "a", "the", "new", "openstack", "release", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/templating.py#L336-L343
12,445
juju/charm-helpers
charmhelpers/contrib/openstack/templating.py
OSConfigRenderer.complete_contexts
def complete_contexts(self): ''' Returns a list of context interfaces that yield a complete context. ''' interfaces = [] [interfaces.extend(i.complete_contexts()) for i in six.itervalues(self.templates)] return interfaces
python
def complete_contexts(self): ''' Returns a list of context interfaces that yield a complete context. ''' interfaces = [] [interfaces.extend(i.complete_contexts()) for i in six.itervalues(self.templates)] return interfaces
[ "def", "complete_contexts", "(", "self", ")", ":", "interfaces", "=", "[", "]", "[", "interfaces", ".", "extend", "(", "i", ".", "complete_contexts", "(", ")", ")", "for", "i", "in", "six", ".", "itervalues", "(", "self", ".", "templates", ")", "]", ...
Returns a list of context interfaces that yield a complete context.
[ "Returns", "a", "list", "of", "context", "interfaces", "that", "yield", "a", "complete", "context", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/templating.py#L345-L352
12,446
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
is_elected_leader
def is_elected_leader(resource): """ Returns True if the charm executing this is the elected cluster leader. It relies on two mechanisms to determine leadership: 1. If juju is sufficiently new and leadership election is supported, the is_leader command will be used. 2. If the charm ...
python
def is_elected_leader(resource): """ Returns True if the charm executing this is the elected cluster leader. It relies on two mechanisms to determine leadership: 1. If juju is sufficiently new and leadership election is supported, the is_leader command will be used. 2. If the charm ...
[ "def", "is_elected_leader", "(", "resource", ")", ":", "try", ":", "return", "juju_is_leader", "(", ")", "except", "NotImplementedError", ":", "log", "(", "'Juju leadership election feature not enabled'", "', using fallback support'", ",", "level", "=", "WARNING", ")", ...
Returns True if the charm executing this is the elected cluster leader. It relies on two mechanisms to determine leadership: 1. If juju is sufficiently new and leadership election is supported, the is_leader command will be used. 2. If the charm is part of a corosync cluster, call corosync ...
[ "Returns", "True", "if", "the", "charm", "executing", "this", "is", "the", "elected", "cluster", "leader", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L78-L107
12,447
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
is_crm_dc
def is_crm_dc(): """ Determine leadership by querying the pacemaker Designated Controller """ cmd = ['crm', 'status'] try: status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) if not isinstance(status, six.text_type): status = six.text_type(status, "utf-8") ...
python
def is_crm_dc(): """ Determine leadership by querying the pacemaker Designated Controller """ cmd = ['crm', 'status'] try: status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) if not isinstance(status, six.text_type): status = six.text_type(status, "utf-8") ...
[ "def", "is_crm_dc", "(", ")", ":", "cmd", "=", "[", "'crm'", ",", "'status'", "]", "try", ":", "status", "=", "subprocess", ".", "check_output", "(", "cmd", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", "if", "not", "isinstance", "(", "status",...
Determine leadership by querying the pacemaker Designated Controller
[ "Determine", "leadership", "by", "querying", "the", "pacemaker", "Designated", "Controller" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L121-L143
12,448
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
is_crm_leader
def is_crm_leader(resource, retry=False): """ Returns True if the charm calling this is the elected corosync leader, as returned by calling the external "crm" command. We allow this operation to be retried to avoid the possibility of getting a false negative. See LP #1396246 for more info. """ ...
python
def is_crm_leader(resource, retry=False): """ Returns True if the charm calling this is the elected corosync leader, as returned by calling the external "crm" command. We allow this operation to be retried to avoid the possibility of getting a false negative. See LP #1396246 for more info. """ ...
[ "def", "is_crm_leader", "(", "resource", ",", "retry", "=", "False", ")", ":", "if", "resource", "==", "DC_RESOURCE_NAME", ":", "return", "is_crm_dc", "(", ")", "cmd", "=", "[", "'crm'", ",", "'resource'", ",", "'show'", ",", "resource", "]", "try", ":",...
Returns True if the charm calling this is the elected corosync leader, as returned by calling the external "crm" command. We allow this operation to be retried to avoid the possibility of getting a false negative. See LP #1396246 for more info.
[ "Returns", "True", "if", "the", "charm", "calling", "this", "is", "the", "elected", "corosync", "leader", "as", "returned", "by", "calling", "the", "external", "crm", "command", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L148-L172
12,449
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
peer_ips
def peer_ips(peer_relation='cluster', addr_key='private-address'): '''Return a dict of peers and their private-address''' peers = {} for r_id in relation_ids(peer_relation): for unit in relation_list(r_id): peers[unit] = relation_get(addr_key, rid=r_id, unit=unit) return peers
python
def peer_ips(peer_relation='cluster', addr_key='private-address'): '''Return a dict of peers and their private-address''' peers = {} for r_id in relation_ids(peer_relation): for unit in relation_list(r_id): peers[unit] = relation_get(addr_key, rid=r_id, unit=unit) return peers
[ "def", "peer_ips", "(", "peer_relation", "=", "'cluster'", ",", "addr_key", "=", "'private-address'", ")", ":", "peers", "=", "{", "}", "for", "r_id", "in", "relation_ids", "(", "peer_relation", ")", ":", "for", "unit", "in", "relation_list", "(", "r_id", ...
Return a dict of peers and their private-address
[ "Return", "a", "dict", "of", "peers", "and", "their", "private", "-", "address" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L189-L195
12,450
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
oldest_peer
def oldest_peer(peers): """Determines who the oldest peer is by comparing unit numbers.""" local_unit_no = int(os.getenv('JUJU_UNIT_NAME').split('/')[1]) for peer in peers: remote_unit_no = int(peer.split('/')[1]) if remote_unit_no < local_unit_no: return False return True
python
def oldest_peer(peers): """Determines who the oldest peer is by comparing unit numbers.""" local_unit_no = int(os.getenv('JUJU_UNIT_NAME').split('/')[1]) for peer in peers: remote_unit_no = int(peer.split('/')[1]) if remote_unit_no < local_unit_no: return False return True
[ "def", "oldest_peer", "(", "peers", ")", ":", "local_unit_no", "=", "int", "(", "os", ".", "getenv", "(", "'JUJU_UNIT_NAME'", ")", ".", "split", "(", "'/'", ")", "[", "1", "]", ")", "for", "peer", "in", "peers", ":", "remote_unit_no", "=", "int", "("...
Determines who the oldest peer is by comparing unit numbers.
[ "Determines", "who", "the", "oldest", "peer", "is", "by", "comparing", "unit", "numbers", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L198-L205
12,451
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
canonical_url
def canonical_url(configs, vip_setting='vip'): ''' Returns the correct HTTP URL to this host given the state of HTTPS configuration and hacluster. :configs : OSTemplateRenderer: A config tempating object to inspect for a complete https context. :vip_setting...
python
def canonical_url(configs, vip_setting='vip'): ''' Returns the correct HTTP URL to this host given the state of HTTPS configuration and hacluster. :configs : OSTemplateRenderer: A config tempating object to inspect for a complete https context. :vip_setting...
[ "def", "canonical_url", "(", "configs", ",", "vip_setting", "=", "'vip'", ")", ":", "scheme", "=", "'http'", "if", "'https'", "in", "configs", ".", "complete_contexts", "(", ")", ":", "scheme", "=", "'https'", "if", "is_clustered", "(", ")", ":", "addr", ...
Returns the correct HTTP URL to this host given the state of HTTPS configuration and hacluster. :configs : OSTemplateRenderer: A config tempating object to inspect for a complete https context. :vip_setting: str: Setting in charm config that specifie...
[ "Returns", "the", "correct", "HTTP", "URL", "to", "this", "host", "given", "the", "state", "of", "HTTPS", "configuration", "and", "hacluster", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L354-L372
12,452
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
distributed_wait
def distributed_wait(modulo=None, wait=None, operation_name='operation'): ''' Distribute operations by waiting based on modulo_distribution If modulo and or wait are not set, check config_get for those values. If config values are not set, default to modulo=3 and wait=30. :param modulo: int The modulo...
python
def distributed_wait(modulo=None, wait=None, operation_name='operation'): ''' Distribute operations by waiting based on modulo_distribution If modulo and or wait are not set, check config_get for those values. If config values are not set, default to modulo=3 and wait=30. :param modulo: int The modulo...
[ "def", "distributed_wait", "(", "modulo", "=", "None", ",", "wait", "=", "None", ",", "operation_name", "=", "'operation'", ")", ":", "if", "modulo", "is", "None", ":", "modulo", "=", "config_get", "(", "'modulo-nodes'", ")", "or", "3", "if", "wait", "is...
Distribute operations by waiting based on modulo_distribution If modulo and or wait are not set, check config_get for those values. If config values are not set, default to modulo=3 and wait=30. :param modulo: int The modulo number creates the group distribution :param wait: int The constant time wait...
[ "Distribute", "operations", "by", "waiting", "based", "on", "modulo_distribution" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L375-L406
12,453
juju/charm-helpers
charmhelpers/fetch/centos.py
update
def update(fatal=False): """Update local yum cache.""" cmd = ['yum', '--assumeyes', 'update'] log("Update with fatal: {}".format(fatal)) _run_yum_command(cmd, fatal)
python
def update(fatal=False): """Update local yum cache.""" cmd = ['yum', '--assumeyes', 'update'] log("Update with fatal: {}".format(fatal)) _run_yum_command(cmd, fatal)
[ "def", "update", "(", "fatal", "=", "False", ")", ":", "cmd", "=", "[", "'yum'", ",", "'--assumeyes'", ",", "'update'", "]", "log", "(", "\"Update with fatal: {}\"", ".", "format", "(", "fatal", ")", ")", "_run_yum_command", "(", "cmd", ",", "fatal", ")"...
Update local yum cache.
[ "Update", "local", "yum", "cache", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/centos.py#L64-L68
12,454
juju/charm-helpers
charmhelpers/fetch/centos.py
yum_search
def yum_search(packages): """Search for a package.""" output = {} cmd = ['yum', 'search'] if isinstance(packages, six.string_types): cmd.append(packages) else: cmd.extend(packages) log("Searching for {}".format(packages)) result = subprocess.check_output(cmd) for package ...
python
def yum_search(packages): """Search for a package.""" output = {} cmd = ['yum', 'search'] if isinstance(packages, six.string_types): cmd.append(packages) else: cmd.extend(packages) log("Searching for {}".format(packages)) result = subprocess.check_output(cmd) for package ...
[ "def", "yum_search", "(", "packages", ")", ":", "output", "=", "{", "}", "cmd", "=", "[", "'yum'", ",", "'search'", "]", "if", "isinstance", "(", "packages", ",", "six", ".", "string_types", ")", ":", "cmd", ".", "append", "(", "packages", ")", "else...
Search for a package.
[ "Search", "for", "a", "package", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/centos.py#L82-L94
12,455
juju/charm-helpers
charmhelpers/fetch/centos.py
_run_yum_command
def _run_yum_command(cmd, fatal=False): """Run an YUM command. Checks the output and retry if the fatal flag is set to True. :param: cmd: str: The yum command to run. :param: fatal: bool: Whether the command's output should be checked and retried. """ env = os.environ.copy() if fa...
python
def _run_yum_command(cmd, fatal=False): """Run an YUM command. Checks the output and retry if the fatal flag is set to True. :param: cmd: str: The yum command to run. :param: fatal: bool: Whether the command's output should be checked and retried. """ env = os.environ.copy() if fa...
[ "def", "_run_yum_command", "(", "cmd", ",", "fatal", "=", "False", ")", ":", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "fatal", ":", "retry_count", "=", "0", "result", "=", "None", "# If the command is considered \"fatal\", we need to retr...
Run an YUM command. Checks the output and retry if the fatal flag is set to True. :param: cmd: str: The yum command to run. :param: fatal: bool: Whether the command's output should be checked and retried.
[ "Run", "an", "YUM", "command", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/centos.py#L140-L171
12,456
juju/charm-helpers
charmhelpers/cli/__init__.py
OutputFormatter.py
def py(self, output): """Output data as a nicely-formatted python data structure""" import pprint pprint.pprint(output, stream=self.outfile)
python
def py(self, output): """Output data as a nicely-formatted python data structure""" import pprint pprint.pprint(output, stream=self.outfile)
[ "def", "py", "(", "self", ",", "output", ")", ":", "import", "pprint", "pprint", ".", "pprint", "(", "output", ",", "stream", "=", "self", ".", "outfile", ")" ]
Output data as a nicely-formatted python data structure
[ "Output", "data", "as", "a", "nicely", "-", "formatted", "python", "data", "structure" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/cli/__init__.py#L60-L63
12,457
juju/charm-helpers
charmhelpers/cli/__init__.py
OutputFormatter.csv
def csv(self, output): """Output data as excel-compatible CSV""" import csv csvwriter = csv.writer(self.outfile) csvwriter.writerows(output)
python
def csv(self, output): """Output data as excel-compatible CSV""" import csv csvwriter = csv.writer(self.outfile) csvwriter.writerows(output)
[ "def", "csv", "(", "self", ",", "output", ")", ":", "import", "csv", "csvwriter", "=", "csv", ".", "writer", "(", "self", ".", "outfile", ")", "csvwriter", ".", "writerows", "(", "output", ")" ]
Output data as excel-compatible CSV
[ "Output", "data", "as", "excel", "-", "compatible", "CSV" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/cli/__init__.py#L75-L79
12,458
juju/charm-helpers
charmhelpers/cli/__init__.py
OutputFormatter.tab
def tab(self, output): """Output data in excel-compatible tab-delimited format""" import csv csvwriter = csv.writer(self.outfile, dialect=csv.excel_tab) csvwriter.writerows(output)
python
def tab(self, output): """Output data in excel-compatible tab-delimited format""" import csv csvwriter = csv.writer(self.outfile, dialect=csv.excel_tab) csvwriter.writerows(output)
[ "def", "tab", "(", "self", ",", "output", ")", ":", "import", "csv", "csvwriter", "=", "csv", ".", "writer", "(", "self", ".", "outfile", ",", "dialect", "=", "csv", ".", "excel_tab", ")", "csvwriter", ".", "writerows", "(", "output", ")" ]
Output data in excel-compatible tab-delimited format
[ "Output", "data", "in", "excel", "-", "compatible", "tab", "-", "delimited", "format" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/cli/__init__.py#L81-L85
12,459
juju/charm-helpers
charmhelpers/cli/__init__.py
CommandLine.subcommand
def subcommand(self, command_name=None): """ Decorate a function as a subcommand. Use its arguments as the command-line arguments""" def wrapper(decorated): cmd_name = command_name or decorated.__name__ subparser = self.subparsers.add_parser(cmd_name, ...
python
def subcommand(self, command_name=None): """ Decorate a function as a subcommand. Use its arguments as the command-line arguments""" def wrapper(decorated): cmd_name = command_name or decorated.__name__ subparser = self.subparsers.add_parser(cmd_name, ...
[ "def", "subcommand", "(", "self", ",", "command_name", "=", "None", ")", ":", "def", "wrapper", "(", "decorated", ")", ":", "cmd_name", "=", "command_name", "or", "decorated", ".", "__name__", "subparser", "=", "self", ".", "subparsers", ".", "add_parser", ...
Decorate a function as a subcommand. Use its arguments as the command-line arguments
[ "Decorate", "a", "function", "as", "a", "subcommand", ".", "Use", "its", "arguments", "as", "the", "command", "-", "line", "arguments" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/cli/__init__.py#L107-L119
12,460
juju/charm-helpers
charmhelpers/cli/__init__.py
CommandLine.run
def run(self): "Run cli, processing arguments and executing subcommands." arguments = self.argument_parser.parse_args() argspec = inspect.getargspec(arguments.func) vargs = [] for arg in argspec.args: vargs.append(getattr(arguments, arg)) if argspec.varargs: ...
python
def run(self): "Run cli, processing arguments and executing subcommands." arguments = self.argument_parser.parse_args() argspec = inspect.getargspec(arguments.func) vargs = [] for arg in argspec.args: vargs.append(getattr(arguments, arg)) if argspec.varargs: ...
[ "def", "run", "(", "self", ")", ":", "arguments", "=", "self", ".", "argument_parser", ".", "parse_args", "(", ")", "argspec", "=", "inspect", ".", "getargspec", "(", "arguments", ".", "func", ")", "vargs", "=", "[", "]", "for", "arg", "in", "argspec",...
Run cli, processing arguments and executing subcommands.
[ "Run", "cli", "processing", "arguments", "and", "executing", "subcommands", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/cli/__init__.py#L148-L165
12,461
juju/charm-helpers
charmhelpers/contrib/unison/__init__.py
ssh_authorized_peers
def ssh_authorized_peers(peer_interface, user, group=None, ensure_local_user=False): """ Main setup function, should be called from both peer -changed and -joined hooks with the same parameters. """ if ensure_local_user: ensure_user(user, group) priv_key, pub_key...
python
def ssh_authorized_peers(peer_interface, user, group=None, ensure_local_user=False): """ Main setup function, should be called from both peer -changed and -joined hooks with the same parameters. """ if ensure_local_user: ensure_user(user, group) priv_key, pub_key...
[ "def", "ssh_authorized_peers", "(", "peer_interface", ",", "user", ",", "group", "=", "None", ",", "ensure_local_user", "=", "False", ")", ":", "if", "ensure_local_user", ":", "ensure_user", "(", "user", ",", "group", ")", "priv_key", ",", "pub_key", "=", "g...
Main setup function, should be called from both peer -changed and -joined hooks with the same parameters.
[ "Main", "setup", "function", "should", "be", "called", "from", "both", "peer", "-", "changed", "and", "-", "joined", "hooks", "with", "the", "same", "parameters", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/unison/__init__.py#L185-L219
12,462
juju/charm-helpers
charmhelpers/contrib/unison/__init__.py
collect_authed_hosts
def collect_authed_hosts(peer_interface): '''Iterate through the units on peer interface to find all that have the calling host in its authorized hosts list''' hosts = [] for r_id in (relation_ids(peer_interface) or []): for unit in related_units(r_id): private_addr = relation_get('p...
python
def collect_authed_hosts(peer_interface): '''Iterate through the units on peer interface to find all that have the calling host in its authorized hosts list''' hosts = [] for r_id in (relation_ids(peer_interface) or []): for unit in related_units(r_id): private_addr = relation_get('p...
[ "def", "collect_authed_hosts", "(", "peer_interface", ")", ":", "hosts", "=", "[", "]", "for", "r_id", "in", "(", "relation_ids", "(", "peer_interface", ")", "or", "[", "]", ")", ":", "for", "unit", "in", "related_units", "(", "r_id", ")", ":", "private_...
Iterate through the units on peer interface to find all that have the calling host in its authorized hosts list
[ "Iterate", "through", "the", "units", "on", "peer", "interface", "to", "find", "all", "that", "have", "the", "calling", "host", "in", "its", "authorized", "hosts", "list" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/unison/__init__.py#L242-L263
12,463
juju/charm-helpers
charmhelpers/contrib/unison/__init__.py
sync_path_to_host
def sync_path_to_host(path, host, user, verbose=False, cmd=None, gid=None, fatal=False): """Sync path to an specific peer host Propagates exception if operation fails and fatal=True. """ cmd = cmd or copy(BASE_CMD) if not verbose: cmd.append('-silent') # removing ...
python
def sync_path_to_host(path, host, user, verbose=False, cmd=None, gid=None, fatal=False): """Sync path to an specific peer host Propagates exception if operation fails and fatal=True. """ cmd = cmd or copy(BASE_CMD) if not verbose: cmd.append('-silent') # removing ...
[ "def", "sync_path_to_host", "(", "path", ",", "host", ",", "user", ",", "verbose", "=", "False", ",", "cmd", "=", "None", ",", "gid", "=", "None", ",", "fatal", "=", "False", ")", ":", "cmd", "=", "cmd", "or", "copy", "(", "BASE_CMD", ")", "if", ...
Sync path to an specific peer host Propagates exception if operation fails and fatal=True.
[ "Sync", "path", "to", "an", "specific", "peer", "host" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/unison/__init__.py#L266-L289
12,464
juju/charm-helpers
charmhelpers/contrib/unison/__init__.py
sync_to_peer
def sync_to_peer(host, user, paths=None, verbose=False, cmd=None, gid=None, fatal=False): """Sync paths to an specific peer host Propagates exception if any operation fails and fatal=True. """ if paths: for p in paths: sync_path_to_host(p, host, user, verbose, cmd, ...
python
def sync_to_peer(host, user, paths=None, verbose=False, cmd=None, gid=None, fatal=False): """Sync paths to an specific peer host Propagates exception if any operation fails and fatal=True. """ if paths: for p in paths: sync_path_to_host(p, host, user, verbose, cmd, ...
[ "def", "sync_to_peer", "(", "host", ",", "user", ",", "paths", "=", "None", ",", "verbose", "=", "False", ",", "cmd", "=", "None", ",", "gid", "=", "None", ",", "fatal", "=", "False", ")", ":", "if", "paths", ":", "for", "p", "in", "paths", ":", ...
Sync paths to an specific peer host Propagates exception if any operation fails and fatal=True.
[ "Sync", "paths", "to", "an", "specific", "peer", "host" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/unison/__init__.py#L292-L300
12,465
juju/charm-helpers
charmhelpers/contrib/unison/__init__.py
sync_to_peers
def sync_to_peers(peer_interface, user, paths=None, verbose=False, cmd=None, gid=None, fatal=False): """Sync all hosts to an specific path The type of group is integer, it allows user has permissions to operate a directory have a different group id with the user id. Propagates except...
python
def sync_to_peers(peer_interface, user, paths=None, verbose=False, cmd=None, gid=None, fatal=False): """Sync all hosts to an specific path The type of group is integer, it allows user has permissions to operate a directory have a different group id with the user id. Propagates except...
[ "def", "sync_to_peers", "(", "peer_interface", ",", "user", ",", "paths", "=", "None", ",", "verbose", "=", "False", ",", "cmd", "=", "None", ",", "gid", "=", "None", ",", "fatal", "=", "False", ")", ":", "if", "paths", ":", "for", "host", "in", "c...
Sync all hosts to an specific path The type of group is integer, it allows user has permissions to operate a directory have a different group id with the user id. Propagates exception if any operation fails and fatal=True.
[ "Sync", "all", "hosts", "to", "an", "specific", "path" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/unison/__init__.py#L303-L314
12,466
juju/charm-helpers
charmhelpers/fetch/python/packages.py
parse_options
def parse_options(given, available): """Given a set of options, check if available""" for key, value in sorted(given.items()): if not value: continue if key in available: yield "--{0}={1}".format(key, value)
python
def parse_options(given, available): """Given a set of options, check if available""" for key, value in sorted(given.items()): if not value: continue if key in available: yield "--{0}={1}".format(key, value)
[ "def", "parse_options", "(", "given", ",", "available", ")", ":", "for", "key", ",", "value", "in", "sorted", "(", "given", ".", "items", "(", ")", ")", ":", "if", "not", "value", ":", "continue", "if", "key", "in", "available", ":", "yield", "\"--{0...
Given a set of options, check if available
[ "Given", "a", "set", "of", "options", "check", "if", "available" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/python/packages.py#L53-L59
12,467
juju/charm-helpers
charmhelpers/fetch/python/packages.py
pip_install_requirements
def pip_install_requirements(requirements, constraints=None, **options): """Install a requirements file. :param constraints: Path to pip constraints file. http://pip.readthedocs.org/en/stable/user_guide/#constraints-files """ command = ["install"] available_options = ('proxy', 'src', 'log', ) ...
python
def pip_install_requirements(requirements, constraints=None, **options): """Install a requirements file. :param constraints: Path to pip constraints file. http://pip.readthedocs.org/en/stable/user_guide/#constraints-files """ command = ["install"] available_options = ('proxy', 'src', 'log', ) ...
[ "def", "pip_install_requirements", "(", "requirements", ",", "constraints", "=", "None", ",", "*", "*", "options", ")", ":", "command", "=", "[", "\"install\"", "]", "available_options", "=", "(", "'proxy'", ",", "'src'", ",", "'log'", ",", ")", "for", "op...
Install a requirements file. :param constraints: Path to pip constraints file. http://pip.readthedocs.org/en/stable/user_guide/#constraints-files
[ "Install", "a", "requirements", "file", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/python/packages.py#L62-L82
12,468
juju/charm-helpers
charmhelpers/fetch/python/packages.py
pip_install
def pip_install(package, fatal=False, upgrade=False, venv=None, constraints=None, **options): """Install a python package""" if venv: venv_python = os.path.join(venv, 'bin/pip') command = [venv_python, "install"] else: command = ["install"] available_options = ('...
python
def pip_install(package, fatal=False, upgrade=False, venv=None, constraints=None, **options): """Install a python package""" if venv: venv_python = os.path.join(venv, 'bin/pip') command = [venv_python, "install"] else: command = ["install"] available_options = ('...
[ "def", "pip_install", "(", "package", ",", "fatal", "=", "False", ",", "upgrade", "=", "False", ",", "venv", "=", "None", ",", "constraints", "=", "None", ",", "*", "*", "options", ")", ":", "if", "venv", ":", "venv_python", "=", "os", ".", "path", ...
Install a python package
[ "Install", "a", "python", "package" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/python/packages.py#L85-L114
12,469
juju/charm-helpers
charmhelpers/fetch/python/packages.py
pip_uninstall
def pip_uninstall(package, **options): """Uninstall a python package""" command = ["uninstall", "-q", "-y"] available_options = ('proxy', 'log', ) for option in parse_options(options, available_options): command.append(option) if isinstance(package, list): command.extend(package) ...
python
def pip_uninstall(package, **options): """Uninstall a python package""" command = ["uninstall", "-q", "-y"] available_options = ('proxy', 'log', ) for option in parse_options(options, available_options): command.append(option) if isinstance(package, list): command.extend(package) ...
[ "def", "pip_uninstall", "(", "package", ",", "*", "*", "options", ")", ":", "command", "=", "[", "\"uninstall\"", ",", "\"-q\"", ",", "\"-y\"", "]", "available_options", "=", "(", "'proxy'", ",", "'log'", ",", ")", "for", "option", "in", "parse_options", ...
Uninstall a python package
[ "Uninstall", "a", "python", "package" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/python/packages.py#L117-L132
12,470
juju/charm-helpers
charmhelpers/fetch/python/packages.py
pip_create_virtualenv
def pip_create_virtualenv(path=None): """Create an isolated Python environment.""" if six.PY2: apt_install('python-virtualenv') else: apt_install('python3-virtualenv') if path: venv_path = path else: venv_path = os.path.join(charm_dir(), 'venv') if not os.path.e...
python
def pip_create_virtualenv(path=None): """Create an isolated Python environment.""" if six.PY2: apt_install('python-virtualenv') else: apt_install('python3-virtualenv') if path: venv_path = path else: venv_path = os.path.join(charm_dir(), 'venv') if not os.path.e...
[ "def", "pip_create_virtualenv", "(", "path", "=", "None", ")", ":", "if", "six", ".", "PY2", ":", "apt_install", "(", "'python-virtualenv'", ")", "else", ":", "apt_install", "(", "'python3-virtualenv'", ")", "if", "path", ":", "venv_path", "=", "path", "else...
Create an isolated Python environment.
[ "Create", "an", "isolated", "Python", "environment", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/python/packages.py#L141-L154
12,471
juju/charm-helpers
charmhelpers/fetch/__init__.py
configure_sources
def configure_sources(update=False, sources_var='install_sources', keys_var='install_keys'): """Configure multiple sources from charm configuration. The lists are encoded as yaml fragments in the configuration. The fragment needs to be included as a string. Sourc...
python
def configure_sources(update=False, sources_var='install_sources', keys_var='install_keys'): """Configure multiple sources from charm configuration. The lists are encoded as yaml fragments in the configuration. The fragment needs to be included as a string. Sourc...
[ "def", "configure_sources", "(", "update", "=", "False", ",", "sources_var", "=", "'install_sources'", ",", "keys_var", "=", "'install_keys'", ")", ":", "sources", "=", "safe_load", "(", "(", "config", "(", "sources_var", ")", "or", "''", ")", ".", "strip", ...
Configure multiple sources from charm configuration. The lists are encoded as yaml fragments in the configuration. The fragment needs to be included as a string. Sources and their corresponding keys are of the types supported by add_source(). Example config: install_sources: | - "ppa...
[ "Configure", "multiple", "sources", "from", "charm", "configuration", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/__init__.py#L110-L148
12,472
juju/charm-helpers
charmhelpers/fetch/__init__.py
install_remote
def install_remote(source, *args, **kwargs): """Install a file tree from a remote source. The specified source should be a url of the form: scheme://[host]/path[#[option=value][&...]] Schemes supported are based on this modules submodules. Options supported are submodule-specific. Addition...
python
def install_remote(source, *args, **kwargs): """Install a file tree from a remote source. The specified source should be a url of the form: scheme://[host]/path[#[option=value][&...]] Schemes supported are based on this modules submodules. Options supported are submodule-specific. Addition...
[ "def", "install_remote", "(", "source", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# We ONLY check for True here because can_handle may return a string", "# explaining why it can't handle a given source.", "handlers", "=", "[", "h", "for", "h", "in", "plugins",...
Install a file tree from a remote source. The specified source should be a url of the form: scheme://[host]/path[#[option=value][&...]] Schemes supported are based on this modules submodules. Options supported are submodule-specific. Additional arguments are passed through to the submodule. ...
[ "Install", "a", "file", "tree", "from", "a", "remote", "source", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/__init__.py#L151-L181
12,473
juju/charm-helpers
charmhelpers/fetch/__init__.py
BaseFetchHandler.base_url
def base_url(self, url): """Return url without querystring or fragment""" parts = list(self.parse_url(url)) parts[4:] = ['' for i in parts[4:]] return urlunparse(parts)
python
def base_url(self, url): """Return url without querystring or fragment""" parts = list(self.parse_url(url)) parts[4:] = ['' for i in parts[4:]] return urlunparse(parts)
[ "def", "base_url", "(", "self", ",", "url", ")", ":", "parts", "=", "list", "(", "self", ".", "parse_url", "(", "url", ")", ")", "parts", "[", "4", ":", "]", "=", "[", "''", "for", "i", "in", "parts", "[", "4", ":", "]", "]", "return", "urlun...
Return url without querystring or fragment
[ "Return", "url", "without", "querystring", "or", "fragment" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/__init__.py#L75-L79
12,474
juju/charm-helpers
charmhelpers/contrib/storage/linux/utils.py
is_block_device
def is_block_device(path): ''' Confirm device at path is a valid block device node. :returns: boolean: True if path is a block device, False if not. ''' if not os.path.exists(path): return False return S_ISBLK(os.stat(path).st_mode)
python
def is_block_device(path): ''' Confirm device at path is a valid block device node. :returns: boolean: True if path is a block device, False if not. ''' if not os.path.exists(path): return False return S_ISBLK(os.stat(path).st_mode)
[ "def", "is_block_device", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "False", "return", "S_ISBLK", "(", "os", ".", "stat", "(", "path", ")", ".", "st_mode", ")" ]
Confirm device at path is a valid block device node. :returns: boolean: True if path is a block device, False if not.
[ "Confirm", "device", "at", "path", "is", "a", "valid", "block", "device", "node", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/utils.py#L67-L75
12,475
juju/charm-helpers
charmhelpers/contrib/storage/linux/utils.py
zap_disk
def zap_disk(block_device): ''' Clear a block device of partition table. Relies on sgdisk, which is installed as pat of the 'gdisk' package in Ubuntu. :param block_device: str: Full path of block device to clean. ''' # https://github.com/ceph/ceph/commit/fdd7f8d83afa25c4e09aaedd90ab93f3b64a677b...
python
def zap_disk(block_device): ''' Clear a block device of partition table. Relies on sgdisk, which is installed as pat of the 'gdisk' package in Ubuntu. :param block_device: str: Full path of block device to clean. ''' # https://github.com/ceph/ceph/commit/fdd7f8d83afa25c4e09aaedd90ab93f3b64a677b...
[ "def", "zap_disk", "(", "block_device", ")", ":", "# https://github.com/ceph/ceph/commit/fdd7f8d83afa25c4e09aaedd90ab93f3b64a677b", "# sometimes sgdisk exits non-zero; this is OK, dd will clean up", "call", "(", "[", "'sgdisk'", ",", "'--zap-all'", ",", "'--'", ",", "block_device",...
Clear a block device of partition table. Relies on sgdisk, which is installed as pat of the 'gdisk' package in Ubuntu. :param block_device: str: Full path of block device to clean.
[ "Clear", "a", "block", "device", "of", "partition", "table", ".", "Relies", "on", "sgdisk", "which", "is", "installed", "as", "pat", "of", "the", "gdisk", "package", "in", "Ubuntu", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/utils.py#L78-L95
12,476
juju/charm-helpers
charmhelpers/contrib/storage/linux/utils.py
is_device_mounted
def is_device_mounted(device): '''Given a device path, return True if that device is mounted, and False if it isn't. :param device: str: Full path of the device to check. :returns: boolean: True if the path represents a mounted device, False if it doesn't. ''' try: out = check_o...
python
def is_device_mounted(device): '''Given a device path, return True if that device is mounted, and False if it isn't. :param device: str: Full path of the device to check. :returns: boolean: True if the path represents a mounted device, False if it doesn't. ''' try: out = check_o...
[ "def", "is_device_mounted", "(", "device", ")", ":", "try", ":", "out", "=", "check_output", "(", "[", "'lsblk'", ",", "'-P'", ",", "device", "]", ")", ".", "decode", "(", "'UTF-8'", ")", "except", "Exception", ":", "return", "False", "return", "bool", ...
Given a device path, return True if that device is mounted, and False if it isn't. :param device: str: Full path of the device to check. :returns: boolean: True if the path represents a mounted device, False if it doesn't.
[ "Given", "a", "device", "path", "return", "True", "if", "that", "device", "is", "mounted", "and", "False", "if", "it", "isn", "t", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/utils.py#L98-L110
12,477
juju/charm-helpers
charmhelpers/contrib/storage/linux/utils.py
mkfs_xfs
def mkfs_xfs(device, force=False): """Format device with XFS filesystem. By default this should fail if the device already has a filesystem on it. :param device: Full path to device to format :ptype device: tr :param force: Force operation :ptype: force: boolean""" cmd = ['mkfs.xfs'] if...
python
def mkfs_xfs(device, force=False): """Format device with XFS filesystem. By default this should fail if the device already has a filesystem on it. :param device: Full path to device to format :ptype device: tr :param force: Force operation :ptype: force: boolean""" cmd = ['mkfs.xfs'] if...
[ "def", "mkfs_xfs", "(", "device", ",", "force", "=", "False", ")", ":", "cmd", "=", "[", "'mkfs.xfs'", "]", "if", "force", ":", "cmd", ".", "append", "(", "\"-f\"", ")", "cmd", "+=", "[", "'-i'", ",", "'size=1024'", ",", "device", "]", "check_call", ...
Format device with XFS filesystem. By default this should fail if the device already has a filesystem on it. :param device: Full path to device to format :ptype device: tr :param force: Force operation :ptype: force: boolean
[ "Format", "device", "with", "XFS", "filesystem", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/utils.py#L113-L126
12,478
juju/charm-helpers
charmhelpers/contrib/charmhelpers/__init__.py
wait_for_machine
def wait_for_machine(num_machines=1, timeout=300): """Wait `timeout` seconds for `num_machines` machines to come up. This wait_for... function can be called by other wait_for functions whose timeouts might be too short in situations where only a bare Juju setup has been bootstrapped. :return: A tu...
python
def wait_for_machine(num_machines=1, timeout=300): """Wait `timeout` seconds for `num_machines` machines to come up. This wait_for... function can be called by other wait_for functions whose timeouts might be too short in situations where only a bare Juju setup has been bootstrapped. :return: A tu...
[ "def", "wait_for_machine", "(", "num_machines", "=", "1", ",", "timeout", "=", "300", ")", ":", "# You may think this is a hack, and you'd be right. The easiest way", "# to tell what environment we're working in (LXC vs EC2) is to check", "# the dns-name of the first machine. If it's loc...
Wait `timeout` seconds for `num_machines` machines to come up. This wait_for... function can be called by other wait_for functions whose timeouts might be too short in situations where only a bare Juju setup has been bootstrapped. :return: A tuple of (num_machines, time_taken). This is used for ...
[ "Wait", "timeout", "seconds", "for", "num_machines", "machines", "to", "come", "up", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/charmhelpers/__init__.py#L119-L155
12,479
juju/charm-helpers
charmhelpers/contrib/charmhelpers/__init__.py
wait_for_unit
def wait_for_unit(service_name, timeout=480): """Wait `timeout` seconds for a given service name to come up.""" wait_for_machine(num_machines=1) start_time = time.time() while True: state = unit_info(service_name, 'agent-state') if 'error' in state or state == 'started': brea...
python
def wait_for_unit(service_name, timeout=480): """Wait `timeout` seconds for a given service name to come up.""" wait_for_machine(num_machines=1) start_time = time.time() while True: state = unit_info(service_name, 'agent-state') if 'error' in state or state == 'started': brea...
[ "def", "wait_for_unit", "(", "service_name", ",", "timeout", "=", "480", ")", ":", "wait_for_machine", "(", "num_machines", "=", "1", ")", "start_time", "=", "time", ".", "time", "(", ")", "while", "True", ":", "state", "=", "unit_info", "(", "service_name...
Wait `timeout` seconds for a given service name to come up.
[ "Wait", "timeout", "seconds", "for", "a", "given", "service", "name", "to", "come", "up", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/charmhelpers/__init__.py#L159-L171
12,480
juju/charm-helpers
charmhelpers/contrib/charmhelpers/__init__.py
wait_for_relation
def wait_for_relation(service_name, relation_name, timeout=120): """Wait `timeout` seconds for a given relation to come up.""" start_time = time.time() while True: relation = unit_info(service_name, 'relations').get(relation_name) if relation is not None and relation['state'] == 'up': ...
python
def wait_for_relation(service_name, relation_name, timeout=120): """Wait `timeout` seconds for a given relation to come up.""" start_time = time.time() while True: relation = unit_info(service_name, 'relations').get(relation_name) if relation is not None and relation['state'] == 'up': ...
[ "def", "wait_for_relation", "(", "service_name", ",", "relation_name", ",", "timeout", "=", "120", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "while", "True", ":", "relation", "=", "unit_info", "(", "service_name", ",", "'relations'", ")", ...
Wait `timeout` seconds for a given relation to come up.
[ "Wait", "timeout", "seconds", "for", "a", "given", "relation", "to", "come", "up", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/charmhelpers/__init__.py#L175-L184
12,481
juju/charm-helpers
charmhelpers/core/host_factory/ubuntu.py
service_available
def service_available(service_name): """Determine whether a system service is available""" try: subprocess.check_output( ['service', service_name, 'status'], stderr=subprocess.STDOUT).decode('UTF-8') except subprocess.CalledProcessError as e: return b'unrecognized ser...
python
def service_available(service_name): """Determine whether a system service is available""" try: subprocess.check_output( ['service', service_name, 'status'], stderr=subprocess.STDOUT).decode('UTF-8') except subprocess.CalledProcessError as e: return b'unrecognized ser...
[ "def", "service_available", "(", "service_name", ")", ":", "try", ":", "subprocess", ".", "check_output", "(", "[", "'service'", ",", "service_name", ",", "'status'", "]", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", ".", "decode", "(", "'UTF-8'", ...
Determine whether a system service is available
[ "Determine", "whether", "a", "system", "service", "is", "available" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host_factory/ubuntu.py#L41-L50
12,482
juju/charm-helpers
charmhelpers/contrib/saltstack/__init__.py
install_salt_support
def install_salt_support(from_ppa=True): """Installs the salt-minion helper for machine state. By default the salt-minion package is installed from the saltstack PPA. If from_ppa is False you must ensure that the salt-minion package is available in the apt cache. """ if from_ppa: subpro...
python
def install_salt_support(from_ppa=True): """Installs the salt-minion helper for machine state. By default the salt-minion package is installed from the saltstack PPA. If from_ppa is False you must ensure that the salt-minion package is available in the apt cache. """ if from_ppa: subpro...
[ "def", "install_salt_support", "(", "from_ppa", "=", "True", ")", ":", "if", "from_ppa", ":", "subprocess", ".", "check_call", "(", "[", "'/usr/bin/add-apt-repository'", ",", "'--yes'", ",", "'ppa:saltstack/salt'", ",", "]", ")", "subprocess", ".", "check_call", ...
Installs the salt-minion helper for machine state. By default the salt-minion package is installed from the saltstack PPA. If from_ppa is False you must ensure that the salt-minion package is available in the apt cache.
[ "Installs", "the", "salt", "-", "minion", "helper", "for", "machine", "state", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/saltstack/__init__.py#L88-L104
12,483
juju/charm-helpers
charmhelpers/contrib/saltstack/__init__.py
update_machine_state
def update_machine_state(state_path): """Update the machine state using the provided state declaration.""" charmhelpers.contrib.templating.contexts.juju_state_to_yaml( salt_grains_path) subprocess.check_call([ 'salt-call', '--local', 'state.template', state_path, ...
python
def update_machine_state(state_path): """Update the machine state using the provided state declaration.""" charmhelpers.contrib.templating.contexts.juju_state_to_yaml( salt_grains_path) subprocess.check_call([ 'salt-call', '--local', 'state.template', state_path, ...
[ "def", "update_machine_state", "(", "state_path", ")", ":", "charmhelpers", ".", "contrib", ".", "templating", ".", "contexts", ".", "juju_state_to_yaml", "(", "salt_grains_path", ")", "subprocess", ".", "check_call", "(", "[", "'salt-call'", ",", "'--local'", ","...
Update the machine state using the provided state declaration.
[ "Update", "the", "machine", "state", "using", "the", "provided", "state", "declaration", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/saltstack/__init__.py#L107-L116
12,484
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
pool_exists
def pool_exists(service, name): """Check to see if a RADOS pool already exists.""" try: out = check_output(['rados', '--id', service, 'lspools']) if six.PY3: out = out.decode('UTF-8') except CalledProcessError: return False return name in out.split()
python
def pool_exists(service, name): """Check to see if a RADOS pool already exists.""" try: out = check_output(['rados', '--id', service, 'lspools']) if six.PY3: out = out.decode('UTF-8') except CalledProcessError: return False return name in out.split()
[ "def", "pool_exists", "(", "service", ",", "name", ")", ":", "try", ":", "out", "=", "check_output", "(", "[", "'rados'", ",", "'--id'", ",", "service", ",", "'lspools'", "]", ")", "if", "six", ".", "PY3", ":", "out", "=", "out", ".", "decode", "("...
Check to see if a RADOS pool already exists.
[ "Check", "to", "see", "if", "a", "RADOS", "pool", "already", "exists", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L753-L762
12,485
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
install
def install(): """Basic Ceph client installation.""" ceph_dir = "/etc/ceph" if not os.path.exists(ceph_dir): os.mkdir(ceph_dir) apt_install('ceph-common', fatal=True)
python
def install(): """Basic Ceph client installation.""" ceph_dir = "/etc/ceph" if not os.path.exists(ceph_dir): os.mkdir(ceph_dir) apt_install('ceph-common', fatal=True)
[ "def", "install", "(", ")", ":", "ceph_dir", "=", "\"/etc/ceph\"", "if", "not", "os", ".", "path", ".", "exists", "(", "ceph_dir", ")", ":", "os", ".", "mkdir", "(", "ceph_dir", ")", "apt_install", "(", "'ceph-common'", ",", "fatal", "=", "True", ")" ]
Basic Ceph client installation.
[ "Basic", "Ceph", "client", "installation", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L787-L793
12,486
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
rbd_exists
def rbd_exists(service, pool, rbd_img): """Check to see if a RADOS block device exists.""" try: out = check_output(['rbd', 'list', '--id', service, '--pool', pool]) if six.PY3: out = out.decode('UTF-8') except CalledProcessError: return False ...
python
def rbd_exists(service, pool, rbd_img): """Check to see if a RADOS block device exists.""" try: out = check_output(['rbd', 'list', '--id', service, '--pool', pool]) if six.PY3: out = out.decode('UTF-8') except CalledProcessError: return False ...
[ "def", "rbd_exists", "(", "service", ",", "pool", ",", "rbd_img", ")", ":", "try", ":", "out", "=", "check_output", "(", "[", "'rbd'", ",", "'list'", ",", "'--id'", ",", "service", ",", "'--pool'", ",", "pool", "]", ")", "if", "six", ".", "PY3", ":...
Check to see if a RADOS block device exists.
[ "Check", "to", "see", "if", "a", "RADOS", "block", "device", "exists", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L796-L806
12,487
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
create_rbd_image
def create_rbd_image(service, pool, image, sizemb): """Create a new RADOS block device.""" cmd = ['rbd', 'create', image, '--size', str(sizemb), '--id', service, '--pool', pool] check_call(cmd)
python
def create_rbd_image(service, pool, image, sizemb): """Create a new RADOS block device.""" cmd = ['rbd', 'create', image, '--size', str(sizemb), '--id', service, '--pool', pool] check_call(cmd)
[ "def", "create_rbd_image", "(", "service", ",", "pool", ",", "image", ",", "sizemb", ")", ":", "cmd", "=", "[", "'rbd'", ",", "'create'", ",", "image", ",", "'--size'", ",", "str", "(", "sizemb", ")", ",", "'--id'", ",", "service", ",", "'--pool'", "...
Create a new RADOS block device.
[ "Create", "a", "new", "RADOS", "block", "device", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L809-L813
12,488
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
set_app_name_for_pool
def set_app_name_for_pool(client, pool, name): """ Calls `osd pool application enable` for the specified pool name :param client: Name of the ceph client to use :type client: str :param pool: Pool to set app name for :type pool: str :param name: app name for the specified pool :type nam...
python
def set_app_name_for_pool(client, pool, name): """ Calls `osd pool application enable` for the specified pool name :param client: Name of the ceph client to use :type client: str :param pool: Pool to set app name for :type pool: str :param name: app name for the specified pool :type nam...
[ "def", "set_app_name_for_pool", "(", "client", ",", "pool", ",", "name", ")", ":", "if", "cmp_pkgrevno", "(", "'ceph-common'", ",", "'12.0.0'", ")", ">=", "0", ":", "cmd", "=", "[", "'ceph'", ",", "'--id'", ",", "client", ",", "'osd'", ",", "'pool'", "...
Calls `osd pool application enable` for the specified pool name :param client: Name of the ceph client to use :type client: str :param pool: Pool to set app name for :type pool: str :param name: app name for the specified pool :type name: str :raises: CalledProcessError if ceph call fails
[ "Calls", "osd", "pool", "application", "enable", "for", "the", "specified", "pool", "name" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L825-L841
12,489
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
create_pool
def create_pool(service, name, replicas=3, pg_num=None): """Create a new RADOS pool.""" if pool_exists(service, name): log("Ceph pool {} already exists, skipping creation".format(name), level=WARNING) return if not pg_num: # Calculate the number of placement groups based...
python
def create_pool(service, name, replicas=3, pg_num=None): """Create a new RADOS pool.""" if pool_exists(service, name): log("Ceph pool {} already exists, skipping creation".format(name), level=WARNING) return if not pg_num: # Calculate the number of placement groups based...
[ "def", "create_pool", "(", "service", ",", "name", ",", "replicas", "=", "3", ",", "pg_num", "=", "None", ")", ":", "if", "pool_exists", "(", "service", ",", "name", ")", ":", "log", "(", "\"Ceph pool {} already exists, skipping creation\"", ".", "format", "...
Create a new RADOS pool.
[ "Create", "a", "new", "RADOS", "pool", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L844-L865
12,490
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
add_key
def add_key(service, key): """ Add a key to a keyring. Creates the keyring if it doesn't already exist. Logs and returns if the key is already in the keyring. """ keyring = _keyring_path(service) if os.path.exists(keyring): with open(keyring, 'r') as ring: if key in rin...
python
def add_key(service, key): """ Add a key to a keyring. Creates the keyring if it doesn't already exist. Logs and returns if the key is already in the keyring. """ keyring = _keyring_path(service) if os.path.exists(keyring): with open(keyring, 'r') as ring: if key in rin...
[ "def", "add_key", "(", "service", ",", "key", ")", ":", "keyring", "=", "_keyring_path", "(", "service", ")", "if", "os", ".", "path", ".", "exists", "(", "keyring", ")", ":", "with", "open", "(", "keyring", ",", "'r'", ")", "as", "ring", ":", "if"...
Add a key to a keyring. Creates the keyring if it doesn't already exist. Logs and returns if the key is already in the keyring.
[ "Add", "a", "key", "to", "a", "keyring", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L883-L903
12,491
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
delete_keyring
def delete_keyring(service): """Delete an existing Ceph keyring.""" keyring = _keyring_path(service) if not os.path.exists(keyring): log('Keyring does not exist at %s' % keyring, level=WARNING) return os.remove(keyring) log('Deleted ring at %s.' % keyring, level=INFO)
python
def delete_keyring(service): """Delete an existing Ceph keyring.""" keyring = _keyring_path(service) if not os.path.exists(keyring): log('Keyring does not exist at %s' % keyring, level=WARNING) return os.remove(keyring) log('Deleted ring at %s.' % keyring, level=INFO)
[ "def", "delete_keyring", "(", "service", ")", ":", "keyring", "=", "_keyring_path", "(", "service", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "keyring", ")", ":", "log", "(", "'Keyring does not exist at %s'", "%", "keyring", ",", "level", "=...
Delete an existing Ceph keyring.
[ "Delete", "an", "existing", "Ceph", "keyring", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L911-L919
12,492
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
create_key_file
def create_key_file(service, key): """Create a file containing key.""" keyfile = _keyfile_path(service) if os.path.exists(keyfile): log('Keyfile exists at %s.' % keyfile, level=WARNING) return with open(keyfile, 'w') as fd: fd.write(key) log('Created new keyfile at %s.' % k...
python
def create_key_file(service, key): """Create a file containing key.""" keyfile = _keyfile_path(service) if os.path.exists(keyfile): log('Keyfile exists at %s.' % keyfile, level=WARNING) return with open(keyfile, 'w') as fd: fd.write(key) log('Created new keyfile at %s.' % k...
[ "def", "create_key_file", "(", "service", ",", "key", ")", ":", "keyfile", "=", "_keyfile_path", "(", "service", ")", "if", "os", ".", "path", ".", "exists", "(", "keyfile", ")", ":", "log", "(", "'Keyfile exists at %s.'", "%", "keyfile", ",", "level", "...
Create a file containing key.
[ "Create", "a", "file", "containing", "key", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L922-L932
12,493
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
get_ceph_nodes
def get_ceph_nodes(relation='ceph'): """Query named relation to determine current nodes.""" hosts = [] for r_id in relation_ids(relation): for unit in related_units(r_id): hosts.append(relation_get('private-address', unit=unit, rid=r_id)) return hosts
python
def get_ceph_nodes(relation='ceph'): """Query named relation to determine current nodes.""" hosts = [] for r_id in relation_ids(relation): for unit in related_units(r_id): hosts.append(relation_get('private-address', unit=unit, rid=r_id)) return hosts
[ "def", "get_ceph_nodes", "(", "relation", "=", "'ceph'", ")", ":", "hosts", "=", "[", "]", "for", "r_id", "in", "relation_ids", "(", "relation", ")", ":", "for", "unit", "in", "related_units", "(", "r_id", ")", ":", "hosts", ".", "append", "(", "relati...
Query named relation to determine current nodes.
[ "Query", "named", "relation", "to", "determine", "current", "nodes", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L935-L942
12,494
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
configure
def configure(service, key, auth, use_syslog): """Perform basic configuration of Ceph.""" add_key(service, key) create_key_file(service, key) hosts = get_ceph_nodes() with open('/etc/ceph/ceph.conf', 'w') as ceph_conf: ceph_conf.write(CEPH_CONF.format(auth=auth, ...
python
def configure(service, key, auth, use_syslog): """Perform basic configuration of Ceph.""" add_key(service, key) create_key_file(service, key) hosts = get_ceph_nodes() with open('/etc/ceph/ceph.conf', 'w') as ceph_conf: ceph_conf.write(CEPH_CONF.format(auth=auth, ...
[ "def", "configure", "(", "service", ",", "key", ",", "auth", ",", "use_syslog", ")", ":", "add_key", "(", "service", ",", "key", ")", "create_key_file", "(", "service", ",", "key", ")", "hosts", "=", "get_ceph_nodes", "(", ")", "with", "open", "(", "'/...
Perform basic configuration of Ceph.
[ "Perform", "basic", "configuration", "of", "Ceph", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L945-L955
12,495
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
image_mapped
def image_mapped(name): """Determine whether a RADOS block device is mapped locally.""" try: out = check_output(['rbd', 'showmapped']) if six.PY3: out = out.decode('UTF-8') except CalledProcessError: return False return name in out
python
def image_mapped(name): """Determine whether a RADOS block device is mapped locally.""" try: out = check_output(['rbd', 'showmapped']) if six.PY3: out = out.decode('UTF-8') except CalledProcessError: return False return name in out
[ "def", "image_mapped", "(", "name", ")", ":", "try", ":", "out", "=", "check_output", "(", "[", "'rbd'", ",", "'showmapped'", "]", ")", "if", "six", ".", "PY3", ":", "out", "=", "out", ".", "decode", "(", "'UTF-8'", ")", "except", "CalledProcessError",...
Determine whether a RADOS block device is mapped locally.
[ "Determine", "whether", "a", "RADOS", "block", "device", "is", "mapped", "locally", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L958-L967
12,496
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
map_block_storage
def map_block_storage(service, pool, image): """Map a RADOS block device for local use.""" cmd = [ 'rbd', 'map', '{}/{}'.format(pool, image), '--user', service, '--secret', _keyfile_path(service), ] check_call(cmd)
python
def map_block_storage(service, pool, image): """Map a RADOS block device for local use.""" cmd = [ 'rbd', 'map', '{}/{}'.format(pool, image), '--user', service, '--secret', _keyfile_path(service), ] check_call(cmd)
[ "def", "map_block_storage", "(", "service", ",", "pool", ",", "image", ")", ":", "cmd", "=", "[", "'rbd'", ",", "'map'", ",", "'{}/{}'", ".", "format", "(", "pool", ",", "image", ")", ",", "'--user'", ",", "service", ",", "'--secret'", ",", "_keyfile_p...
Map a RADOS block device for local use.
[ "Map", "a", "RADOS", "block", "device", "for", "local", "use", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L970-L981
12,497
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
make_filesystem
def make_filesystem(blk_device, fstype='ext4', timeout=10): """Make a new filesystem on the specified block device.""" count = 0 e_noent = os.errno.ENOENT while not os.path.exists(blk_device): if count >= timeout: log('Gave up waiting on block device %s' % blk_device, ...
python
def make_filesystem(blk_device, fstype='ext4', timeout=10): """Make a new filesystem on the specified block device.""" count = 0 e_noent = os.errno.ENOENT while not os.path.exists(blk_device): if count >= timeout: log('Gave up waiting on block device %s' % blk_device, ...
[ "def", "make_filesystem", "(", "blk_device", ",", "fstype", "=", "'ext4'", ",", "timeout", "=", "10", ")", ":", "count", "=", "0", "e_noent", "=", "os", ".", "errno", ".", "ENOENT", "while", "not", "os", ".", "path", ".", "exists", "(", "blk_device", ...
Make a new filesystem on the specified block device.
[ "Make", "a", "new", "filesystem", "on", "the", "specified", "block", "device", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L989-L1006
12,498
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
place_data_on_block_device
def place_data_on_block_device(blk_device, data_src_dst): """Migrate data in data_src_dst to blk_device and then remount.""" # mount block device into /mnt mount(blk_device, '/mnt') # copy data to /mnt copy_files(data_src_dst, '/mnt') # umount block device umount('/mnt') # Grab user/grou...
python
def place_data_on_block_device(blk_device, data_src_dst): """Migrate data in data_src_dst to blk_device and then remount.""" # mount block device into /mnt mount(blk_device, '/mnt') # copy data to /mnt copy_files(data_src_dst, '/mnt') # umount block device umount('/mnt') # Grab user/grou...
[ "def", "place_data_on_block_device", "(", "blk_device", ",", "data_src_dst", ")", ":", "# mount block device into /mnt", "mount", "(", "blk_device", ",", "'/mnt'", ")", "# copy data to /mnt", "copy_files", "(", "data_src_dst", ",", "'/mnt'", ")", "# umount block device", ...
Migrate data in data_src_dst to blk_device and then remount.
[ "Migrate", "data", "in", "data_src_dst", "to", "blk_device", "and", "then", "remount", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1009-L1025
12,499
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
ensure_ceph_keyring
def ensure_ceph_keyring(service, user=None, group=None, relation='ceph', key=None): """Ensures a ceph keyring is created for a named service and optionally ensures user and group ownership. @returns boolean: Flag to indicate whether a key was successfully written ...
python
def ensure_ceph_keyring(service, user=None, group=None, relation='ceph', key=None): """Ensures a ceph keyring is created for a named service and optionally ensures user and group ownership. @returns boolean: Flag to indicate whether a key was successfully written ...
[ "def", "ensure_ceph_keyring", "(", "service", ",", "user", "=", "None", ",", "group", "=", "None", ",", "relation", "=", "'ceph'", ",", "key", "=", "None", ")", ":", "if", "not", "key", ":", "for", "rid", "in", "relation_ids", "(", "relation", ")", "...
Ensures a ceph keyring is created for a named service and optionally ensures user and group ownership. @returns boolean: Flag to indicate whether a key was successfully written to disk based on either relation data or a supplied key
[ "Ensures", "a", "ceph", "keyring", "is", "created", "for", "a", "named", "service", "and", "optionally", "ensures", "user", "and", "group", "ownership", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1092-L1115