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/amulet/utils.py
OpenStackAmuletUtils.create_cirros_image
def create_cirros_image(self, glance, image_name, hypervisor_type=None): """Download the latest cirros image and upload it to glance, validate and return a resource pointer. :param glance: pointer to authenticated glance connection :param image_name: display name for new image :...
python
def create_cirros_image(self, glance, image_name, hypervisor_type=None): """Download the latest cirros image and upload it to glance, validate and return a resource pointer. :param glance: pointer to authenticated glance connection :param image_name: display name for new image :...
[ "def", "create_cirros_image", "(", "self", ",", "glance", ",", "image_name", ",", "hypervisor_type", "=", "None", ")", ":", "# /!\\ DEPRECATION WARNING", "self", ".", "log", ".", "warn", "(", "'/!\\\\ DEPRECATION WARNING: use '", "'glance_create_image instead of '", "'...
Download the latest cirros image and upload it to glance, validate and return a resource pointer. :param glance: pointer to authenticated glance connection :param image_name: display name for new image :param hypervisor_type: glance image hypervisor property :returns: glance ima...
[ "Download", "the", "latest", "cirros", "image", "and", "upload", "it", "to", "glance", "validate", "and", "return", "a", "resource", "pointer", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L781-L818
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.delete_image
def delete_image(self, glance, image): """Delete the specified image.""" # /!\ DEPRECATION WARNING self.log.warn('/!\\ DEPRECATION WARNING: use ' 'delete_resource instead of delete_image.') self.log.debug('Deleting glance image ({})...'.format(image)) retu...
python
def delete_image(self, glance, image): """Delete the specified image.""" # /!\ DEPRECATION WARNING self.log.warn('/!\\ DEPRECATION WARNING: use ' 'delete_resource instead of delete_image.') self.log.debug('Deleting glance image ({})...'.format(image)) retu...
[ "def", "delete_image", "(", "self", ",", "glance", ",", "image", ")", ":", "# /!\\ DEPRECATION WARNING", "self", ".", "log", ".", "warn", "(", "'/!\\\\ DEPRECATION WARNING: use '", "'delete_resource instead of delete_image.'", ")", "self", ".", "log", ".", "debug", ...
Delete the specified image.
[ "Delete", "the", "specified", "image", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L820-L827
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.create_instance
def create_instance(self, nova, image_name, instance_name, flavor): """Create the specified instance.""" self.log.debug('Creating instance ' '({}|{}|{})'.format(instance_name, image_name, flavor)) image = nova.glance.find_image(image_name) flavor = nova.flavors.fin...
python
def create_instance(self, nova, image_name, instance_name, flavor): """Create the specified instance.""" self.log.debug('Creating instance ' '({}|{}|{})'.format(instance_name, image_name, flavor)) image = nova.glance.find_image(image_name) flavor = nova.flavors.fin...
[ "def", "create_instance", "(", "self", ",", "nova", ",", "image_name", ",", "instance_name", ",", "flavor", ")", ":", "self", ".", "log", ".", "debug", "(", "'Creating instance '", "'({}|{}|{})'", ".", "format", "(", "instance_name", ",", "image_name", ",", ...
Create the specified instance.
[ "Create", "the", "specified", "instance", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L829-L851
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.delete_instance
def delete_instance(self, nova, instance): """Delete the specified instance.""" # /!\ DEPRECATION WARNING self.log.warn('/!\\ DEPRECATION WARNING: use ' 'delete_resource instead of delete_instance.') self.log.debug('Deleting instance ({})...'.format(instance)) ...
python
def delete_instance(self, nova, instance): """Delete the specified instance.""" # /!\ DEPRECATION WARNING self.log.warn('/!\\ DEPRECATION WARNING: use ' 'delete_resource instead of delete_instance.') self.log.debug('Deleting instance ({})...'.format(instance)) ...
[ "def", "delete_instance", "(", "self", ",", "nova", ",", "instance", ")", ":", "# /!\\ DEPRECATION WARNING", "self", ".", "log", ".", "warn", "(", "'/!\\\\ DEPRECATION WARNING: use '", "'delete_resource instead of delete_instance.'", ")", "self", ".", "log", ".", "de...
Delete the specified instance.
[ "Delete", "the", "specified", "instance", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L853-L861
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.create_or_get_keypair
def create_or_get_keypair(self, nova, keypair_name="testkey"): """Create a new keypair, or return pointer if it already exists.""" try: _keypair = nova.keypairs.get(keypair_name) self.log.debug('Keypair ({}) already exists, ' 'using it.'.format(keypair_...
python
def create_or_get_keypair(self, nova, keypair_name="testkey"): """Create a new keypair, or return pointer if it already exists.""" try: _keypair = nova.keypairs.get(keypair_name) self.log.debug('Keypair ({}) already exists, ' 'using it.'.format(keypair_...
[ "def", "create_or_get_keypair", "(", "self", ",", "nova", ",", "keypair_name", "=", "\"testkey\"", ")", ":", "try", ":", "_keypair", "=", "nova", ".", "keypairs", ".", "get", "(", "keypair_name", ")", "self", ".", "log", ".", "debug", "(", "'Keypair ({}) a...
Create a new keypair, or return pointer if it already exists.
[ "Create", "a", "new", "keypair", "or", "return", "pointer", "if", "it", "already", "exists", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L863-L875
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.create_cinder_volume
def create_cinder_volume(self, cinder, vol_name="demo-vol", vol_size=1, img_id=None, src_vol_id=None, snap_id=None): """Create cinder volume, optionally from a glance image, OR optionally as a clone of an existing volume, OR optionally from a snapshot. Wait for the ...
python
def create_cinder_volume(self, cinder, vol_name="demo-vol", vol_size=1, img_id=None, src_vol_id=None, snap_id=None): """Create cinder volume, optionally from a glance image, OR optionally as a clone of an existing volume, OR optionally from a snapshot. Wait for the ...
[ "def", "create_cinder_volume", "(", "self", ",", "cinder", ",", "vol_name", "=", "\"demo-vol\"", ",", "vol_size", "=", "1", ",", "img_id", "=", "None", ",", "src_vol_id", "=", "None", ",", "snap_id", "=", "None", ")", ":", "# Handle parameter input and avoid i...
Create cinder volume, optionally from a glance image, OR optionally as a clone of an existing volume, OR optionally from a snapshot. Wait for the new volume status to reach the expected status, validate and return a resource pointer. :param vol_name: cinder volume display name ...
[ "Create", "cinder", "volume", "optionally", "from", "a", "glance", "image", "OR", "optionally", "as", "a", "clone", "of", "an", "existing", "volume", "OR", "optionally", "from", "a", "snapshot", ".", "Wait", "for", "the", "new", "volume", "status", "to", "...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L889-L976
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.delete_resource
def delete_resource(self, resource, resource_id, msg="resource", max_wait=120): """Delete one openstack resource, such as one instance, keypair, image, volume, stack, etc., and confirm deletion within max wait time. :param resource: pointer to os resource type, ex:glance...
python
def delete_resource(self, resource, resource_id, msg="resource", max_wait=120): """Delete one openstack resource, such as one instance, keypair, image, volume, stack, etc., and confirm deletion within max wait time. :param resource: pointer to os resource type, ex:glance...
[ "def", "delete_resource", "(", "self", ",", "resource", ",", "resource_id", ",", "msg", "=", "\"resource\"", ",", "max_wait", "=", "120", ")", ":", "self", ".", "log", ".", "debug", "(", "'Deleting OpenStack resource '", "'{} ({})'", ".", "format", "(", "res...
Delete one openstack resource, such as one instance, keypair, image, volume, stack, etc., and confirm deletion within max wait time. :param resource: pointer to os resource type, ex:glance_client.images :param resource_id: unique name or id for the openstack resource :param msg: text to...
[ "Delete", "one", "openstack", "resource", "such", "as", "one", "instance", "keypair", "image", "volume", "stack", "etc", ".", "and", "confirm", "deletion", "within", "max", "wait", "time", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L978-L1013
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.resource_reaches_status
def resource_reaches_status(self, resource, resource_id, expected_stat='available', msg='resource', max_wait=120): """Wait for an openstack resources status to reach an expected status within a specified time. Useful to confirm that ...
python
def resource_reaches_status(self, resource, resource_id, expected_stat='available', msg='resource', max_wait=120): """Wait for an openstack resources status to reach an expected status within a specified time. Useful to confirm that ...
[ "def", "resource_reaches_status", "(", "self", ",", "resource", ",", "resource_id", ",", "expected_stat", "=", "'available'", ",", "msg", "=", "'resource'", ",", "max_wait", "=", "120", ")", ":", "tries", "=", "0", "resource_stat", "=", "resource", ".", "get...
Wait for an openstack resources status to reach an expected status within a specified time. Useful to confirm that nova instances, cinder vols, snapshots, glance images, heat stacks and other resources eventually reach the expected status. :param resource: pointer to os resour...
[ "Wait", "for", "an", "openstack", "resources", "status", "to", "reach", "an", "expected", "status", "within", "a", "specified", "time", ".", "Useful", "to", "confirm", "that", "nova", "instances", "cinder", "vols", "snapshots", "glance", "images", "heat", "sta...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1015-L1051
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.get_ceph_pools
def get_ceph_pools(self, sentry_unit): """Return a dict of ceph pools from a single ceph unit, with pool name as keys, pool id as vals.""" pools = {} cmd = 'sudo ceph osd lspools' output, code = sentry_unit.run(cmd) if code != 0: msg = ('{} `{}` returned {} ' ...
python
def get_ceph_pools(self, sentry_unit): """Return a dict of ceph pools from a single ceph unit, with pool name as keys, pool id as vals.""" pools = {} cmd = 'sudo ceph osd lspools' output, code = sentry_unit.run(cmd) if code != 0: msg = ('{} `{}` returned {} ' ...
[ "def", "get_ceph_pools", "(", "self", ",", "sentry_unit", ")", ":", "pools", "=", "{", "}", "cmd", "=", "'sudo ceph osd lspools'", "output", ",", "code", "=", "sentry_unit", ".", "run", "(", "cmd", ")", "if", "code", "!=", "0", ":", "msg", "=", "(", ...
Return a dict of ceph pools from a single ceph unit, with pool name as keys, pool id as vals.
[ "Return", "a", "dict", "of", "ceph", "pools", "from", "a", "single", "ceph", "unit", "with", "pool", "name", "as", "keys", "pool", "id", "as", "vals", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1059-L1084
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.get_ceph_df
def get_ceph_df(self, sentry_unit): """Return dict of ceph df json output, including ceph pool state. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :returns: Dict of ceph df output """ cmd = 'sudo ceph df --format=json' output, code = sentry_unit.run(...
python
def get_ceph_df(self, sentry_unit): """Return dict of ceph df json output, including ceph pool state. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :returns: Dict of ceph df output """ cmd = 'sudo ceph df --format=json' output, code = sentry_unit.run(...
[ "def", "get_ceph_df", "(", "self", ",", "sentry_unit", ")", ":", "cmd", "=", "'sudo ceph df --format=json'", "output", ",", "code", "=", "sentry_unit", ".", "run", "(", "cmd", ")", "if", "code", "!=", "0", ":", "msg", "=", "(", "'{} `{}` returned {} '", "'...
Return dict of ceph df json output, including ceph pool state. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :returns: Dict of ceph df output
[ "Return", "dict", "of", "ceph", "df", "json", "output", "including", "ceph", "pool", "state", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1086-L1099
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.get_ceph_pool_sample
def get_ceph_pool_sample(self, sentry_unit, pool_id=0): """Take a sample of attributes of a ceph pool, returning ceph pool name, object count and disk space used for the specified pool ID number. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :param pool_id: C...
python
def get_ceph_pool_sample(self, sentry_unit, pool_id=0): """Take a sample of attributes of a ceph pool, returning ceph pool name, object count and disk space used for the specified pool ID number. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :param pool_id: C...
[ "def", "get_ceph_pool_sample", "(", "self", ",", "sentry_unit", ",", "pool_id", "=", "0", ")", ":", "df", "=", "self", ".", "get_ceph_df", "(", "sentry_unit", ")", "for", "pool", "in", "df", "[", "'pools'", "]", ":", "if", "pool", "[", "'id'", "]", "...
Take a sample of attributes of a ceph pool, returning ceph pool name, object count and disk space used for the specified pool ID number. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :param pool_id: Ceph pool ID :returns: List of pool name, object count, kb d...
[ "Take", "a", "sample", "of", "attributes", "of", "a", "ceph", "pool", "returning", "ceph", "pool", "name", "object", "count", "and", "disk", "space", "used", "for", "the", "specified", "pool", "ID", "number", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1101-L1120
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.validate_ceph_pool_samples
def validate_ceph_pool_samples(self, samples, sample_type="resource pool"): """Validate ceph pool samples taken over time, such as pool object counts or pool kb used, before adding, after adding, and after deleting items which affect those pool attributes. The 2nd element is expected to...
python
def validate_ceph_pool_samples(self, samples, sample_type="resource pool"): """Validate ceph pool samples taken over time, such as pool object counts or pool kb used, before adding, after adding, and after deleting items which affect those pool attributes. The 2nd element is expected to...
[ "def", "validate_ceph_pool_samples", "(", "self", ",", "samples", ",", "sample_type", "=", "\"resource pool\"", ")", ":", "original", ",", "created", ",", "deleted", "=", "range", "(", "3", ")", "if", "samples", "[", "created", "]", "<=", "samples", "[", "...
Validate ceph pool samples taken over time, such as pool object counts or pool kb used, before adding, after adding, and after deleting items which affect those pool attributes. The 2nd element is expected to be greater than the 1st; 3rd is expected to be less than the 2nd. :pa...
[ "Validate", "ceph", "pool", "samples", "taken", "over", "time", "such", "as", "pool", "object", "counts", "or", "pool", "kb", "used", "before", "adding", "after", "adding", "and", "after", "deleting", "items", "which", "affect", "those", "pool", "attributes", ...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1122-L1141
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.rmq_wait_for_cluster
def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200): """Wait for rmq units extended status to show cluster readiness, after an optional initial sleep period. Initial sleep is likely necessary to be effective following a config change, as status message may not instan...
python
def rmq_wait_for_cluster(self, deployment, init_sleep=15, timeout=1200): """Wait for rmq units extended status to show cluster readiness, after an optional initial sleep period. Initial sleep is likely necessary to be effective following a config change, as status message may not instan...
[ "def", "rmq_wait_for_cluster", "(", "self", ",", "deployment", ",", "init_sleep", "=", "15", ",", "timeout", "=", "1200", ")", ":", "if", "init_sleep", ":", "time", ".", "sleep", "(", "init_sleep", ")", "message", "=", "re", ".", "compile", "(", "'^Unit ...
Wait for rmq units extended status to show cluster readiness, after an optional initial sleep period. Initial sleep is likely necessary to be effective following a config change, as status message may not instantly update to non-ready.
[ "Wait", "for", "rmq", "units", "extended", "status", "to", "show", "cluster", "readiness", "after", "an", "optional", "initial", "sleep", "period", ".", "Initial", "sleep", "is", "likely", "necessary", "to", "be", "effective", "following", "a", "config", "chan...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1145-L1157
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.get_rmq_cluster_status
def get_rmq_cluster_status(self, sentry_unit): """Execute rabbitmq cluster status command on a unit and return the full output. :param unit: sentry unit :returns: String containing console output of cluster status command """ cmd = 'rabbitmqctl cluster_status' ou...
python
def get_rmq_cluster_status(self, sentry_unit): """Execute rabbitmq cluster status command on a unit and return the full output. :param unit: sentry unit :returns: String containing console output of cluster status command """ cmd = 'rabbitmqctl cluster_status' ou...
[ "def", "get_rmq_cluster_status", "(", "self", ",", "sentry_unit", ")", ":", "cmd", "=", "'rabbitmqctl cluster_status'", "output", ",", "_", "=", "self", ".", "run_cmd_unit", "(", "sentry_unit", ",", "cmd", ")", "self", ".", "log", ".", "debug", "(", "'{} clu...
Execute rabbitmq cluster status command on a unit and return the full output. :param unit: sentry unit :returns: String containing console output of cluster status command
[ "Execute", "rabbitmq", "cluster", "status", "command", "on", "a", "unit", "and", "return", "the", "full", "output", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1218-L1229
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.get_rmq_cluster_running_nodes
def get_rmq_cluster_running_nodes(self, sentry_unit): """Parse rabbitmqctl cluster_status output string, return list of running rabbitmq cluster nodes. :param unit: sentry unit :returns: List containing node names of running nodes """ # NOTE(beisner): rabbitmqctl cluster...
python
def get_rmq_cluster_running_nodes(self, sentry_unit): """Parse rabbitmqctl cluster_status output string, return list of running rabbitmq cluster nodes. :param unit: sentry unit :returns: List containing node names of running nodes """ # NOTE(beisner): rabbitmqctl cluster...
[ "def", "get_rmq_cluster_running_nodes", "(", "self", ",", "sentry_unit", ")", ":", "# NOTE(beisner): rabbitmqctl cluster_status output is not", "# json-parsable, do string chop foo, then json.loads that.", "str_stat", "=", "self", ".", "get_rmq_cluster_status", "(", "sentry_unit", ...
Parse rabbitmqctl cluster_status output string, return list of running rabbitmq cluster nodes. :param unit: sentry unit :returns: List containing node names of running nodes
[ "Parse", "rabbitmqctl", "cluster_status", "output", "string", "return", "list", "of", "running", "rabbitmq", "cluster", "nodes", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1231-L1248
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.validate_rmq_cluster_running_nodes
def validate_rmq_cluster_running_nodes(self, sentry_units): """Check that all rmq unit hostnames are represented in the cluster_status output of all units. :param host_names: dict of juju unit names to host names :param units: list of sentry unit pointers (all rmq units) :return...
python
def validate_rmq_cluster_running_nodes(self, sentry_units): """Check that all rmq unit hostnames are represented in the cluster_status output of all units. :param host_names: dict of juju unit names to host names :param units: list of sentry unit pointers (all rmq units) :return...
[ "def", "validate_rmq_cluster_running_nodes", "(", "self", ",", "sentry_units", ")", ":", "host_names", "=", "self", ".", "get_unit_hostnames", "(", "sentry_units", ")", "errors", "=", "[", "]", "# Query every unit for cluster_status running nodes", "for", "query_unit", ...
Check that all rmq unit hostnames are represented in the cluster_status output of all units. :param host_names: dict of juju unit names to host names :param units: list of sentry unit pointers (all rmq units) :returns: None if successful, otherwise return error message
[ "Check", "that", "all", "rmq", "unit", "hostnames", "are", "represented", "in", "the", "cluster_status", "output", "of", "all", "units", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1250-L1278
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.rmq_ssl_is_enabled_on_unit
def rmq_ssl_is_enabled_on_unit(self, sentry_unit, port=None): """Check a single juju rmq unit for ssl and port in the config file.""" host = sentry_unit.info['public-address'] unit_name = sentry_unit.info['unit_name'] conf_file = '/etc/rabbitmq/rabbitmq.config' conf_contents = s...
python
def rmq_ssl_is_enabled_on_unit(self, sentry_unit, port=None): """Check a single juju rmq unit for ssl and port in the config file.""" host = sentry_unit.info['public-address'] unit_name = sentry_unit.info['unit_name'] conf_file = '/etc/rabbitmq/rabbitmq.config' conf_contents = s...
[ "def", "rmq_ssl_is_enabled_on_unit", "(", "self", ",", "sentry_unit", ",", "port", "=", "None", ")", ":", "host", "=", "sentry_unit", ".", "info", "[", "'public-address'", "]", "unit_name", "=", "sentry_unit", ".", "info", "[", "'unit_name'", "]", "conf_file",...
Check a single juju rmq unit for ssl and port in the config file.
[ "Check", "a", "single", "juju", "rmq", "unit", "for", "ssl", "and", "port", "in", "the", "config", "file", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1280-L1313
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.validate_rmq_ssl_enabled_units
def validate_rmq_ssl_enabled_units(self, sentry_units, port=None): """Check that ssl is enabled on rmq juju sentry units. :param sentry_units: list of all rmq sentry units :param port: optional ssl port override to validate :returns: None if successful, otherwise return error message ...
python
def validate_rmq_ssl_enabled_units(self, sentry_units, port=None): """Check that ssl is enabled on rmq juju sentry units. :param sentry_units: list of all rmq sentry units :param port: optional ssl port override to validate :returns: None if successful, otherwise return error message ...
[ "def", "validate_rmq_ssl_enabled_units", "(", "self", ",", "sentry_units", ",", "port", "=", "None", ")", ":", "for", "sentry_unit", "in", "sentry_units", ":", "if", "not", "self", ".", "rmq_ssl_is_enabled_on_unit", "(", "sentry_unit", ",", "port", "=", "port", ...
Check that ssl is enabled on rmq juju sentry units. :param sentry_units: list of all rmq sentry units :param port: optional ssl port override to validate :returns: None if successful, otherwise return error message
[ "Check", "that", "ssl", "is", "enabled", "on", "rmq", "juju", "sentry", "units", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1315-L1326
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.validate_rmq_ssl_disabled_units
def validate_rmq_ssl_disabled_units(self, sentry_units): """Check that ssl is enabled on listed rmq juju sentry units. :param sentry_units: list of all rmq sentry units :returns: True if successful. Raise on error. """ for sentry_unit in sentry_units: if self.rmq_ss...
python
def validate_rmq_ssl_disabled_units(self, sentry_units): """Check that ssl is enabled on listed rmq juju sentry units. :param sentry_units: list of all rmq sentry units :returns: True if successful. Raise on error. """ for sentry_unit in sentry_units: if self.rmq_ss...
[ "def", "validate_rmq_ssl_disabled_units", "(", "self", ",", "sentry_units", ")", ":", "for", "sentry_unit", "in", "sentry_units", ":", "if", "self", ".", "rmq_ssl_is_enabled_on_unit", "(", "sentry_unit", ")", ":", "return", "(", "'Unexpected condition: ssl is enabled o...
Check that ssl is enabled on listed rmq juju sentry units. :param sentry_units: list of all rmq sentry units :returns: True if successful. Raise on error.
[ "Check", "that", "ssl", "is", "enabled", "on", "listed", "rmq", "juju", "sentry", "units", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1328-L1338
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.configure_rmq_ssl_on
def configure_rmq_ssl_on(self, sentry_units, deployment, port=None, max_wait=60): """Turn ssl charm config option on, with optional non-default ssl port specification. Confirm that it is enabled on every unit. :param sentry_units: list of sentry units ...
python
def configure_rmq_ssl_on(self, sentry_units, deployment, port=None, max_wait=60): """Turn ssl charm config option on, with optional non-default ssl port specification. Confirm that it is enabled on every unit. :param sentry_units: list of sentry units ...
[ "def", "configure_rmq_ssl_on", "(", "self", ",", "sentry_units", ",", "deployment", ",", "port", "=", "None", ",", "max_wait", "=", "60", ")", ":", "self", ".", "log", ".", "debug", "(", "'Setting ssl charm config option: on'", ")", "# Enable RMQ SSL", "config"...
Turn ssl charm config option on, with optional non-default ssl port specification. Confirm that it is enabled on every unit. :param sentry_units: list of sentry units :param deployment: amulet deployment object pointer :param port: amqp port, use defaults if None :param...
[ "Turn", "ssl", "charm", "config", "option", "on", "with", "optional", "non", "-", "default", "ssl", "port", "specification", ".", "Confirm", "that", "it", "is", "enabled", "on", "every", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1340-L1374
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.configure_rmq_ssl_off
def configure_rmq_ssl_off(self, sentry_units, deployment, max_wait=60): """Turn ssl charm config option off, confirm that it is disabled on every unit. :param sentry_units: list of sentry units :param deployment: amulet deployment object pointer :param max_wait: maximum time to ...
python
def configure_rmq_ssl_off(self, sentry_units, deployment, max_wait=60): """Turn ssl charm config option off, confirm that it is disabled on every unit. :param sentry_units: list of sentry units :param deployment: amulet deployment object pointer :param max_wait: maximum time to ...
[ "def", "configure_rmq_ssl_off", "(", "self", ",", "sentry_units", ",", "deployment", ",", "max_wait", "=", "60", ")", ":", "self", ".", "log", ".", "debug", "(", "'Setting ssl charm config option: off'", ")", "# Disable RMQ SSL", "config", "=", "{", "'ssl'", ":...
Turn ssl charm config option off, confirm that it is disabled on every unit. :param sentry_units: list of sentry units :param deployment: amulet deployment object pointer :param max_wait: maximum time to wait in seconds to confirm :returns: None if successful. Raise on error.
[ "Turn", "ssl", "charm", "config", "option", "off", "confirm", "that", "it", "is", "disabled", "on", "every", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1376-L1404
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.connect_amqp_by_unit
def connect_amqp_by_unit(self, sentry_unit, ssl=False, port=None, fatal=True, username="testuser1", password="changeme"): """Establish and return a pika amqp connection to the rabbitmq service running on a rmq juju unit. :param sentry_un...
python
def connect_amqp_by_unit(self, sentry_unit, ssl=False, port=None, fatal=True, username="testuser1", password="changeme"): """Establish and return a pika amqp connection to the rabbitmq service running on a rmq juju unit. :param sentry_un...
[ "def", "connect_amqp_by_unit", "(", "self", ",", "sentry_unit", ",", "ssl", "=", "False", ",", "port", "=", "None", ",", "fatal", "=", "True", ",", "username", "=", "\"testuser1\"", ",", "password", "=", "\"changeme\"", ")", ":", "host", "=", "sentry_unit"...
Establish and return a pika amqp connection to the rabbitmq service running on a rmq juju unit. :param sentry_unit: sentry unit pointer :param ssl: boolean, default to False :param port: amqp port, use defaults if None :param fatal: boolean, default to True (raises on connect er...
[ "Establish", "and", "return", "a", "pika", "amqp", "connection", "to", "the", "rabbitmq", "service", "running", "on", "a", "rmq", "juju", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1406-L1452
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.publish_amqp_message_by_unit
def publish_amqp_message_by_unit(self, sentry_unit, message, queue="test", ssl=False, username="testuser1", password="changeme", port=None): """Publish an amqp mess...
python
def publish_amqp_message_by_unit(self, sentry_unit, message, queue="test", ssl=False, username="testuser1", password="changeme", port=None): """Publish an amqp mess...
[ "def", "publish_amqp_message_by_unit", "(", "self", ",", "sentry_unit", ",", "message", ",", "queue", "=", "\"test\"", ",", "ssl", "=", "False", ",", "username", "=", "\"testuser1\"", ",", "password", "=", "\"changeme\"", ",", "port", "=", "None", ")", ":", ...
Publish an amqp message to a rmq juju unit. :param sentry_unit: sentry unit pointer :param message: amqp message string :param queue: message queue, default to test :param username: amqp user name, default to testuser1 :param password: amqp user password :param ssl: bool...
[ "Publish", "an", "amqp", "message", "to", "a", "rmq", "juju", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1454-L1489
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.get_amqp_message_by_unit
def get_amqp_message_by_unit(self, sentry_unit, queue="test", username="testuser1", password="changeme", ssl=False, port=None): """Get an amqp message from a rmq juju unit. :param sentry_unit: sentry unit...
python
def get_amqp_message_by_unit(self, sentry_unit, queue="test", username="testuser1", password="changeme", ssl=False, port=None): """Get an amqp message from a rmq juju unit. :param sentry_unit: sentry unit...
[ "def", "get_amqp_message_by_unit", "(", "self", ",", "sentry_unit", ",", "queue", "=", "\"test\"", ",", "username", "=", "\"testuser1\"", ",", "password", "=", "\"changeme\"", ",", "ssl", "=", "False", ",", "port", "=", "None", ")", ":", "connection", "=", ...
Get an amqp message from a rmq juju unit. :param sentry_unit: sentry unit pointer :param queue: message queue, default to test :param username: amqp user name, default to testuser1 :param password: amqp user password :param ssl: boolean, default to False :param port: amq...
[ "Get", "an", "amqp", "message", "from", "a", "rmq", "juju", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1491-L1521
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
OpenStackAmuletUtils.validate_memcache
def validate_memcache(self, sentry_unit, conf, os_release, earliest_release=5, section='keystone_authtoken', check_kvs=None): """Check Memcache is running and is configured to be used Example call from Amulet test: def test_110_memcache(s...
python
def validate_memcache(self, sentry_unit, conf, os_release, earliest_release=5, section='keystone_authtoken', check_kvs=None): """Check Memcache is running and is configured to be used Example call from Amulet test: def test_110_memcache(s...
[ "def", "validate_memcache", "(", "self", ",", "sentry_unit", ",", "conf", ",", "os_release", ",", "earliest_release", "=", "5", ",", "section", "=", "'keystone_authtoken'", ",", "check_kvs", "=", "None", ")", ":", "if", "os_release", "<", "earliest_release", "...
Check Memcache is running and is configured to be used Example call from Amulet test: def test_110_memcache(self): u.validate_memcache(self.neutron_api_sentry, '/etc/neutron/neutron.conf', self._get_openstack_r...
[ "Check", "Memcache", "is", "running", "and", "is", "configured", "to", "be", "used" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1523-L1588
train
juju/charm-helpers
charmhelpers/coordinator.py
BaseCoordinator.acquire
def acquire(self, lock): '''Acquire the named lock, non-blocking. The lock may be granted immediately, or in a future hook. Returns True if the lock has been granted. The lock will be automatically released at the end of the hook in which it is granted. Do not mindless...
python
def acquire(self, lock): '''Acquire the named lock, non-blocking. The lock may be granted immediately, or in a future hook. Returns True if the lock has been granted. The lock will be automatically released at the end of the hook in which it is granted. Do not mindless...
[ "def", "acquire", "(", "self", ",", "lock", ")", ":", "unit", "=", "hookenv", ".", "local_unit", "(", ")", "ts", "=", "self", ".", "requests", "[", "unit", "]", ".", "get", "(", "lock", ")", "if", "not", "ts", ":", "# If there is no outstanding request...
Acquire the named lock, non-blocking. The lock may be granted immediately, or in a future hook. Returns True if the lock has been granted. The lock will be automatically released at the end of the hook in which it is granted. Do not mindlessly call this method, as it triggers ...
[ "Acquire", "the", "named", "lock", "non", "-", "blocking", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/coordinator.py#L301-L336
train
juju/charm-helpers
charmhelpers/coordinator.py
BaseCoordinator.granted
def granted(self, lock): '''Return True if a previously requested lock has been granted''' unit = hookenv.local_unit() ts = self.requests[unit].get(lock) if ts and self.grants.get(unit, {}).get(lock) == ts: return True return False
python
def granted(self, lock): '''Return True if a previously requested lock has been granted''' unit = hookenv.local_unit() ts = self.requests[unit].get(lock) if ts and self.grants.get(unit, {}).get(lock) == ts: return True return False
[ "def", "granted", "(", "self", ",", "lock", ")", ":", "unit", "=", "hookenv", ".", "local_unit", "(", ")", "ts", "=", "self", ".", "requests", "[", "unit", "]", ".", "get", "(", "lock", ")", "if", "ts", "and", "self", ".", "grants", ".", "get", ...
Return True if a previously requested lock has been granted
[ "Return", "True", "if", "a", "previously", "requested", "lock", "has", "been", "granted" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/coordinator.py#L338-L344
train
juju/charm-helpers
charmhelpers/coordinator.py
BaseCoordinator.request_timestamp
def request_timestamp(self, lock): '''Return the timestamp of our outstanding request for lock, or None. Returns a datetime.datetime() UTC timestamp, with no tzinfo attribute. ''' ts = self.requests[hookenv.local_unit()].get(lock, None) if ts is not None: return date...
python
def request_timestamp(self, lock): '''Return the timestamp of our outstanding request for lock, or None. Returns a datetime.datetime() UTC timestamp, with no tzinfo attribute. ''' ts = self.requests[hookenv.local_unit()].get(lock, None) if ts is not None: return date...
[ "def", "request_timestamp", "(", "self", ",", "lock", ")", ":", "ts", "=", "self", ".", "requests", "[", "hookenv", ".", "local_unit", "(", ")", "]", ".", "get", "(", "lock", ",", "None", ")", "if", "ts", "is", "not", "None", ":", "return", "dateti...
Return the timestamp of our outstanding request for lock, or None. Returns a datetime.datetime() UTC timestamp, with no tzinfo attribute.
[ "Return", "the", "timestamp", "of", "our", "outstanding", "request", "for", "lock", "or", "None", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/coordinator.py#L350-L357
train
juju/charm-helpers
charmhelpers/coordinator.py
BaseCoordinator.grant
def grant(self, lock, unit): '''Maybe grant the lock to a unit. The decision to grant the lock or not is made for $lock by a corresponding method grant_$lock, which you may define in a subclass. If no such method is defined, the default_grant method is used. See Serial.default_g...
python
def grant(self, lock, unit): '''Maybe grant the lock to a unit. The decision to grant the lock or not is made for $lock by a corresponding method grant_$lock, which you may define in a subclass. If no such method is defined, the default_grant method is used. See Serial.default_g...
[ "def", "grant", "(", "self", ",", "lock", ",", "unit", ")", ":", "if", "not", "hookenv", ".", "is_leader", "(", ")", ":", "return", "False", "# Not the leader, so we cannot grant.", "# Set of units already granted the lock.", "granted", "=", "set", "(", ")", "fo...
Maybe grant the lock to a unit. The decision to grant the lock or not is made for $lock by a corresponding method grant_$lock, which you may define in a subclass. If no such method is defined, the default_grant method is used. See Serial.default_grant() for details.
[ "Maybe", "grant", "the", "lock", "to", "a", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/coordinator.py#L387-L427
train
juju/charm-helpers
charmhelpers/coordinator.py
BaseCoordinator.released
def released(self, unit, lock, timestamp): '''Called on the leader when it has released a lock. By default, does nothing but log messages. Override if you need to perform additional housekeeping when a lock is released, for example recording timestamps. ''' interval = _u...
python
def released(self, unit, lock, timestamp): '''Called on the leader when it has released a lock. By default, does nothing but log messages. Override if you need to perform additional housekeeping when a lock is released, for example recording timestamps. ''' interval = _u...
[ "def", "released", "(", "self", ",", "unit", ",", "lock", ",", "timestamp", ")", ":", "interval", "=", "_utcnow", "(", ")", "-", "timestamp", "self", ".", "msg", "(", "'Leader released {} from {}, held {}'", ".", "format", "(", "lock", ",", "unit", ",", ...
Called on the leader when it has released a lock. By default, does nothing but log messages. Override if you need to perform additional housekeeping when a lock is released, for example recording timestamps.
[ "Called", "on", "the", "leader", "when", "it", "has", "released", "a", "lock", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/coordinator.py#L429-L438
train
juju/charm-helpers
charmhelpers/coordinator.py
BaseCoordinator.require
def require(self, lock, guard_func, *guard_args, **guard_kw): """Decorate a function to be run only when a lock is acquired. The lock is requested if the guard function returns True. The decorated function is called if the lock has been granted. """ def decorator(f): ...
python
def require(self, lock, guard_func, *guard_args, **guard_kw): """Decorate a function to be run only when a lock is acquired. The lock is requested if the guard function returns True. The decorated function is called if the lock has been granted. """ def decorator(f): ...
[ "def", "require", "(", "self", ",", "lock", ",", "guard_func", ",", "*", "guard_args", ",", "*", "*", "guard_kw", ")", ":", "def", "decorator", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", ...
Decorate a function to be run only when a lock is acquired. The lock is requested if the guard function returns True. The decorated function is called if the lock has been granted.
[ "Decorate", "a", "function", "to", "be", "run", "only", "when", "a", "lock", "is", "acquired", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/coordinator.py#L440-L457
train
juju/charm-helpers
charmhelpers/coordinator.py
BaseCoordinator.msg
def msg(self, msg): '''Emit a message. Override to customize log spam.''' hookenv.log('coordinator.{} {}'.format(self._name(), msg), level=hookenv.INFO)
python
def msg(self, msg): '''Emit a message. Override to customize log spam.''' hookenv.log('coordinator.{} {}'.format(self._name(), msg), level=hookenv.INFO)
[ "def", "msg", "(", "self", ",", "msg", ")", ":", "hookenv", ".", "log", "(", "'coordinator.{} {}'", ".", "format", "(", "self", ".", "_name", "(", ")", ",", "msg", ")", ",", "level", "=", "hookenv", ".", "INFO", ")" ]
Emit a message. Override to customize log spam.
[ "Emit", "a", "message", ".", "Override", "to", "customize", "log", "spam", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/coordinator.py#L459-L462
train
juju/charm-helpers
charmhelpers/__init__.py
deprecate
def deprecate(warning, date=None, log=None): """Add a deprecation warning the first time the function is used. The date, which is a string in semi-ISO8660 format indicate the year-month that the function is officially going to be removed. usage: @deprecate('use core/fetch/add_source() instead', '2...
python
def deprecate(warning, date=None, log=None): """Add a deprecation warning the first time the function is used. The date, which is a string in semi-ISO8660 format indicate the year-month that the function is officially going to be removed. usage: @deprecate('use core/fetch/add_source() instead', '2...
[ "def", "deprecate", "(", "warning", ",", "date", "=", "None", ",", "log", "=", "None", ")", ":", "def", "wrap", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapped_f", "(", "*", "args", ",", "*", "*", "kwargs", ")...
Add a deprecation warning the first time the function is used. The date, which is a string in semi-ISO8660 format indicate the year-month that the function is officially going to be removed. usage: @deprecate('use core/fetch/add_source() instead', '2017-04') def contributed_add_source_thing(...): ...
[ "Add", "a", "deprecation", "warning", "the", "first", "time", "the", "function", "is", "used", ".", "The", "date", "which", "is", "a", "string", "in", "semi", "-", "ISO8660", "format", "indicate", "the", "year", "-", "month", "that", "the", "function", "...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/__init__.py#L50-L97
train
juju/charm-helpers
charmhelpers/fetch/archiveurl.py
ArchiveUrlFetchHandler.download
def download(self, source, dest): """ Download an archive file. :param str source: URL pointing to an archive file. :param str dest: Local path location to download archive file to. """ # propagate all exceptions # URLError, OSError, etc proto, netloc, pa...
python
def download(self, source, dest): """ Download an archive file. :param str source: URL pointing to an archive file. :param str dest: Local path location to download archive file to. """ # propagate all exceptions # URLError, OSError, etc proto, netloc, pa...
[ "def", "download", "(", "self", ",", "source", ",", "dest", ")", ":", "# propagate all exceptions", "# URLError, OSError, etc", "proto", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "fragment", "=", "urlparse", "(", "source", ")", "if", "pro...
Download an archive file. :param str source: URL pointing to an archive file. :param str dest: Local path location to download archive file to.
[ "Download", "an", "archive", "file", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/archiveurl.py#L85-L114
train
juju/charm-helpers
charmhelpers/fetch/archiveurl.py
ArchiveUrlFetchHandler.install
def install(self, source, dest=None, checksum=None, hash_type='sha1'): """ Download and install an archive file, with optional checksum validation. The checksum can also be given on the `source` URL's fragment. For example:: handler.install('http://example.com/file.tgz#sha1...
python
def install(self, source, dest=None, checksum=None, hash_type='sha1'): """ Download and install an archive file, with optional checksum validation. The checksum can also be given on the `source` URL's fragment. For example:: handler.install('http://example.com/file.tgz#sha1...
[ "def", "install", "(", "self", ",", "source", ",", "dest", "=", "None", ",", "checksum", "=", "None", ",", "hash_type", "=", "'sha1'", ")", ":", "url_parts", "=", "self", ".", "parse_url", "(", "source", ")", "dest_dir", "=", "os", ".", "path", ".", ...
Download and install an archive file, with optional checksum validation. The checksum can also be given on the `source` URL's fragment. For example:: handler.install('http://example.com/file.tgz#sha1=deadbeef') :param str source: URL pointing to an archive file. :param str...
[ "Download", "and", "install", "an", "archive", "file", "with", "optional", "checksum", "validation", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/archiveurl.py#L122-L165
train
juju/charm-helpers
charmhelpers/fetch/python/debug.py
set_trace
def set_trace(addr=DEFAULT_ADDR, port=DEFAULT_PORT): """ Set a trace point using the remote debugger """ atexit.register(close_port, port) try: log("Starting a remote python debugger session on %s:%s" % (addr, port)) ...
python
def set_trace(addr=DEFAULT_ADDR, port=DEFAULT_PORT): """ Set a trace point using the remote debugger """ atexit.register(close_port, port) try: log("Starting a remote python debugger session on %s:%s" % (addr, port)) ...
[ "def", "set_trace", "(", "addr", "=", "DEFAULT_ADDR", ",", "port", "=", "DEFAULT_PORT", ")", ":", "atexit", ".", "register", "(", "close_port", ",", "port", ")", "try", ":", "log", "(", "\"Starting a remote python debugger session on %s:%s\"", "%", "(", "addr", ...
Set a trace point using the remote debugger
[ "Set", "a", "trace", "point", "using", "the", "remote", "debugger" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/python/debug.py#L41-L54
train
juju/charm-helpers
charmhelpers/contrib/mellanox/infiniband.py
device_info
def device_info(device): """Returns a DeviceInfo object with the current device settings""" status = subprocess.check_output([ 'ibstat', device, '-s']).splitlines() regexes = { "CA type: (.*)": "device_type", "Number of ports: (.*)": "num_ports", "Firmware version: (.*)": "...
python
def device_info(device): """Returns a DeviceInfo object with the current device settings""" status = subprocess.check_output([ 'ibstat', device, '-s']).splitlines() regexes = { "CA type: (.*)": "device_type", "Number of ports: (.*)": "num_ports", "Firmware version: (.*)": "...
[ "def", "device_info", "(", "device", ")", ":", "status", "=", "subprocess", ".", "check_output", "(", "[", "'ibstat'", ",", "device", ",", "'-s'", "]", ")", ".", "splitlines", "(", ")", "regexes", "=", "{", "\"CA type: (.*)\"", ":", "\"device_type\"", ",",...
Returns a DeviceInfo object with the current device settings
[ "Returns", "a", "DeviceInfo", "object", "with", "the", "current", "device", "settings" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/mellanox/infiniband.py#L111-L134
train
juju/charm-helpers
charmhelpers/contrib/mellanox/infiniband.py
ipoib_interfaces
def ipoib_interfaces(): """Return a list of IPOIB capable ethernet interfaces""" interfaces = [] for interface in network_interfaces(): try: driver = re.search('^driver: (.+)$', subprocess.check_output([ 'ethtool', '-i', interface]), re.M).group(1) ...
python
def ipoib_interfaces(): """Return a list of IPOIB capable ethernet interfaces""" interfaces = [] for interface in network_interfaces(): try: driver = re.search('^driver: (.+)$', subprocess.check_output([ 'ethtool', '-i', interface]), re.M).group(1) ...
[ "def", "ipoib_interfaces", "(", ")", ":", "interfaces", "=", "[", "]", "for", "interface", "in", "network_interfaces", "(", ")", ":", "try", ":", "driver", "=", "re", ".", "search", "(", "'^driver: (.+)$'", ",", "subprocess", ".", "check_output", "(", "[",...
Return a list of IPOIB capable ethernet interfaces
[ "Return", "a", "list", "of", "IPOIB", "capable", "ethernet", "interfaces" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/mellanox/infiniband.py#L137-L153
train
juju/charm-helpers
charmhelpers/contrib/hardening/host/checks/login.py
get_audits
def get_audits(): """Get OS hardening login.defs audits. :returns: dictionary of audits """ audits = [TemplatedFile('/etc/login.defs', LoginContext(), template_dir=TEMPLATES_DIR, user='root', group='root', mode=0o0444)] return audits
python
def get_audits(): """Get OS hardening login.defs audits. :returns: dictionary of audits """ audits = [TemplatedFile('/etc/login.defs', LoginContext(), template_dir=TEMPLATES_DIR, user='root', group='root', mode=0o0444)] return audits
[ "def", "get_audits", "(", ")", ":", "audits", "=", "[", "TemplatedFile", "(", "'/etc/login.defs'", ",", "LoginContext", "(", ")", ",", "template_dir", "=", "TEMPLATES_DIR", ",", "user", "=", "'root'", ",", "group", "=", "'root'", ",", "mode", "=", "0o0444"...
Get OS hardening login.defs audits. :returns: dictionary of audits
[ "Get", "OS", "hardening", "login", ".", "defs", "audits", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/host/checks/login.py#L22-L30
train
juju/charm-helpers
charmhelpers/contrib/hardening/utils.py
_get_defaults
def _get_defaults(modules): """Load the default config for the provided modules. :param modules: stack modules config defaults to lookup. :returns: modules default config dictionary. """ default = os.path.join(os.path.dirname(__file__), 'defaults/%s.yaml' % (modules)) ...
python
def _get_defaults(modules): """Load the default config for the provided modules. :param modules: stack modules config defaults to lookup. :returns: modules default config dictionary. """ default = os.path.join(os.path.dirname(__file__), 'defaults/%s.yaml' % (modules)) ...
[ "def", "_get_defaults", "(", "modules", ")", ":", "default", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'defaults/%s.yaml'", "%", "(", "modules", ")", ")", "return", "yaml", ".", "safe_load"...
Load the default config for the provided modules. :param modules: stack modules config defaults to lookup. :returns: modules default config dictionary.
[ "Load", "the", "default", "config", "for", "the", "provided", "modules", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/utils.py#L37-L45
train
juju/charm-helpers
charmhelpers/contrib/hardening/utils.py
_get_schema
def _get_schema(modules): """Load the config schema for the provided modules. NOTE: this schema is intended to have 1-1 relationship with they keys in the default config and is used a means to verify valid overrides provided by the user. :param modules: stack modules config schema to lookup. :...
python
def _get_schema(modules): """Load the config schema for the provided modules. NOTE: this schema is intended to have 1-1 relationship with they keys in the default config and is used a means to verify valid overrides provided by the user. :param modules: stack modules config schema to lookup. :...
[ "def", "_get_schema", "(", "modules", ")", ":", "schema", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'defaults/%s.yaml.schema'", "%", "(", "modules", ")", ")", "return", "yaml", ".", "safe_l...
Load the config schema for the provided modules. NOTE: this schema is intended to have 1-1 relationship with they keys in the default config and is used a means to verify valid overrides provided by the user. :param modules: stack modules config schema to lookup. :returns: modules default schema d...
[ "Load", "the", "config", "schema", "for", "the", "provided", "modules", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/utils.py#L48-L60
train
juju/charm-helpers
charmhelpers/contrib/hardening/utils.py
_get_user_provided_overrides
def _get_user_provided_overrides(modules): """Load user-provided config overrides. :param modules: stack modules to lookup in user overrides yaml file. :returns: overrides dictionary. """ overrides = os.path.join(os.environ['JUJU_CHARM_DIR'], 'hardening.yaml') if os...
python
def _get_user_provided_overrides(modules): """Load user-provided config overrides. :param modules: stack modules to lookup in user overrides yaml file. :returns: overrides dictionary. """ overrides = os.path.join(os.environ['JUJU_CHARM_DIR'], 'hardening.yaml') if os...
[ "def", "_get_user_provided_overrides", "(", "modules", ")", ":", "overrides", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'JUJU_CHARM_DIR'", "]", ",", "'hardening.yaml'", ")", "if", "os", ".", "path", ".", "exists", "(", "override...
Load user-provided config overrides. :param modules: stack modules to lookup in user overrides yaml file. :returns: overrides dictionary.
[ "Load", "user", "-", "provided", "config", "overrides", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/utils.py#L63-L84
train
juju/charm-helpers
charmhelpers/contrib/hardening/utils.py
_apply_overrides
def _apply_overrides(settings, overrides, schema): """Get overrides config overlayed onto modules defaults. :param modules: require stack modules config. :returns: dictionary of modules config with user overrides applied. """ if overrides: for k, v in six.iteritems(overrides): i...
python
def _apply_overrides(settings, overrides, schema): """Get overrides config overlayed onto modules defaults. :param modules: require stack modules config. :returns: dictionary of modules config with user overrides applied. """ if overrides: for k, v in six.iteritems(overrides): i...
[ "def", "_apply_overrides", "(", "settings", ",", "overrides", ",", "schema", ")", ":", "if", "overrides", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "overrides", ")", ":", "if", "k", "in", "schema", ":", "if", "schema", "[", "k", ...
Get overrides config overlayed onto modules defaults. :param modules: require stack modules config. :returns: dictionary of modules config with user overrides applied.
[ "Get", "overrides", "config", "overlayed", "onto", "modules", "defaults", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/utils.py#L87-L107
train
juju/charm-helpers
charmhelpers/contrib/hardening/utils.py
ensure_permissions
def ensure_permissions(path, user, group, permissions, maxdepth=-1): """Ensure permissions for path. If path is a file, apply to file and return. If path is a directory, apply recursively (if required) to directory contents and return. :param user: user name :param group: group name :param per...
python
def ensure_permissions(path, user, group, permissions, maxdepth=-1): """Ensure permissions for path. If path is a file, apply to file and return. If path is a directory, apply recursively (if required) to directory contents and return. :param user: user name :param group: group name :param per...
[ "def", "ensure_permissions", "(", "path", ",", "user", ",", "group", ",", "permissions", ",", "maxdepth", "=", "-", "1", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "log", "(", "\"File '%s' does not exist - cannot set pe...
Ensure permissions for path. If path is a file, apply to file and return. If path is a directory, apply recursively (if required) to directory contents and return. :param user: user name :param group: group name :param permissions: octal permissions :param maxdepth: maximum recursion depth. A ...
[ "Ensure", "permissions", "for", "path", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/utils.py#L122-L155
train
juju/charm-helpers
charmhelpers/core/sysctl.py
create
def create(sysctl_dict, sysctl_file, ignore=False): """Creates a sysctl.conf file from a YAML associative array :param sysctl_dict: a dict or YAML-formatted string of sysctl options eg "{ 'kernel.max_pid': 1337 }" :type sysctl_dict: str :param sysctl_file: path to the sysctl fil...
python
def create(sysctl_dict, sysctl_file, ignore=False): """Creates a sysctl.conf file from a YAML associative array :param sysctl_dict: a dict or YAML-formatted string of sysctl options eg "{ 'kernel.max_pid': 1337 }" :type sysctl_dict: str :param sysctl_file: path to the sysctl fil...
[ "def", "create", "(", "sysctl_dict", ",", "sysctl_file", ",", "ignore", "=", "False", ")", ":", "if", "type", "(", "sysctl_dict", ")", "is", "not", "dict", ":", "try", ":", "sysctl_dict_parsed", "=", "yaml", ".", "safe_load", "(", "sysctl_dict", ")", "ex...
Creates a sysctl.conf file from a YAML associative array :param sysctl_dict: a dict or YAML-formatted string of sysctl options eg "{ 'kernel.max_pid': 1337 }" :type sysctl_dict: str :param sysctl_file: path to the sysctl file to be saved :type sysctl_file: str or unicode :pa...
[ "Creates", "a", "sysctl", ".", "conf", "file", "from", "a", "YAML", "associative", "array" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/sysctl.py#L31-L65
train
juju/charm-helpers
charmhelpers/contrib/openstack/ip.py
canonical_url
def canonical_url(configs, endpoint_type=PUBLIC): """Returns the correct HTTP URL to this host given the state of HTTPS configuration, hacluster and charm configuration. :param configs: OSTemplateRenderer config templating object to inspect for a complete https context. :param endpo...
python
def canonical_url(configs, endpoint_type=PUBLIC): """Returns the correct HTTP URL to this host given the state of HTTPS configuration, hacluster and charm configuration. :param configs: OSTemplateRenderer config templating object to inspect for a complete https context. :param endpo...
[ "def", "canonical_url", "(", "configs", ",", "endpoint_type", "=", "PUBLIC", ")", ":", "scheme", "=", "_get_scheme", "(", "configs", ")", "address", "=", "resolve_address", "(", "endpoint_type", ")", "if", "is_ipv6", "(", "address", ")", ":", "address", "=",...
Returns the correct HTTP URL to this host given the state of HTTPS configuration, hacluster and charm configuration. :param configs: OSTemplateRenderer config templating object to inspect for a complete https context. :param endpoint_type: str endpoint type to resolve. :param return...
[ "Returns", "the", "correct", "HTTP", "URL", "to", "this", "host", "given", "the", "state", "of", "HTTPS", "configuration", "hacluster", "and", "charm", "configuration", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/ip.py#L64-L79
train
juju/charm-helpers
charmhelpers/contrib/openstack/ip.py
_get_address_override
def _get_address_override(endpoint_type=PUBLIC): """Returns any address overrides that the user has defined based on the endpoint type. Note: this function allows for the service name to be inserted into the address if the user specifies {service_name}.somehost.org. :param endpoint_type: the type ...
python
def _get_address_override(endpoint_type=PUBLIC): """Returns any address overrides that the user has defined based on the endpoint type. Note: this function allows for the service name to be inserted into the address if the user specifies {service_name}.somehost.org. :param endpoint_type: the type ...
[ "def", "_get_address_override", "(", "endpoint_type", "=", "PUBLIC", ")", ":", "override_key", "=", "ADDRESS_MAP", "[", "endpoint_type", "]", "[", "'override'", "]", "addr_override", "=", "config", "(", "override_key", ")", "if", "not", "addr_override", ":", "re...
Returns any address overrides that the user has defined based on the endpoint type. Note: this function allows for the service name to be inserted into the address if the user specifies {service_name}.somehost.org. :param endpoint_type: the type of endpoint to retrieve the override ...
[ "Returns", "any", "address", "overrides", "that", "the", "user", "has", "defined", "based", "on", "the", "endpoint", "type", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/ip.py#L97-L114
train
juju/charm-helpers
charmhelpers/contrib/openstack/ip.py
resolve_address
def resolve_address(endpoint_type=PUBLIC, override=True): """Return unit address depending on net config. If unit is clustered with vip(s) and has net splits defined, return vip on correct network. If clustered with no nets defined, return primary vip. If not clustered, return unit address ensuring ad...
python
def resolve_address(endpoint_type=PUBLIC, override=True): """Return unit address depending on net config. If unit is clustered with vip(s) and has net splits defined, return vip on correct network. If clustered with no nets defined, return primary vip. If not clustered, return unit address ensuring ad...
[ "def", "resolve_address", "(", "endpoint_type", "=", "PUBLIC", ",", "override", "=", "True", ")", ":", "resolved_address", "=", "None", "if", "override", ":", "resolved_address", "=", "_get_address_override", "(", "endpoint_type", ")", "if", "resolved_address", ":...
Return unit address depending on net config. If unit is clustered with vip(s) and has net splits defined, return vip on correct network. If clustered with no nets defined, return primary vip. If not clustered, return unit address ensuring address is on configured net split if one is configured, or a J...
[ "Return", "unit", "address", "depending", "on", "net", "config", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/ip.py#L117-L187
train
juju/charm-helpers
charmhelpers/core/hugepage.py
hugepage_support
def hugepage_support(user, group='hugetlb', nr_hugepages=256, max_map_count=65536, mnt_point='/run/hugepages/kvm', pagesize='2MB', mount=True, set_shmmax=False): """Enable hugepages on system. Args: user (str) -- Username to allow access to hugepages to group ...
python
def hugepage_support(user, group='hugetlb', nr_hugepages=256, max_map_count=65536, mnt_point='/run/hugepages/kvm', pagesize='2MB', mount=True, set_shmmax=False): """Enable hugepages on system. Args: user (str) -- Username to allow access to hugepages to group ...
[ "def", "hugepage_support", "(", "user", ",", "group", "=", "'hugetlb'", ",", "nr_hugepages", "=", "256", ",", "max_map_count", "=", "65536", ",", "mnt_point", "=", "'/run/hugepages/kvm'", ",", "pagesize", "=", "'2MB'", ",", "mount", "=", "True", ",", "set_sh...
Enable hugepages on system. Args: user (str) -- Username to allow access to hugepages to group (str) -- Group name to own hugepages nr_hugepages (int) -- Number of pages to reserve max_map_count (int) -- Number of Virtual Memory Areas a process can own mnt_point (str) -- Directory to mount hug...
[ "Enable", "hugepages", "on", "system", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/hugepage.py#L30-L69
train
juju/charm-helpers
charmhelpers/contrib/hardening/audits/apache.py
DisabledModuleAudit.ensure_compliance
def ensure_compliance(self): """Ensures that the modules are not loaded.""" if not self.modules: return try: loaded_modules = self._get_loaded_modules() non_compliant_modules = [] for module in self.modules: if module in loaded_mod...
python
def ensure_compliance(self): """Ensures that the modules are not loaded.""" if not self.modules: return try: loaded_modules = self._get_loaded_modules() non_compliant_modules = [] for module in self.modules: if module in loaded_mod...
[ "def", "ensure_compliance", "(", "self", ")", ":", "if", "not", "self", ".", "modules", ":", "return", "try", ":", "loaded_modules", "=", "self", ".", "_get_loaded_modules", "(", ")", "non_compliant_modules", "=", "[", "]", "for", "module", "in", "self", "...
Ensures that the modules are not loaded.
[ "Ensures", "that", "the", "modules", "are", "not", "loaded", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/audits/apache.py#L43-L66
train
juju/charm-helpers
charmhelpers/contrib/hardening/audits/apache.py
DisabledModuleAudit._get_loaded_modules
def _get_loaded_modules(): """Returns the modules which are enabled in Apache.""" output = subprocess.check_output(['apache2ctl', '-M']) if six.PY3: output = output.decode('utf-8') modules = [] for line in output.splitlines(): # Each line of the enabled mo...
python
def _get_loaded_modules(): """Returns the modules which are enabled in Apache.""" output = subprocess.check_output(['apache2ctl', '-M']) if six.PY3: output = output.decode('utf-8') modules = [] for line in output.splitlines(): # Each line of the enabled mo...
[ "def", "_get_loaded_modules", "(", ")", ":", "output", "=", "subprocess", ".", "check_output", "(", "[", "'apache2ctl'", ",", "'-M'", "]", ")", "if", "six", ".", "PY3", ":", "output", "=", "output", ".", "decode", "(", "'utf-8'", ")", "modules", "=", "...
Returns the modules which are enabled in Apache.
[ "Returns", "the", "modules", "which", "are", "enabled", "in", "Apache", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/audits/apache.py#L69-L83
train
juju/charm-helpers
charmhelpers/contrib/hardening/audits/apache.py
DisabledModuleAudit._disable_module
def _disable_module(module): """Disables the specified module in Apache.""" try: subprocess.check_call(['a2dismod', module]) except subprocess.CalledProcessError as e: # Note: catch error here to allow the attempt of disabling # multiple modules in one go rath...
python
def _disable_module(module): """Disables the specified module in Apache.""" try: subprocess.check_call(['a2dismod', module]) except subprocess.CalledProcessError as e: # Note: catch error here to allow the attempt of disabling # multiple modules in one go rath...
[ "def", "_disable_module", "(", "module", ")", ":", "try", ":", "subprocess", ".", "check_call", "(", "[", "'a2dismod'", ",", "module", "]", ")", "except", "subprocess", ".", "CalledProcessError", "as", "e", ":", "# Note: catch error here to allow the attempt of disa...
Disables the specified module in Apache.
[ "Disables", "the", "specified", "module", "in", "Apache", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/audits/apache.py#L86-L95
train
juju/charm-helpers
charmhelpers/contrib/hardening/templating.py
get_template_path
def get_template_path(template_dir, path): """Returns the template file which would be used to render the path. The path to the template file is returned. :param template_dir: the directory the templates are located in :param path: the file path to be written to. :returns: path to the template file...
python
def get_template_path(template_dir, path): """Returns the template file which would be used to render the path. The path to the template file is returned. :param template_dir: the directory the templates are located in :param path: the file path to be written to. :returns: path to the template file...
[ "def", "get_template_path", "(", "template_dir", ",", "path", ")", ":", "return", "os", ".", "path", ".", "join", "(", "template_dir", ",", "os", ".", "path", ".", "basename", "(", "path", ")", ")" ]
Returns the template file which would be used to render the path. The path to the template file is returned. :param template_dir: the directory the templates are located in :param path: the file path to be written to. :returns: path to the template file
[ "Returns", "the", "template", "file", "which", "would", "be", "used", "to", "render", "the", "path", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/templating.py#L44-L52
train
juju/charm-helpers
charmhelpers/contrib/hardening/templating.py
render_and_write
def render_and_write(template_dir, path, context): """Renders the specified template into the file. :param template_dir: the directory to load the template from :param path: the path to write the templated contents to :param context: the parameters to pass to the rendering engine """ env = Envi...
python
def render_and_write(template_dir, path, context): """Renders the specified template into the file. :param template_dir: the directory to load the template from :param path: the path to write the templated contents to :param context: the parameters to pass to the rendering engine """ env = Envi...
[ "def", "render_and_write", "(", "template_dir", ",", "path", ",", "context", ")", ":", "env", "=", "Environment", "(", "loader", "=", "FileSystemLoader", "(", "template_dir", ")", ")", "template_file", "=", "os", ".", "path", ".", "basename", "(", "path", ...
Renders the specified template into the file. :param template_dir: the directory to load the template from :param path: the path to write the templated contents to :param context: the parameters to pass to the rendering engine
[ "Renders", "the", "specified", "template", "into", "the", "file", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/templating.py#L55-L73
train
juju/charm-helpers
charmhelpers/contrib/hardening/host/checks/apt.py
get_audits
def get_audits(): """Get OS hardening apt audits. :returns: dictionary of audits """ audits = [AptConfig([{'key': 'APT::Get::AllowUnauthenticated', 'expected': 'false'}])] settings = get_settings('os') clean_packages = settings['security']['packages_clean'] if cl...
python
def get_audits(): """Get OS hardening apt audits. :returns: dictionary of audits """ audits = [AptConfig([{'key': 'APT::Get::AllowUnauthenticated', 'expected': 'false'}])] settings = get_settings('os') clean_packages = settings['security']['packages_clean'] if cl...
[ "def", "get_audits", "(", ")", ":", "audits", "=", "[", "AptConfig", "(", "[", "{", "'key'", ":", "'APT::Get::AllowUnauthenticated'", ",", "'expected'", ":", "'false'", "}", "]", ")", "]", "settings", "=", "get_settings", "(", "'os'", ")", "clean_packages", ...
Get OS hardening apt audits. :returns: dictionary of audits
[ "Get", "OS", "hardening", "apt", "audits", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/host/checks/apt.py#L22-L37
train
juju/charm-helpers
charmhelpers/contrib/hardening/host/checks/pam.py
get_audits
def get_audits(): """Get OS hardening PAM authentication audits. :returns: dictionary of audits """ audits = [] settings = utils.get_settings('os') if settings['auth']['pam_passwdqc_enable']: audits.append(PasswdqcPAM('/etc/passwdqc.conf')) if settings['auth']['retries']: ...
python
def get_audits(): """Get OS hardening PAM authentication audits. :returns: dictionary of audits """ audits = [] settings = utils.get_settings('os') if settings['auth']['pam_passwdqc_enable']: audits.append(PasswdqcPAM('/etc/passwdqc.conf')) if settings['auth']['retries']: ...
[ "def", "get_audits", "(", ")", ":", "audits", "=", "[", "]", "settings", "=", "utils", ".", "get_settings", "(", "'os'", ")", "if", "settings", "[", "'auth'", "]", "[", "'pam_passwdqc_enable'", "]", ":", "audits", ".", "append", "(", "PasswdqcPAM", "(", ...
Get OS hardening PAM authentication audits. :returns: dictionary of audits
[ "Get", "OS", "hardening", "PAM", "authentication", "audits", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/host/checks/pam.py#L38-L55
train
juju/charm-helpers
charmhelpers/contrib/ansible/__init__.py
install_ansible_support
def install_ansible_support(from_ppa=True, ppa_location='ppa:rquillo/ansible'): """Installs the ansible package. By default it is installed from the `PPA`_ linked from the ansible `website`_ or from a ppa specified by a charm config.. .. _PPA: https://launchpad.net/~rquillo/+archive/ansible .. _we...
python
def install_ansible_support(from_ppa=True, ppa_location='ppa:rquillo/ansible'): """Installs the ansible package. By default it is installed from the `PPA`_ linked from the ansible `website`_ or from a ppa specified by a charm config.. .. _PPA: https://launchpad.net/~rquillo/+archive/ansible .. _we...
[ "def", "install_ansible_support", "(", "from_ppa", "=", "True", ",", "ppa_location", "=", "'ppa:rquillo/ansible'", ")", ":", "if", "from_ppa", ":", "charmhelpers", ".", "fetch", ".", "add_source", "(", "ppa_location", ")", "charmhelpers", ".", "fetch", ".", "apt...
Installs the ansible package. By default it is installed from the `PPA`_ linked from the ansible `website`_ or from a ppa specified by a charm config.. .. _PPA: https://launchpad.net/~rquillo/+archive/ansible .. _website: http://docs.ansible.com/intro_installation.html#latest-releases-via-apt-ubuntu ...
[ "Installs", "the", "ansible", "package", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/ansible/__init__.py#L120-L137
train
juju/charm-helpers
charmhelpers/contrib/ansible/__init__.py
AnsibleHooks.execute
def execute(self, args): """Execute the hook followed by the playbook using the hook as tag.""" hook_name = os.path.basename(args[0]) extra_vars = None if hook_name in self._actions: extra_vars = self._actions[hook_name](args[1:]) else: super(AnsibleHooks,...
python
def execute(self, args): """Execute the hook followed by the playbook using the hook as tag.""" hook_name = os.path.basename(args[0]) extra_vars = None if hook_name in self._actions: extra_vars = self._actions[hook_name](args[1:]) else: super(AnsibleHooks,...
[ "def", "execute", "(", "self", ",", "args", ")", ":", "hook_name", "=", "os", ".", "path", ".", "basename", "(", "args", "[", "0", "]", ")", "extra_vars", "=", "None", "if", "hook_name", "in", "self", ".", "_actions", ":", "extra_vars", "=", "self", ...
Execute the hook followed by the playbook using the hook as tag.
[ "Execute", "the", "hook", "followed", "by", "the", "playbook", "using", "the", "hook", "as", "tag", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/ansible/__init__.py#L219-L229
train
juju/charm-helpers
charmhelpers/contrib/ansible/__init__.py
AnsibleHooks.action
def action(self, *action_names): """Decorator, registering them as actions""" def action_wrapper(decorated): @functools.wraps(decorated) def wrapper(argv): kwargs = dict(arg.split('=') for arg in argv) try: return decorated(**k...
python
def action(self, *action_names): """Decorator, registering them as actions""" def action_wrapper(decorated): @functools.wraps(decorated) def wrapper(argv): kwargs = dict(arg.split('=') for arg in argv) try: return decorated(**k...
[ "def", "action", "(", "self", ",", "*", "action_names", ")", ":", "def", "action_wrapper", "(", "decorated", ")", ":", "@", "functools", ".", "wraps", "(", "decorated", ")", "def", "wrapper", "(", "argv", ")", ":", "kwargs", "=", "dict", "(", "arg", ...
Decorator, registering them as actions
[ "Decorator", "registering", "them", "as", "actions" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/ansible/__init__.py#L231-L252
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/deployment.py
OpenStackAmuletDeployment.get_logger
def get_logger(self, name="deployment-logger", level=logging.DEBUG): """Get a logger object that will log to stdout.""" log = logging logger = log.getLogger(name) fmt = log.Formatter("%(asctime)s %(funcName)s " "%(levelname)s: %(message)s") handler = ...
python
def get_logger(self, name="deployment-logger", level=logging.DEBUG): """Get a logger object that will log to stdout.""" log = logging logger = log.getLogger(name) fmt = log.Formatter("%(asctime)s %(funcName)s " "%(levelname)s: %(message)s") handler = ...
[ "def", "get_logger", "(", "self", ",", "name", "=", "\"deployment-logger\"", ",", "level", "=", "logging", ".", "DEBUG", ")", ":", "log", "=", "logging", "logger", "=", "log", ".", "getLogger", "(", "name", ")", "fmt", "=", "log", ".", "Formatter", "("...
Get a logger object that will log to stdout.
[ "Get", "a", "logger", "object", "that", "will", "log", "to", "stdout", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/deployment.py#L49-L63
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/deployment.py
OpenStackAmuletDeployment._determine_branch_locations
def _determine_branch_locations(self, other_services): """Determine the branch locations for the other services. Determine if the local branch being tested is derived from its stable or next (dev) branch, and based on this, use the corresonding stable or next branches for the o...
python
def _determine_branch_locations(self, other_services): """Determine the branch locations for the other services. Determine if the local branch being tested is derived from its stable or next (dev) branch, and based on this, use the corresonding stable or next branches for the o...
[ "def", "_determine_branch_locations", "(", "self", ",", "other_services", ")", ":", "self", ".", "log", ".", "info", "(", "'OpenStackAmuletDeployment: determine branch locations'", ")", "# Charms outside the ~openstack-charmers", "base_charms", "=", "{", "'mysql'", ":", ...
Determine the branch locations for the other services. Determine if the local branch being tested is derived from its stable or next (dev) branch, and based on this, use the corresonding stable or next branches for the other_services.
[ "Determine", "the", "branch", "locations", "for", "the", "other", "services", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/deployment.py#L65-L103
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/deployment.py
OpenStackAmuletDeployment._auto_wait_for_status
def _auto_wait_for_status(self, message=None, exclude_services=None, include_only=None, timeout=None): """Wait for all units to have a specific extended status, except for any defined as excluded. Unless specified via message, any status containing any case of 'rea...
python
def _auto_wait_for_status(self, message=None, exclude_services=None, include_only=None, timeout=None): """Wait for all units to have a specific extended status, except for any defined as excluded. Unless specified via message, any status containing any case of 'rea...
[ "def", "_auto_wait_for_status", "(", "self", ",", "message", "=", "None", ",", "exclude_services", "=", "None", ",", "include_only", "=", "None", ",", "timeout", "=", "None", ")", ":", "if", "not", "timeout", ":", "timeout", "=", "int", "(", "os", ".", ...
Wait for all units to have a specific extended status, except for any defined as excluded. Unless specified via message, any status containing any case of 'ready' will be considered a match. Examples of message usage: Wait for all unit status to CONTAIN any case of 'ready' or 'ok': ...
[ "Wait", "for", "all", "units", "to", "have", "a", "specific", "extended", "status", "except", "for", "any", "defined", "as", "excluded", ".", "Unless", "specified", "via", "message", "any", "status", "containing", "any", "case", "of", "ready", "will", "be", ...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/deployment.py#L192-L269
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/deployment.py
OpenStackAmuletDeployment._get_openstack_release
def _get_openstack_release(self): """Get openstack release. Return an integer representing the enum value of the openstack release. """ # Must be ordered by OpenStack release (not by Ubuntu release): for i, os_pair in enumerate(OPENSTACK_RELEASES_PAIRS): ...
python
def _get_openstack_release(self): """Get openstack release. Return an integer representing the enum value of the openstack release. """ # Must be ordered by OpenStack release (not by Ubuntu release): for i, os_pair in enumerate(OPENSTACK_RELEASES_PAIRS): ...
[ "def", "_get_openstack_release", "(", "self", ")", ":", "# Must be ordered by OpenStack release (not by Ubuntu release):", "for", "i", ",", "os_pair", "in", "enumerate", "(", "OPENSTACK_RELEASES_PAIRS", ")", ":", "setattr", "(", "self", ",", "os_pair", ",", "i", ")", ...
Get openstack release. Return an integer representing the enum value of the openstack release.
[ "Get", "openstack", "release", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/deployment.py#L271-L300
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/deployment.py
OpenStackAmuletDeployment._get_openstack_release_string
def _get_openstack_release_string(self): """Get openstack release string. Return a string representing the openstack release. """ releases = OrderedDict([ ('trusty', 'icehouse'), ('xenial', 'mitaka'), ('yakkety', 'newton'), ('zesty',...
python
def _get_openstack_release_string(self): """Get openstack release string. Return a string representing the openstack release. """ releases = OrderedDict([ ('trusty', 'icehouse'), ('xenial', 'mitaka'), ('yakkety', 'newton'), ('zesty',...
[ "def", "_get_openstack_release_string", "(", "self", ")", ":", "releases", "=", "OrderedDict", "(", "[", "(", "'trusty'", ",", "'icehouse'", ")", ",", "(", "'xenial'", ",", "'mitaka'", ")", ",", "(", "'yakkety'", ",", "'newton'", ")", ",", "(", "'zesty'", ...
Get openstack release string. Return a string representing the openstack release.
[ "Get", "openstack", "release", "string", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/deployment.py#L302-L321
train
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/deployment.py
OpenStackAmuletDeployment.get_ceph_expected_pools
def get_ceph_expected_pools(self, radosgw=False): """Return a list of expected ceph pools in a ceph + cinder + glance test scenario, based on OpenStack release and whether ceph radosgw is flagged as present or not.""" if self._get_openstack_release() == self.trusty_icehouse: ...
python
def get_ceph_expected_pools(self, radosgw=False): """Return a list of expected ceph pools in a ceph + cinder + glance test scenario, based on OpenStack release and whether ceph radosgw is flagged as present or not.""" if self._get_openstack_release() == self.trusty_icehouse: ...
[ "def", "get_ceph_expected_pools", "(", "self", ",", "radosgw", "=", "False", ")", ":", "if", "self", ".", "_get_openstack_release", "(", ")", "==", "self", ".", "trusty_icehouse", ":", "# Icehouse", "pools", "=", "[", "'data'", ",", "'metadata'", ",", "'rbd'...
Return a list of expected ceph pools in a ceph + cinder + glance test scenario, based on OpenStack release and whether ceph radosgw is flagged as present or not.
[ "Return", "a", "list", "of", "expected", "ceph", "pools", "in", "a", "ceph", "+", "cinder", "+", "glance", "test", "scenario", "based", "on", "OpenStack", "release", "and", "whether", "ceph", "radosgw", "is", "flagged", "as", "present", "or", "not", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/deployment.py#L323-L361
train
juju/charm-helpers
charmhelpers/osplatform.py
get_platform
def get_platform(): """Return the current OS platform. For example: if current os platform is Ubuntu then a string "ubuntu" will be returned (which is the name of the module). This string is used to decide which platform module should be imported. """ # linux_distribution is deprecated and will...
python
def get_platform(): """Return the current OS platform. For example: if current os platform is Ubuntu then a string "ubuntu" will be returned (which is the name of the module). This string is used to decide which platform module should be imported. """ # linux_distribution is deprecated and will...
[ "def", "get_platform", "(", ")", ":", "# linux_distribution is deprecated and will be removed in Python 3.7", "# Warings *not* disabled, as we certainly need to fix this.", "tuple_platform", "=", "platform", ".", "linux_distribution", "(", ")", "current_platform", "=", "tuple_platfor...
Return the current OS platform. For example: if current os platform is Ubuntu then a string "ubuntu" will be returned (which is the name of the module). This string is used to decide which platform module should be imported.
[ "Return", "the", "current", "OS", "platform", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/osplatform.py#L4-L25
train
juju/charm-helpers
charmhelpers/fetch/python/version.py
current_version_string
def current_version_string(): """Current system python version as string major.minor.micro""" return "{0}.{1}.{2}".format(sys.version_info.major, sys.version_info.minor, sys.version_info.micro)
python
def current_version_string(): """Current system python version as string major.minor.micro""" return "{0}.{1}.{2}".format(sys.version_info.major, sys.version_info.minor, sys.version_info.micro)
[ "def", "current_version_string", "(", ")", ":", "return", "\"{0}.{1}.{2}\"", ".", "format", "(", "sys", ".", "version_info", ".", "major", ",", "sys", ".", "version_info", ".", "minor", ",", "sys", ".", "version_info", ".", "micro", ")" ]
Current system python version as string major.minor.micro
[ "Current", "system", "python", "version", "as", "string", "major", ".", "minor", ".", "micro" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/python/version.py#L28-L32
train
juju/charm-helpers
charmhelpers/contrib/hardening/mysql/checks/config.py
get_audits
def get_audits(): """Get MySQL hardening config audits. :returns: dictionary of audits """ if subprocess.call(['which', 'mysql'], stdout=subprocess.PIPE) != 0: log("MySQL does not appear to be installed on this node - " "skipping mysql hardening", level=WARNING) return [] ...
python
def get_audits(): """Get MySQL hardening config audits. :returns: dictionary of audits """ if subprocess.call(['which', 'mysql'], stdout=subprocess.PIPE) != 0: log("MySQL does not appear to be installed on this node - " "skipping mysql hardening", level=WARNING) return [] ...
[ "def", "get_audits", "(", ")", ":", "if", "subprocess", ".", "call", "(", "[", "'which'", ",", "'mysql'", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", "!=", "0", ":", "log", "(", "\"MySQL does not appear to be installed on this node - \"", "\"skipp...
Get MySQL hardening config audits. :returns: dictionary of audits
[ "Get", "MySQL", "hardening", "config", "audits", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/mysql/checks/config.py#L31-L73
train
juju/charm-helpers
charmhelpers/core/host.py
service_reload
def service_reload(service_name, restart_on_failure=False, **kwargs): """Reload a system service, optionally falling back to restart if reload fails. The specified service name is managed via the system level init system. Some init systems (e.g. upstart) require that additional arguments be provide...
python
def service_reload(service_name, restart_on_failure=False, **kwargs): """Reload a system service, optionally falling back to restart if reload fails. The specified service name is managed via the system level init system. Some init systems (e.g. upstart) require that additional arguments be provide...
[ "def", "service_reload", "(", "service_name", ",", "restart_on_failure", "=", "False", ",", "*", "*", "kwargs", ")", ":", "service_result", "=", "service", "(", "'reload'", ",", "service_name", ",", "*", "*", "kwargs", ")", "if", "not", "service_result", "an...
Reload a system service, optionally falling back to restart if reload fails. The specified service name is managed via the system level init system. Some init systems (e.g. upstart) require that additional arguments be provided in order to directly control service instances whereas other init syste...
[ "Reload", "a", "system", "service", "optionally", "falling", "back", "to", "restart", "if", "reload", "fails", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L143-L173
train
juju/charm-helpers
charmhelpers/core/host.py
service_pause
def service_pause(service_name, init_dir="/etc/init", initd_dir="/etc/init.d", **kwargs): """Pause a system service. Stop it, and prevent it from starting again at boot. :param service_name: the name of the service to pause :param init_dir: path to the upstart init directory :par...
python
def service_pause(service_name, init_dir="/etc/init", initd_dir="/etc/init.d", **kwargs): """Pause a system service. Stop it, and prevent it from starting again at boot. :param service_name: the name of the service to pause :param init_dir: path to the upstart init directory :par...
[ "def", "service_pause", "(", "service_name", ",", "init_dir", "=", "\"/etc/init\"", ",", "initd_dir", "=", "\"/etc/init.d\"", ",", "*", "*", "kwargs", ")", ":", "stopped", "=", "True", "if", "service_running", "(", "service_name", ",", "*", "*", "kwargs", ")...
Pause a system service. Stop it, and prevent it from starting again at boot. :param service_name: the name of the service to pause :param init_dir: path to the upstart init directory :param initd_dir: path to the sysv init directory :param **kwargs: additional parameters to pass to the init system...
[ "Pause", "a", "system", "service", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L176-L211
train
juju/charm-helpers
charmhelpers/core/host.py
service_resume
def service_resume(service_name, init_dir="/etc/init", initd_dir="/etc/init.d", **kwargs): """Resume a system service. Reenable starting again at boot. Start the service. :param service_name: the name of the service to resume :param init_dir: the path to the init dir :param init...
python
def service_resume(service_name, init_dir="/etc/init", initd_dir="/etc/init.d", **kwargs): """Resume a system service. Reenable starting again at boot. Start the service. :param service_name: the name of the service to resume :param init_dir: the path to the init dir :param init...
[ "def", "service_resume", "(", "service_name", ",", "init_dir", "=", "\"/etc/init\"", ",", "initd_dir", "=", "\"/etc/init.d\"", ",", "*", "*", "kwargs", ")", ":", "upstart_file", "=", "os", ".", "path", ".", "join", "(", "init_dir", ",", "\"{}.conf\"", ".", ...
Resume a system service. Reenable starting again at boot. Start the service. :param service_name: the name of the service to resume :param init_dir: the path to the init dir :param initd dir: the path to the initd dir :param **kwargs: additional parameters to pass to the init system when ...
[ "Resume", "a", "system", "service", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L214-L249
train
juju/charm-helpers
charmhelpers/core/host.py
service
def service(action, service_name, **kwargs): """Control a system service. :param action: the action to take on the service :param service_name: the name of the service to perform th action on :param **kwargs: additional params to be passed to the service command in the form of key=v...
python
def service(action, service_name, **kwargs): """Control a system service. :param action: the action to take on the service :param service_name: the name of the service to perform th action on :param **kwargs: additional params to be passed to the service command in the form of key=v...
[ "def", "service", "(", "action", ",", "service_name", ",", "*", "*", "kwargs", ")", ":", "if", "init_is_systemd", "(", ")", ":", "cmd", "=", "[", "'systemctl'", ",", "action", ",", "service_name", "]", "else", ":", "cmd", "=", "[", "'service'", ",", ...
Control a system service. :param action: the action to take on the service :param service_name: the name of the service to perform th action on :param **kwargs: additional params to be passed to the service command in the form of key=value.
[ "Control", "a", "system", "service", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L252-L267
train
juju/charm-helpers
charmhelpers/core/host.py
service_running
def service_running(service_name, **kwargs): """Determine whether a system service is running. :param service_name: the name of the service :param **kwargs: additional args to pass to the service command. This is used to pass additional key=value arguments to the s...
python
def service_running(service_name, **kwargs): """Determine whether a system service is running. :param service_name: the name of the service :param **kwargs: additional args to pass to the service command. This is used to pass additional key=value arguments to the s...
[ "def", "service_running", "(", "service_name", ",", "*", "*", "kwargs", ")", ":", "if", "init_is_systemd", "(", ")", ":", "return", "service", "(", "'is-active'", ",", "service_name", ")", "else", ":", "if", "os", ".", "path", ".", "exists", "(", "_UPSTA...
Determine whether a system service is running. :param service_name: the name of the service :param **kwargs: additional args to pass to the service command. This is used to pass additional key=value arguments to the service command line for managing specific instance ...
[ "Determine", "whether", "a", "system", "service", "is", "running", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L274-L308
train
juju/charm-helpers
charmhelpers/core/host.py
adduser
def adduser(username, password=None, shell='/bin/bash', system_user=False, primary_group=None, secondary_groups=None, uid=None, home_dir=None): """Add a user to the system. Will log but otherwise succeed if the user already exists. :param str username: Username to create :param...
python
def adduser(username, password=None, shell='/bin/bash', system_user=False, primary_group=None, secondary_groups=None, uid=None, home_dir=None): """Add a user to the system. Will log but otherwise succeed if the user already exists. :param str username: Username to create :param...
[ "def", "adduser", "(", "username", ",", "password", "=", "None", ",", "shell", "=", "'/bin/bash'", ",", "system_user", "=", "False", ",", "primary_group", "=", "None", ",", "secondary_groups", "=", "None", ",", "uid", "=", "None", ",", "home_dir", "=", "...
Add a user to the system. Will log but otherwise succeed if the user already exists. :param str username: Username to create :param str password: Password for user; if ``None``, create a system user :param str shell: The default shell for the user :param bool system_user: Whether to create a login...
[ "Add", "a", "user", "to", "the", "system", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L321-L373
train
juju/charm-helpers
charmhelpers/core/host.py
user_exists
def user_exists(username): """Check if a user exists""" try: pwd.getpwnam(username) user_exists = True except KeyError: user_exists = False return user_exists
python
def user_exists(username): """Check if a user exists""" try: pwd.getpwnam(username) user_exists = True except KeyError: user_exists = False return user_exists
[ "def", "user_exists", "(", "username", ")", ":", "try", ":", "pwd", ".", "getpwnam", "(", "username", ")", "user_exists", "=", "True", "except", "KeyError", ":", "user_exists", "=", "False", "return", "user_exists" ]
Check if a user exists
[ "Check", "if", "a", "user", "exists" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L376-L383
train
juju/charm-helpers
charmhelpers/core/host.py
uid_exists
def uid_exists(uid): """Check if a uid exists""" try: pwd.getpwuid(uid) uid_exists = True except KeyError: uid_exists = False return uid_exists
python
def uid_exists(uid): """Check if a uid exists""" try: pwd.getpwuid(uid) uid_exists = True except KeyError: uid_exists = False return uid_exists
[ "def", "uid_exists", "(", "uid", ")", ":", "try", ":", "pwd", ".", "getpwuid", "(", "uid", ")", "uid_exists", "=", "True", "except", "KeyError", ":", "uid_exists", "=", "False", "return", "uid_exists" ]
Check if a uid exists
[ "Check", "if", "a", "uid", "exists" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L386-L393
train
juju/charm-helpers
charmhelpers/core/host.py
group_exists
def group_exists(groupname): """Check if a group exists""" try: grp.getgrnam(groupname) group_exists = True except KeyError: group_exists = False return group_exists
python
def group_exists(groupname): """Check if a group exists""" try: grp.getgrnam(groupname) group_exists = True except KeyError: group_exists = False return group_exists
[ "def", "group_exists", "(", "groupname", ")", ":", "try", ":", "grp", ".", "getgrnam", "(", "groupname", ")", "group_exists", "=", "True", "except", "KeyError", ":", "group_exists", "=", "False", "return", "group_exists" ]
Check if a group exists
[ "Check", "if", "a", "group", "exists" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L396-L403
train
juju/charm-helpers
charmhelpers/core/host.py
gid_exists
def gid_exists(gid): """Check if a gid exists""" try: grp.getgrgid(gid) gid_exists = True except KeyError: gid_exists = False return gid_exists
python
def gid_exists(gid): """Check if a gid exists""" try: grp.getgrgid(gid) gid_exists = True except KeyError: gid_exists = False return gid_exists
[ "def", "gid_exists", "(", "gid", ")", ":", "try", ":", "grp", ".", "getgrgid", "(", "gid", ")", "gid_exists", "=", "True", "except", "KeyError", ":", "gid_exists", "=", "False", "return", "gid_exists" ]
Check if a gid exists
[ "Check", "if", "a", "gid", "exists" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L406-L413
train
juju/charm-helpers
charmhelpers/core/host.py
add_group
def add_group(group_name, system_group=False, gid=None): """Add a group to the system Will log but otherwise succeed if the group already exists. :param str group_name: group to create :param bool system_group: Create system group :param int gid: GID for user being created :returns: The passw...
python
def add_group(group_name, system_group=False, gid=None): """Add a group to the system Will log but otherwise succeed if the group already exists. :param str group_name: group to create :param bool system_group: Create system group :param int gid: GID for user being created :returns: The passw...
[ "def", "add_group", "(", "group_name", ",", "system_group", "=", "False", ",", "gid", "=", "None", ")", ":", "try", ":", "group_info", "=", "grp", ".", "getgrnam", "(", "group_name", ")", "log", "(", "'group {0} already exists!'", ".", "format", "(", "grou...
Add a group to the system Will log but otherwise succeed if the group already exists. :param str group_name: group to create :param bool system_group: Create system group :param int gid: GID for user being created :returns: The password database entry struct, as returned by `grp.getgrnam`
[ "Add", "a", "group", "to", "the", "system" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L416-L437
train
juju/charm-helpers
charmhelpers/core/host.py
chage
def chage(username, lastday=None, expiredate=None, inactive=None, mindays=None, maxdays=None, root=None, warndays=None): """Change user password expiry information :param str username: User to update :param str lastday: Set when password was changed in YYYY-MM-DD format :param str expiredate:...
python
def chage(username, lastday=None, expiredate=None, inactive=None, mindays=None, maxdays=None, root=None, warndays=None): """Change user password expiry information :param str username: User to update :param str lastday: Set when password was changed in YYYY-MM-DD format :param str expiredate:...
[ "def", "chage", "(", "username", ",", "lastday", "=", "None", ",", "expiredate", "=", "None", ",", "inactive", "=", "None", ",", "mindays", "=", "None", ",", "maxdays", "=", "None", ",", "root", "=", "None", ",", "warndays", "=", "None", ")", ":", ...
Change user password expiry information :param str username: User to update :param str lastday: Set when password was changed in YYYY-MM-DD format :param str expiredate: Set when user's account will no longer be accessible in YYYY-MM-DD format. -1 will ...
[ "Change", "user", "password", "expiry", "information" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L447-L486
train
juju/charm-helpers
charmhelpers/core/host.py
rsync
def rsync(from_path, to_path, flags='-r', options=None, timeout=None): """Replicate the contents of a path""" options = options or ['--delete', '--executability'] cmd = ['/usr/bin/rsync', flags] if timeout: cmd = ['timeout', str(timeout)] + cmd cmd.extend(options) cmd.append(from_path) ...
python
def rsync(from_path, to_path, flags='-r', options=None, timeout=None): """Replicate the contents of a path""" options = options or ['--delete', '--executability'] cmd = ['/usr/bin/rsync', flags] if timeout: cmd = ['timeout', str(timeout)] + cmd cmd.extend(options) cmd.append(from_path) ...
[ "def", "rsync", "(", "from_path", ",", "to_path", ",", "flags", "=", "'-r'", ",", "options", "=", "None", ",", "timeout", "=", "None", ")", ":", "options", "=", "options", "or", "[", "'--delete'", ",", "'--executability'", "]", "cmd", "=", "[", "'/usr/...
Replicate the contents of a path
[ "Replicate", "the", "contents", "of", "a", "path" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L492-L502
train
juju/charm-helpers
charmhelpers/core/host.py
write_file
def write_file(path, content, owner='root', group='root', perms=0o444): """Create or overwrite a file with the contents of a byte string.""" uid = pwd.getpwnam(owner).pw_uid gid = grp.getgrnam(group).gr_gid # lets see if we can grab the file and compare the context, to avoid doing # a write. exi...
python
def write_file(path, content, owner='root', group='root', perms=0o444): """Create or overwrite a file with the contents of a byte string.""" uid = pwd.getpwnam(owner).pw_uid gid = grp.getgrnam(group).gr_gid # lets see if we can grab the file and compare the context, to avoid doing # a write. exi...
[ "def", "write_file", "(", "path", ",", "content", ",", "owner", "=", "'root'", ",", "group", "=", "'root'", ",", "perms", "=", "0o444", ")", ":", "uid", "=", "pwd", ".", "getpwnam", "(", "owner", ")", ".", "pw_uid", "gid", "=", "grp", ".", "getgrna...
Create or overwrite a file with the contents of a byte string.
[ "Create", "or", "overwrite", "a", "file", "with", "the", "contents", "of", "a", "byte", "string", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L536-L576
train
juju/charm-helpers
charmhelpers/core/host.py
mount
def mount(device, mountpoint, options=None, persist=False, filesystem="ext3"): """Mount a filesystem at a particular mountpoint""" cmd_args = ['mount'] if options is not None: cmd_args.extend(['-o', options]) cmd_args.extend([device, mountpoint]) try: subprocess.check_output(cmd_args...
python
def mount(device, mountpoint, options=None, persist=False, filesystem="ext3"): """Mount a filesystem at a particular mountpoint""" cmd_args = ['mount'] if options is not None: cmd_args.extend(['-o', options]) cmd_args.extend([device, mountpoint]) try: subprocess.check_output(cmd_args...
[ "def", "mount", "(", "device", ",", "mountpoint", ",", "options", "=", "None", ",", "persist", "=", "False", ",", "filesystem", "=", "\"ext3\"", ")", ":", "cmd_args", "=", "[", "'mount'", "]", "if", "options", "is", "not", "None", ":", "cmd_args", ".",...
Mount a filesystem at a particular mountpoint
[ "Mount", "a", "filesystem", "at", "a", "particular", "mountpoint" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L589-L603
train
juju/charm-helpers
charmhelpers/core/host.py
umount
def umount(mountpoint, persist=False): """Unmount a filesystem""" cmd_args = ['umount', mountpoint] try: subprocess.check_output(cmd_args) except subprocess.CalledProcessError as e: log('Error unmounting {}\n{}'.format(mountpoint, e.output)) return False if persist: ...
python
def umount(mountpoint, persist=False): """Unmount a filesystem""" cmd_args = ['umount', mountpoint] try: subprocess.check_output(cmd_args) except subprocess.CalledProcessError as e: log('Error unmounting {}\n{}'.format(mountpoint, e.output)) return False if persist: ...
[ "def", "umount", "(", "mountpoint", ",", "persist", "=", "False", ")", ":", "cmd_args", "=", "[", "'umount'", ",", "mountpoint", "]", "try", ":", "subprocess", ".", "check_output", "(", "cmd_args", ")", "except", "subprocess", ".", "CalledProcessError", "as"...
Unmount a filesystem
[ "Unmount", "a", "filesystem" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L606-L617
train
juju/charm-helpers
charmhelpers/core/host.py
fstab_mount
def fstab_mount(mountpoint): """Mount filesystem using fstab""" cmd_args = ['mount', mountpoint] try: subprocess.check_output(cmd_args) except subprocess.CalledProcessError as e: log('Error unmounting {}\n{}'.format(mountpoint, e.output)) return False return True
python
def fstab_mount(mountpoint): """Mount filesystem using fstab""" cmd_args = ['mount', mountpoint] try: subprocess.check_output(cmd_args) except subprocess.CalledProcessError as e: log('Error unmounting {}\n{}'.format(mountpoint, e.output)) return False return True
[ "def", "fstab_mount", "(", "mountpoint", ")", ":", "cmd_args", "=", "[", "'mount'", ",", "mountpoint", "]", "try", ":", "subprocess", ".", "check_output", "(", "cmd_args", ")", "except", "subprocess", ".", "CalledProcessError", "as", "e", ":", "log", "(", ...
Mount filesystem using fstab
[ "Mount", "filesystem", "using", "fstab" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L629-L637
train
juju/charm-helpers
charmhelpers/core/host.py
file_hash
def file_hash(path, hash_type='md5'): """Generate a hash checksum of the contents of 'path' or None if not found. :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`, such as md5, sha1, sha256, sha512, etc. """ if os.path.exists(path): h = getattr(has...
python
def file_hash(path, hash_type='md5'): """Generate a hash checksum of the contents of 'path' or None if not found. :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`, such as md5, sha1, sha256, sha512, etc. """ if os.path.exists(path): h = getattr(has...
[ "def", "file_hash", "(", "path", ",", "hash_type", "=", "'md5'", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "h", "=", "getattr", "(", "hashlib", ",", "hash_type", ")", "(", ")", "with", "open", "(", "path", ",", "'rb...
Generate a hash checksum of the contents of 'path' or None if not found. :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`, such as md5, sha1, sha256, sha512, etc.
[ "Generate", "a", "hash", "checksum", "of", "the", "contents", "of", "path", "or", "None", "if", "not", "found", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L640-L652
train
juju/charm-helpers
charmhelpers/core/host.py
check_hash
def check_hash(path, checksum, hash_type='md5'): """Validate a file using a cryptographic checksum. :param str checksum: Value of the checksum used to validate the file. :param str hash_type: Hash algorithm used to generate `checksum`. Can be any hash alrgorithm supported by :mod:`hashlib`, ...
python
def check_hash(path, checksum, hash_type='md5'): """Validate a file using a cryptographic checksum. :param str checksum: Value of the checksum used to validate the file. :param str hash_type: Hash algorithm used to generate `checksum`. Can be any hash alrgorithm supported by :mod:`hashlib`, ...
[ "def", "check_hash", "(", "path", ",", "checksum", ",", "hash_type", "=", "'md5'", ")", ":", "actual_checksum", "=", "file_hash", "(", "path", ",", "hash_type", ")", "if", "checksum", "!=", "actual_checksum", ":", "raise", "ChecksumError", "(", "\"'%s' != '%s'...
Validate a file using a cryptographic checksum. :param str checksum: Value of the checksum used to validate the file. :param str hash_type: Hash algorithm used to generate `checksum`. Can be any hash alrgorithm supported by :mod:`hashlib`, such as md5, sha1, sha256, sha512, etc. :raises Che...
[ "Validate", "a", "file", "using", "a", "cryptographic", "checksum", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L669-L681
train
juju/charm-helpers
charmhelpers/core/host.py
restart_on_change
def restart_on_change(restart_map, stopstart=False, restart_functions=None): """Restart services based on configuration files changing This function is used a decorator, for example:: @restart_on_change({ '/etc/ceph/ceph.conf': [ 'cinder-api', 'cinder-volume' ] '/etc/apache/sit...
python
def restart_on_change(restart_map, stopstart=False, restart_functions=None): """Restart services based on configuration files changing This function is used a decorator, for example:: @restart_on_change({ '/etc/ceph/ceph.conf': [ 'cinder-api', 'cinder-volume' ] '/etc/apache/sit...
[ "def", "restart_on_change", "(", "restart_map", ",", "stopstart", "=", "False", ",", "restart_functions", "=", "None", ")", ":", "def", "wrap", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapped_f", "(", "*", "args", ","...
Restart services based on configuration files changing This function is used a decorator, for example:: @restart_on_change({ '/etc/ceph/ceph.conf': [ 'cinder-api', 'cinder-volume' ] '/etc/apache/sites-enabled/*': [ 'apache2' ] }) def config_changed(): ...
[ "Restart", "services", "based", "on", "configuration", "files", "changing" ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L689-L721
train
juju/charm-helpers
charmhelpers/core/host.py
restart_on_change_helper
def restart_on_change_helper(lambda_f, restart_map, stopstart=False, restart_functions=None): """Helper function to perform the restart_on_change function. This is provided for decorators to restart services if files described in the restart_map have changed after an invocation...
python
def restart_on_change_helper(lambda_f, restart_map, stopstart=False, restart_functions=None): """Helper function to perform the restart_on_change function. This is provided for decorators to restart services if files described in the restart_map have changed after an invocation...
[ "def", "restart_on_change_helper", "(", "lambda_f", ",", "restart_map", ",", "stopstart", "=", "False", ",", "restart_functions", "=", "None", ")", ":", "if", "restart_functions", "is", "None", ":", "restart_functions", "=", "{", "}", "checksums", "=", "{", "p...
Helper function to perform the restart_on_change function. This is provided for decorators to restart services if files described in the restart_map have changed after an invocation of lambda_f(). @param lambda_f: function to call. @param restart_map: {file: [service, ...]} @param stopstart: wheth...
[ "Helper", "function", "to", "perform", "the", "restart_on_change", "function", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L724-L756
train
juju/charm-helpers
charmhelpers/core/host.py
pwgen
def pwgen(length=None): """Generate a random pasword.""" if length is None: # A random length is ok to use a weak PRNG length = random.choice(range(35, 45)) alphanumeric_chars = [ l for l in (string.ascii_letters + string.digits) if l not in 'l0QD1vAEIOUaeiou'] # Use a cr...
python
def pwgen(length=None): """Generate a random pasword.""" if length is None: # A random length is ok to use a weak PRNG length = random.choice(range(35, 45)) alphanumeric_chars = [ l for l in (string.ascii_letters + string.digits) if l not in 'l0QD1vAEIOUaeiou'] # Use a cr...
[ "def", "pwgen", "(", "length", "=", "None", ")", ":", "if", "length", "is", "None", ":", "# A random length is ok to use a weak PRNG", "length", "=", "random", ".", "choice", "(", "range", "(", "35", ",", "45", ")", ")", "alphanumeric_chars", "=", "[", "l"...
Generate a random pasword.
[ "Generate", "a", "random", "pasword", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L759-L772
train
juju/charm-helpers
charmhelpers/core/host.py
is_phy_iface
def is_phy_iface(interface): """Returns True if interface is not virtual, otherwise False.""" if interface: sys_net = '/sys/class/net' if os.path.isdir(sys_net): for iface in glob.glob(os.path.join(sys_net, '*')): if '/virtual/' in os.path.realpath(iface): ...
python
def is_phy_iface(interface): """Returns True if interface is not virtual, otherwise False.""" if interface: sys_net = '/sys/class/net' if os.path.isdir(sys_net): for iface in glob.glob(os.path.join(sys_net, '*')): if '/virtual/' in os.path.realpath(iface): ...
[ "def", "is_phy_iface", "(", "interface", ")", ":", "if", "interface", ":", "sys_net", "=", "'/sys/class/net'", "if", "os", ".", "path", ".", "isdir", "(", "sys_net", ")", ":", "for", "iface", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "j...
Returns True if interface is not virtual, otherwise False.
[ "Returns", "True", "if", "interface", "is", "not", "virtual", "otherwise", "False", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L775-L787
train
juju/charm-helpers
charmhelpers/core/host.py
get_bond_master
def get_bond_master(interface): """Returns bond master if interface is bond slave otherwise None. NOTE: the provided interface is expected to be physical """ if interface: iface_path = '/sys/class/net/%s' % (interface) if os.path.exists(iface_path): if '/virtual/' in os.path...
python
def get_bond_master(interface): """Returns bond master if interface is bond slave otherwise None. NOTE: the provided interface is expected to be physical """ if interface: iface_path = '/sys/class/net/%s' % (interface) if os.path.exists(iface_path): if '/virtual/' in os.path...
[ "def", "get_bond_master", "(", "interface", ")", ":", "if", "interface", ":", "iface_path", "=", "'/sys/class/net/%s'", "%", "(", "interface", ")", "if", "os", ".", "path", ".", "exists", "(", "iface_path", ")", ":", "if", "'/virtual/'", "in", "os", ".", ...
Returns bond master if interface is bond slave otherwise None. NOTE: the provided interface is expected to be physical
[ "Returns", "bond", "master", "if", "interface", "is", "bond", "slave", "otherwise", "None", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L790-L808
train
juju/charm-helpers
charmhelpers/core/host.py
chdir
def chdir(directory): """Change the current working directory to a different directory for a code block and return the previous directory after the block exits. Useful to run commands from a specificed directory. :param str directory: The directory path to change to for this context. """ cur = ...
python
def chdir(directory): """Change the current working directory to a different directory for a code block and return the previous directory after the block exits. Useful to run commands from a specificed directory. :param str directory: The directory path to change to for this context. """ cur = ...
[ "def", "chdir", "(", "directory", ")", ":", "cur", "=", "os", ".", "getcwd", "(", ")", "try", ":", "yield", "os", ".", "chdir", "(", "directory", ")", "finally", ":", "os", ".", "chdir", "(", "cur", ")" ]
Change the current working directory to a different directory for a code block and return the previous directory after the block exits. Useful to run commands from a specificed directory. :param str directory: The directory path to change to for this context.
[ "Change", "the", "current", "working", "directory", "to", "a", "different", "directory", "for", "a", "code", "block", "and", "return", "the", "previous", "directory", "after", "the", "block", "exits", ".", "Useful", "to", "run", "commands", "from", "a", "spe...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L883-L894
train
juju/charm-helpers
charmhelpers/core/host.py
chownr
def chownr(path, owner, group, follow_links=True, chowntopdir=False): """Recursively change user and group ownership of files and directories in given path. Doesn't chown path itself by default, only its children. :param str path: The string path to start changing ownership. :param str owner: The owner...
python
def chownr(path, owner, group, follow_links=True, chowntopdir=False): """Recursively change user and group ownership of files and directories in given path. Doesn't chown path itself by default, only its children. :param str path: The string path to start changing ownership. :param str owner: The owner...
[ "def", "chownr", "(", "path", ",", "owner", ",", "group", ",", "follow_links", "=", "True", ",", "chowntopdir", "=", "False", ")", ":", "uid", "=", "pwd", ".", "getpwnam", "(", "owner", ")", ".", "pw_uid", "gid", "=", "grp", ".", "getgrnam", "(", "...
Recursively change user and group ownership of files and directories in given path. Doesn't chown path itself by default, only its children. :param str path: The string path to start changing ownership. :param str owner: The owner string to use when looking up the uid. :param str group: The group strin...
[ "Recursively", "change", "user", "and", "group", "ownership", "of", "files", "and", "directories", "in", "given", "path", ".", "Doesn", "t", "chown", "path", "itself", "by", "default", "only", "its", "children", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L897-L923
train
juju/charm-helpers
charmhelpers/core/host.py
lchownr
def lchownr(path, owner, group): """Recursively change user and group ownership of files and directories in a given path, not following symbolic links. See the documentation for 'os.lchown' for more information. :param str path: The string path to start changing ownership. :param str owner: The own...
python
def lchownr(path, owner, group): """Recursively change user and group ownership of files and directories in a given path, not following symbolic links. See the documentation for 'os.lchown' for more information. :param str path: The string path to start changing ownership. :param str owner: The own...
[ "def", "lchownr", "(", "path", ",", "owner", ",", "group", ")", ":", "chownr", "(", "path", ",", "owner", ",", "group", ",", "follow_links", "=", "False", ")" ]
Recursively change user and group ownership of files and directories in a given path, not following symbolic links. See the documentation for 'os.lchown' for more information. :param str path: The string path to start changing ownership. :param str owner: The owner string to use when looking up the uid...
[ "Recursively", "change", "user", "and", "group", "ownership", "of", "files", "and", "directories", "in", "a", "given", "path", "not", "following", "symbolic", "links", ".", "See", "the", "documentation", "for", "os", ".", "lchown", "for", "more", "information"...
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L926-L935
train
juju/charm-helpers
charmhelpers/core/host.py
owner
def owner(path): """Returns a tuple containing the username & groupname owning the path. :param str path: the string path to retrieve the ownership :return tuple(str, str): A (username, groupname) tuple containing the name of the user and group owning the path. :raises OSEr...
python
def owner(path): """Returns a tuple containing the username & groupname owning the path. :param str path: the string path to retrieve the ownership :return tuple(str, str): A (username, groupname) tuple containing the name of the user and group owning the path. :raises OSEr...
[ "def", "owner", "(", "path", ")", ":", "stat", "=", "os", ".", "stat", "(", "path", ")", "username", "=", "pwd", ".", "getpwuid", "(", "stat", ".", "st_uid", ")", "[", "0", "]", "groupname", "=", "grp", ".", "getgrgid", "(", "stat", ".", "st_gid"...
Returns a tuple containing the username & groupname owning the path. :param str path: the string path to retrieve the ownership :return tuple(str, str): A (username, groupname) tuple containing the name of the user and group owning the path. :raises OSError: if the specified pa...
[ "Returns", "a", "tuple", "containing", "the", "username", "&", "groupname", "owning", "the", "path", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L938-L949
train
juju/charm-helpers
charmhelpers/core/host.py
get_total_ram
def get_total_ram(): """The total amount of system RAM in bytes. This is what is reported by the OS, and may be overcommitted when there are multiple containers hosted on the same machine. """ with open('/proc/meminfo', 'r') as f: for line in f.readlines(): if line: ...
python
def get_total_ram(): """The total amount of system RAM in bytes. This is what is reported by the OS, and may be overcommitted when there are multiple containers hosted on the same machine. """ with open('/proc/meminfo', 'r') as f: for line in f.readlines(): if line: ...
[ "def", "get_total_ram", "(", ")", ":", "with", "open", "(", "'/proc/meminfo'", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "f", ".", "readlines", "(", ")", ":", "if", "line", ":", "key", ",", "value", ",", "unit", "=", "line", ".", "spl...
The total amount of system RAM in bytes. This is what is reported by the OS, and may be overcommitted when there are multiple containers hosted on the same machine.
[ "The", "total", "amount", "of", "system", "RAM", "in", "bytes", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L952-L965
train
juju/charm-helpers
charmhelpers/core/host.py
add_to_updatedb_prunepath
def add_to_updatedb_prunepath(path, updatedb_path=UPDATEDB_PATH): """Adds the specified path to the mlocate's udpatedb.conf PRUNEPATH list. This method has no effect if the path specified by updatedb_path does not exist or is not a file. @param path: string the path to add to the updatedb.conf PRUNEPA...
python
def add_to_updatedb_prunepath(path, updatedb_path=UPDATEDB_PATH): """Adds the specified path to the mlocate's udpatedb.conf PRUNEPATH list. This method has no effect if the path specified by updatedb_path does not exist or is not a file. @param path: string the path to add to the updatedb.conf PRUNEPA...
[ "def", "add_to_updatedb_prunepath", "(", "path", ",", "updatedb_path", "=", "UPDATEDB_PATH", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "updatedb_path", ")", "or", "os", ".", "path", ".", "isdir", "(", "updatedb_path", ")", ":", "# If th...
Adds the specified path to the mlocate's udpatedb.conf PRUNEPATH list. This method has no effect if the path specified by updatedb_path does not exist or is not a file. @param path: string the path to add to the updatedb.conf PRUNEPATHS value @param updatedb_path: the path the updatedb.conf file
[ "Adds", "the", "specified", "path", "to", "the", "mlocate", "s", "udpatedb", ".", "conf", "PRUNEPATH", "list", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L985-L1005
train
juju/charm-helpers
charmhelpers/core/host.py
install_ca_cert
def install_ca_cert(ca_cert, name=None): """ Install the given cert as a trusted CA. The ``name`` is the stem of the filename where the cert is written, and if not provided, it will default to ``juju-{charm_name}``. If the cert is empty or None, or is unchanged, nothing is done. """ if not...
python
def install_ca_cert(ca_cert, name=None): """ Install the given cert as a trusted CA. The ``name`` is the stem of the filename where the cert is written, and if not provided, it will default to ``juju-{charm_name}``. If the cert is empty or None, or is unchanged, nothing is done. """ if not...
[ "def", "install_ca_cert", "(", "ca_cert", ",", "name", "=", "None", ")", ":", "if", "not", "ca_cert", ":", "return", "if", "not", "isinstance", "(", "ca_cert", ",", "bytes", ")", ":", "ca_cert", "=", "ca_cert", ".", "encode", "(", "'utf8'", ")", "if", ...
Install the given cert as a trusted CA. The ``name`` is the stem of the filename where the cert is written, and if not provided, it will default to ``juju-{charm_name}``. If the cert is empty or None, or is unchanged, nothing is done.
[ "Install", "the", "given", "cert", "as", "a", "trusted", "CA", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L1056-L1077
train
juju/charm-helpers
charmhelpers/contrib/hardening/host/checks/securetty.py
get_audits
def get_audits(): """Get OS hardening Secure TTY audits. :returns: dictionary of audits """ audits = [] audits.append(TemplatedFile('/etc/securetty', SecureTTYContext(), template_dir=TEMPLATES_DIR, mode=0o0400, user='root', group='roo...
python
def get_audits(): """Get OS hardening Secure TTY audits. :returns: dictionary of audits """ audits = [] audits.append(TemplatedFile('/etc/securetty', SecureTTYContext(), template_dir=TEMPLATES_DIR, mode=0o0400, user='root', group='roo...
[ "def", "get_audits", "(", ")", ":", "audits", "=", "[", "]", "audits", ".", "append", "(", "TemplatedFile", "(", "'/etc/securetty'", ",", "SecureTTYContext", "(", ")", ",", "template_dir", "=", "TEMPLATES_DIR", ",", "mode", "=", "0o0400", ",", "user", "=",...
Get OS hardening Secure TTY audits. :returns: dictionary of audits
[ "Get", "OS", "hardening", "Secure", "TTY", "audits", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/host/checks/securetty.py#L20-L29
train