INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Ensure domain exists and is up-to-date name Name of the domain enabled Boolean to control if domain is enabled description An arbitrary description of the domain
def present(name, auth=None, **kwargs): ''' Ensure domain exists and is up-to-date name Name of the domain enabled Boolean to control if domain is enabled description An arbitrary description of the domain ''' ret = {'name': name, 'changes': {}, ...
Ensure domain does not exist name Name of the domain
def absent(name, auth=None): ''' Ensure domain does not exist name Name of the domain ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} __salt__['keystoneng.setup_clouds'](auth) domain = __salt__['keystoneng.domain_get'](name=n...
Runs the compound target check
def match(tgt, opts=None): ''' Runs the compound target check ''' if not opts: opts = __opts__ nodegroups = opts.get('nodegroups', {}) matchers = salt.loader.matchers(opts) if not isinstance(tgt, six.string_types) and not isinstance(tgt, (list, tuple)): log.error('Compound t...
Ensure that the marathon app with the given id is present and is configured to match the given config values. :param name: The app name/id :param config: The configuration to apply (dict) :return: A standard Salt changes dictionary
def config(name, config): ''' Ensure that the marathon app with the given id is present and is configured to match the given config values. :param name: The app name/id :param config: The configuration to apply (dict) :return: A standard Salt changes dictionary ''' # setup return struct...
Ensure that the marathon app with the given id is present and restart if set. :param name: The app name/id :param restart: Restart the app :param force: Override the current deployment :return: A standard Salt changes dictionary
def running(name, restart=False, force=True): ''' Ensure that the marathon app with the given id is present and restart if set. :param name: The app name/id :param restart: Restart the app :param force: Override the current deployment :return: A standard Salt changes dictionary ''' ret ...
Ensure cloud formation stack is present. name (string) - Name of the stack. template_body (string) – Structure containing the template body. Can also be loaded from a file by using salt://. template_url (string) – Location of file containing the template body. The URL must point to a template located in ...
def present(name, template_body=None, template_url=None, parameters=None, notification_arns=None, disable_rollback=None, timeout_in_minutes=None, capabilities=None, tags=None, on_failure=None, stack_policy_body=None, stack_policy_url=None, use_previous_template=None, stack_policy_during_update_b...
Ensure cloud formation stack is absent. name (string) – The name of the stack to delete. region (string) - Region to connect to. key (string) - Secret key to be used. keyid (string) - Access key to be used. profile (dict) - A dict with region, key and keyid, or a pillar key (string) that contai...
def absent(name, region=None, key=None, keyid=None, profile=None): ''' Ensure cloud formation stack is absent. name (string) – The name of the stack to delete. region (string) - Region to connect to. key (string) - Secret key to be used. keyid (string) - Access key to be used. profile (...
Ensure that given continuous query is present. name Name of the continuous query to create. database Database to create continuous query on. query The query content resample_time : None Duration between continuous query resampling. coverage_period : None ...
def present(name, database, query, resample_time=None, coverage_period=None, **client_args): ''' Ensure that given continuous query is present. name Name of the continuous query to create. database Database to create continuous query on. query The query content resamp...
Set the timezone for the system. name The name of the timezone to use (e.g.: America/Denver) utc Whether or not to set the hardware clock to UTC (default is True)
def system(name, utc=True): ''' Set the timezone for the system. name The name of the timezone to use (e.g.: America/Denver) utc Whether or not to set the hardware clock to UTC (default is True) ''' ret = {'name': name, 'changes': {}, 'result': None, ...
Set up nova credentials
def _auth(profile=None, **kwargs): ''' Set up nova credentials ''' keystone_api_args = None if kwargs is not None: if kwargs.get('keystone_api_args') is not None: keystone_api_args = kwargs['keystone_api_args'] if profile: credentials = __salt__['config.option'](prof...
Boot (create) a new instance name Name of the new instance (must be first) flavor_id Unique integer ID for the flavor image_id Unique integer ID for the image timeout How long to wait, after creating the instance, for the provider to return information about i...
def boot(name, flavor_id=0, image_id=0, profile=None, timeout=300, **kwargs): ''' Boot (create) a new instance name Name of the new instance (must be first) flavor_id Unique integer ID for the flavor image_id Unique integer ID for the image timeout How long to...
Create a block storage volume name Name of the volume profile Profile to use CLI Example: .. code-block:: bash salt '*' nova.volume_show myblock profile=openstack
def volume_show(name, profile=None, **kwargs): ''' Create a block storage volume name Name of the volume profile Profile to use CLI Example: .. code-block:: bash salt '*' nova.volume_show myblock profile=openstack ''' conn = _auth(profile, **kwargs) retu...
List storage volumes search_opts Dictionary of search options profile Profile to use CLI Example: .. code-block:: bash salt '*' nova.volume_list search_opts='{"display_name": "myblock"}' profile=openstack
def volume_list(search_opts=None, profile=None, **kwargs): ''' List storage volumes search_opts Dictionary of search options profile Profile to use CLI Example: .. code-block:: bash salt '*' nova.volume_list search_opts='{"display_name": "myblock"}' profile=openstack...
Create a block storage volume name Name of the new volume (must be first) size Volume size snapshot Block storage snapshot id voltype Type of storage profile Profile to build on CLI Example: .. code-block:: bash salt '*' nova.volume_cre...
def volume_create(name, size=100, snapshot=None, voltype=None, profile=None, **kwargs): ''' Create a block storage volume name Name of the new volume (must be first) size Volume size snapshot Block storage snapshot id voltype Type of storage profile ...
Destroy the volume name Name of the volume profile Profile to build on CLI Example: .. code-block:: bash salt '*' nova.volume_delete myblock profile=openstack
def volume_delete(name, profile=None, **kwargs): ''' Destroy the volume name Name of the volume profile Profile to build on CLI Example: .. code-block:: bash salt '*' nova.volume_delete myblock profile=openstack ''' conn = _auth(profile, **kwargs) return...
Attach a block storage volume name Name of the new volume to attach server_name Name of the server to detach from profile Profile to build on CLI Example: .. code-block:: bash salt '*' nova.volume_detach myblock profile=openstack
def volume_detach(name, profile=None, timeout=300, **kwargs): ''' Attach a block storage volume name Name of the new volume to attach server_name Name of the server to detach from profile Profile to build on CLI Example: .. code-block:: bash salt '*' nov...
Attach a block storage volume name Name of the new volume to attach server_name Name of the server to attach to device Name of the device on the server profile Profile to build on CLI Example: .. code-block:: bash salt '*' nova.volume_attach myblock...
def volume_attach(name, server_name, device='/dev/xvdb', profile=None, timeout=300, **kwargs): ''' Attach a block storage volume name Name of the new volume to attach server_name Name of the server to attach to ...
Suspend an instance instance_id ID of the instance to be suspended CLI Example: .. code-block:: bash salt '*' nova.suspend 1138
def suspend(instance_id, profile=None, **kwargs): ''' Suspend an instance instance_id ID of the instance to be suspended CLI Example: .. code-block:: bash salt '*' nova.suspend 1138 ''' conn = _auth(profile, **kwargs) return conn.suspend(instance_id)
Resume an instance instance_id ID of the instance to be resumed CLI Example: .. code-block:: bash salt '*' nova.resume 1138
def resume(instance_id, profile=None, **kwargs): ''' Resume an instance instance_id ID of the instance to be resumed CLI Example: .. code-block:: bash salt '*' nova.resume 1138 ''' conn = _auth(profile, **kwargs) return conn.resume(instance_id)
Lock an instance instance_id ID of the instance to be locked CLI Example: .. code-block:: bash salt '*' nova.lock 1138
def lock(instance_id, profile=None, **kwargs): ''' Lock an instance instance_id ID of the instance to be locked CLI Example: .. code-block:: bash salt '*' nova.lock 1138 ''' conn = _auth(profile, **kwargs) return conn.lock(instance_id)
Delete an instance instance_id ID of the instance to be deleted CLI Example: .. code-block:: bash salt '*' nova.delete 1138
def delete(instance_id, profile=None, **kwargs): ''' Delete an instance instance_id ID of the instance to be deleted CLI Example: .. code-block:: bash salt '*' nova.delete 1138 ''' conn = _auth(profile, **kwargs) return conn.delete(instance_id)
Return a list of available flavors (nova flavor-list) CLI Example: .. code-block:: bash salt '*' nova.flavor_list
def flavor_list(profile=None, **kwargs): ''' Return a list of available flavors (nova flavor-list) CLI Example: .. code-block:: bash salt '*' nova.flavor_list ''' filters = kwargs.get('filter', {}) conn = _auth(profile, **kwargs) return conn.flavor_list(**filters)
Add a flavor to nova (nova flavor-create). The following parameters are required: name Name of the new flavor (must be first) flavor_id Unique integer ID for the new flavor ram Memory size in MB disk Disk size in GB vcpus Number of vcpus is_public ...
def flavor_create(name, # pylint: disable=C0103 flavor_id=0, # pylint: disable=C0103 ram=0, disk=0, vcpus=1, is_public=True, profile=None, **kwargs): ''' Add a flavor to nova (nova flavor-create...
Delete a flavor from nova by id (nova flavor-delete) CLI Example: .. code-block:: bash salt '*' nova.flavor_delete 7
def flavor_delete(flavor_id, profile=None, **kwargs): # pylint: disable=C0103 ''' Delete a flavor from nova by id (nova flavor-delete) CLI Example: .. code-block:: bash salt '*' nova.flavor_delete 7 ''' conn = _auth(profile, **kwargs) return conn.flavor_delete(flavor_id)
Return a list of project IDs assigned to flavor ID CLI Example: .. code-block:: bash salt '*' nova.flavor_access_list flavor_id=ID
def flavor_access_list(flavor_id, profile=None, **kwargs): ''' Return a list of project IDs assigned to flavor ID CLI Example: .. code-block:: bash salt '*' nova.flavor_access_list flavor_id=ID ''' conn = _auth(profile, **kwargs) return conn.flavor_access_list(flavor_id=flavor_id,...
Add a project to the flavor access list CLI Example: .. code-block:: bash salt '*' nova.flavor_access_add flavor_id=fID project_id=pID
def flavor_access_add(flavor_id, project_id, profile=None, **kwargs): ''' Add a project to the flavor access list CLI Example: .. code-block:: bash salt '*' nova.flavor_access_add flavor_id=fID project_id=pID ''' conn = _auth(profile, **kwargs) return conn.flavor_access_add(flavor...
Remove a project from the flavor access list CLI Example: .. code-block:: bash salt '*' nova.flavor_access_remove flavor_id=fID project_id=pID
def flavor_access_remove(flavor_id, project_id, profile=None, **kwargs): ''' Remove a project from the flavor access list CLI Example: .. code-block:: bash salt '*' nova.flavor_access_remove flavor_id=fID project_id=pID ''' conn = _auth(profile, **kwargs) return conn.flavor_access...
Add a keypair to nova (nova keypair-add) CLI Examples: .. code-block:: bash salt '*' nova.keypair_add mykey pubfile='/home/myuser/.ssh/id_rsa.pub' salt '*' nova.keypair_add mykey pubkey='ssh-rsa <key> myuser@mybox'
def keypair_add(name, pubfile=None, pubkey=None, profile=None, **kwargs): ''' Add a keypair to nova (nova keypair-add) CLI Examples: .. code-block:: bash salt '*' nova.keypair_add mykey pubfile='/home/myuser/.ssh/id_rsa.pub' salt '*' nova.keypair_add mykey pubkey='ssh-rsa <key> myuser...
Add a keypair to nova (nova keypair-delete) CLI Example: .. code-block:: bash salt '*' nova.keypair_delete mykey
def keypair_delete(name, profile=None, **kwargs): ''' Add a keypair to nova (nova keypair-delete) CLI Example: .. code-block:: bash salt '*' nova.keypair_delete mykey ''' conn = _auth(profile, **kwargs) return conn.keypair_delete(name)
Return a list of available images (nova images-list + nova image-show) If a name is provided, only that image will be displayed. CLI Examples: .. code-block:: bash salt '*' nova.image_list salt '*' nova.image_list myimage
def image_list(name=None, profile=None, **kwargs): ''' Return a list of available images (nova images-list + nova image-show) If a name is provided, only that image will be displayed. CLI Examples: .. code-block:: bash salt '*' nova.image_list salt '*' nova.image_list myimage ...
Sets a key=value pair in the metadata for an image (nova image-meta set) CLI Examples: .. code-block:: bash salt '*' nova.image_meta_set 6f52b2ff-0b31-4d84-8fd1-af45b84824f6 cheese=gruyere salt '*' nova.image_meta_set name=myimage salad=pasta beans=baked
def image_meta_set(image_id=None, name=None, profile=None, **kwargs): # pylint: disable=C0103 ''' Sets a key=value pair in the metadata for an image (nova image-meta set) CLI Examples: .. code-block:: bash salt '*' nova.image_meta_set ...
Return detailed information for an active server CLI Example: .. code-block:: bash salt '*' nova.server_show <server_id>
def server_show(server_id, profile=None, **kwargs): ''' Return detailed information for an active server CLI Example: .. code-block:: bash salt '*' nova.server_show <server_id> ''' conn = _auth(profile, **kwargs) return conn.server_show(server_id)
Add a secgroup to nova (nova secgroup-create) CLI Example: .. code-block:: bash salt '*' nova.secgroup_create mygroup 'This is my security group'
def secgroup_create(name, description, profile=None, **kwargs): ''' Add a secgroup to nova (nova secgroup-create) CLI Example: .. code-block:: bash salt '*' nova.secgroup_create mygroup 'This is my security group' ''' conn = _auth(profile, **kwargs) return conn.secgroup_create(nam...
Delete a secgroup to nova (nova secgroup-delete) CLI Example: .. code-block:: bash salt '*' nova.secgroup_delete mygroup
def secgroup_delete(name, profile=None, **kwargs): ''' Delete a secgroup to nova (nova secgroup-delete) CLI Example: .. code-block:: bash salt '*' nova.secgroup_delete mygroup ''' conn = _auth(profile, **kwargs) return conn.secgroup_delete(name)
Return information about a server name Server Name CLI Example: .. code-block:: bash salt '*' nova.server_by_name myserver profile=openstack
def server_by_name(name, profile=None, **kwargs): ''' Return information about a server name Server Name CLI Example: .. code-block:: bash salt '*' nova.server_by_name myserver profile=openstack ''' conn = _auth(profile, **kwargs) return conn.server_by_name(name)
Read list of models and returns a Root object with the proper models added.
def _get_root_object(models): ''' Read list of models and returns a Root object with the proper models added. ''' root = napalm_yang.base.Root() for model in models: current = napalm_yang for part in model.split('.'): current = getattr(current, part) root.add_mode...
Returns the difference between two configuration entities structured according to the YANG model. .. note:: This function is recommended to be used mostly as a state helper. candidate First model to compare. running Second model to compare. models A list of models...
def diff(candidate, running, *models): ''' Returns the difference between two configuration entities structured according to the YANG model. .. note:: This function is recommended to be used mostly as a state helper. candidate First model to compare. running Second mod...
Parse configuration from the device. models A list of models to be used when parsing. config: ``False`` Parse config. state: ``False`` Parse state. profiles: ``None`` Use certain profiles to parse. If not specified, will use the device default profile(s). ...
def parse(*models, **kwargs): ''' Parse configuration from the device. models A list of models to be used when parsing. config: ``False`` Parse config. state: ``False`` Parse state. profiles: ``None`` Use certain profiles to parse. If not specified, will use t...
Return the native config. data Dictionary structured with respect to the models referenced. models A list of models to be used when generating the config. profiles: ``None`` Use certain profiles to generate the config. If not specified, will use the platform default profil...
def get_config(data, *models, **kwargs): ''' Return the native config. data Dictionary structured with respect to the models referenced. models A list of models to be used when generating the config. profiles: ``None`` Use certain profiles to generate the config. I...
Generate and load the config on the device using the OpenConfig or IETF models and device profiles. data Dictionary structured with respect to the models referenced. models A list of models to be used when generating the config. profiles: ``None`` Use certain profiles to gener...
def load_config(data, *models, **kwargs): ''' Generate and load the config on the device using the OpenConfig or IETF models and device profiles. data Dictionary structured with respect to the models referenced. models A list of models to be used when generating the config. pr...
Return the compliance report using YANG objects. data Dictionary structured with respect to the models referenced. models A list of models to be used when generating the config. filepath The absolute path to the validation file. CLI Example: .. code-block:: bash ...
def compliance_report(data, *models, **kwargs): ''' Return the compliance report using YANG objects. data Dictionary structured with respect to the models referenced. models A list of models to be used when generating the config. filepath The absolute path to the validatio...
Ensure a specific value exists at a given path :param name: The name for this rule :type name: ``str`` :param datastore: The datastore, e.g. running, operational. One of the NETCONF store IETF types :type datastore: :class:`DatastoreType` (``str`` enum). :param path: The device path to ...
def value_present(name, datastore, path, config): ''' Ensure a specific value exists at a given path :param name: The name for this rule :type name: ``str`` :param datastore: The datastore, e.g. running, operational. One of the NETCONF store IETF types :type datastore: :class:`Datast...
Manage RBAC properties for user name : string username roles : list list of roles for user profiles : list list of profiles for user authorizations : list list of authorizations for user .. warning:: All existing roles, profiles and authorizations will be re...
def managed(name, roles=None, profiles=None, authorizations=None): ''' Manage RBAC properties for user name : string username roles : list list of roles for user profiles : list list of profiles for user authorizations : list list of authorizations for user ...
Return True if the minion matches the given data target CLI Example: .. code-block:: bash salt '*' match.data 'spam:eggs'
def data(tgt): ''' Return True if the minion matches the given data target CLI Example: .. code-block:: bash salt '*' match.data 'spam:eggs' ''' matchers = salt.loader.matchers(__opts__) try: return matchers['data_match.match'](tgt, opts=__opts__) except Exception as e...
Return True if the minion ID matches the given pcre target minion_id Specify the minion ID to match against the target expression .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' match.pcre '.*'
def pcre(tgt, minion_id=None): ''' Return True if the minion ID matches the given pcre target minion_id Specify the minion ID to match against the target expression .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' match.pcre '.*' ''' if minio...
Return the first match in a dictionary of target patterns .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' match.filter_by '{foo*: Foo!, bar*: Bar!}' minion_id=bar03 Pillar Example: .. code-block:: jinja # Filter the data for the current minion into a vari...
def filter_by(lookup, tgt_type='compound', minion_id=None, merge=None, merge_lists=False, default='default'): ''' Return the first match in a dictionary of target patterns .. versionadded:: 2014.7.0 CLI Example: .. code-block::...
Search a dictionary of target strings for matching targets This is the inverse of :py:func:`match.filter_by <salt.modules.match.filter_by>` and allows matching values instead of matching keys. A minion can be matched by multiple entries. .. versionadded:: 2017.7.0 CLI Example: .. code-block:...
def search_by(lookup, tgt_type='compound', minion_id=None): ''' Search a dictionary of target strings for matching targets This is the inverse of :py:func:`match.filter_by <salt.modules.match.filter_by>` and allows matching values instead of matching keys. A minion can be matched by multiple entrie...
Execute varnishadm command return the output of the command cmd The command to run in varnishadm params Any additional args to add to the command line kwargs Additional options to pass to the salt cmd.run_all function
def _run_varnishadm(cmd, params=(), **kwargs): ''' Execute varnishadm command return the output of the command cmd The command to run in varnishadm params Any additional args to add to the command line kwargs Additional options to pass to the salt cmd.run_all function ...
Return server version from varnishd -V CLI Example: .. code-block:: bash salt '*' varnish.version
def version(): ''' Return server version from varnishd -V CLI Example: .. code-block:: bash salt '*' varnish.version ''' cmd = ['varnishd', '-V'] out = __salt__['cmd.run'](cmd, python_shell=False) ret = re.search(r'\(varnish-([^\)]+)\)', out).group(1) return ret
Show params of varnish cache CLI Example: .. code-block:: bash salt '*' varnish.param_show param
def param_show(param=None): ''' Show params of varnish cache CLI Example: .. code-block:: bash salt '*' varnish.param_show param ''' ret = _run_varnishadm('param.show', [param]) if ret['retcode']: return False else: result = {} for line in ret['stdout']...
Removes dirtyID tags from the candidate config result. Palo Alto devices will make the candidate configuration with a dirty ID after a change. This can cause unexpected results when parsing.
def _strip_dirty(xmltree): ''' Removes dirtyID tags from the candidate config result. Palo Alto devices will make the candidate configuration with a dirty ID after a change. This can cause unexpected results when parsing. ''' dirty = xmltree.attrib.pop('dirtyId', None) if dirty: xmltree....
This function gets called when the proxy starts up. For panos devices, a determination is made on the connection type and the appropriate connection details that must be cached.
def init(opts): ''' This function gets called when the proxy starts up. For panos devices, a determination is made on the connection type and the appropriate connection details that must be cached. ''' if 'host' not in opts['proxy']: log.critical('No \'host\' key found in pillar for this...
This function captures the query string and sends it to the Palo Alto device.
def call(payload=None): ''' This function captures the query string and sends it to the Palo Alto device. ''' r = None try: if DETAILS['method'] == 'dev_key': # Pass the api key without the target declaration conditional_payload = {'key': DETAILS['apikey']} ...
Because different versions of Palo Alto support different command sets, this function will return true if the current version of Palo Alto supports the required command.
def is_required_version(required_version='0.0.0'): ''' Because different versions of Palo Alto support different command sets, this function will return true if the current version of Palo Alto supports the required command. ''' if 'sw-version' in DETAILS['grains_cache']: current_version = D...
Get the grains from the proxied device
def grains(): ''' Get the grains from the proxied device ''' if not DETAILS.get('grains_cache', {}): DETAILS['grains_cache'] = GRAINS_CACHE try: query = {'type': 'op', 'cmd': '<show><system><info></info></system></show>'} DETAILS['grains_cache'] = call(query)['res...
append ``comment`` to ``ret['comment']``
def _append_comment(ret, comment): ''' append ``comment`` to ``ret['comment']`` ''' if ret['comment']: ret['comment'] = ret['comment'].rstrip() + '\n' + comment else: ret['comment'] = comment return ret
Ensure that the specified kernel module is loaded name The name of the kernel module to verify is loaded persist Also add module to ``/etc/modules`` mods A list of modules to verify are loaded. If this argument is used, the ``name`` argument, although still required, is n...
def present(name, persist=False, mods=None): ''' Ensure that the specified kernel module is loaded name The name of the kernel module to verify is loaded persist Also add module to ``/etc/modules`` mods A list of modules to verify are loaded. If this argument is used, the...
Verify that the named kernel module is not loaded name The name of the kernel module to verify is not loaded persist Remove module from ``/etc/modules`` comment Comment out module in ``/etc/modules`` rather than remove it mods A list of modules to verify are unloaded....
def absent(name, persist=False, comment=True, mods=None): ''' Verify that the named kernel module is not loaded name The name of the kernel module to verify is not loaded persist Remove module from ``/etc/modules`` comment Comment out module in ``/etc/modules`` rather than...
Invoke a function in the lxc module with no args path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0
def _do(name, fun, path=None): ''' Invoke a function in the lxc module with no args path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 ''' host = find_guest(name, quiet=True, path=path) if not host: return False ...
Invoke a function in the lxc module with no args path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0
def _do_names(names, fun, path=None): ''' Invoke a function in the lxc module with no args path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 ''' ret = {} hosts = find_guests(names, path=path) if not hosts: re...
Returns the host for a container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 .. code-block:: bash salt-run lxc.find_guest name
def find_guest(name, quiet=False, path=None): ''' Returns the host for a container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 .. code-block:: bash salt-run lxc.find_guest name ''' if quiet: log...
Return a dict of hosts and named guests path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0
def find_guests(names, path=None): ''' Return a dict of hosts and named guests path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 ''' ret = {} names = names.split(',') for data in _list_iter(path=path): host,...
Initialize a new container .. code-block:: bash salt-run lxc.init name host=minion_id [cpuset=cgroups_cpuset] \\ [cpushare=cgroups_cpushare] [memory=cgroups_memory] \\ [template=lxc_template_name] [clone=original name] \\ [profile=lxc_profile] [network_prof...
def init(names, host=None, saltcloud_mode=False, quiet=False, **kwargs): ''' Initialize a new container .. code-block:: bash salt-run lxc.init name host=minion_id [cpuset=cgroups_cpuset] \\ [cpushare=cgroups_cpushare] [memory=cgroups_memory] \\ [template=lxc_templa...
Wrapper for using lxc.init in saltcloud compatibility mode names Name of the containers, supports a single name or a comma delimited list of names. host Minion to start the container on. Required. path path to the container parent default: /var/lib/lxc (system defa...
def cloud_init(names, host=None, quiet=False, **kwargs): ''' Wrapper for using lxc.init in saltcloud compatibility mode names Name of the containers, supports a single name or a comma delimited list of names. host Minion to start the container on. Required. path pa...
Return a generator iterating over hosts path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0
def _list_iter(host=None, path=None): ''' Return a generator iterating over hosts path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 ''' tgt = host or '*' client = salt.client.get_local_client(__opts__['conf_file']) f...
List defined containers (running, stopped, and frozen) for the named (or all) host(s). path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 .. code-block:: bash salt-run lxc.list [host=minion_id]
def list_(host=None, quiet=False, path=None): ''' List defined containers (running, stopped, and frozen) for the named (or all) host(s). path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 .. code-block:: bash salt-r...
Purge the named container and delete its minion key if present. WARNING: Destroys all data associated with the container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 .. code-block:: bash salt-run lxc.purge name
def purge(name, delete_key=True, quiet=False, path=None): ''' Purge the named container and delete its minion key if present. WARNING: Destroys all data associated with the container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 201...
Start the named container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 .. code-block:: bash salt-run lxc.start name
def start(name, quiet=False, path=None): ''' Start the named container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 .. code-block:: bash salt-run lxc.start name ''' data = _do_names(name, 'start', path=pa...
Return the location of the SELinux VFS directory CLI Example: .. code-block:: bash salt '*' selinux.selinux_fs_path
def selinux_fs_path(): ''' Return the location of the SELinux VFS directory CLI Example: .. code-block:: bash salt '*' selinux.selinux_fs_path ''' # systems running systemd (e.g. Fedora 15 and newer) # have the selinux filesystem in a different location try: for direct...
Return the mode selinux is running in CLI Example: .. code-block:: bash salt '*' selinux.getenforce
def getenforce(): ''' Return the mode selinux is running in CLI Example: .. code-block:: bash salt '*' selinux.getenforce ''' _selinux_fs_path = selinux_fs_path() if _selinux_fs_path is None: return 'Disabled' try: enforce = os.path.join(_selinux_fs_path, 'enfo...
Return the selinux mode from the config file CLI Example: .. code-block:: bash salt '*' selinux.getconfig
def getconfig(): ''' Return the selinux mode from the config file CLI Example: .. code-block:: bash salt '*' selinux.getconfig ''' try: config = '/etc/selinux/config' with salt.utils.files.fopen(config, 'r') as _fp: for line in _fp: line = s...
Set the SELinux enforcing mode CLI Example: .. code-block:: bash salt '*' selinux.setenforce enforcing
def setenforce(mode): ''' Set the SELinux enforcing mode CLI Example: .. code-block:: bash salt '*' selinux.setenforce enforcing ''' if isinstance(mode, six.string_types): if mode.lower() == 'enforcing': mode = '1' modestring = 'Enforcing' elif ...
Set the value of multiple booleans CLI Example: .. code-block:: bash salt '*' selinux.setsebools '{virt_use_usb: on, squid_use_tproxy: off}'
def setsebools(pairs, persist=False): ''' Set the value of multiple booleans CLI Example: .. code-block:: bash salt '*' selinux.setsebools '{virt_use_usb: on, squid_use_tproxy: off}' ''' if not isinstance(pairs, dict): return {} if persist: cmd = 'setsebool -P ' ...
Set the value for a boolean CLI Example: .. code-block:: bash salt '*' selinux.setsebool virt_use_usb off
def setsebool(boolean, value, persist=False): ''' Set the value for a boolean CLI Example: .. code-block:: bash salt '*' selinux.setsebool virt_use_usb off ''' if persist: cmd = 'setsebool -P {0} {1}'.format(boolean, value) else: cmd = 'setsebool {0} {1}'.format(bo...
Return a structure listing all of the selinux booleans on the system and what state they are in CLI Example: .. code-block:: bash salt '*' selinux.list_sebool
def list_sebool(): ''' Return a structure listing all of the selinux booleans on the system and what state they are in CLI Example: .. code-block:: bash salt '*' selinux.list_sebool ''' bdata = __salt__['cmd.run']('semanage boolean -l').splitlines() ret = {} for line in bd...
Enable or disable an SELinux module. CLI Example: .. code-block:: bash salt '*' selinux.setsemod nagios Enabled .. versionadded:: 2016.3.0
def setsemod(module, state): ''' Enable or disable an SELinux module. CLI Example: .. code-block:: bash salt '*' selinux.setsemod nagios Enabled .. versionadded:: 2016.3.0 ''' if state.lower() == 'enabled': cmd = 'semodule -e {0}'.format(module) elif state.lower() == ...
Install custom SELinux module from file CLI Example: .. code-block:: bash salt '*' selinux.install_semod [salt://]path/to/module.pp .. versionadded:: 2016.11.6
def install_semod(module_path): ''' Install custom SELinux module from file CLI Example: .. code-block:: bash salt '*' selinux.install_semod [salt://]path/to/module.pp .. versionadded:: 2016.11.6 ''' if module_path.find('salt://') == 0: module_path = __salt__['cp.cache_fi...
Return a structure listing all of the selinux modules on the system and what state they are in CLI Example: .. code-block:: bash salt '*' selinux.list_semod .. versionadded:: 2016.3.0
def list_semod(): ''' Return a structure listing all of the selinux modules on the system and what state they are in CLI Example: .. code-block:: bash salt '*' selinux.list_semod .. versionadded:: 2016.3.0 ''' helptext = __salt__['cmd.run']('semodule -h').splitlines() sem...
.. versionadded:: 2019.2.0 Validates and parses the protocol and port/port range from the name if both protocol and port are not provided. If the name is in a valid format, the protocol and port are ignored if provided Examples: tcp/8080 or udp/20-21
def _parse_protocol_port(name, protocol, port): ''' .. versionadded:: 2019.2.0 Validates and parses the protocol and port/port range from the name if both protocol and port are not provided. If the name is in a valid format, the protocol and port are ignored if provided Examples: tcp/8080 or ...
.. versionadded:: 2017.7.0 Converts an SELinux file context from string to dict.
def _context_string_to_dict(context): ''' .. versionadded:: 2017.7.0 Converts an SELinux file context from string to dict. ''' if not re.match('[^:]+:[^:]+:[^:]+:[^:]+$', context): raise SaltInvocationError('Invalid SELinux context string: {0}. ' + 'Expecte...
.. versionadded:: 2017.7.0 Returns the current entry in the SELinux policy list as a dictionary. Returns None if no exact match was found. Returned keys are: * filespec (the name supplied and matched) * filetype (the descriptive name of the filetype supplied) * sel_user, sel_role, sel_type, s...
def fcontext_get_policy(name, filetype=None, sel_type=None, sel_user=None, sel_level=None): ''' .. versionadded:: 2017.7.0 Returns the current entry in the SELinux policy list as a dictionary. Returns None if no exact match was found. Returned keys are: * filespec (the name supplied and match...
.. versionadded:: 2019.2.0 Adds the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry before setting a new one for a given filespec and filetype, as adding one with semanage automatically over...
def fcontext_add_policy(name, filetype=None, sel_type=None, sel_user=None, sel_level=None): ''' .. versionadded:: 2019.2.0 Adds the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry before set...
.. versionadded:: 2019.2.0 Deletes the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry before setting a new one for a given filespec and filetype, as adding one with semanage automatically o...
def fcontext_delete_policy(name, filetype=None, sel_type=None, sel_user=None, sel_level=None): ''' .. versionadded:: 2019.2.0 Deletes the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry befo...
.. versionadded:: 2017.7.0 Adds or deletes the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry before setting a new one for a given filespec and filetype, as adding one with semanage automat...
def fcontext_add_or_delete_policy(action, name, filetype=None, sel_type=None, sel_user=None, sel_level=None): ''' .. versionadded:: 2017.7.0 Adds or deletes the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have ...
.. versionadded:: 2019.2.0 Performs the action as called from ``fcontext_add_policy`` or ``fcontext_delete_policy``. Returns the result of the call to semanage.
def _fcontext_add_or_delete_policy(action, name, filetype=None, sel_type=None, sel_user=None, sel_level=None): ''' .. versionadded:: 2019.2.0 Performs the action as called from ``fcontext_add_policy`` or ``fcontext_delete_policy``. Returns the result of the call to semanage. ''' if action not ...
.. versionadded:: 2017.7.0 Returns an empty string if the SELinux policy for a given filespec is applied, returns string with differences in policy and actual situation otherwise. name filespec of the file or directory. Regex syntax is allowed. CLI Example: .. code-block:: bash ...
def fcontext_policy_is_applied(name, recursive=False): ''' .. versionadded:: 2017.7.0 Returns an empty string if the SELinux policy for a given filespec is applied, returns string with differences in policy and actual situation otherwise. name filespec of the file or directory. Regex s...
.. versionadded:: 2017.7.0 Applies SElinux policies to filespec using `restorecon [-R] filespec`. Returns dict with changes if successful, the output of the restorecon command otherwise. name filespec of the file or directory. Regex syntax is allowed. recursive Recursively apply S...
def fcontext_apply_policy(name, recursive=False): ''' .. versionadded:: 2017.7.0 Applies SElinux policies to filespec using `restorecon [-R] filespec`. Returns dict with changes if successful, the output of the restorecon command otherwise. name filespec of the file or directory. Regex...
.. versionadded:: 2019.2.0 Returns the current entry in the SELinux policy list as a dictionary. Returns None if no exact match was found. Returned keys are: * sel_type (the selinux type) * proto (the protocol) * port (the port(s) and/or port range(s)) name The protocol and port ...
def port_get_policy(name, sel_type=None, protocol=None, port=None): ''' .. versionadded:: 2019.2.0 Returns the current entry in the SELinux policy list as a dictionary. Returns None if no exact match was found. Returned keys are: * sel_type (the selinux type) * proto (the protocol) * ...
.. versionadded:: 2019.2.0 Adds the SELinux policy for a given protocol and port. Returns the result of the call to semanage. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_type The SELinux Type. Required. protocol The protocol ...
def port_add_policy(name, sel_type=None, protocol=None, port=None, sel_range=None): ''' .. versionadded:: 2019.2.0 Adds the SELinux policy for a given protocol and port. Returns the result of the call to semanage. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port...
.. versionadded:: 2019.2.0 Performs the action as called from ``port_add_policy`` or ``port_delete_policy``. Returns the result of the call to semanage.
def _port_add_or_delete_policy(action, name, sel_type=None, protocol=None, port=None, sel_range=None): ''' .. versionadded:: 2019.2.0 Performs the action as called from ``port_add_policy`` or ``port_delete_policy``. Returns the result of the call to semanage. ''' if action not in ['add', 'dele...
Establish a connection to etcd
def _get_conn(opts, profile=None): ''' Establish a connection to etcd ''' if profile is None: profile = opts.get('etcd.returner') path = opts.get('etcd.returner_root', '/salt/return') return salt.utils.etcd_util.get_conn(opts, profile), path
Return data to an etcd server or cluster
def returner(ret): ''' Return data to an etcd server or cluster ''' write_profile = __opts__.get('etcd.returner_write_profile') if write_profile: ttl = __opts__.get(write_profile, {}).get('etcd.ttl') else: ttl = __opts__.get('etcd.ttl') client, path = _get_conn(__opts__, wri...
Save the load to the specified jid
def save_load(jid, load, minions=None): ''' Save the load to the specified jid ''' log.debug('sdstack_etcd returner <save_load> called jid: %s', jid) write_profile = __opts__.get('etcd.returner_write_profile') client, path = _get_conn(__opts__, write_profile) if write_profile: ttl = ...
Return the load data that marks a specified jid
def get_load(jid): ''' Return the load data that marks a specified jid ''' log.debug('sdstack_etcd returner <get_load> called jid: %s', jid) read_profile = __opts__.get('etcd.returner_read_profile') client, path = _get_conn(__opts__, read_profile) return salt.utils.json.loads(client.get('/'....
Return the information returned when the specified job id was executed
def get_jid(jid): ''' Return the information returned when the specified job id was executed ''' log.debug('sdstack_etcd returner <get_jid> called jid: %s', jid) ret = {} client, path = _get_conn(__opts__) items = client.get('/'.join((path, 'jobs', jid))) for item in items.children: ...
Return a dict of the last function called for all minions
def get_fun(fun): ''' Return a dict of the last function called for all minions ''' log.debug('sdstack_etcd returner <get_fun> called fun: %s', fun) ret = {} client, path = _get_conn(__opts__) items = client.get('/'.join((path, 'minions'))) for item in items.children: comps = str...
Return a list of all job ids
def get_jids(): ''' Return a list of all job ids ''' log.debug('sdstack_etcd returner <get_jids> called') ret = [] client, path = _get_conn(__opts__) items = client.get('/'.join((path, 'jobs'))) for item in items.children: if item.dir is True: jid = str(item.key).spli...
Return a list of minions
def get_minions(): ''' Return a list of minions ''' log.debug('sdstack_etcd returner <get_minions> called') ret = [] client, path = _get_conn(__opts__) items = client.get('/'.join((path, 'minions'))) for item in items.children: comps = str(item.key).split('/') ret.append(...
Ensure a Linux ACL is present name The acl path acl_type The type of the acl is used for it can be 'user' or 'group' acl_name The user or group perms Set the permissions eg.: rwx recurse Set the permissions recursive in the path force Wipe o...
def present(name, acl_type, acl_name='', perms='', recurse=False, force=False): ''' Ensure a Linux ACL is present name The acl path acl_type The type of the acl is used for it can be 'user' or 'group' acl_name The user or group perms Set the permissions eg.: ...
Ensure a Linux ACL does not exist name The acl path acl_type The type of the acl is used for, it can be 'user' or 'group' acl_names The user or group perms Remove the permissions eg.: rwx recurse Set the permissions recursive in the path
def absent(name, acl_type, acl_name='', perms='', recurse=False): ''' Ensure a Linux ACL does not exist name The acl path acl_type The type of the acl is used for, it can be 'user' or 'group' acl_names The user or group perms Remove the permissions eg.: rwx ...