Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def destroy(name, call=None): ''' Destroy a node. Will check termination protection and warn if enabled. CLI Example: .. code-block:: bash salt-cloud --destroy mymachine ''' if call == 'function': raise SaltCloudSystemExit( ...
[]
Please provide a description of the function:def post_dns_record(**kwargs): ''' Creates a DNS record for the given name if the domain is managed with DO. ''' if 'kwargs' in kwargs: # flatten kwargs if called via salt-cloud -f f_kwargs = kwargs['kwargs'] del kwargs['kwargs'] kwar...
[]
Please provide a description of the function:def destroy_dns_records(fqdn): ''' Deletes DNS records for the given hostname if the domain is managed with DO. ''' domain = '.'.join(fqdn.split('.')[-2:]) hostname = '.'.join(fqdn.split('.')[:-2]) # TODO: remove this when the todo on 754 is available...
[]
Please provide a description of the function:def show_pricing(kwargs=None, call=None): ''' Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my...
[]
Please provide a description of the function:def show_floating_ip(kwargs=None, call=None): ''' Show the details of a floating IP .. versionadded:: 2016.3.0 CLI Examples: .. code-block:: bash salt-cloud -f show_floating_ip my-digitalocean-config floating_ip='45.55.96.47' ''' if ca...
[]
Please provide a description of the function:def create_floating_ip(kwargs=None, call=None): ''' Create a new floating IP .. versionadded:: 2016.3.0 CLI Examples: .. code-block:: bash salt-cloud -f create_floating_ip my-digitalocean-config region='NYC2' salt-cloud -f create_floa...
[]
Please provide a description of the function:def delete_floating_ip(kwargs=None, call=None): ''' Delete a floating IP .. versionadded:: 2016.3.0 CLI Examples: .. code-block:: bash salt-cloud -f delete_floating_ip my-digitalocean-config floating_ip='45.55.96.47' ''' if call != 'fu...
[]
Please provide a description of the function:def unassign_floating_ip(kwargs=None, call=None): ''' Unassign a floating IP .. versionadded:: 2016.3.0 CLI Examples: .. code-block:: bash salt-cloud -f unassign_floating_ip my-digitalocean-config floating_ip='45.55.96.47' ''' if call ...
[]
Please provide a description of the function:def _list_nodes(full=False, for_output=False): ''' Helper function to format and parse node data. ''' fetch = True page = 1 ret = {} while fetch: items = query(method='droplets', command='?page=' + six.text_type(page...
[]
Please provide a description of the function:def reboot(name, call=None): ''' Reboot a droplet in DigitalOcean. .. versionadded:: 2015.8.8 name The name of the droplet to restart. CLI Example: .. code-block:: bash salt-cloud -a reboot droplet_name ''' if call != 'act...
[]
Please provide a description of the function:def _get_full_output(node, for_output=False): ''' Helper function for _list_nodes to loop through all node information. Returns a dictionary containing the full information of a node. ''' ret = {} for item in six.iterkeys(node): value = node[i...
[]
Please provide a description of the function:def _get_ips(networks): ''' Helper function for list_nodes. Returns public and private ip lists based on a given network dictionary. ''' v4s = networks.get('v4') v6s = networks.get('v6') public_ips = [] private_ips = [] if v4s: fo...
[]
Please provide a description of the function:def cluster_create(version, name='main', port=None, locale=None, encoding=None, datadir=None, allow_group_access=None, data_checksums=None, ...
[]
Please provide a description of the function:def cluster_list(verbose=False): ''' Return a list of cluster of Postgres server (tuples of version and name). CLI Example: .. code-block:: bash salt '*' postgres.cluster_list salt '*' postgres.cluster_list verbose=True ''' cmd = [...
[]
Please provide a description of the function:def _parse_pg_lscluster(output): ''' Helper function to parse the output of pg_lscluster ''' cluster_dict = {} for line in output.splitlines(): version, name, port, status, user, datadir, log = ( line.split()) cluster_dict['{0}...
[]
Please provide a description of the function:def _find_credentials(host): ''' Cycle through all the possible credentials and return the first one that works. ''' user_names = [__pillar__['proxy'].get('username', 'root')] passwords = __pillar__['proxy']['passwords'] for user in user_names: ...
[]
Please provide a description of the function:def _grains(): ''' Get the grains from the proxied device. ''' try: host = __pillar__['proxy']['host'] if host: username, password = _find_credentials(host) protocol = __pillar__['proxy'].get('protocol') por...
[]
Please provide a description of the function:def ext_pillar(minion_id, pillar, # pylint: disable=W0613 conf): ''' Check etcd for all data ''' comps = conf.split() profile = None if comps[0]: profile = comps[0] client = salt.utils.etcd_util.get_conn(__o...
[]
Please provide a description of the function:def rule_absent(name, method, port=None, proto='tcp', direction='in', port_origin='d', ip_origin='s', ttl=None, reload=False): ''' Ensure i...
[]
Please provide a description of the function:def ports_open(name, ports, proto='tcp', direction='in'): ''' Ensure ports are open for a protocol, in a direction. e.g. - proto='tcp', direction='in' would set the values for TCP_IN in the csf.conf file. ports A list of ports that should be open...
[]
Please provide a description of the function:def nics_skip(name, nics, ipv6): ''' Alias for :mod:`csf.nics_skipped <salt.states.csf.nics_skipped>` ''' return nics_skipped(name, nics=nics, ipv6=ipv6)
[]
Please provide a description of the function:def nics_skipped(name, nics, ipv6=False): ''' name Meaningless arg, but required for state. nics A list of nics to skip. ipv6 Boolean. Set to true if you want to skip the ipv6 interface. Default false (ipv4). ''' ret ...
[]
Please provide a description of the function:def option_present(name, value, reload=False): ''' Ensure the state of a particular option/setting in csf. name The option name in csf.conf value The value it should be set to. reload Boolean. If set to true, csf will be reloade...
[]
Please provide a description of the function:def _parse_stack_cfg(content): ''' Allow top level cfg to be YAML ''' try: obj = salt.utils.yaml.safe_load(content) if isinstance(obj, list): return obj except Exception as e: pass return content.splitlines()
[]
Please provide a description of the function:def _clear_context(bin_env=None): ''' Remove the cached pip version ''' contextkey = 'pip.version' if bin_env is not None: contextkey = '{0}.{1}'.format(contextkey, bin_env) __context__.pop(contextkey, None)
[]
Please provide a description of the function:def _get_pip_bin(bin_env): ''' Locate the pip binary, either from `bin_env` as a virtualenv, as the executable itself, or from searching conventional filesystem locations ''' if not bin_env: logger.debug('pip: Using pip from currently-running Pyth...
[]
Please provide a description of the function:def _get_cached_requirements(requirements, saltenv): ''' Get the location of a cached requirements file; caching if necessary. ''' req_file, senv = salt.utils.url.parse(requirements) if senv: saltenv = senv if req_file not in __salt__['cp.li...
[]
Please provide a description of the function:def _get_env_activate(bin_env): ''' Return the path to the activate binary ''' if not bin_env: raise CommandNotFoundError('Could not find a `activate` binary') if os.path.isdir(bin_env): if salt.utils.platform.is_windows(): ac...
[]
Please provide a description of the function:def _resolve_requirements_chain(requirements): ''' Return an array of requirements file paths that can be used to complete the no_chown==False && user != None conundrum ''' chain = [] if isinstance(requirements, six.string_types): requiremen...
[]
Please provide a description of the function:def _process_requirements(requirements, cmd, cwd, saltenv, user): ''' Process the requirements argument ''' cleanup_requirements = [] if requirements is not None: if isinstance(requirements, six.string_types): requirements = [r.strip(...
[]
Please provide a description of the function:def install(pkgs=None, # pylint: disable=R0912,R0913,R0914 requirements=None, bin_env=None, use_wheel=False, no_use_wheel=False, log=None, proxy=None, timeout=None, editable=None...
[]
Please provide a description of the function:def uninstall(pkgs=None, requirements=None, bin_env=None, log=None, proxy=None, timeout=None, user=None, cwd=None, saltenv='base', use_vt=False): ...
[]
Please provide a description of the function:def freeze(bin_env=None, user=None, cwd=None, use_vt=False, env_vars=None, **kwargs): ''' Return a list of installed packages either globally or in the specified virtualenv bin_env Path to pip (o...
[]
Please provide a description of the function:def list_(prefix=None, bin_env=None, user=None, cwd=None, env_vars=None, **kwargs): ''' Filter list of installed apps from ``freeze`` and check to see if ``prefix`` exists in the list of packages installed. ....
[]
Please provide a description of the function:def version(bin_env=None): ''' .. versionadded:: 0.17.0 Returns the version of pip. Use ``bin_env`` to specify the path to a virtualenv and get the version of pip in that virtualenv. If unable to detect the pip version, returns ``None``. CLI Exampl...
[]
Please provide a description of the function:def list_upgrades(bin_env=None, user=None, cwd=None): ''' Check whether or not an upgrade is available for all packages CLI Example: .. code-block:: bash salt '*' pip.list_upgrades ''' cmd = _get_pip_bin(...
[]
Please provide a description of the function:def is_installed(pkgname=None, bin_env=None, user=None, cwd=None): ''' .. versionadded:: 2018.3.0 Filter list of installed apps from ``freeze`` and return True or False if ``pkgname`` exists in the list of ...
[]
Please provide a description of the function:def upgrade_available(pkg, bin_env=None, user=None, cwd=None): ''' .. versionadded:: 2015.5.0 Check whether or not an upgrade is available for a given package CLI Example: .. code-block:...
[]
Please provide a description of the function:def upgrade(bin_env=None, user=None, cwd=None, use_vt=False): ''' .. versionadded:: 2015.5.0 Upgrades outdated pip packages. .. note:: On Windows you can't update salt from pip using salt, so salt will be ...
[]
Please provide a description of the function:def list_all_versions(pkg, bin_env=None, include_alpha=False, include_beta=False, include_rc=False, user=None, cwd=None, ...
[]
Please provide a description of the function:def verify_certs(*args): ''' Sanity checking for the specified SSL certificates ''' msg = ("Could not find a certificate: {0}\n" "If you want to quickly generate a self-signed certificate, " "use the tls.create_self_signed_cert functio...
[]
Please provide a description of the function:def start(): ''' Start the server loop ''' from . import app root, apiopts, conf = app.get_app(__opts__) if not apiopts.get('disable_ssl', False): if 'ssl_crt' not in apiopts or 'ssl_key' not in apiopts: logger.error("Not starting...
[]
Please provide a description of the function:def get_osarch(): ''' Get the os architecture using rpm --eval ''' if salt.utils.path.which('rpm'): ret = subprocess.Popen( 'rpm --eval "%{_host_cpu}"', shell=True, close_fds=True, stdout=subprocess.PIPE...
[]
Please provide a description of the function:def check_32(arch, osarch=None): ''' Returns True if both the OS arch and the passed arch are 32-bit ''' if osarch is None: osarch = get_osarch() return all(x in ARCHES_32 for x in (osarch, arch))
[]
Please provide a description of the function:def pkginfo(name, version, arch, repoid, install_date=None, install_date_time_t=None): ''' Build and return a pkginfo namedtuple ''' pkginfo_tuple = collections.namedtuple( 'PkgInfo', ('name', 'version', 'arch', 'repoid', 'install_date', ...
[]
Please provide a description of the function:def resolve_name(name, arch, osarch=None): ''' Resolve the package name and arch into a unique name referred to by salt. For example, on a 64-bit OS, a 32-bit package will be pkgname.i386. ''' if osarch is None: osarch = get_osarch() if not c...
[]
Please provide a description of the function:def parse_pkginfo(line, osarch=None): ''' A small helper to parse an rpm/repoquery command's output. Returns a pkginfo namedtuple. ''' try: name, epoch, version, release, arch, repoid, install_time = line.split('_|-') # Handle unpack errors (s...
[]
Please provide a description of the function:def combine_comments(comments): ''' Given a list of comments, strings, a single comment or a single string, return a single string of text containing all of the comments, prepending the '#' and joining with newlines as necessary. ''' if not isinstance...
[]
Please provide a description of the function:def version_to_evr(verstring): ''' Split the package version string into epoch, version and release. Return this as tuple. The epoch is always not empty. The version and the release can be an empty string if such a component could not be found in the ver...
[]
Please provide a description of the function:def present( name, description, vpc_id=None, vpc_name=None, rules=None, rules_egress=None, delete_ingress_rules=True, delete_egress_rules=True, region=None, key=None, keyid=None, ...
[]
Please provide a description of the function:def _security_group_present(name, description, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' given a group name or a group name and vpc id (or vpc name): 1. determine if the group exists 2. if th...
[]
Please provide a description of the function:def _split_rules(rules): ''' Split rules with lists into individual rules. We accept some attributes as lists or strings. The data we get back from the execution module lists rules as individual rules. We need to split the provided rules into individual ...
[]
Please provide a description of the function:def _check_rule(rule, _rule): ''' Check to see if two rules are the same. Needed to compare rules fetched from boto, since they may not completely match rules defined in sls files but may be functionally equivalent. ''' # We need to alter what Boto r...
[]
Please provide a description of the function:def _get_rule_changes(rules, _rules): ''' given a list of desired rules (rules) and existing rules (_rules) return a list of rules to delete (to_delete) and to create (to_create) ''' to_delete = [] to_create = [] # for each rule in state file ...
[]
Please provide a description of the function:def _rules_present(name, rules, delete_ingress_rules=True, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' given a group name or group name and vpc_id (or vpc name): 1. get lists of desired rule changes (using ...
[ "Security group {0} set to have rules modified.\n To be created: {1}\n To be deleted: {2}" ]
Please provide a description of the function:def absent( name, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Ensure a security group with the specified name does not exist. name Name of the security group. ...
[]
Please provide a description of the function:def _tags_present(name, tags, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' helper function to validate tags are correct ''' ret = {'result': True, 'comment': '', 'changes': {}} if tags: sg = _...
[]
Please provide a description of the function:def _ordereddict2dict(input_ordered_dict): ''' Convert ordered dictionary to a dictionary ''' return salt.utils.json.loads(salt.utils.json.dumps(input_ordered_dict))
[]
Please provide a description of the function:def quorum(name, **kwargs): ''' Quorum state This state checks the mon daemons are in quorum. It does not alter the cluster but can be used in formula as a dependency for many cluster operations. Example usage in sls file: .. code-block:: yaml ...
[]
Please provide a description of the function:def ext_pillar(minion_id, pillar, # pylint: disable=W0613 conf): ''' Check consul for all data ''' opts = {} temp = conf target_re = re.compile('target="(.*?)"') match = target_re.search(temp) if match: o...
[]
Please provide a description of the function:def consul_fetch(client, path): ''' Query consul for all keys/values within base path ''' # Unless the root path is blank, it needs a trailing slash for # the kv get from Consul to work as expected return client.kv.get('' if not path else path.rstrip(...
[]
Please provide a description of the function:def fetch_tree(client, path, expand_keys): ''' Grab data from consul, trim base path and remove any keys which are folders. Take the remaining data and send it to be formatted in such a way as to be used as pillar data. ''' _, items = consul_fetch(cli...
[]
Please provide a description of the function:def pillar_format(ret, keys, value, expand_keys): ''' Perform data formatting to be used as pillar data and merge it with the current pillar data ''' # if value is empty in Consul then it's None here - skip it if value is None: return ret ...
[]
Please provide a description of the function:def _resolve_datacenter(dc, pillarenv): ''' If ``dc`` is a string - return it as is. If it's a dict then sort it in descending order by key length and try to use keys as RegEx patterns to match against ``pillarenv``. The value for matched pattern should ...
[]
Please provide a description of the function:def _gather_group_members(group, groups, users): ''' Gather group members ''' _group = __salt__['group.info'](group) if not _group: log.warning('Group %s does not exist, ignoring.', group) return for member in _group['members']: ...
[]
Please provide a description of the function:def _check_time_range(time_range, now): ''' Check time range ''' if _TIME_SUPPORTED: _start = dateutil_parser.parse(time_range['start']) _end = dateutil_parser.parse(time_range['end']) return bool(_start <= now <= _end) else: ...
[]
Please provide a description of the function:def beacon(config): ''' Read the last btmp file and return information on the failed logins ''' ret = [] users = {} groups = {} defaults = None for config_item in config: if 'users' in config_item: users = config_item['us...
[]
Please provide a description of the function:def _sprinkle(config_str): ''' Sprinkle with grains of salt, that is convert 'test {id} test {host} ' types of strings :param config_str: The string to be sprinkled :return: The string sprinkled ''' parts = [x for sub in config_str.split('{') for ...
[]
Please provide a description of the function:def _generate_payload(author_icon, title, report): ''' Prepare the payload for Slack :param author_icon: The url for the thumbnail to be displayed :param title: The title of the message :param report: A dictionary with the report of the Salt function ...
[]
Please provide a description of the function:def _generate_report(ret, show_tasks): ''' Generate a report of the Salt function :param ret: The Salt return :param show_tasks: Flag to show the name of the changed and failed states :return: The report ''' returns = ret.get('return') sorte...
[]
Please provide a description of the function:def _post_message(webhook, author_icon, title, report): ''' Send a message to a Slack room through a webhook :param webhook: The url of the incoming webhook :param author_icon: The thumbnail image to be displayed on the right side of the message :para...
[]
Please provide a description of the function:def returner(ret): ''' Send a slack message with the data through a webhook :param ret: The Salt return :return: The result of the post ''' _options = _get_options(ret) webhook = _options.get('webhook', None) show_tasks = _options.get('show_...
[]
Please provide a description of the function:def update_git_repos(clean=False): ''' Checkout git repos containing :ref:`Windows Software Package Definitions <windows-package-manager>`. .. important:: This function requires `Git for Windows`_ to be installed in order to work. When instal...
[]
Please provide a description of the function:def show_sls(name, saltenv='base'): r''' .. versionadded:: 2015.8.0 Display the rendered software definition from a specific sls file in the local winrepo cache. This will parse all Jinja. Run pkg.refresh_db to pull the latest software definitions from t...
[]
Please provide a description of the function:def version(): ''' Return the actual lxc client version .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.version ''' k = 'lxc.version' if not __context__.get(k, None): cversion = __salt__['cmd.run_...
[]
Please provide a description of the function:def _clear_context(): ''' Clear any lxc variables set in __context__ ''' for var in [x for x in __context__ if x.startswith('lxc.')]: log.trace('Clearing __context__[\'%s\']', var) __context__.pop(var, None)
[]
Please provide a description of the function:def _ip_sort(ip): '''Ip sorting''' idx = '001' if ip == '127.0.0.1': idx = '200' if ip == '::1': idx = '201' elif '::' in ip: idx = '100' return '{0}___{1}'.format(idx, ip)
[]
Please provide a description of the function:def cloud_init_interface(name, vm_=None, **kwargs): ''' Interface between salt.cloud.lxc driver and lxc.init ``vm_`` is a mapping of vm opts in the salt.cloud format as documented for the lxc driver. This can be used either: - from the salt cloud dr...
[]
Please provide a description of the function:def _rand_cpu_str(cpu): ''' Return a random subset of cpus for the cpuset config ''' cpu = int(cpu) avail = __salt__['status.nproc']() if cpu < avail: return '0-{0}'.format(avail) to_set = set() while len(to_set) < cpu: choice ...
[]
Please provide a description of the function:def _network_conf(conf_tuples=None, **kwargs): ''' Network configuration defaults network_profile as for containers, we can either call this function either with a network_profile dict or network profile name in the kwargs...
[]
Please provide a description of the function:def _config_list(conf_tuples=None, only_net=False, **kwargs): ''' Return a list of dicts from the salt level configurations conf_tuples _LXCConfig compatible list of entries which can contain - string line - tuple (lxc config par...
[]
Please provide a description of the function:def _get_veths(net_data): ''' Parse the nic setup inside lxc conf tuples back to a dictionary indexed by network interface ''' if isinstance(net_data, dict): net_data = list(net_data.items()) nics = salt.utils.odict.OrderedDict() current_n...
[]
Please provide a description of the function:def _get_base(**kwargs): ''' If the needed base does not exist, then create it, if it does exist create nothing and return the name of the base lxc container so it can be cloned. ''' profile = get_container_profile(copy.deepcopy(kwargs.get('profile'))...
[]
Please provide a description of the function:def init(name, config=None, cpuset=None, cpushare=None, memory=None, profile=None, network_profile=None, nic_opts=None, cpu=None, autostart=True, password=None, password_encryp...
[]
Please provide a description of the function:def cloud_init(name, vm_=None, **kwargs): ''' Thin wrapper to lxc.init to be used from the saltcloud lxc driver name Name of the container may be None and then guessed from saltcloud mapping `vm_` saltcloud mapping defaults for the vm...
[]
Please provide a description of the function:def images(dist=None): ''' .. versionadded:: 2015.5.0 List the available images for LXC's ``download`` template. dist : None Filter results to a single Linux distribution CLI Examples: .. code-block:: bash salt myminion lxc.images...
[]
Please provide a description of the function:def templates(): ''' .. versionadded:: 2015.5.0 List the available LXC template scripts installed on the minion CLI Examples: .. code-block:: bash salt myminion lxc.templates ''' try: template_scripts = os.listdir('/usr/share/l...
[]
Please provide a description of the function:def create(name, config=None, profile=None, network_profile=None, nic_opts=None, **kwargs): ''' Create a new container. name Name of the container config The config file to use for the c...
[]
Please provide a description of the function:def clone(name, orig, profile=None, network_profile=None, nic_opts=None, **kwargs): ''' Create a new container as a clone of another container name Name of the container orig Name of the orig...
[]
Please provide a description of the function:def ls_(active=None, cache=True, path=None): ''' Return a list of the containers available on the minion path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 active If ``True`...
[]
Please provide a description of the function:def list_(extra=False, limit=None, path=None): ''' List containers classified by state extra Also get per-container specific info. This will change the return data. Instead of returning a list of containers, a dictionary of containers and...
[]
Please provide a description of the function:def _ensure_exists(name, path=None): ''' Raise an exception if the container does not exist ''' if not exists(name, path=path): raise CommandExecutionError( 'Container \'{0}\' does not exist'.format(name) )
[]
Please provide a description of the function:def _ensure_running(name, no_start=False, path=None): ''' If the container is not currently running, start it. This function returns the state that the container was in before changing path path to the container parent directory default: /var...
[]
Please provide a description of the function:def restart(name, path=None, lxc_config=None, force=False): ''' .. versionadded:: 2015.5.0 Restart the named container. If the container was not running, the container will merely be started. name The name of the container path path...
[]
Please provide a description of the function:def start(name, **kwargs): ''' Start the named container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 lxc_config path to a lxc config file config file will be ...
[]
Please provide a description of the function:def stop(name, kill=False, path=None, use_vt=None): ''' Stop the named container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 kill: False Do not wait for the container...
[]
Please provide a description of the function:def freeze(name, **kwargs): ''' Freeze the named container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 start : False If ``True`` and the container is stopped, the con...
[]
Please provide a description of the function:def unfreeze(name, path=None, use_vt=None): ''' Unfreeze the named container. path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 use_vt run the command through VT ....
[]
Please provide a description of the function:def destroy(name, stop=False, path=None): ''' Destroy the named container. .. warning:: Destroys all data associated with the container. path path to the container parent directory (default: /var/lib/lxc) .. versionadded:: 2015.8.0...
[]
Please provide a description of the function:def exists(name, path=None): ''' Returns whether the named container exists. path path to the container parent directory (default: /var/lib/lxc) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.exists...
[]