The tacker.common.utils Module

Utilities and helper functions.

class tacker.common.utils.cache_method_results(func)

Bases: object

This decorator is intended for object methods only.

tacker.common.utils.change_memory_unit(mem, to)

Changes the memory value(mem) based on the unit(‘to’) specified.

If the unit is not specified in ‘mem’, by default, it is considered as “MB”. And this method returns only integer.

tacker.common.utils.deep_update(orig_dict, new_dict)
tacker.common.utils.deprecate_warning(what, as_of, in_favor_of=None, remove_in=1)
tacker.common.utils.dict2tuple(d)
tacker.common.utils.find_config_file(options, config_file)

Return the first config file found.

We search for the paste config file in the following order: * If –config-file option is used, use that * Search for the configuration files via common cfg directories :retval Full path to config file, or None if no config file found

tacker.common.utils.generate_resource_name(resource, prefix='tmpl')
tacker.common.utils.get_hostname()
tacker.common.utils.is_valid_ipv4(address)

Verify that address represents a valid IPv4 address.

tacker.common.utils.is_valid_vlan_tag(vlan)
tacker.common.utils.load_class_by_alias_or_classname(namespace, name)

Load class using stevedore alias or the class name

Load class using the stevedore driver manager :param namespace: namespace where the alias is defined :param name: alias or class name of the class to be loaded :returns class if calls can be loaded :raises ImportError if class cannot be loaded

tacker.common.utils.log_opt_values(log)
tacker.common.utils.parse_mappings(mapping_list, unique_values=True)

Parse a list of mapping strings into a dictionary.

Parameters:
  • mapping_list – a list of strings of the form ‘<key>:<value>’
  • unique_values – values must be unique if True
Returns:

a dict mapping keys to values

tacker.common.utils.subprocess_popen(args, stdin=None, stdout=None, stderr=None, shell=False, env=None)