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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | get_previous_request | def get_previous_request(rid):
"""Return the last ceph broker request sent on a given relation
@param rid: Relation id to query for request
"""
request = None
broker_req = relation_get(attribute='broker_req', rid=rid,
unit=local_unit())
if broker_req:
reque... | python | def get_previous_request(rid):
"""Return the last ceph broker request sent on a given relation
@param rid: Relation id to query for request
"""
request = None
broker_req = relation_get(attribute='broker_req', rid=rid,
unit=local_unit())
if broker_req:
reque... | [
"def",
"get_previous_request",
"(",
"rid",
")",
":",
"request",
"=",
"None",
"broker_req",
"=",
"relation_get",
"(",
"attribute",
"=",
"'broker_req'",
",",
"rid",
"=",
"rid",
",",
"unit",
"=",
"local_unit",
"(",
")",
")",
"if",
"broker_req",
":",
"request_... | Return the last ceph broker request sent on a given relation
@param rid: Relation id to query for request | [
"Return",
"the",
"last",
"ceph",
"broker",
"request",
"sent",
"on",
"a",
"given",
"relation"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1351-L1365 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | get_request_states | def get_request_states(request, relation='ceph'):
"""Return a dict of requests per relation id with their corresponding
completion state.
This allows a charm, which has a request for ceph, to see whether there is
an equivalent request already being processed and if so what state that
request is ... | python | def get_request_states(request, relation='ceph'):
"""Return a dict of requests per relation id with their corresponding
completion state.
This allows a charm, which has a request for ceph, to see whether there is
an equivalent request already being processed and if so what state that
request is ... | [
"def",
"get_request_states",
"(",
"request",
",",
"relation",
"=",
"'ceph'",
")",
":",
"complete",
"=",
"[",
"]",
"requests",
"=",
"{",
"}",
"for",
"rid",
"in",
"relation_ids",
"(",
"relation",
")",
":",
"complete",
"=",
"False",
"previous_request",
"=",
... | Return a dict of requests per relation id with their corresponding
completion state.
This allows a charm, which has a request for ceph, to see whether there is
an equivalent request already being processed and if so what state that
request is in.
@param request: A CephBrokerRq object | [
"Return",
"a",
"dict",
"of",
"requests",
"per",
"relation",
"id",
"with",
"their",
"corresponding",
"completion",
"state",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1368-L1395 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | is_request_sent | def is_request_sent(request, relation='ceph'):
"""Check to see if a functionally equivalent request has already been sent
Returns True if a similair request has been sent
@param request: A CephBrokerRq object
"""
states = get_request_states(request, relation=relation)
for rid in states.keys():... | python | def is_request_sent(request, relation='ceph'):
"""Check to see if a functionally equivalent request has already been sent
Returns True if a similair request has been sent
@param request: A CephBrokerRq object
"""
states = get_request_states(request, relation=relation)
for rid in states.keys():... | [
"def",
"is_request_sent",
"(",
"request",
",",
"relation",
"=",
"'ceph'",
")",
":",
"states",
"=",
"get_request_states",
"(",
"request",
",",
"relation",
"=",
"relation",
")",
"for",
"rid",
"in",
"states",
".",
"keys",
"(",
")",
":",
"if",
"not",
"states... | Check to see if a functionally equivalent request has already been sent
Returns True if a similair request has been sent
@param request: A CephBrokerRq object | [
"Check",
"to",
"see",
"if",
"a",
"functionally",
"equivalent",
"request",
"has",
"already",
"been",
"sent"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1398-L1410 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | is_request_complete_for_rid | def is_request_complete_for_rid(request, rid):
"""Check if a given request has been completed on the given relation
@param request: A CephBrokerRq object
@param rid: Relation ID
"""
broker_key = get_broker_rsp_key()
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit... | python | def is_request_complete_for_rid(request, rid):
"""Check if a given request has been completed on the given relation
@param request: A CephBrokerRq object
@param rid: Relation ID
"""
broker_key = get_broker_rsp_key()
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit... | [
"def",
"is_request_complete_for_rid",
"(",
"request",
",",
"rid",
")",
":",
"broker_key",
"=",
"get_broker_rsp_key",
"(",
")",
"for",
"unit",
"in",
"related_units",
"(",
"rid",
")",
":",
"rdata",
"=",
"relation_get",
"(",
"rid",
"=",
"rid",
",",
"unit",
"=... | Check if a given request has been completed on the given relation
@param request: A CephBrokerRq object
@param rid: Relation ID | [
"Check",
"if",
"a",
"given",
"request",
"has",
"been",
"completed",
"on",
"the",
"given",
"relation"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1429-L1459 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | send_request_if_needed | def send_request_if_needed(request, relation='ceph'):
"""Send broker request if an equivalent request has not already been sent
@param request: A CephBrokerRq object
"""
if is_request_sent(request, relation=relation):
log('Request already sent but not complete, not sending new request',
... | python | def send_request_if_needed(request, relation='ceph'):
"""Send broker request if an equivalent request has not already been sent
@param request: A CephBrokerRq object
"""
if is_request_sent(request, relation=relation):
log('Request already sent but not complete, not sending new request',
... | [
"def",
"send_request_if_needed",
"(",
"request",
",",
"relation",
"=",
"'ceph'",
")",
":",
"if",
"is_request_sent",
"(",
"request",
",",
"relation",
"=",
"relation",
")",
":",
"log",
"(",
"'Request already sent but not complete, not sending new request'",
",",
"level"... | Send broker request if an equivalent request has not already been sent
@param request: A CephBrokerRq object | [
"Send",
"broker",
"request",
"if",
"an",
"equivalent",
"request",
"has",
"not",
"already",
"been",
"sent"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1471-L1482 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | is_broker_action_done | def is_broker_action_done(action, rid=None, unit=None):
"""Check whether broker action has completed yet.
@param action: name of action to be performed
@returns True if action complete otherwise False
"""
rdata = relation_get(rid, unit) or {}
broker_rsp = rdata.get(get_broker_rsp_key())
if ... | python | def is_broker_action_done(action, rid=None, unit=None):
"""Check whether broker action has completed yet.
@param action: name of action to be performed
@returns True if action complete otherwise False
"""
rdata = relation_get(rid, unit) or {}
broker_rsp = rdata.get(get_broker_rsp_key())
if ... | [
"def",
"is_broker_action_done",
"(",
"action",
",",
"rid",
"=",
"None",
",",
"unit",
"=",
"None",
")",
":",
"rdata",
"=",
"relation_get",
"(",
"rid",
",",
"unit",
")",
"or",
"{",
"}",
"broker_rsp",
"=",
"rdata",
".",
"get",
"(",
"get_broker_rsp_key",
"... | Check whether broker action has completed yet.
@param action: name of action to be performed
@returns True if action complete otherwise False | [
"Check",
"whether",
"broker",
"action",
"has",
"completed",
"yet",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1485-L1504 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | mark_broker_action_done | def mark_broker_action_done(action, rid=None, unit=None):
"""Mark action as having been completed.
@param action: name of action to be performed
@returns None
"""
rdata = relation_get(rid, unit) or {}
broker_rsp = rdata.get(get_broker_rsp_key())
if not broker_rsp:
return
rsp = ... | python | def mark_broker_action_done(action, rid=None, unit=None):
"""Mark action as having been completed.
@param action: name of action to be performed
@returns None
"""
rdata = relation_get(rid, unit) or {}
broker_rsp = rdata.get(get_broker_rsp_key())
if not broker_rsp:
return
rsp = ... | [
"def",
"mark_broker_action_done",
"(",
"action",
",",
"rid",
"=",
"None",
",",
"unit",
"=",
"None",
")",
":",
"rdata",
"=",
"relation_get",
"(",
"rid",
",",
"unit",
")",
"or",
"{",
"}",
"broker_rsp",
"=",
"rdata",
".",
"get",
"(",
"get_broker_rsp_key",
... | Mark action as having been completed.
@param action: name of action to be performed
@returns None | [
"Mark",
"action",
"as",
"having",
"been",
"completed",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1507-L1523 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | Pool.get_pgs | def get_pgs(self, pool_size, percent_data=DEFAULT_POOL_WEIGHT,
device_class=None):
"""Return the number of placement groups to use when creating the pool.
Returns the number of placement groups which should be specified when
creating the pool. This is based upon the calculation ... | python | def get_pgs(self, pool_size, percent_data=DEFAULT_POOL_WEIGHT,
device_class=None):
"""Return the number of placement groups to use when creating the pool.
Returns the number of placement groups which should be specified when
creating the pool. This is based upon the calculation ... | [
"def",
"get_pgs",
"(",
"self",
",",
"pool_size",
",",
"percent_data",
"=",
"DEFAULT_POOL_WEIGHT",
",",
"device_class",
"=",
"None",
")",
":",
"# Note: This calculation follows the approach that is provided",
"# by the Ceph PG Calculator located at http://ceph.com/pgcalc/.",
"vali... | Return the number of placement groups to use when creating the pool.
Returns the number of placement groups which should be specified when
creating the pool. This is based upon the calculation guidelines
provided by the Ceph Placement Group Calculator (located online at
http://ceph.com/... | [
"Return",
"the",
"number",
"of",
"placement",
"groups",
"to",
"use",
"when",
"creating",
"the",
"pool",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L199-L296 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | CephBrokerRq.add_op_create_replicated_pool | def add_op_create_replicated_pool(self, name, replica_count=3, pg_num=None,
weight=None, group=None, namespace=None,
app_name=None, max_bytes=None,
max_objects=None):
"""Adds an operation to create ... | python | def add_op_create_replicated_pool(self, name, replica_count=3, pg_num=None,
weight=None, group=None, namespace=None,
app_name=None, max_bytes=None,
max_objects=None):
"""Adds an operation to create ... | [
"def",
"add_op_create_replicated_pool",
"(",
"self",
",",
"name",
",",
"replica_count",
"=",
"3",
",",
"pg_num",
"=",
"None",
",",
"weight",
"=",
"None",
",",
"group",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"app_name",
"=",
"None",
",",
"max_by... | Adds an operation to create a replicated pool.
:param name: Name of pool to create
:type name: str
:param replica_count: Number of copies Ceph should keep of your data.
:type replica_count: int
:param pg_num: Request specific number of Placement Groups to create
... | [
"Adds",
"an",
"operation",
"to",
"create",
"a",
"replicated",
"pool",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1168-L1207 | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | CephBrokerRq.add_op_create_erasure_pool | def add_op_create_erasure_pool(self, name, erasure_profile=None,
weight=None, group=None, app_name=None,
max_bytes=None, max_objects=None):
"""Adds an operation to create a erasure coded pool.
:param name: Name of pool to create
... | python | def add_op_create_erasure_pool(self, name, erasure_profile=None,
weight=None, group=None, app_name=None,
max_bytes=None, max_objects=None):
"""Adds an operation to create a erasure coded pool.
:param name: Name of pool to create
... | [
"def",
"add_op_create_erasure_pool",
"(",
"self",
",",
"name",
",",
"erasure_profile",
"=",
"None",
",",
"weight",
"=",
"None",
",",
"group",
"=",
"None",
",",
"app_name",
"=",
"None",
",",
"max_bytes",
"=",
"None",
",",
"max_objects",
"=",
"None",
")",
... | Adds an operation to create a erasure coded pool.
:param name: Name of pool to create
:type name: str
:param erasure_profile: Name of erasure code profile to use. If not
set the ceph-mon unit handling the broker
request will set i... | [
"Adds",
"an",
"operation",
"to",
"create",
"a",
"erasure",
"coded",
"pool",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1209-L1240 | train |
juju/charm-helpers | charmhelpers/contrib/charmsupport/nrpe.py | get_nagios_unit_name | def get_nagios_unit_name(relation_name='nrpe-external-master'):
"""
Return the nagios unit name prepended with host_context if needed
:param str relation_name: Name of relation nrpe sub joined to
"""
host_context = get_nagios_hostcontext(relation_name)
if host_context:
unit = "%s:%s" % ... | python | def get_nagios_unit_name(relation_name='nrpe-external-master'):
"""
Return the nagios unit name prepended with host_context if needed
:param str relation_name: Name of relation nrpe sub joined to
"""
host_context = get_nagios_hostcontext(relation_name)
if host_context:
unit = "%s:%s" % ... | [
"def",
"get_nagios_unit_name",
"(",
"relation_name",
"=",
"'nrpe-external-master'",
")",
":",
"host_context",
"=",
"get_nagios_hostcontext",
"(",
"relation_name",
")",
"if",
"host_context",
":",
"unit",
"=",
"\"%s:%s\"",
"%",
"(",
"host_context",
",",
"local_unit",
... | Return the nagios unit name prepended with host_context if needed
:param str relation_name: Name of relation nrpe sub joined to | [
"Return",
"the",
"nagios",
"unit",
"name",
"prepended",
"with",
"host_context",
"if",
"needed"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/charmsupport/nrpe.py#L341-L352 | train |
juju/charm-helpers | charmhelpers/contrib/charmsupport/nrpe.py | copy_nrpe_checks | def copy_nrpe_checks(nrpe_files_dir=None):
"""
Copy the nrpe checks into place
"""
NAGIOS_PLUGINS = '/usr/local/lib/nagios/plugins'
if nrpe_files_dir is None:
# determine if "charmhelpers" is in CHARMDIR or CHARMDIR/hooks
for segment in ['.', 'hooks']:
nrpe_files_dir = o... | python | def copy_nrpe_checks(nrpe_files_dir=None):
"""
Copy the nrpe checks into place
"""
NAGIOS_PLUGINS = '/usr/local/lib/nagios/plugins'
if nrpe_files_dir is None:
# determine if "charmhelpers" is in CHARMDIR or CHARMDIR/hooks
for segment in ['.', 'hooks']:
nrpe_files_dir = o... | [
"def",
"copy_nrpe_checks",
"(",
"nrpe_files_dir",
"=",
"None",
")",
":",
"NAGIOS_PLUGINS",
"=",
"'/usr/local/lib/nagios/plugins'",
"if",
"nrpe_files_dir",
"is",
"None",
":",
"# determine if \"charmhelpers\" is in CHARMDIR or CHARMDIR/hooks",
"for",
"segment",
"in",
"[",
"'.... | Copy the nrpe checks into place | [
"Copy",
"the",
"nrpe",
"checks",
"into",
"place"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/charmsupport/nrpe.py#L413-L438 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/vaultlocker.py | write_vaultlocker_conf | def write_vaultlocker_conf(context, priority=100):
"""Write vaultlocker configuration to disk and install alternative
:param context: Dict of data from vault-kv relation
:ptype: context: dict
:param priority: Priority of alternative configuration
:ptype: priority: int"""
charm_vl_path = "/var/l... | python | def write_vaultlocker_conf(context, priority=100):
"""Write vaultlocker configuration to disk and install alternative
:param context: Dict of data from vault-kv relation
:ptype: context: dict
:param priority: Priority of alternative configuration
:ptype: priority: int"""
charm_vl_path = "/var/l... | [
"def",
"write_vaultlocker_conf",
"(",
"context",
",",
"priority",
"=",
"100",
")",
":",
"charm_vl_path",
"=",
"\"/var/lib/charm/{}/vaultlocker.conf\"",
".",
"format",
"(",
"hookenv",
".",
"service_name",
"(",
")",
")",
"host",
".",
"mkdir",
"(",
"os",
".",
"pa... | Write vaultlocker configuration to disk and install alternative
:param context: Dict of data from vault-kv relation
:ptype: context: dict
:param priority: Priority of alternative configuration
:ptype: priority: int | [
"Write",
"vaultlocker",
"configuration",
"to",
"disk",
"and",
"install",
"alternative"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/vaultlocker.py#L80-L96 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/vaultlocker.py | vault_relation_complete | def vault_relation_complete(backend=None):
"""Determine whether vault relation is complete
:param backend: Name of secrets backend requested
:ptype backend: string
:returns: whether the relation to vault is complete
:rtype: bool"""
vault_kv = VaultKVContext(secret_backend=backend or VAULTLOCKER... | python | def vault_relation_complete(backend=None):
"""Determine whether vault relation is complete
:param backend: Name of secrets backend requested
:ptype backend: string
:returns: whether the relation to vault is complete
:rtype: bool"""
vault_kv = VaultKVContext(secret_backend=backend or VAULTLOCKER... | [
"def",
"vault_relation_complete",
"(",
"backend",
"=",
"None",
")",
":",
"vault_kv",
"=",
"VaultKVContext",
"(",
"secret_backend",
"=",
"backend",
"or",
"VAULTLOCKER_BACKEND",
")",
"vault_kv",
"(",
")",
"return",
"vault_kv",
".",
"complete"
] | Determine whether vault relation is complete
:param backend: Name of secrets backend requested
:ptype backend: string
:returns: whether the relation to vault is complete
:rtype: bool | [
"Determine",
"whether",
"vault",
"relation",
"is",
"complete"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/vaultlocker.py#L99-L108 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/vaultlocker.py | retrieve_secret_id | def retrieve_secret_id(url, token):
"""Retrieve a response-wrapped secret_id from Vault
:param url: URL to Vault Server
:ptype url: str
:param token: One shot Token to use
:ptype token: str
:returns: secret_id to use for Vault Access
:rtype: str"""
import hvac
client = hvac.Client(u... | python | def retrieve_secret_id(url, token):
"""Retrieve a response-wrapped secret_id from Vault
:param url: URL to Vault Server
:ptype url: str
:param token: One shot Token to use
:ptype token: str
:returns: secret_id to use for Vault Access
:rtype: str"""
import hvac
client = hvac.Client(u... | [
"def",
"retrieve_secret_id",
"(",
"url",
",",
"token",
")",
":",
"import",
"hvac",
"client",
"=",
"hvac",
".",
"Client",
"(",
"url",
"=",
"url",
",",
"token",
"=",
"token",
")",
"response",
"=",
"client",
".",
"_post",
"(",
"'/v1/sys/wrapping/unwrap'",
"... | Retrieve a response-wrapped secret_id from Vault
:param url: URL to Vault Server
:ptype url: str
:param token: One shot Token to use
:ptype token: str
:returns: secret_id to use for Vault Access
:rtype: str | [
"Retrieve",
"a",
"response",
"-",
"wrapped",
"secret_id",
"from",
"Vault"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/vaultlocker.py#L112-L126 | train |
juju/charm-helpers | charmhelpers/core/decorators.py | retry_on_exception | def retry_on_exception(num_retries, base_delay=0, exc_type=Exception):
"""If the decorated function raises exception exc_type, allow num_retries
retry attempts before raise the exception.
"""
def _retry_on_exception_inner_1(f):
def _retry_on_exception_inner_2(*args, **kwargs):
retrie... | python | def retry_on_exception(num_retries, base_delay=0, exc_type=Exception):
"""If the decorated function raises exception exc_type, allow num_retries
retry attempts before raise the exception.
"""
def _retry_on_exception_inner_1(f):
def _retry_on_exception_inner_2(*args, **kwargs):
retrie... | [
"def",
"retry_on_exception",
"(",
"num_retries",
",",
"base_delay",
"=",
"0",
",",
"exc_type",
"=",
"Exception",
")",
":",
"def",
"_retry_on_exception_inner_1",
"(",
"f",
")",
":",
"def",
"_retry_on_exception_inner_2",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs"... | If the decorated function raises exception exc_type, allow num_retries
retry attempts before raise the exception. | [
"If",
"the",
"decorated",
"function",
"raises",
"exception",
"exc_type",
"allow",
"num_retries",
"retry",
"attempts",
"before",
"raise",
"the",
"exception",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/decorators.py#L30-L55 | train |
juju/charm-helpers | charmhelpers/fetch/snap.py | _snap_exec | def _snap_exec(commands):
"""
Execute snap commands.
:param commands: List commands
:return: Integer exit code
"""
assert type(commands) == list
retry_count = 0
return_code = None
while return_code is None or return_code == SNAP_NO_LOCK:
try:
return_code = subp... | python | def _snap_exec(commands):
"""
Execute snap commands.
:param commands: List commands
:return: Integer exit code
"""
assert type(commands) == list
retry_count = 0
return_code = None
while return_code is None or return_code == SNAP_NO_LOCK:
try:
return_code = subp... | [
"def",
"_snap_exec",
"(",
"commands",
")",
":",
"assert",
"type",
"(",
"commands",
")",
"==",
"list",
"retry_count",
"=",
"0",
"return_code",
"=",
"None",
"while",
"return_code",
"is",
"None",
"or",
"return_code",
"==",
"SNAP_NO_LOCK",
":",
"try",
":",
"re... | Execute snap commands.
:param commands: List commands
:return: Integer exit code | [
"Execute",
"snap",
"commands",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/snap.py#L48-L75 | train |
juju/charm-helpers | charmhelpers/fetch/snap.py | snap_remove | def snap_remove(packages, *flags):
"""
Remove a snap package.
:param packages: String or List String package name
:param flags: List String flags to pass to remove command
:return: Integer return code from snap
"""
if type(packages) is not list:
packages = [packages]
flags = li... | python | def snap_remove(packages, *flags):
"""
Remove a snap package.
:param packages: String or List String package name
:param flags: List String flags to pass to remove command
:return: Integer return code from snap
"""
if type(packages) is not list:
packages = [packages]
flags = li... | [
"def",
"snap_remove",
"(",
"packages",
",",
"*",
"flags",
")",
":",
"if",
"type",
"(",
"packages",
")",
"is",
"not",
"list",
":",
"packages",
"=",
"[",
"packages",
"]",
"flags",
"=",
"list",
"(",
"flags",
")",
"message",
"=",
"'Removing snap(s) \"%s\"'",... | Remove a snap package.
:param packages: String or List String package name
:param flags: List String flags to pass to remove command
:return: Integer return code from snap | [
"Remove",
"a",
"snap",
"package",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/snap.py#L99-L117 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.validate_v2_endpoint_data | def validate_v2_endpoint_data(self, endpoints, admin_port, internal_port,
public_port, expected):
"""Validate endpoint data.
Validate actual endpoint data vs expected endpoint data. The ports
are used to find the matching endpoint.
"""
... | python | def validate_v2_endpoint_data(self, endpoints, admin_port, internal_port,
public_port, expected):
"""Validate endpoint data.
Validate actual endpoint data vs expected endpoint data. The ports
are used to find the matching endpoint.
"""
... | [
"def",
"validate_v2_endpoint_data",
"(",
"self",
",",
"endpoints",
",",
"admin_port",
",",
"internal_port",
",",
"public_port",
",",
"expected",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Validating endpoint data...'",
")",
"self",
".",
"log",
".",
"de... | Validate endpoint data.
Validate actual endpoint data vs expected endpoint data. The ports
are used to find the matching endpoint. | [
"Validate",
"endpoint",
"data",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L102-L129 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.validate_v3_endpoint_data | def validate_v3_endpoint_data(self, endpoints, admin_port, internal_port,
public_port, expected, expected_num_eps=3):
"""Validate keystone v3 endpoint data.
Validate the v3 endpoint data which has changed from v2. The
ports are used to find the matching endpoi... | python | def validate_v3_endpoint_data(self, endpoints, admin_port, internal_port,
public_port, expected, expected_num_eps=3):
"""Validate keystone v3 endpoint data.
Validate the v3 endpoint data which has changed from v2. The
ports are used to find the matching endpoi... | [
"def",
"validate_v3_endpoint_data",
"(",
"self",
",",
"endpoints",
",",
"admin_port",
",",
"internal_port",
",",
"public_port",
",",
"expected",
",",
"expected_num_eps",
"=",
"3",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Validating v3 endpoint data...'",... | Validate keystone v3 endpoint data.
Validate the v3 endpoint data which has changed from v2. The
ports are used to find the matching endpoint.
The new v3 endpoint data looks like:
[<Endpoint enabled=True,
id=0432655fc2f74d1e9fa17bdaa6f6e60b,
inte... | [
"Validate",
"keystone",
"v3",
"endpoint",
"data",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L131-L179 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.convert_svc_catalog_endpoint_data_to_v3 | def convert_svc_catalog_endpoint_data_to_v3(self, ep_data):
"""Convert v2 endpoint data into v3.
{
'service_name1': [
{
'adminURL': adminURL,
'id': id,
'region': region.
'pub... | python | def convert_svc_catalog_endpoint_data_to_v3(self, ep_data):
"""Convert v2 endpoint data into v3.
{
'service_name1': [
{
'adminURL': adminURL,
'id': id,
'region': region.
'pub... | [
"def",
"convert_svc_catalog_endpoint_data_to_v3",
"(",
"self",
",",
"ep_data",
")",
":",
"self",
".",
"log",
".",
"warn",
"(",
"\"Endpoint ID and Region ID validation is limited to not \"",
"\"null checks after v2 to v3 conversion\"",
")",
"for",
"svc",
"in",
"ep_data",
"."... | Convert v2 endpoint data into v3.
{
'service_name1': [
{
'adminURL': adminURL,
'id': id,
'region': region.
'publicURL': publicURL,
'internalURL': internalURL
... | [
"Convert",
"v2",
"endpoint",
"data",
"into",
"v3",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L181-L227 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.validate_v2_svc_catalog_endpoint_data | def validate_v2_svc_catalog_endpoint_data(self, expected, actual):
"""Validate service catalog endpoint data.
Validate a list of actual service catalog endpoints vs a list of
expected service catalog endpoints.
"""
self.log.debug('Validating service catalog endpoint dat... | python | def validate_v2_svc_catalog_endpoint_data(self, expected, actual):
"""Validate service catalog endpoint data.
Validate a list of actual service catalog endpoints vs a list of
expected service catalog endpoints.
"""
self.log.debug('Validating service catalog endpoint dat... | [
"def",
"validate_v2_svc_catalog_endpoint_data",
"(",
"self",
",",
"expected",
",",
"actual",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Validating service catalog endpoint data...'",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'actual: {}'",
".",
"format"... | Validate service catalog endpoint data.
Validate a list of actual service catalog endpoints vs a list of
expected service catalog endpoints. | [
"Validate",
"service",
"catalog",
"endpoint",
"data",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L260-L275 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.validate_v3_svc_catalog_endpoint_data | def validate_v3_svc_catalog_endpoint_data(self, expected, actual):
"""Validate the keystone v3 catalog endpoint data.
Validate a list of dictinaries that make up the keystone v3 service
catalogue.
It is in the form of:
{u'identity': [{u'id': u'48346b01c6804b298cdd7349aadb732e... | python | def validate_v3_svc_catalog_endpoint_data(self, expected, actual):
"""Validate the keystone v3 catalog endpoint data.
Validate a list of dictinaries that make up the keystone v3 service
catalogue.
It is in the form of:
{u'identity': [{u'id': u'48346b01c6804b298cdd7349aadb732e... | [
"def",
"validate_v3_svc_catalog_endpoint_data",
"(",
"self",
",",
"expected",
",",
"actual",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Validating v3 service catalog endpoint data...'",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'actual: {}'",
".",
"form... | Validate the keystone v3 catalog endpoint data.
Validate a list of dictinaries that make up the keystone v3 service
catalogue.
It is in the form of:
{u'identity': [{u'id': u'48346b01c6804b298cdd7349aadb732e',
u'interface': u'admin',
u'r... | [
"Validate",
"the",
"keystone",
"v3",
"catalog",
"endpoint",
"data",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L277-L341 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.validate_tenant_data | def validate_tenant_data(self, expected, actual):
"""Validate tenant data.
Validate a list of actual tenant data vs list of expected tenant
data.
"""
self.log.debug('Validating tenant data...')
self.log.debug('actual: {}'.format(repr(actual)))
for e in e... | python | def validate_tenant_data(self, expected, actual):
"""Validate tenant data.
Validate a list of actual tenant data vs list of expected tenant
data.
"""
self.log.debug('Validating tenant data...')
self.log.debug('actual: {}'.format(repr(actual)))
for e in e... | [
"def",
"validate_tenant_data",
"(",
"self",
",",
"expected",
",",
"actual",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Validating tenant data...'",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'actual: {}'",
".",
"format",
"(",
"repr",
"(",
"actual... | Validate tenant data.
Validate a list of actual tenant data vs list of expected tenant
data. | [
"Validate",
"tenant",
"data",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L343-L363 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.validate_user_data | def validate_user_data(self, expected, actual, api_version=None):
"""Validate user data.
Validate a list of actual user data vs a list of expected user
data.
"""
self.log.debug('Validating user data...')
self.log.debug('actual: {}'.format(repr(actual)))
... | python | def validate_user_data(self, expected, actual, api_version=None):
"""Validate user data.
Validate a list of actual user data vs a list of expected user
data.
"""
self.log.debug('Validating user data...')
self.log.debug('actual: {}'.format(repr(actual)))
... | [
"def",
"validate_user_data",
"(",
"self",
",",
"expected",
",",
"actual",
",",
"api_version",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Validating user data...'",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'actual: {}'",
".",
"forma... | Validate user data.
Validate a list of actual user data vs a list of expected user
data. | [
"Validate",
"user",
"data",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L386-L412 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.validate_flavor_data | def validate_flavor_data(self, expected, actual):
"""Validate flavor data.
Validate a list of actual flavors vs a list of expected flavors.
"""
self.log.debug('Validating flavor data...')
self.log.debug('actual: {}'.format(repr(actual)))
act = [a.name for a in actu... | python | def validate_flavor_data(self, expected, actual):
"""Validate flavor data.
Validate a list of actual flavors vs a list of expected flavors.
"""
self.log.debug('Validating flavor data...')
self.log.debug('actual: {}'.format(repr(actual)))
act = [a.name for a in actu... | [
"def",
"validate_flavor_data",
"(",
"self",
",",
"expected",
",",
"actual",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Validating flavor data...'",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'actual: {}'",
".",
"format",
"(",
"repr",
"(",
"actual... | Validate flavor data.
Validate a list of actual flavors vs a list of expected flavors. | [
"Validate",
"flavor",
"data",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L414-L422 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.tenant_exists | def tenant_exists(self, keystone, tenant):
"""Return True if tenant exists."""
self.log.debug('Checking if tenant exists ({})...'.format(tenant))
return tenant in [t.name for t in keystone.tenants.list()] | python | def tenant_exists(self, keystone, tenant):
"""Return True if tenant exists."""
self.log.debug('Checking if tenant exists ({})...'.format(tenant))
return tenant in [t.name for t in keystone.tenants.list()] | [
"def",
"tenant_exists",
"(",
"self",
",",
"keystone",
",",
"tenant",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Checking if tenant exists ({})...'",
".",
"format",
"(",
"tenant",
")",
")",
"return",
"tenant",
"in",
"[",
"t",
".",
"name",
"for",
"... | Return True if tenant exists. | [
"Return",
"True",
"if",
"tenant",
"exists",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L424-L427 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.keystone_wait_for_propagation | def keystone_wait_for_propagation(self, sentry_relation_pairs,
api_version):
"""Iterate over list of sentry and relation tuples and verify that
api_version has the expected value.
:param sentry_relation_pairs: list of sentry, relation name tuples used
... | python | def keystone_wait_for_propagation(self, sentry_relation_pairs,
api_version):
"""Iterate over list of sentry and relation tuples and verify that
api_version has the expected value.
:param sentry_relation_pairs: list of sentry, relation name tuples used
... | [
"def",
"keystone_wait_for_propagation",
"(",
"self",
",",
"sentry_relation_pairs",
",",
"api_version",
")",
":",
"for",
"(",
"sentry",
",",
"relation_name",
")",
"in",
"sentry_relation_pairs",
":",
"rel",
"=",
"sentry",
".",
"relation",
"(",
"'identity-service'",
... | Iterate over list of sentry and relation tuples and verify that
api_version has the expected value.
:param sentry_relation_pairs: list of sentry, relation name tuples used
for monitoring propagation of relation
data
... | [
"Iterate",
"over",
"list",
"of",
"sentry",
"and",
"relation",
"tuples",
"and",
"verify",
"that",
"api_version",
"has",
"the",
"expected",
"value",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L430-L448 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.keystone_configure_api_version | def keystone_configure_api_version(self, sentry_relation_pairs, deployment,
api_version):
"""Configure preferred-api-version of keystone in deployment and
monitor provided list of relation objects for propagation
before returning to caller.
:... | python | def keystone_configure_api_version(self, sentry_relation_pairs, deployment,
api_version):
"""Configure preferred-api-version of keystone in deployment and
monitor provided list of relation objects for propagation
before returning to caller.
:... | [
"def",
"keystone_configure_api_version",
"(",
"self",
",",
"sentry_relation_pairs",
",",
"deployment",
",",
"api_version",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Setting keystone preferred-api-version: '{}'\"",
"\"\"",
".",
"format",
"(",
"api_version",
"... | Configure preferred-api-version of keystone in deployment and
monitor provided list of relation objects for propagation
before returning to caller.
:param sentry_relation_pairs: list of sentry, relation tuples used for
monitoring propagation of relati... | [
"Configure",
"preferred",
"-",
"api",
"-",
"version",
"of",
"keystone",
"in",
"deployment",
"and",
"monitor",
"provided",
"list",
"of",
"relation",
"objects",
"for",
"propagation",
"before",
"returning",
"to",
"caller",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L450-L468 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_cinder_admin | def authenticate_cinder_admin(self, keystone, api_version=2):
"""Authenticates admin user with cinder."""
self.log.debug('Authenticating cinder admin...')
_clients = {
1: cinder_client.Client,
2: cinder_clientv2.Client}
return _clients[api_version](session=keyston... | python | def authenticate_cinder_admin(self, keystone, api_version=2):
"""Authenticates admin user with cinder."""
self.log.debug('Authenticating cinder admin...')
_clients = {
1: cinder_client.Client,
2: cinder_clientv2.Client}
return _clients[api_version](session=keyston... | [
"def",
"authenticate_cinder_admin",
"(",
"self",
",",
"keystone",
",",
"api_version",
"=",
"2",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Authenticating cinder admin...'",
")",
"_clients",
"=",
"{",
"1",
":",
"cinder_client",
".",
"Client",
",",
"2"... | Authenticates admin user with cinder. | [
"Authenticates",
"admin",
"user",
"with",
"cinder",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L470-L476 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_keystone | def authenticate_keystone(self, keystone_ip, username, password,
api_version=False, admin_port=False,
user_domain_name=None, domain_name=None,
project_domain_name=None, project_name=None):
"""Authenticate with Keystone"""
... | python | def authenticate_keystone(self, keystone_ip, username, password,
api_version=False, admin_port=False,
user_domain_name=None, domain_name=None,
project_domain_name=None, project_name=None):
"""Authenticate with Keystone"""
... | [
"def",
"authenticate_keystone",
"(",
"self",
",",
"keystone_ip",
",",
"username",
",",
"password",
",",
"api_version",
"=",
"False",
",",
"admin_port",
"=",
"False",
",",
"user_domain_name",
"=",
"None",
",",
"domain_name",
"=",
"None",
",",
"project_domain_name... | Authenticate with Keystone | [
"Authenticate",
"with",
"Keystone"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L478-L503 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.get_keystone_session | def get_keystone_session(self, keystone_ip, username, password,
api_version=False, admin_port=False,
user_domain_name=None, domain_name=None,
project_domain_name=None, project_name=None):
"""Return a keystone session object""... | python | def get_keystone_session(self, keystone_ip, username, password,
api_version=False, admin_port=False,
user_domain_name=None, domain_name=None,
project_domain_name=None, project_name=None):
"""Return a keystone session object""... | [
"def",
"get_keystone_session",
"(",
"self",
",",
"keystone_ip",
",",
"username",
",",
"password",
",",
"api_version",
"=",
"False",
",",
"admin_port",
"=",
"False",
",",
"user_domain_name",
"=",
"None",
",",
"domain_name",
"=",
"None",
",",
"project_domain_name"... | Return a keystone session object | [
"Return",
"a",
"keystone",
"session",
"object"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L505-L532 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.get_keystone_endpoint | def get_keystone_endpoint(self, keystone_ip, api_version=None,
admin_port=False):
"""Return keystone endpoint"""
port = 5000
if admin_port:
port = 35357
base_ep = "http://{}:{}".format(keystone_ip.strip().decode('utf-8'),
... | python | def get_keystone_endpoint(self, keystone_ip, api_version=None,
admin_port=False):
"""Return keystone endpoint"""
port = 5000
if admin_port:
port = 35357
base_ep = "http://{}:{}".format(keystone_ip.strip().decode('utf-8'),
... | [
"def",
"get_keystone_endpoint",
"(",
"self",
",",
"keystone_ip",
",",
"api_version",
"=",
"None",
",",
"admin_port",
"=",
"False",
")",
":",
"port",
"=",
"5000",
"if",
"admin_port",
":",
"port",
"=",
"35357",
"base_ep",
"=",
"\"http://{}:{}\"",
".",
"format"... | Return keystone endpoint | [
"Return",
"keystone",
"endpoint"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L534-L546 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.get_default_keystone_session | def get_default_keystone_session(self, keystone_sentry,
openstack_release=None, api_version=2):
"""Return a keystone session object and client object assuming standard
default settings
Example call in amulet tests:
self.keystone_session,... | python | def get_default_keystone_session(self, keystone_sentry,
openstack_release=None, api_version=2):
"""Return a keystone session object and client object assuming standard
default settings
Example call in amulet tests:
self.keystone_session,... | [
"def",
"get_default_keystone_session",
"(",
"self",
",",
"keystone_sentry",
",",
"openstack_release",
"=",
"None",
",",
"api_version",
"=",
"2",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Authenticating keystone admin...'",
")",
"# 11 => xenial_queens",
"if"... | Return a keystone session object and client object assuming standard
default settings
Example call in amulet tests:
self.keystone_session, self.keystone = u.get_default_keystone_session(
self.keystone_sentry,
openstack_release=self._get_opensta... | [
"Return",
"a",
"keystone",
"session",
"object",
"and",
"client",
"object",
"assuming",
"standard",
"default",
"settings"
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L548-L582 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_keystone_admin | def authenticate_keystone_admin(self, keystone_sentry, user, password,
tenant=None, api_version=None,
keystone_ip=None, user_domain_name=None,
project_domain_name=None,
project... | python | def authenticate_keystone_admin(self, keystone_sentry, user, password,
tenant=None, api_version=None,
keystone_ip=None, user_domain_name=None,
project_domain_name=None,
project... | [
"def",
"authenticate_keystone_admin",
"(",
"self",
",",
"keystone_sentry",
",",
"user",
",",
"password",
",",
"tenant",
"=",
"None",
",",
"api_version",
"=",
"None",
",",
"keystone_ip",
"=",
"None",
",",
"user_domain_name",
"=",
"None",
",",
"project_domain_name... | Authenticates admin user with the keystone admin endpoint. | [
"Authenticates",
"admin",
"user",
"with",
"the",
"keystone",
"admin",
"endpoint",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L584-L610 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_keystone_user | def authenticate_keystone_user(self, keystone, user, password, tenant):
"""Authenticates a regular user with the keystone public endpoint."""
self.log.debug('Authenticating keystone user ({})...'.format(user))
ep = keystone.service_catalog.url_for(service_type='identity',
... | python | def authenticate_keystone_user(self, keystone, user, password, tenant):
"""Authenticates a regular user with the keystone public endpoint."""
self.log.debug('Authenticating keystone user ({})...'.format(user))
ep = keystone.service_catalog.url_for(service_type='identity',
... | [
"def",
"authenticate_keystone_user",
"(",
"self",
",",
"keystone",
",",
"user",
",",
"password",
",",
"tenant",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Authenticating keystone user ({})...'",
".",
"format",
"(",
"user",
")",
")",
"ep",
"=",
"keyst... | Authenticates a regular user with the keystone public endpoint. | [
"Authenticates",
"a",
"regular",
"user",
"with",
"the",
"keystone",
"public",
"endpoint",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L612-L620 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_glance_admin | def authenticate_glance_admin(self, keystone, force_v1_client=False):
"""Authenticates admin user with glance."""
self.log.debug('Authenticating glance admin...')
ep = keystone.service_catalog.url_for(service_type='image',
interface='adminURL')
... | python | def authenticate_glance_admin(self, keystone, force_v1_client=False):
"""Authenticates admin user with glance."""
self.log.debug('Authenticating glance admin...')
ep = keystone.service_catalog.url_for(service_type='image',
interface='adminURL')
... | [
"def",
"authenticate_glance_admin",
"(",
"self",
",",
"keystone",
",",
"force_v1_client",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Authenticating glance admin...'",
")",
"ep",
"=",
"keystone",
".",
"service_catalog",
".",
"url_for",
"(",
... | Authenticates admin user with glance. | [
"Authenticates",
"admin",
"user",
"with",
"glance",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L622-L630 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_heat_admin | def authenticate_heat_admin(self, keystone):
"""Authenticates the admin user with heat."""
self.log.debug('Authenticating heat admin...')
ep = keystone.service_catalog.url_for(service_type='orchestration',
interface='publicURL')
if keystone.s... | python | def authenticate_heat_admin(self, keystone):
"""Authenticates the admin user with heat."""
self.log.debug('Authenticating heat admin...')
ep = keystone.service_catalog.url_for(service_type='orchestration',
interface='publicURL')
if keystone.s... | [
"def",
"authenticate_heat_admin",
"(",
"self",
",",
"keystone",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Authenticating heat admin...'",
")",
"ep",
"=",
"keystone",
".",
"service_catalog",
".",
"url_for",
"(",
"service_type",
"=",
"'orchestration'",
",... | Authenticates the admin user with heat. | [
"Authenticates",
"the",
"admin",
"user",
"with",
"heat",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L632-L640 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_nova_user | def authenticate_nova_user(self, keystone, user, password, tenant):
"""Authenticates a regular user with nova-api."""
self.log.debug('Authenticating nova user ({})...'.format(user))
ep = keystone.service_catalog.url_for(service_type='identity',
inter... | python | def authenticate_nova_user(self, keystone, user, password, tenant):
"""Authenticates a regular user with nova-api."""
self.log.debug('Authenticating nova user ({})...'.format(user))
ep = keystone.service_catalog.url_for(service_type='identity',
inter... | [
"def",
"authenticate_nova_user",
"(",
"self",
",",
"keystone",
",",
"user",
",",
"password",
",",
"tenant",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Authenticating nova user ({})...'",
".",
"format",
"(",
"user",
")",
")",
"ep",
"=",
"keystone",
... | Authenticates a regular user with nova-api. | [
"Authenticates",
"a",
"regular",
"user",
"with",
"nova",
"-",
"api",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L642-L658 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.authenticate_swift_user | def authenticate_swift_user(self, keystone, user, password, tenant):
"""Authenticates a regular user with swift api."""
self.log.debug('Authenticating swift user ({})...'.format(user))
ep = keystone.service_catalog.url_for(service_type='identity',
in... | python | def authenticate_swift_user(self, keystone, user, password, tenant):
"""Authenticates a regular user with swift api."""
self.log.debug('Authenticating swift user ({})...'.format(user))
ep = keystone.service_catalog.url_for(service_type='identity',
in... | [
"def",
"authenticate_swift_user",
"(",
"self",
",",
"keystone",
",",
"user",
",",
"password",
",",
"tenant",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Authenticating swift user ({})...'",
".",
"format",
"(",
"user",
")",
")",
"ep",
"=",
"keystone",
... | Authenticates a regular user with swift api. | [
"Authenticates",
"a",
"regular",
"user",
"with",
"swift",
"api",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L660-L672 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.create_flavor | def create_flavor(self, nova, name, ram, vcpus, disk, flavorid="auto",
ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True):
"""Create the specified flavor."""
try:
nova.flavors.find(name=name)
except (exceptions.NotFound, exceptions.NoUniqueMatch):
... | python | def create_flavor(self, nova, name, ram, vcpus, disk, flavorid="auto",
ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True):
"""Create the specified flavor."""
try:
nova.flavors.find(name=name)
except (exceptions.NotFound, exceptions.NoUniqueMatch):
... | [
"def",
"create_flavor",
"(",
"self",
",",
"nova",
",",
"name",
",",
"ram",
",",
"vcpus",
",",
"disk",
",",
"flavorid",
"=",
"\"auto\"",
",",
"ephemeral",
"=",
"0",
",",
"swap",
"=",
"0",
",",
"rxtx_factor",
"=",
"1.0",
",",
"is_public",
"=",
"True",
... | Create the specified flavor. | [
"Create",
"the",
"specified",
"flavor",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L674-L682 | train |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | OpenStackAmuletUtils.glance_create_image | def glance_create_image(self, glance, image_name, image_url,
download_dir='tests',
hypervisor_type=None,
disk_format='qcow2',
architecture='x86_64',
container_format='bare'):
... | python | def glance_create_image(self, glance, image_name, image_url,
download_dir='tests',
hypervisor_type=None,
disk_format='qcow2',
architecture='x86_64',
container_format='bare'):
... | [
"def",
"glance_create_image",
"(",
"self",
",",
"glance",
",",
"image_name",
",",
"image_url",
",",
"download_dir",
"=",
"'tests'",
",",
"hypervisor_type",
"=",
"None",
",",
"disk_format",
"=",
"'qcow2'",
",",
"architecture",
"=",
"'x86_64'",
",",
"container_for... | Download an image and upload it to glance, validate its status
and return an image object pointer. KVM defaults, can override for
LXD.
:param glance: pointer to authenticated glance api connection
:param image_name: display name for new image
:param image_url: url to retrieve
... | [
"Download",
"an",
"image",
"and",
"upload",
"it",
"to",
"glance",
"validate",
"its",
"status",
"and",
"return",
"an",
"image",
"object",
"pointer",
".",
"KVM",
"defaults",
"can",
"override",
"for",
"LXD",
"."
] | aa785c40c3b7a8c69dbfbc7921d6b9f30142e171 | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L684-L779 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.