INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Remove container name from HostConfig: Links values to enable comparing container configurations correctly.
def _scrub_links(links, name): ''' Remove container name from HostConfig:Links values to enable comparing container configurations correctly. ''' if isinstance(links, list): ret = [] for l in links: ret.append(l.replace('/{0}/'.format(name), '/', 1)) else: ret...
Format bytes as human - readable file sizes
def _size_fmt(num): ''' Format bytes as human-readable file sizes ''' try: num = int(num) if num < 1024: return '{0} bytes'.format(num) num /= 1024.0 for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'): if num < 1024.0: return '{0:3.1f}...
Common functionality for running low - level API calls
def _client_wrapper(attr, *args, **kwargs): ''' Common functionality for running low-level API calls ''' catch_api_errors = kwargs.pop('catch_api_errors', True) func = getattr(__context__['docker.client'], attr, None) if func is None or not hasattr(func, '__call__'): raise SaltInvocation...
Process a status update from a docker build updating the data structure
def _build_status(data, item): ''' Process a status update from a docker build, updating the data structure ''' stream = item['stream'] if 'Running in' in stream: data.setdefault('Intermediate_Containers', []).append( stream.rstrip().split()[-1]) if 'Successfully built' in st...
Process a status update from docker import updating the data structure
def _import_status(data, item, repo_name, repo_tag): ''' Process a status update from docker import, updating the data structure ''' status = item['status'] try: if 'Downloading from' in status: return elif all(x in string.hexdigits for x in status): # Status ...
Process a status update from a docker pull updating the data structure.
def _pull_status(data, item): ''' Process a status update from a docker pull, updating the data structure. For containers created with older versions of Docker, there is no distinction in the status updates between layers that were already present (and thus not necessary to download), and those whi...
Process a status update from a docker push updating the data structure
def _push_status(data, item): ''' Process a status update from a docker push, updating the data structure ''' status = item['status'].lower() if 'id' in item: if 'already pushed' in status or 'already exists' in status: # Layer already exists already_pushed = data.set...
Process an API error updating the data structure
def _error_detail(data, item): ''' Process an API error, updating the data structure ''' err = item['errorDetail'] if 'code' in err: try: msg = ': '.join(( item['errorDetail']['code'], item['errorDetail']['message'] )) except Ty...
Take input kwargs and return a kwargs dict to pass to docker - py s create_container () function.
def _get_create_kwargs(skip_translate=None, ignore_collisions=False, validate_ip_addrs=True, client_args=None, **kwargs): ''' Take input kwargs and return a kwargs dict to pass to docker-py's create_container() funct...
.. versionadded:: 2017. 7. 0.. versionchanged:: 2018. 3. 0 Renamed from docker. compare_container to docker. compare_containers ( old function name remains as an alias )
def compare_containers(first, second, ignore=None): ''' .. versionadded:: 2017.7.0 .. versionchanged:: 2018.3.0 Renamed from ``docker.compare_container`` to ``docker.compare_containers`` (old function name remains as an alias) Compare two containers' Config and and HostConfig and return...
.. versionadded:: 2018. 3. 0
def compare_container_networks(first, second): ''' .. versionadded:: 2018.3.0 Returns the differences between two containers' networks. When a network is only present one of the two containers, that network's diff will simply be represented with ``True`` for the side of the diff in which the networ...
.. versionadded:: 2018. 3. 0
def compare_networks(first, second, ignore='Name,Id,Created,Containers'): ''' .. versionadded:: 2018.3.0 Compare two networks and return any differences between the two first Name or ID of first container second Name or ID of second container ignore : Name,Id,Created,Containe...
.. versionadded:: 2018. 3. 0
def connected(name, verbose=False): ''' .. versionadded:: 2018.3.0 Return a list of running containers attached to the specified network name Network name verbose : False If ``True``, return extended info about each container (IP configuration, etc.) CLI Example: ...
.. versionadded:: 2016. 3. 7 2016. 11. 4 2017. 7. 0
def login(*registries): ''' .. versionadded:: 2016.3.7,2016.11.4,2017.7.0 Performs a ``docker login`` to authenticate to one or more configured repositories. See the documentation at the top of this page to configure authentication credentials. Multiple registry URLs (matching those configured...
Returns the containers and images if any which depend on the given image
def depends(name): ''' Returns the containers and images, if any, which depend on the given image name Name or ID of image **RETURN DATA** A dictionary containing the following keys: - ``Containers`` - A list of containers which depend on the specified image - ``Images`` - A lis...
Get information on changes made to container s filesystem since it was created. Equivalent to running the docker diff Docker CLI command.
def diff(name): ''' Get information on changes made to container's filesystem since it was created. Equivalent to running the ``docker diff`` Docker CLI command. name Container name or ID **RETURN DATA** A dictionary containing any of the following keys: - ``Added`` - A list of ...
Check if a given container exists
def exists(name): ''' Check if a given container exists name Container name or ID **RETURN DATA** A boolean (``True`` if the container exists, otherwise ``False``) CLI Example: .. code-block:: bash salt myminion docker.exists mycontainer ''' contextkey = 'dock...
Return the history for an image. Equivalent to running the docker history Docker CLI command.
def history(name, quiet=False): ''' Return the history for an image. Equivalent to running the ``docker history`` Docker CLI command. name Container name or ID quiet : False If ``True``, the return data will simply be a list of the commands run to build the container. ...
Returns information about the Docker images on the Minion. Equivalent to running the docker images Docker CLI command.
def images(verbose=False, **kwargs): ''' Returns information about the Docker images on the Minion. Equivalent to running the ``docker images`` Docker CLI command. all : False If ``True``, untagged images will also be returned verbose : False If ``True``, a ``docker inspect`` will ...
.. versionchanged:: 2017. 7. 0 Volumes and networks are now checked in addition to containers and images.
def inspect(name): ''' .. versionchanged:: 2017.7.0 Volumes and networks are now checked, in addition to containers and images. This is a generic container/image/volume/network inspecton function. It will run the following functions in order: - :py:func:`docker.inspect_container ...
Retrieves image information. Equivalent to running the docker inspect Docker CLI command but will only look for image information.
def inspect_image(name): ''' Retrieves image information. Equivalent to running the ``docker inspect`` Docker CLI command, but will only look for image information. .. note:: To inspect an image, it must have been pulled from a registry or built locally. Images on a Docker registry whic...
Returns a list of containers by name. This is different from: py: func: docker. ps <salt. modules. dockermod. ps_ > in that: py: func: docker. ps <salt. modules. dockermod. ps_ > returns its results organized by container ID.
def list_containers(**kwargs): ''' Returns a list of containers by name. This is different from :py:func:`docker.ps <salt.modules.dockermod.ps_>` in that :py:func:`docker.ps <salt.modules.dockermod.ps_>` returns its results organized by container ID. all : False If ``True``, stopped con...
Returns a list of tagged images
def list_tags(): ''' Returns a list of tagged images CLI Example: .. code-block:: bash salt myminion docker.list_tags ''' ret = set() for item in six.itervalues(images()): if not item.get('RepoTags'): continue ret.update(set(item['RepoTags'])) retur...
.. versionadded:: 2018. 3. 0
def resolve_image_id(name): ''' .. versionadded:: 2018.3.0 Given an image name (or partial image ID), return the full image ID. If no match is found among the locally-pulled images, then ``False`` will be returned. CLI Examples: .. code-block:: bash salt myminion docker.resolve_i...
.. versionadded:: 2017. 7. 2.. versionchanged:: 2018. 3. 0 Instead of matching against pulled tags using: py: func: docker. list_tags <salt. modules. dockermod. list_tags > this function now simply inspects the passed image name using: py: func: docker. inspect_image <salt. modules. dockermod. inspect_image > and retur...
def resolve_tag(name, **kwargs): ''' .. versionadded:: 2017.7.2 .. versionchanged:: 2018.3.0 Instead of matching against pulled tags using :py:func:`docker.list_tags <salt.modules.dockermod.list_tags>`, this function now simply inspects the passed image name using :py:func:`d...
.. versionchanged:: 2018. 3. 0 Support for all of docker - py s logs () _ function s arguments with the exception of stream.
def logs(name, **kwargs): ''' .. versionchanged:: 2018.3.0 Support for all of docker-py's `logs()`_ function's arguments, with the exception of ``stream``. Returns the logs for the container. An interface to docker-py's `logs()`_ function. name Container name or ID std...
Returns port mapping information for a given container. Equivalent to running the docker port Docker CLI command.
def port(name, private_port=None): ''' Returns port mapping information for a given container. Equivalent to running the ``docker port`` Docker CLI command. name Container name or ID .. versionchanged:: 2019.2.0 This value can now be a pattern expression (using the ...
Returns information about the Docker containers on the Minion. Equivalent to running the docker ps Docker CLI command.
def ps_(filters=None, **kwargs): ''' Returns information about the Docker containers on the Minion. Equivalent to running the ``docker ps`` Docker CLI command. all : False If ``True``, stopped containers will also be returned host: False If ``True``, local host's network topology w...
Returns the state of the container
def state(name): ''' Returns the state of the container name Container name or ID **RETURN DATA** A string representing the current state of the container (either ``running``, ``paused``, or ``stopped``) CLI Example: .. code-block:: bash salt myminion docker.state...
Searches the registry for an image
def search(name, official=False, trusted=False): ''' Searches the registry for an image name Search keyword official : False Limit results to official builds trusted : False Limit results to `trusted builds`_ **RETURN DATA** A dictionary with each key being the n...
Runs the docker top command on a specific container
def top(name): ''' Runs the `docker top` command on a specific container name Container name or ID CLI Example: **RETURN DATA** A list of dictionaries containing information about each process .. code-block:: bash salt myminion docker.top mycontainer salt mymi...
Returns a dictionary of Docker version information. Equivalent to running the docker version Docker CLI command.
def version(): ''' Returns a dictionary of Docker version information. Equivalent to running the ``docker version`` Docker CLI command. CLI Example: .. code-block:: bash salt myminion docker.version ''' ret = _client_wrapper('version') version_re = re.compile(VERSION_RE) i...
Create a new container
def create(image, name=None, start=False, skip_translate=None, ignore_collisions=False, validate_ip_addrs=True, client_timeout=salt.utils.docker.CLIENT_TIMEOUT, **kwargs): ''' Create a new container image Image from which ...
.. versionadded:: 2018. 3. 0
def run_container(image, name=None, skip_translate=None, ignore_collisions=False, validate_ip_addrs=True, client_timeout=salt.utils.docker.CLIENT_TIMEOUT, bg=False, replace=False, ...
Copy a file from inside a container to the Minion
def copy_from(name, source, dest, overwrite=False, makedirs=False): ''' Copy a file from inside a container to the Minion name Container name source Path of the file on the container's filesystem dest Destination on the Minion. Must be an absolute path. If the destination ...
Copy a file from the host into a container
def copy_to(name, source, dest, exec_driver=None, overwrite=False, makedirs=False): ''' Copy a file from the host into a container name Container name source File to be copied to the container. Can be a local path on the Minio...
Exports a container to a tar archive. It can also optionally compress that tar archive and push it up to the Master.
def export(name, path, overwrite=False, makedirs=False, compression=None, **kwargs): ''' Exports a container to a tar archive. It can also optionally compress that tar archive, and push it up to the Master. name Container name or ID pa...
Removes a container
def rm_(name, force=False, volumes=False, **kwargs): ''' Removes a container name Container name or ID force : False If ``True``, the container will be killed first before removal, as the Docker API will not permit a running container to be removed. This option is set t...
.. versionadded:: 2017. 7. 0
def rename(name, new_name): ''' .. versionadded:: 2017.7.0 Renames a container. Returns ``True`` if successful, and raises an error if the API returns one. If unsuccessful and the API returns no error (should not happen), then ``False`` will be returned. name Name or ID of existing con...
.. versionchanged:: 2018. 3. 0 If the built image should be tagged then the repository and tag must now be passed separately using the repository and tag arguments rather than together in the ( now deprecated ) image argument.
def build(path=None, repository=None, tag=None, cache=True, rm=True, api_response=False, fileobj=None, dockerfile=None, buildargs=None, network_mode=None, labels=None, cache_from=None, target=None): ...
.. versionchanged:: 2018. 3. 0 The repository and tag must now be passed separately using the repository and tag arguments rather than together in the ( now deprecated ) image argument.
def commit(name, repository, tag='latest', message=None, author=None): ''' .. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprec...
Return top - level images ( those on which no other images depend ) which do not have a tag assigned to them. These include:
def dangling(prune=False, force=False): ''' Return top-level images (those on which no other images depend) which do not have a tag assigned to them. These include: - Images which were once tagged but were later untagged, such as those which were superseded by committing a new copy of an existing...
.. versionchanged:: 2018. 3. 0 The repository and tag must now be passed separately using the repository and tag arguments rather than together in the ( now deprecated ) image argument.
def import_(source, repository, tag='latest', api_response=False): ''' .. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``imag...
.. versionchanged:: 2018. 3. 0 If the loaded image should be tagged then the repository and tag must now be passed separately using the repository and tag arguments rather than together in the ( now deprecated ) image argument.
def load(path, repository=None, tag=None): ''' .. versionchanged:: 2018.3.0 If the loaded image should be tagged, then the repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argum...
Returns a list of the IDs of layers belonging to the specified image with the top - most layer ( the one correspnding to the passed name ) appearing last.
def layers(name): ''' Returns a list of the IDs of layers belonging to the specified image, with the top-most layer (the one correspnding to the passed name) appearing last. name Image name or ID CLI Example: .. code-block:: bash salt myminion docker.layers centos:7 '...
.. versionchanged:: 2018. 3. 0 If no tag is specified in the image argument all tags for the image will be pulled. For this reason is it recommended to pass image using the repo: tag notation.
def pull(image, insecure_registry=False, api_response=False, client_timeout=salt.utils.docker.CLIENT_TIMEOUT): ''' .. versionchanged:: 2018.3.0 If no tag is specified in the ``image`` argument, all tags for the image will be pulled. For this reason is it recommended to...
.. versionchanged:: 2015. 8. 4 The Id and Image keys are no longer present in the return data. This is due to changes in the Docker Remote API.
def push(image, insecure_registry=False, api_response=False, client_timeout=salt.utils.docker.CLIENT_TIMEOUT): ''' .. versionchanged:: 2015.8.4 The ``Id`` and ``Image`` keys are no longer present in the return data. This is due to changes in the Docker Remote API. ...
Removes an image
def rmi(*names, **kwargs): ''' Removes an image name Name (in ``repo:tag`` notation) or ID of image. force : False If ``True``, the image will be removed even if the Minion has containers created from that image prune : True If ``True``, untagged parent image layer...
.. versionchanged:: 2018. 3. 0 The repository and tag must now be passed separately using the repository and tag arguments rather than together in the ( now deprecated ) image argument.
def tag_(name, repository, tag='latest', force=False): ''' .. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argument. Tag an image into a repositor...
.. versionchanged:: 2017. 7. 0 The names and ids can be passed as a comma - separated list now as well as a Python list... versionchanged:: 2018. 3. 0 The Containers key for each network is no longer always empty.
def networks(names=None, ids=None): ''' .. versionchanged:: 2017.7.0 The ``names`` and ``ids`` can be passed as a comma-separated list now, as well as a Python list. .. versionchanged:: 2018.3.0 The ``Containers`` key for each network is no longer always empty. List existing net...
.. versionchanged:: 2018. 3. 0 Support added for network configuration options other than driver and driver_opts as well as IPAM configuration.
def create_network(name, skip_translate=None, ignore_collisions=False, validate_ip_addrs=True, client_timeout=salt.utils.docker.CLIENT_TIMEOUT, **kwargs): ''' .. versionchanged:: 2018.3.0 Support added for net...
.. versionadded:: 2015. 8. 3.. versionchanged:: 2017. 7. 0 Support for ipv4_address argument added.. versionchanged:: 2018. 3. 0 All arguments are now passed through to connect_container_to_network () _ allowing for any new arguments added to this function to be supported automagically.
def connect_container_to_network(container, net_id, **kwargs): ''' .. versionadded:: 2015.8.3 .. versionchanged:: 2017.7.0 Support for ``ipv4_address`` argument added .. versionchanged:: 2018.3.0 All arguments are now passed through to `connect_container_to_network()`_, allowing ...
.. versionadded:: 2015. 8. 3
def disconnect_container_from_network(container, network_id): ''' .. versionadded:: 2015.8.3 Disconnect container from network container Container name or ID network_id Network name or ID CLI Examples: .. code-block:: bash salt myminion docker.disconnect_contain...
.. versionadded:: 2018. 3. 0
def disconnect_all_containers_from_network(network_id): ''' .. versionadded:: 2018.3.0 Runs :py:func:`docker.disconnect_container_from_network <salt.modules.dockermod.disconnect_container_from_network>` on all containers connected to the specified network, and returns the names of all container...
Create a new volume
def create_volume(name, driver=None, driver_opts=None): ''' Create a new volume .. versionadded:: 2015.8.4 name name of volume driver Driver of the volume driver_opts Options for the driver volume CLI Example: .. code-block:: bash salt myminion dock...
Pauses a container
def pause(name): ''' Pauses a container name Container name or ID **RETURN DATA** A dictionary will be returned, containing the following keys: - ``status`` - A dictionary showing the prior state of the container as well as the new state - ``result`` - A boolean noting whe...
Restarts a container
def restart(name, timeout=10): ''' Restarts a container name Container name or ID timeout : 10 Timeout in seconds after which the container will be killed (if it has not yet gracefully shut down) **RETURN DATA** A dictionary will be returned, containing the following...
Start a container
def start_(name): ''' Start a container name Container name or ID **RETURN DATA** A dictionary will be returned, containing the following keys: - ``status`` - A dictionary showing the prior state of the container as well as the new state - ``result`` - A boolean noting whet...
Stops a running container
def stop(name, timeout=None, **kwargs): ''' Stops a running container name Container name or ID unpause : False If ``True`` and the container is paused, it will be unpaused before attempting to stop the container. timeout Timeout in seconds after which the containe...
Unpauses a container
def unpause(name): ''' Unpauses a container name Container name or ID **RETURN DATA** A dictionary will be returned, containing the following keys: - ``status`` - A dictionary showing the prior state of the container as well as the new state - ``result`` - A boolean noting...
Wait for the container to exit gracefully and return its exit code
def wait(name, ignore_already_stopped=False, fail_on_exit_status=False): ''' Wait for the container to exit gracefully, and return its exit code .. note:: This function will block until the container is stopped. name Container name or ID ignore_already_stopped Boolean fla...
.. versionadded:: 2019. 2. 0
def prune(containers=False, networks=False, images=False, build=False, volumes=False, system=None, **filters): ''' .. versionadded:: 2019.2.0 Prune Docker's various subsystems .. note:: This requires docker-py version 2.1.0 or later. containers : False If ``True``, prune...
Common logic for docker. run functions
def _run(name, cmd, exec_driver=None, output=None, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=None): ''' Common logic for docker.run functions ''' if exec_driver is ...
Common logic to run a script on a container
def _script(name, source, saltenv='base', args=None, template=None, exec_driver=None, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=N...
Run: py: func: cmd. script <salt. modules. cmdmod. script > within a container
def script(name, source, saltenv='base', args=None, template=None, exec_driver=None, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=None): ''...
Prepares a self contained tarball that has the state to be applied in the container
def _prepare_trans_tar(name, sls_opts, mods=None, pillar=None, extra_filerefs=''): ''' Prepares a self contained tarball that has the state to be applied in the container ''' chunks = _compile_state(sls_opts, mods) # reuse it from salt.ssh, however this function should ...
Generates the chunks of lowdata from the list of modules
def _compile_state(sls_opts, mods=None): ''' Generates the chunks of lowdata from the list of modules ''' st_ = HighState(sls_opts) if not mods: return st_.compile_low_chunks() high_data, errors = st_.render_highstate({sls_opts['saltenv']: mods}) high_data, ext_errors = st_.state.r...
Executes a Salt function inside a running container
def call(name, function, *args, **kwargs): ''' Executes a Salt function inside a running container .. versionadded:: 2016.11.0 The container does not need to have Salt installed, but Python is required. name Container name or ID function Salt execution module function CL...
.. versionadded:: 2019. 2. 0
def apply_(name, mods=None, **kwargs): ''' .. versionadded:: 2019.2.0 Apply states! This function will call highstate or state.sls based on the arguments passed in, ``apply`` is intended to be the main gateway for all state executions. CLI Example: .. code-block:: bash salt 'dock...
Apply the states defined by the specified SLS modules to the running container
def sls(name, mods=None, **kwargs): ''' Apply the states defined by the specified SLS modules to the running container .. versionadded:: 2016.11.0 The container does not need to have Salt installed, but Python is required. name Container name or ID mods : None A string co...
.. versionchanged:: 2018. 3. 0 The repository and tag must now be passed separately using the repository and tag arguments rather than together in the ( now deprecated ) image argument.
def sls_build(repository, tag='latest', base='opensuse/python', mods=None, dryrun=False, **kwargs): ''' .. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arg...
Checks whether the input is a valid list of peers and transforms domain names into IP Addresses
def _check(peers): '''Checks whether the input is a valid list of peers and transforms domain names into IP Addresses''' if not isinstance(peers, list): return False for peer in peers: if not isinstance(peer, six.string_types): return False if not HAS_NETADDR: # if does ...
Manages the configuration of NTP peers and servers on the device as specified in the state SLS file. NTP entities not specified in these lists will be removed whilst entities not configured on the device will be set.
def managed(name, peers=None, servers=None): ''' Manages the configuration of NTP peers and servers on the device, as specified in the state SLS file. NTP entities not specified in these lists will be removed whilst entities not configured on the device will be set. SLS Example: .. code-block:: y...
Add a virtual service.
def add_service(protocol=None, service_address=None, scheduler='wlc'): ''' Add a virtual service. protocol The service protocol(only support tcp, udp and fwmark service). service_address The LVS service address. scheduler Algorithm for allocating TCP connections and UDP da...
Ensure the kinesis stream is properly configured and scaled.
def present(name, retention_hours=None, enhanced_monitoring=None, num_shards=None, do_reshard=True, region=None, key=None, keyid=None, profile=None): ''' Ensure the kinesis stream is properly configured and scaled. ...
Return information for the specified user
def info(name): ''' Return information for the specified user CLI Example: .. code-block:: bash salt '*' shadow.info someuser ''' try: data = pwd.getpwnam(name) ret = { 'name': data.pw_name, 'passwd': data.pw_passwd} except KeyError: ...
Sets the time at which the password expires ( in seconds since the UNIX epoch ). See man 8 usermod on NetBSD and OpenBSD or man 8 pw on FreeBSD.
def set_change(name, change): ''' Sets the time at which the password expires (in seconds since the UNIX epoch). See ``man 8 usermod`` on NetBSD and OpenBSD or ``man 8 pw`` on FreeBSD. A value of ``0`` sets the password to never expire. CLI Example: .. code-block:: bash salt '*' ...
Sets the time at which the account expires ( in seconds since the UNIX epoch ). See man 8 usermod on NetBSD and OpenBSD or man 8 pw on FreeBSD.
def set_expire(name, expire): ''' Sets the time at which the account expires (in seconds since the UNIX epoch). See ``man 8 usermod`` on NetBSD and OpenBSD or ``man 8 pw`` on FreeBSD. A value of ``0`` sets the account to never expire. CLI Example: .. code-block:: bash salt '*' sh...
Set the password for a named user. The password must be a properly defined hash. The password hash can be generated with this command:
def set_password(name, password): ''' Set the password for a named user. The password must be a properly defined hash. The password hash can be generated with this command: ``python -c "import crypt; print crypt.crypt('password', ciphersalt)"`` .. note:: When constructing the ``ciphersalt`...
Check the token returns a 401 if the token is invalid. Else open the websocket connection
def get(self, token): ''' Check the token, returns a 401 if the token is invalid. Else open the websocket connection ''' log.debug('In the websocket get method') self.token = token # close the connection, if not authenticated if not self.application.auth....
Listens for a websocket client ready message. Once that message is received an asynchronous job is stated that yields messages to the client. These messages make up salt s real time event stream.
def on_message(self, message): """Listens for a "websocket client ready" message. Once that message is received an asynchronous job is stated that yields messages to the client. These messages make up salt's "real time" event stream. """ log.debug('Got websocket m...
If cors is enabled check that the origin is allowed
def check_origin(self, origin): """ If cors is enabled, check that the origin is allowed """ mod_opts = self.application.mod_opts if mod_opts.get('cors_origin'): return bool(_check_cors_origin(origin, mod_opts['cors_origin'])) else: return super(...
Listens for a websocket client ready message. Once that message is received an asynchronous job is stated that yields messages to the client. These messages make up salt s real time event stream.
def on_message(self, message): """Listens for a "websocket client ready" message. Once that message is received an asynchronous job is stated that yields messages to the client. These messages make up salt's "real time" event stream. """ log.debug('Got websocket m...
Return supervisorctl command to call either from a virtualenv an argument passed in or from the global modules options
def _get_supervisorctl_bin(bin_env): ''' Return supervisorctl command to call, either from a virtualenv, an argument passed in, or from the global modules options ''' cmd = 'supervisorctl' if not bin_env: which_result = __salt__['cmd.which_bin']([cmd]) if which_result is None: ...
Return the command list to use
def _ctl_cmd(cmd, name, conf_file, bin_env): ''' Return the command list to use ''' ret = [_get_supervisorctl_bin(bin_env)] if conf_file is not None: ret += ['-c', conf_file] ret.append(cmd) if name: ret.append(name) return ret
Start the named service. Process group names should not include a trailing asterisk.
def start(name='all', user=None, conf_file=None, bin_env=None): ''' Start the named service. Process group names should not include a trailing asterisk. user user to run supervisorctl as conf_file path to supervisord config file bin_env path to supervisorctl bin or path ...
Reload the daemon s configuration files
def reread(user=None, conf_file=None, bin_env=None): ''' Reload the daemon's configuration files user user to run supervisorctl as conf_file path to supervisord config file bin_env path to supervisorctl bin or path to virtualenv with supervisor installed CLI Exa...
Reload config and add/ remove/ update as necessary
def update(user=None, conf_file=None, bin_env=None, name=None): ''' Reload config and add/remove/update as necessary user user to run supervisorctl as conf_file path to supervisord config file bin_env path to supervisorctl bin or path to virtualenv with supervisor in...
List programs and its state
def status(name=None, user=None, conf_file=None, bin_env=None): ''' List programs and its state user user to run supervisorctl as conf_file path to supervisord config file bin_env path to supervisorctl bin or path to virtualenv with supervisor installed CLI Exam...
Display the raw output of status
def status_raw(name=None, user=None, conf_file=None, bin_env=None): ''' Display the raw output of status user user to run supervisorctl as conf_file path to supervisord config file bin_env path to supervisorctl bin or path to virtualenv with supervisor installed ...
Run any custom supervisord command
def custom(command, user=None, conf_file=None, bin_env=None): ''' Run any custom supervisord command user user to run supervisorctl as conf_file path to supervisord config file bin_env path to supervisorctl bin or path to virtualenv with supervisor installed CLI...
Reads the config file using configparser
def _read_config(conf_file=None): ''' Reads the config file using configparser ''' if conf_file is None: paths = ('/etc/supervisor/supervisord.conf', '/etc/supervisord.conf') for path in paths: if os.path.exists(path): conf_file = path break ...
.. versionadded:: 2014. 1. 0
def options(name, conf_file=None): ''' .. versionadded:: 2014.1.0 Read the config file and return the config options for a given process name Name of the configured process conf_file path to supervisord config file CLI Example: .. code-block:: bash salt '*' super...
Add a log to the logadm configuration
def rotate(name, **kwargs): ''' Add a log to the logadm configuration name : string alias for entryname kwargs : boolean|string|int optional additional flags and parameters ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} ...
Remove a log from the logadm configuration
def remove(name, log_file=None): ''' Remove a log from the logadm configuration name : string entryname log_file : string (optional) log file path .. note:: If log_file is specified it will be used instead of the entry name. ''' ret = {'name': name, 'cha...
Add a new inbound or outbound rule to the firewall policy
def add_rule(name, localport, protocol='tcp', action='allow', dir='in', remoteip='any'): ''' Add a new inbound or outbound rule to the firewall policy Args: name (str): The name of the rule. Must be unique and cannot be "all". ...
Delete an existing firewall rule identified by name and optionally by ports protocols direction and remote IP.
def delete_rule(name, localport=None, protocol=None, dir=None, remoteip=None): ''' Delete an existing firewall rule identified by name and optionally by ports, protocols, direction, and remote IP. .. versionadded:: Neon Args: name (str):...
Enable all the firewall profiles ( Windows only )
def enabled(name='allprofiles'): ''' Enable all the firewall profiles (Windows only) Args: profile (Optional[str]): The name of the profile to enable. Default is ``allprofiles``. Valid options are: - allprofiles - domainprofile - privateprofile ...
Send a message to a Mattermost channel.: param channel: The channel name either will work.: param username: The username of the poster.: param message: The message to send to the Mattermost channel.: param api_url: The Mattermost api url if not specified in the configuration.: param hook: The Mattermost hook if not spe...
def post_message(message, channel=None, username=None, api_url=None, hook=None): ''' Send a message to a Mattermost channel. :param channel: The channel name, either will work. :param username: The username of the poster. :pa...
Send an event to a Mattermost channel.: param channel: The channel name either will work.: param username: The username of the poster.: param event: The event to send to the Mattermost channel.: param api_url: The Mattermost api url if not specified in the configuration.: param hook: The Mattermost hook if not specifie...
def post_event(event, channel=None, username=None, api_url=None, hook=None): ''' Send an event to a Mattermost channel. :param channel: The channel name, either will work. :param username: The username of the poster. :param event: ...