text
stringlengths
81
112k
Returns a string describing the changes def changes_str(self): '''Returns a string describing the changes''' changes = '' for item in self._get_recursive_difference(type='intersect'): if item.diffs: changes = ''.join([changes, # Tab...
Returns a string in a more compact format describing the changes. The output better alligns with the one in recursive_diff. def changes_str2(self, tab_string=' '): ''' Returns a string in a more compact format describing the changes. The output better alligns with the one in recursiv...
Returns the new values from the diff def new_values(self): '''Returns the new values from the diff''' def get_new_values_and_key(item): values = item.new_values if item.past_dict: values.update({self._key: item.past_dict[self._key]}) else: ...
Returns the old values from the diff def old_values(self): '''Returns the old values from the diff''' def get_old_values_and_key(item): values = item.old_values values.update({self._key: item.past_dict[self._key]}) return values return [get_old_values_and_ke...
Returns the list of changed values. The key is added to each item. selection Specifies the desired changes. Supported values are ``all`` - all changed items are included in the output ``intersect`` - changed items present in both lists are include...
.. versionchanged:: 2018.3.0 Added ``with_pillar`` argument Execute ``fun`` with the given ``args`` and ``kwargs``. Parameter ``fun`` should be the string :ref:`name <all-salt.modules>` of the execution module to call. .. note:: Execution modules will be loaded *every time* this funct...
.. versionadded:: 2017.7.0 Execute ``fun`` on all minions matched by ``tgt`` and ``tgt_type``. Parameter ``fun`` is the name of execution module function to call. This function should mainly be used as a helper for runner modules, in order to avoid redundant code. For example, when inside a runner...
Resolves the given symlink path to its real path, up to a maximum of the `max_depth` parameter which defaults to 64. If the path is not a symlink path, it is simply returned. def _resolve_symlink(path, max_depth=64): ''' Resolves the given symlink path to its real path, up to a maximum of the `max...
Convert the group id to the group name on this system Under Windows, because groups are just another ACL entity, this function behaves the same as uid_to_user. For maintaining Windows systems, this function is superfluous and only exists for API compatibility with Unix. Use the uid_to_user function ...
Convert the group to the gid on this system Under Windows, because groups are just another ACL entity, this function behaves the same as user_to_uid, except if None is given, '' is returned. For maintaining Windows systems, this function is superfluous and only exists for API compatibility with Unix. ...
Return the id of the primary group that owns a given file (Windows only) This function will return the rarely used primary group of a file. This generally has no bearing on permissions unless intentionally configured and is most commonly used to provide Unix compatibility (e.g. Services For Unix, NFS s...
Return the id of the group that owns a given file Under Windows, this will return the uid of the file. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on permissions unless intentionally configured and is only used to support Unix compatibility ...
Return the group that owns a given file Under Windows, this will return the user (owner) of the file. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on permissions unless intentionally configured and is only used to support Unix compatibility f...
Convert user name to a uid Args: user (str): The user to lookup Returns: str: The user id of the user CLI Example: .. code-block:: bash salt '*' file.user_to_uid myusername def user_to_uid(user): ''' Convert user name to a uid Args: user (str): The user...
Return the id of the user that owns a given file Symlinks are followed by default to mimic Unix behavior. Specify `follow_symlinks=False` to turn off this behavior. Args: path (str): The path to the file or directory follow_symlinks (bool): If the object specified by ``path`` ...
Return the user that owns a given file Symlinks are followed by default to mimic Unix behavior. Specify `follow_symlinks=False` to turn off this behavior. Args: path (str): The path to the file or directory follow_symlinks (bool): If the object specified by ``path`` is a symli...
Return the mode of a file Right now we're just returning None because Windows' doesn't have a mode like Linux Args: path (str): The path to the file or directory Returns: None CLI Example: .. code-block:: bash salt '*' file.get_mode /etc/passwd def get_mode(path): ...
Chown a file, pass the file the desired user and group without following any symlinks. Under Windows, the group parameter will be ignored. This is because while files in Windows do have a 'primary group' property, this is rarely used. It generally has no bearing on permissions unless intentionall...
Chown a file, pass the file the desired user and group Under Windows, the group parameter will be ignored. This is because while files in Windows do have a 'primary group' property, this is rarely used. It generally has no bearing on permissions unless intentionally configured and is most commonly us...
Change the group of a file Under Windows, this will do nothing. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on permissions unless intentionally configured and is only used to support Unix compatibility features (e.g. Services For Unix, N...
Return a dict containing the stats about a given file Under Windows, `gid` will equal `uid` and `group` will equal `user`. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on permissions unless intentionally configured and is only used to support...
Return a dictionary object with the Windows file attributes for a file. Args: path (str): The path to the file or directory Returns: dict: A dictionary of file attributes CLI Example: .. code-block:: bash salt '*' file.get_attributes c:\\temp\\a.txt def get_attributes(p...
Set file attributes for a file. Note that the normal attribute means that all others are false. So setting it will clear all others. Args: path (str): The path to the file or directory archive (bool): Sets the archive attribute. Default is None hidden (bool): Sets the hidden attribute...
Set the mode of a file This just calls get_mode, which returns None because we don't use mode on Windows Args: path: The path to the file or directory mode: The mode (not used) Returns: None CLI Example: .. code-block:: bash salt '*' file.set_mode /etc/passw...
Remove the named file or directory Args: path (str): The path to the file or directory to remove. force (bool): Remove even if marked Read-Only. Default is False Returns: bool: True if successful, False if unsuccessful CLI Example: .. code-block:: bash salt '*' file....
Create a symbolic link to a file This is only supported with Windows Vista or later and must be executed by a user with the SeCreateSymbolicLink privilege. The behavior of this function matches the Unix equivalent, with one exception - invalid symlinks cannot be created. The source path must exist. ...
Check if the path is a symlink This is only supported on Windows Vista or later. Inline with Unix behavior, this function will raise an error if the path is not a symlink, however, the error raised will be a SaltInvocationError, not an OSError. Args: path (str): The path to a file or dire...
Return the path that a symlink points to This is only supported on Windows Vista or later. Inline with Unix behavior, this function will raise an error if the path is not a symlink, however, the error raised will be a SaltInvocationError, not an OSError. Args: path (str): The path to the ...
Ensure that the directory is available and permissions are set. Args: path (str): The full path to the directory. owner (str): The owner of the directory. If not passed, it will be the account that created the directory, likely SYSTEM grant_perms (dict...
Ensure that the parent directory containing this path is available. Args: path (str): The full path to the directory. .. note:: The path must end with a trailing slash otherwise the directory(s) will be created up to the parent directory. For ...
Set owner and permissions for each directory created. Args: path (str): The full path to the directory. owner (str): The owner of the directory. If not passed, it will be the account that created the directory, likely SYSTEM. grant_perms (dict): ...
Check owner and permissions for the passed directory. This function checks the permissions and sets them, returning the changes made. Used by the file state to populate the return dict Args: path (str): The full path to the directory. ret (dict): A dictionary to ap...
Set permissions for the given path Args: path (str): The full path to the directory. grant_perms (dict): A dictionary containing the user/group and the basic permissions to grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also set the...
Validate the beacon configuration def validate(config): ''' Validate the beacon configuration ''' if not isinstance(config, list): return False, ('Configuration for haproxy beacon must ' 'be a list.') else: _config = {} list(map(_config.update, config)...
Check if current number of sessions of a server for a specific haproxy backend is over a defined threshold. .. code-block:: yaml beacons: haproxy: - backends: www-backend: threshold: 45 servers: - web1 ...
Given a thing type name, check to see if the given thing type exists Returns True if the given thing type exists and returns False if the given thing type does not exist. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt myminion boto_iot.thing_type_exists mythingtype ...
Given a thing type name describe its properties. Returns a dictionary of interesting properties. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt myminion boto_iot.describe_thing_type mythingtype def describe_thing_type(thingTypeName, region=None, key=None, keyid=None...
Given a valid config, create a thing type. Returns {created: true} if the thing type was created and returns {created: False} if the thing type was not created. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt myminion boto_iot.create_thing_type mythingtype \\ ...
Given a thing type name, deprecate it when undoDeprecate is False and undeprecate it when undoDeprecate is True. Returns {deprecated: true} if the thing type was deprecated and returns {deprecated: false} if the thing type was not deprecated. .. versionadded:: 2016.11.0 CLI Example: .. code-...
Given a thing type name, delete it. Returns {deleted: true} if the thing type was deleted and returns {deleted: false} if the thing type was not deleted. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt myminion boto_iot.delete_thing_type mythingtype def delete_thing_...
Given a policy name, check to see if the given policy exists. Returns True if the given policy exists and returns False if the given policy does not exist. CLI Example: .. code-block:: bash salt myminion boto_iot.policy_exists mypolicy def policy_exists(policyName, region=None, k...
Given a valid config, create a policy. Returns {created: true} if the policy was created and returns {created: False} if the policy was not created. CLI Example: .. code-block:: bash salt myminion boto_iot.create_policy my_policy \\ '{"Version":"2015-12-12",\\ "St...
Given a policy name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_iot.describe_policy mypolicy def describe_policy(policyName, region=None, key=None, keyid=None, profile=None): ''' Given a polic...
Given a policy name and version ID, check to see if the given policy version exists. Returns True if the given policy version exists and returns False if the given policy version does not exist. CLI Example: .. code-block:: bash salt myminion boto_iot.policy_version_exists mypolicy versionid...
Given a policy name and version, delete it. Returns {deleted: true} if the policy version was deleted and returns {deleted: false} if the policy version was not deleted. CLI Example: .. code-block:: bash salt myminion boto_iot.delete_policy_version mypolicy version def delete_policy_version...
Given a policy name and version describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_iot.describe_policy_version mypolicy version def describe_policy_version(policyName, policyVersionId, region=None, key=None,...
List all policies Returns list of policies CLI Example: .. code-block:: bash salt myminion boto_iot.list_policies Example Return: .. code-block:: yaml policies: - {...} - {...} def list_policies(region=None, key=None, keyid=None, profile=None): ''' ...
List the versions available for the given policy. CLI Example: .. code-block:: bash salt myminion boto_iot.list_policy_versions mypolicy Example Return: .. code-block:: yaml policyVersions: - {...} - {...} def list_policy_versions(policyName, region...
Given a rule name, check to see if the given rule exists. Returns True if the given rule exists and returns False if the given rule does not exist. CLI Example: .. code-block:: bash salt myminion boto_iot.topic_rule_exists myrule def topic_rule_exists(ruleName, region=None, key=N...
Given a valid config, create a topic rule. Returns {created: true} if the rule was created and returns {created: False} if the rule was not created. CLI Example: .. code-block:: bash salt myminion boto_iot.create_topic_rule my_rule "SELECT * FROM 'some/thing'" \\ '[{"lambda":{"fu...
Given a rule name, delete it. Returns {deleted: true} if the rule was deleted and returns {deleted: false} if the rule was not deleted. CLI Example: .. code-block:: bash salt myminion boto_iot.delete_rule myrule def delete_topic_rule(ruleName, region=None, key=None, keyid=None, ...
Given a topic rule name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_iot.describe_topic_rule myrule def describe_topic_rule(ruleName, region=None, key=None, keyid=None, profile=None): ''' Given...
List all rules (for a given topic, if specified) Returns list of rules CLI Example: .. code-block:: bash salt myminion boto_iot.list_topic_rules Example Return: .. code-block:: yaml rules: - {...} - {...} def list_topic_rules(topic=None, ruleDisabled=None,...
Returns a unique service status def _get_svc(rcd, service_status): ''' Returns a unique service status ''' ena = None lines = __salt__['cmd.run']('{0} rcvar'.format(rcd)).splitlines() for rcvar in lines: if rcvar.startswith('$') and '={0}'.format(service_status) in rcvar: en...
Returns all service statuses def _get_svc_list(service_status): ''' Returns all service statuses ''' prefix = '/etc/rc.d/' ret = set() lines = glob.glob('{0}*'.format(prefix)) for line in lines: svc = _get_svc(line, service_status) if svc is not None: ret.add(svc...
Modifies /etc/rc.conf so a service is started or not at boot time and can be started via /etc/rc.d/<service> def _rcconf_status(name, service_status): ''' Modifies /etc/rc.conf so a service is started or not at boot time and can be started via /etc/rc.d/<service> ''' rcconf = '/etc/rc.conf' ...
Return a conn object for the passed VM data def get_conn(): ''' Return a conn object for the passed VM data ''' return ProfitBricksService( username=config.get_cloud_config_value( 'username', get_configured_provider(), __opts__, search_global=Fals...
Return a dict of all available VM locations on the cloud provider with relevant data def avail_locations(call=None): ''' Return a dict of all available VM locations on the cloud provider with relevant data ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images...
Return a list of the images that are on the provider def avail_images(call=None): ''' Return a list of the images that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --function, or with the ...
List all the images with alias by location CLI Example: .. code-block:: bash salt-cloud -f list_images my-profitbricks-config location=us/las def list_images(call=None, kwargs=None): ''' List all the images with alias by location CLI Example: .. code-block:: bash salt-clou...
Return the VM's size object def get_size(vm_): ''' Return the VM's size object ''' vm_size = config.get_cloud_config_value('size', vm_, __opts__) sizes = avail_sizes() if not vm_size: return sizes['Small Instance'] for size in sizes: combinations = (six.text_type(sizes[siz...
Return datacenter ID from provider configuration def get_datacenter_id(): ''' Return datacenter ID from provider configuration ''' datacenter_id = config.get_cloud_config_value( 'datacenter_id', get_configured_provider(), __opts__, search_global=False ) conn = g...
Return a list of the loadbalancers that are on the provider def list_loadbalancers(call=None): ''' Return a list of the loadbalancers that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --fu...
Creates a loadbalancer within the datacenter from the provider config. CLI Example: .. code-block:: bash salt-cloud -f create_loadbalancer profitbricks name=mylb def create_loadbalancer(call=None, kwargs=None): ''' Creates a loadbalancer within the datacenter from the provider config. C...
Return the datacenter from the config provider datacenter ID def get_datacenter(conn): ''' Return the datacenter from the config provider datacenter ID ''' datacenter_id = get_datacenter_id() for item in conn.list_datacenters()['items']: if item['id'] == datacenter_id: return i...
Creates a virtual datacenter based on supplied parameters. CLI Example: .. code-block:: bash salt-cloud -f create_datacenter profitbricks name=mydatacenter location=us/las description="my description" def create_datacenter(call=None, kwargs=None): ''' Creates a virtual datacenter bas...
List all the data centers CLI Example: .. code-block:: bash salt-cloud -f list_datacenters my-profitbricks-config def list_datacenters(conn=None, call=None): ''' List all the data centers CLI Example: .. code-block:: bash salt-cloud -f list_datacenters my-profitbricks-conf...
Return a list of VMs that are on the provider def list_nodes(conn=None, call=None): ''' Return a list of VMs that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) if not conn: ...
Return a list of the VMs that are on the provider, with all fields def list_nodes_full(conn=None, call=None): ''' Return a list of the VMs that are on the provider, with all fields ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function must be called with ...
Reserve the IP Block def reserve_ipblock(call=None, kwargs=None): ''' Reserve the IP Block ''' if call == 'action': raise SaltCloudSystemExit( 'The reserve_ipblock function must be called with -f or ' '--function.' ) conn = get_conn() if kwargs is None:...
Return a node for the named VM def get_node(conn, name): ''' Return a node for the named VM ''' datacenter_id = get_datacenter_id() for item in conn.list_servers(datacenter_id)['items']: if item['properties']['name'] == name: node = {'id': item['id']} node.update(it...
Create network interfaces on appropriate LANs as defined in cloud profile. def _get_nics(vm_): ''' Create network interfaces on appropriate LANs as defined in cloud profile. ''' nics = [] if 'public_lan' in vm_: firewall_rules = [] # Set LAN to public if it already exists, otherwise...
Enables public Internet access for the specified public_lan. If no public LAN is available, then a new public LAN is created. def set_public_lan(lan_id): ''' Enables public Internet access for the specified public_lan. If no public LAN is available, then a new public LAN is created. ''' conn = ...
Retrieve list of SSH public keys. def get_public_keys(vm_): ''' Retrieve list of SSH public keys. ''' key_filename = config.get_cloud_config_value( 'ssh_public_key', vm_, __opts__, search_global=False, default=None ) if key_filename is not None: key_filename = os.path.expanduser...
Check SSH private key file and return absolute path if exists. def get_key_filename(vm_): ''' Check SSH private key file and return absolute path if exists. ''' key_filename = config.get_cloud_config_value( 'ssh_private_key', vm_, __opts__, search_global=False, default=None ) if key_fil...
Create a single VM from a data dict def create(vm_): ''' Create a single VM from a data dict ''' try: # Check for required profile parameters before sending any API calls. if (vm_['profile'] and config.is_profile_configured(__opts__, ...
destroy a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: array of booleans , true if successfully stopped and true if successfully removed CLI Example: .. code-block:: bash salt-cloud -d vm_name def destroy(n...
reboot a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful CLI Example: .. code-block:: bash salt-cloud -a reboot vm_name def reboot(name, call=None): ''' reboot a machine by name :param name: n...
stop a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful CLI Example: .. code-block:: bash salt-cloud -a stop vm_name def stop(name, call=None): ''' stop a machine by name :param name: name give...
start a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful CLI Example: .. code-block:: bash salt-cloud -a start vm_name def start(name, call=None): ''' start a machine by name :param name: name...
Apply any extra component overrides to VM from the cloud profile. def _override_size(vm_): ''' Apply any extra component overrides to VM from the cloud profile. ''' vm_size = get_size(vm_) if 'cores' in vm_: vm_size['cores'] = vm_['cores'] if 'ram' in vm_: vm_size['ram'] = vm_...
Construct server instance from cloud profile config def _get_server(vm_, volumes, nics): ''' Construct server instance from cloud profile config ''' # Apply component overrides to the size from the cloud profile config vm_size = _override_size(vm_) # Set the server availability zone from the c...
Construct VM system volume list from cloud profile config def _get_system_volume(vm_): ''' Construct VM system volume list from cloud profile config ''' # Override system volume size if 'disk_size' is defined in cloud profile disk_size = get_size(vm_)['disk'] if 'disk_size' in vm_: dis...
Construct a list of optional data volumes from the cloud profile def _get_data_volumes(vm_): ''' Construct a list of optional data volumes from the cloud profile ''' ret = [] volumes = vm_['volumes'] for key, value in six.iteritems(volumes): # Verify the required 'disk_size' property is...
Construct a list of optional firewall rules from the cloud profile. def _get_firewall_rules(firewall_rules): ''' Construct a list of optional firewall rules from the cloud profile. ''' ret = [] for key, value in six.iteritems(firewall_rules): # Verify the required 'protocol' property is pre...
Poll request status until resource is provisioned. def _wait_for_completion(conn, promise, wait_timeout, msg): ''' Poll request status until resource is provisioned. ''' if not promise: return wait_timeout = time.time() + wait_timeout while wait_timeout > time.time(): time.sleep...
Determine if a package or runtime is installed. Args: name (str): The name of the package or the runtime. Returns: bool: True if the specified package or runtime is installed. CLI Example: .. code-block:: bash salt '*' flatpak.is_installed org.gimp.GIMP def is_installed(nam...
Uninstall the specified package. Args: pkg (str): The package name. Returns: dict: The ``result`` and ``output``. CLI Example: .. code-block:: bash salt '*' flatpak.uninstall org.gimp.GIMP def uninstall(pkg): ''' Uninstall the specified package. Args: p...
Adds a new location to install flatpak packages from. Args: name (str): The repository's name. location (str): The location of the repository. Returns: dict: The ``result`` and ``output``. CLI Example: .. code-block:: bash salt '*' flatpak.add_remote flathub https://...
Determines if a remote exists. Args: remote (str): The remote's name. Returns: bool: True if the remote has already been added. CLI Example: .. code-block:: bash salt '*' flatpak.is_remote_added flathub def is_remote_added(remote): ''' Determines if a remote exists....
Compatibility helper function to make __utils__ available on demand. def pack_dunder(name): ''' Compatibility helper function to make __utils__ available on demand. ''' # TODO: Deprecate starting with Beryllium mod = sys.modules[name] if not hasattr(mod, '__utils__'): setattr(mod, '__u...
Compatibility helper function to allow copy.deepcopy copy bound methods which is broken on Python 2.6, due to the following bug: https://bugs.python.org/issue1515 Warnings: - This method will mutate the global deepcopy dispatcher, which means that this function is NOT threadsafe! -...
Check if there is an upgrade available for a certain package CLI Example: .. code-block:: bash salt '*' pkgutil.upgrade_available CSWpython def upgrade_available(name): ''' Check if there is an upgrade available for a certain package CLI Example: .. code-block:: bash salt ...
List all available package upgrades on this system CLI Example: .. code-block:: bash salt '*' pkgutil.list_upgrades def list_upgrades(refresh=True, **kwargs): # pylint: disable=W0613 ''' List all available package upgrades on this system CLI Example: .. code-block:: bash ...
Upgrade all of the packages to the latest available version. Returns a dict containing the changes:: {'<package>': {'old': '<old-version>', 'new': '<new-version>'}} CLI Example: .. code-block:: bash salt '*' pkgutil.upgrade def upgrade(refresh=True): ''' ...
Install packages using the pkgutil tool. CLI Example: .. code-block:: bash salt '*' pkg.install <package_name> salt '*' pkg.install SMClgcc346 Multiple Package Installation Options: pkgs A list of packages to install from OpenCSW. Must be passed as a python list. ...
Remove a package and all its dependencies which are not in use by other packages. name The name of the package to be deleted. Multiple Package Options: pkgs A list of packages to delete. Must be passed as a python list. The ``name`` parameter will be ignored if this option is...
Ensure a device is monitored. The 'name' given will be used for Zenoss device name and should be resolvable. .. code-block:: yaml enable_monitoring: zenoss.monitored: - name: web01.example.com - device_class: /Servers/Linux - collector: localhost -...
Find volume by name on minion def _find_volume(name): ''' Find volume by name on minion ''' docker_volumes = __salt__['docker.volumes']()['Volumes'] if docker_volumes: volumes = [v for v in docker_volumes if v['Name'] == name] if volumes: return volumes[0] return No...
Ensure that a volume is present. .. versionadded:: 2015.8.4 .. versionchanged:: 2015.8.6 This state no longer deletes and re-creates a volume if the existing volume's driver does not match the ``driver`` parameter (unless the ``force`` parameter is set to ``True``). .. versionchange...