text
stringlengths
81
112k
Perform a function against a cloud provider def do_function(self, prov, func, kwargs): ''' Perform a function against a cloud provider ''' matches = self.lookup_providers(prov) if len(matches) > 1: raise SaltCloudSystemExit( 'More than one results mat...
Remove any mis-configured cloud providers from the available listing def __filter_non_working_providers(self): ''' Remove any mis-configured cloud providers from the available listing ''' for alias, drivers in six.iteritems(self.opts['providers'].copy()): for driver in drive...
Read in the specified map and return the map structure def read(self): ''' Read in the specified map and return the map structure ''' map_ = None if self.opts.get('map', None) is None: if self.opts.get('map_data', None) is None: if self.opts.get('map_...
Create a data map of what to execute on def map_data(self, cached=False): ''' Create a data map of what to execute on ''' ret = {'create': {}} pmap = self.map_providers_parallel(cached=cached) exist = set() defined = set() rendered_map = copy.deepcopy(sel...
Execute the contents of the VM map def run_map(self, dmap): ''' Execute the contents of the VM map ''' if self._has_loop(dmap): msg = 'Uh-oh, that cloud map has a dependency loop!' log.error(msg) raise SaltCloudException(msg) # Go through the ...
Wrapper for user.info Salt function def _get_user_info(user=None): ''' Wrapper for user.info Salt function ''' if not user: # Get user Salt runnining as user = __salt__['config.option']('user') userinfo = __salt__['user.info'](user) if not userinfo: if user == 'salt': ...
Return default GnuPG home directory path for a user def _get_user_gnupghome(user): ''' Return default GnuPG home directory path for a user ''' if user == 'salt': gnupghome = os.path.join(__salt__['config.get']('config_dir'), 'gpgkeys') else: gnupghome = os.path.join(_get_user_info(u...
Create the GPG object def _create_gpg(user=None, gnupghome=None): ''' Create the GPG object ''' if not gnupghome: gnupghome = _get_user_gnupghome(user) if GPG_1_3_1: gpg = gnupg.GPG(homedir=gnupghome) else: gpg = gnupg.GPG(gnupghome=gnupghome) return gpg
Helper function for Listing keys def _list_keys(user=None, gnupghome=None, secret=False): ''' Helper function for Listing keys ''' gpg = _create_gpg(user, gnupghome) _keys = gpg.list_keys(secret) return _keys
Helper function for searching keys from keyserver def _search_keys(text, keyserver, user=None): ''' Helper function for searching keys from keyserver ''' gpg = _create_gpg(user) if keyserver: _keys = gpg.search_keys(text, keyserver) else: _keys = gpg.search_keys(text) return...
Search keys from keyserver text Text to search the keyserver for, e.g. email address, keyID or fingerprint. keyserver Keyserver to use for searching for GPG keys, defaults to pgp.mit.edu. user Which user's keychain to access, defaults to user Salt is running as. Passing th...
List keys in GPG keychain user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ``/etc/salt/gpgkeys``. gnupghome Specify the location where GPG keyring and related files are stored. ...
Create a key in the GPG keychain .. note:: GPG key generation requires *a lot* of entropy and randomness. Difficult to do over a remote connection, consider having another process available which is generating randomness for the machine. Also especially difficult on virtual machin...
Get a key from the GPG keychain keyid The keyid of the key to be deleted. fingerprint The fingerprint of the key to be deleted. delete_secret Whether to delete a corresponding secret key prior to deleting the public key. Secret keys must be deleted before deleting any corr...
Get a key from the GPG keychain keyid The key ID (short or long) of the key to be retrieved. fingerprint The fingerprint of the key to be retrieved. user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG h...
r''' Import a key from text or file text The text containing to import. filename The filename containing the key to import. user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ...
Export a key from the GPG keychain keyids The key ID(s) of the key(s) to be exported. Can be specified as a comma separated string or a list. Anything which GnuPG itself accepts to identify a key - for example, the key ID or the fingerprint could be used. secret Export ...
Receive key(s) from keyserver and add them to keychain keyserver Keyserver to use for searching for GPG keys, defaults to pgp.mit.edu keys The keyID(s) to retrieve from the keyserver. Can be specified as a comma separated string or a list. user Which user's keychain to ac...
Set the trust level for a key in GPG keychain keyid The keyid of the key to set the trust level for. fingerprint The fingerprint of the key to set the trust level for. trust_level The trust level to set for the specified key, must be one of the following: expired, ...
Sign message or file user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ``/etc/salt/gpgkeys``. keyid The keyid of the key to set the trust level for, defaults to first key in t...
Verify a message or file text The text to verify. filename The filename to verify. user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ``/etc/salt/gpgkeys``. gnupghome...
Encrypt a message or file user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ``/etc/salt/gpgkeys``. recipients The fingerprints for those recipient whom the data is being encrypted for...
Decrypt a message or file user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ``/etc/salt/gpgkeys``. text The encrypted text to decrypt. filename The encrypted filename to ...
.. versionadded:: 2018.3.4 Wraps msgpack.pack and ensures that the passed object is unwrapped if it is a proxy. By default, this function uses the msgpack module and falls back to msgpack_pure, if the msgpack is not available. You can pass an alternate msgpack module using the _msgpack_module argu...
.. versionadded:: 2018.3.4 Wraps msgpack.unpack. By default, this function uses the msgpack module and falls back to msgpack_pure, if the msgpack is not available. You can pass an alternate msgpack module using the _msgpack_module argument. def unpack(stream, **kwargs): ''' .. versionadded:: ...
.. versionadded:: 2018.3.4 Wraps msgpack.unpack. By default, this function uses the msgpack module and falls back to msgpack_pure, if the msgpack is not available. You can pass an alternate msgpack module using the _msgpack_module argument. def unpackb(packed, **kwargs): ''' .. versionadded::...
If any minion's status is older than the timeout value then apply the given action to the timed out key. This example will remove keys to minions that have not checked in for 300 seconds (5 minutes) USAGE: .. code-block:: yaml statreg: status.reg clean_keys: key.t...
Check the context for the notifier and construct it if not present def _get_notifier(config): ''' Check the context for the notifier and construct it if not present ''' if 'inotify.notifier' not in __context__: __context__['inotify.queue'] = collections.deque() wm = pyinotify.WatchManag...
Validate the beacon configuration def validate(config): ''' Validate the beacon configuration ''' VALID_MASK = [ 'access', 'attrib', 'close_nowrite', 'close_write', 'create', 'delete', 'delete_self', 'excl_unlink', 'ignored', ...
Watch the configured files Example Config .. code-block:: yaml beacons: inotify: - files: /path/to/file/or/dir: mask: - open - create - close_write recurse: True ...
Run the actual gem command. If rvm or rbenv is installed, run the command using the corresponding module. rbenv is not available on windows, so don't try. :param command: string Command to run :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Igno...
Installs one or several gems. :param gems: string The gems to install :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. :par...
Uninstall one or several gems. :param gems: string The gems to uninstall. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. ...
Update one or several gems. :param gems: string The gems to update. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. :param...
Update rubygems. :param version: string : (newest) The version of rubygems to install. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is sp...
Print out the version of gem :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. :param runas: string : None The user to run gem a...
List locally installed gems. :param prefix: string : Only list gems when the name matches this prefix. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if `...
.. versionadded:: 2015.8.0 Check if an upgrade is available for installed gems gem_bin : None Full path to ``gem`` binary to use. ruby : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. runas : None The user to...
Add a gem source. :param source_uri: string The source URI to add. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. :param ...
Remove a gem source. :param source_uri: string The source URI to remove. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. :...
List the configured gem sources. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. :param runas: string : None The user to run g...
Generate an icinga2 ticket on the master. name The domain name for which this ticket will be generated output grain: output in a grain other: the file to store results None: output to the result comment (default) grain: grain to store the output (need output=grain...
Generate an icinga2 certificate and key on the client. name The domain name for which this certificate and key will be generated def generate_cert(name): ''' Generate an icinga2 certificate and key on the client. name The domain name for which this certificate and key will be generate...
Save the certificate on master icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved def save_cert(name, master): ''' Save the certificate on master icinga2 node. name The domain nam...
Request CA certificate from master icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved ticket Authentication ticket generated on icinga2 master port Icinga2 port, defaults to 5...
Setup the icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved ticket Authentication ticket generated on icinga2 master def node_setup(name, master, ticket): ''' Setup the icinga2 n...
Return available Linode images. CLI Example: .. code-block:: bash salt-cloud --list-images my-linode-config salt-cloud -f avail_images my-linode-config def avail_images(call=None): ''' Return available Linode images. CLI Example: .. code-block:: bash salt-cloud --l...
Return available Linode datacenter locations. CLI Example: .. code-block:: bash salt-cloud --list-locations my-linode-config salt-cloud -f avail_locations my-linode-config def avail_locations(call=None): ''' Return available Linode datacenter locations. CLI Example: .. code...
Return available Linode sizes. CLI Example: .. code-block:: bash salt-cloud --list-sizes my-linode-config salt-cloud -f avail_sizes my-linode-config def avail_sizes(call=None): ''' Return available Linode sizes. CLI Example: .. code-block:: bash salt-cloud --list-s...
Boot a Linode. name The name of the Linode to boot. Can be used instead of ``linode_id``. linode_id The ID of the Linode to boot. If provided, will be used as an alternative to ``name`` and reduces the number of API calls to Linode by one. Will be preferred over ``name``. ...
Clone a Linode. linode_id The ID of the Linode to clone. Required. datacenter_id The ID of the Datacenter where the Linode will be placed. Required. plan_id The ID of the plan (size) of the Linode. Required. CLI Example: .. code-block:: bash salt-cloud -f clone ...
Create a single Linode VM. def create(vm_): ''' Create a single Linode VM. ''' name = vm_['name'] try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, ...
Creates a Linode Configuration Profile. name The name of the VM to create the config for. linode_id The ID of the Linode to create the configuration for. root_disk_id The Root Disk ID to be used for this config. swap_disk_id The Swap Disk ID to be used for this config...
r''' Creates the disk for the Linode from the distribution. vm\_ The VM profile to create the disk for. linode_id The ID of the Linode to create the distribution disk for. Required. swap_size The size of the disk, in MB. def create_disk_from_distro(vm_, linode_id, swap_size=N...
r''' Creates the disk for the specified Linode. vm\_ The VM profile to create the swap disk for. linode_id The ID of the Linode to create the swap disk for. swap_size The size of the disk, in MB. def create_swap_disk(vm_, linode_id, swap_size=None): r''' Creates the d...
r''' Create a data disk for the linode (type is hardcoded to ext4 at the moment) .. versionadded:: 2016.3.0 vm\_ The VM profile to create the data disk for. linode_id The ID of the Linode to create the data disk for. data_size The size of the disk, in MB. def create_data...
r''' Creates a private IP for the specified Linode. linode_id The ID of the Linode to create the IP address for. def create_private_ip(linode_id): r''' Creates a private IP for the specified Linode. linode_id The ID of the Linode to create the IP address for. ''' kwargs = ...
Returns a config_id for a given linode. .. versionadded:: 2015.8.0 name The name of the Linode for which to get the config_id. Can be used instead of ``linode_id``.h linode_id The ID of the Linode for which to get the config_id. Can be used instead of ``name``. CLI Ex...
r''' Returns the size of of the root disk in MB. vm\_ The VM to get the disk size for. def get_disk_size(vm_, swap, linode_id): r''' Returns the size of of the root disk in MB. vm\_ The VM to get the disk size for. ''' disk_size = get_linode(kwargs={'linode_id': linode_id}...
Return the size of of the data disk in MB .. versionadded:: 2016.3.0 def get_data_disk_size(vm_, swap, linode_id): ''' Return the size of of the data disk in MB .. versionadded:: 2016.3.0 ''' disk_size = get_linode(kwargs={'linode_id': linode_id})['TOTALHD'] root_disk_size = config.get_cl...
r''' Returns the distribution ID for a VM vm\_ The VM to get the distribution ID for def get_distribution_id(vm_): r''' Returns the distribution ID for a VM vm\_ The VM to get the distribution ID for ''' distributions = _query('avail', 'distributions')['DATA'] vm_image...
Returns public and private IP addresses. linode_id Limits the IP addresses returned to the specified Linode ID. def get_ips(linode_id=None): ''' Returns public and private IP addresses. linode_id Limits the IP addresses returned to the specified Linode ID. ''' if linode_id: ...
Returns data for a single named Linode. name The name of the Linode for which to get data. Can be used instead ``linode_id``. Note this will induce an additional API call compared to using ``linode_id``. linode_id The ID of the Linode for which to get data. Can be used instead ...
Returns the Linode ID for a VM from the provided name. name The name of the Linode from which to get the Linode ID. Required. def get_linode_id_from_name(name): ''' Returns the Linode ID for a VM from the provided name. name The name of the Linode from which to get the Linode ID. Requ...
r''' Return the password to use for a VM. vm\_ The configuration to obtain the password from. def get_password(vm_): r''' Return the password to use for a VM. vm\_ The configuration to obtain the password from. ''' return config.get_cloud_config_value( 'password', ...
Attempts to decode a user-supplied Linode plan label into the format in Linode API output label The label, or name, of the plan to decode. Example: `Linode 2048` will decode to `Linode 2GB` def _decode_linode_plan_label(label): ''' Attempts to decode a user-supplied Linode plan la...
Returns the Linode Plan ID. label The label, or name, of the plan to get the ID from. CLI Example: .. code-block:: bash salt-cloud -f get_plan_id linode label="Linode 1024" def get_plan_id(kwargs=None, call=None): ''' Returns the Linode Plan ID. label The label, or ...
r''' Returns the VM's size. vm\_ The VM to get the size for. def get_vm_size(vm_): r''' Returns the VM's size. vm\_ The VM to get the size for. ''' vm_size = config.get_cloud_config_value('size', vm_, __opts__) ram = avail_sizes()[vm_size]['RAM'] if vm_size.starts...
Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt-cloud -f list_nodes_min my-linode-config ...
Reboot a linode. .. versionadded:: 2015.8.0 name The name of the VM to reboot. CLI Example: .. code-block:: bash salt-cloud -a reboot vm_name def reboot(name, call=None): ''' Reboot a linode. .. versionadded:: 2015.8.0 name The name of the VM to reboot. ...
Displays details about a particular Linode VM. Either a name or a linode_id must be provided. .. versionadded:: 2015.8.0 name The name of the VM for which to display details. CLI Example: .. code-block:: bash salt-cloud -a show_instance vm_name .. note:: The ``imag...
Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt-cloud -f show_pricing my-linode-config profile=my-linode-profile def show_pricing(kwargs=None, call=None): ''' Show...
Start a VM in Linode. name The name of the VM to start. CLI Example: .. code-block:: bash salt-cloud -a stop vm_name def start(name, call=None): ''' Start a VM in Linode. name The name of the VM to start. CLI Example: .. code-block:: bash salt-clo...
Updates a Linode's properties. linode_id The ID of the Linode to shutdown. Required. update_args The args to update the Linode with. Must be in dictionary form. def update_linode(linode_id, update_args=None): ''' Updates a Linode's properties. linode_id The ID of the Lino...
Returns the DATA response from a Linode API query as a single pre-formatted dictionary api_response The query to be cleaned. def _clean_data(api_response): ''' Returns the DATA response from a Linode API query as a single pre-formatted dictionary api_response The query to be cleaned. ...
Helper function to format and parse linode data def _list_linodes(full=False): ''' Helper function to format and parse linode data ''' nodes = _query('linode', 'list')['DATA'] ips = get_ips() ret = {} for node in nodes: this_node = {} linode_id = six.text_type(node['LINODEI...
Make a web call to the Linode API. def _query(action=None, command=None, args=None, method='GET', header_dict=None, data=None, url='https://api.linode.com/'): ''' Make a web call to the Linode API. ''' global LASTCALL vm_ = get_confi...
Wait for a Job to return. linode_id The ID of the Linode to wait on. Required. job_id The ID of the job to wait for. timeout The amount of time to wait for a status to update. quiet Log status updates to debug logs when True. Otherwise, logs to info. def _wait_for_jo...
Wait for a certain status from Linode. linode_id The ID of the Linode to wait on. Required. status The status to look for to update. timeout The amount of time to wait for a status to update. quiet Log status updates to debug logs when False. Otherwise, logs to info. ...
Return linode status by ID status_id linode VM status ID def _get_status_descr_by_id(status_id): ''' Return linode status by ID status_id linode VM status ID ''' for status_name, status_data in six.iteritems(LINODE_STATUS): if status_data['code'] == int(status_id): ...
Checks if the provided name fits Linode's labeling parameters. .. versionadded:: 2015.5.6 name The VM name to validate def _validate_name(name): ''' Checks if the provided name fits Linode's labeling parameters. .. versionadded:: 2015.5.6 name The VM name to validate '''...
Given the following NAPALM grains, we can determine the Capirca platform name: - vendor - device model - operating system Not the most optimal. def _get_capirca_platform(): # pylint: disable=too-many-return-statements ''' Given the following NAPALM grains, we can determine the Capirca platfo...
Generate and load the configuration of a policy term. filter_name The name of the policy filter. term_name The name of the term. filter_options Additional filter options. These options are platform-specific. See the complete list of options_. .. _options: https://...
Generate and load the configuration of a policy filter. .. note:: The order of the terms is very important. The configuration loaded on the device respects the order defined in the ``terms`` and/or inside the pillar. When merging the ``terms`` with the pillar data, consider the ...
Generate and load the configuration of the whole policy. .. note:: The order of the filters and their terms is very important. The configuration loaded on the device respects the order defined in the ``filters`` and/or inside the pillar. When merging the ``filters`` with the pilla...
Helper that can be used inside a state SLS, in order to get the filter configuration given its name. filter_name The name of the filter. pillar_key The root key of the whole policy config. pillarenv Query the master to generate fresh pillar data on the fly, specificall...
Helper that can be used inside a state SLS, in order to get the term configuration given its name, under a certain filter uniquely identified by its name. filter_name The name of the filter. term_name The name of the term. pillar_key: ``acl`` The root key of the whole poli...
Get Pure Storage FlasBlade configuration 1) From the minion config pure_tags: fb: san_ip: management vip or hostname for the FlashBlade api_token: A valid api token for the FlashBlade being managed 2) From environment (PUREFB_IP and PUREFB_API) 3) From the pillar (...
Private function to check for existance of a filesystem def _get_fs(name, blade): ''' Private function to check for existance of a filesystem ''' _fs = [] _fs.append(name) try: res = blade.file_systems.list_file_systems(names=_fs) return res.items[0] except rest.ApiE...
Return name of Snapshot or None def _get_snapshot(name, suffix, blade): ''' Return name of Snapshot or None ''' try: filt = 'source=\'{}\' and suffix=\'{}\''.format(name, suffix) res = blade.file_system_snapshots.list_file_system_snapshots(filter=filt) return res.items[0...
Private function to check if a file systeem has already been deleted def _get_deleted_fs(name, blade): ''' Private function to check if a file systeem has already been deleted ''' try: _fs = _get_fs(name, blade) if _fs and _fs.destroyed: return _fs except rest.Ap...
Ensures, that syslog-ng is started via the given parameters. Users shouldn't use this function, if the service module is available on their system. def started(name=None, user=None, group=None, chroot=None, caps=None, no_caps=False, pidfi...
Prepare the arguments def _prep_ssh( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', kwarg=None, **kwargs): ''' Prepare the arguments ''' opts = copy.deepcopy(self.opts) opts.u...
Execute a single command via the salt-ssh subsystem and return a generator .. versionadded:: 2015.5.0 def cmd_iter( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, **k...
Execute a single command via the salt-ssh subsystem and return all routines at once .. versionadded:: 2015.5.0 def cmd(self, tgt, fun, arg=(), timeout=None, tgt_type='glob', kwarg=None, **kwargs): ''' E...
Execute a salt-ssh call synchronously. .. versionadded:: 2015.5.0 WARNING: Eauth is **NOT** respected .. code-block:: python client.cmd_sync({ 'tgt': 'silver', 'fun': 'test.ping', 'arg': (), 'tgt_type'='glob', ...
Execute a command on a random subset of the targeted systems The function signature is the same as :py:meth:`cmd` with the following exceptions. :param sub: The number of systems to execute on .. code-block:: python >>> import salt.client.ssh.client >>> sshcli...
Verify that the given module is set to the given target name The name of the module target The target to be set for this module module_parameter additional params passed to the defined module action_parameter additional params passed to the defined action .. code...
Filters a list of dictionary by a set of key-value pair. :param input_list: is a list of dictionaries :param search_key: is the key we are looking for :param search_value: is the value we are looking for the key specified in search_key :return: filered list of dictionaries def _filter_...
Filters a dictionary of dictionaries by a key-value pair. :param input_dict: is a dictionary whose values are lists of dictionaries :param search_key: is the key in the leaf dictionaries :param search_values: is the value in the leaf dictionaries :return: filtered dictionary def _fi...