INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
List the recent events.
def event_list(consul_url=None, token=None, **kwargs): ''' List the recent events. :param consul_url: The Consul server URL. :param name: The name of the event to fire. :return: List of ACLs CLI Example: .. code-block:: bash salt '*' consul.event_list ''' ret = {} qu...
Ensure a sysrc variable is set to a specific value.
def managed(name, value, **kwargs): ''' Ensure a sysrc variable is set to a specific value. name The variable name to set value Value to set the variable to file (optional) The rc file to add the variable to. jail (option) the name or JID of the jail to set the v...
.. versionadded:: 0. 14
def get(key, default='', merge=False, delimiter=DEFAULT_TARGET_DELIM): ''' .. versionadded:: 0.14 Attempt to retrieve the named value from pillar, if the named value is not available return the passed default. The default return is an empty string. If the merge parameter is set to ``True``, the de...
.. versionadded:: 0. 16. 2
def item(*args): ''' .. versionadded:: 0.16.2 Return one or more pillar entries CLI Examples: .. code-block:: bash salt '*' pillar.item foo salt '*' pillar.item foo bar baz ''' ret = {} for arg in args: try: ret[arg] = __pillar__[arg] excep...
Return the raw pillar data that is available in the module. This will show the pillar as it is loaded as the __pillar__ dict.
def raw(key=None): ''' Return the raw pillar data that is available in the module. This will show the pillar as it is loaded as the __pillar__ dict. CLI Example: .. code-block:: bash salt '*' pillar.raw With the optional key argument, you can select a subtree of the pillar raw da...
.. versionadded:: 2015. 8. 0
def keys(key, delimiter=DEFAULT_TARGET_DELIM): ''' .. versionadded:: 2015.8.0 Attempt to retrieve a list of keys from the named value from the pillar. The value can also represent a value in a nested dict using a ":" delimiter for the dict, similar to how pillar.get works. delimiter S...
Ensure domain exists.
def present(name, DomainName, ElasticsearchClusterConfig=None, EBSOptions=None, AccessPolicies=None, SnapshotOptions=None, AdvancedOptions=None, Tags=None, region=None, key=None, keyid=None, profile=None, ElasticsearchVersio...
Init the database if required.
def open(self, new=False): ''' Init the database, if required. ''' self._db.new() if new else self._db.open() # pylint: disable=W0106 self._run_init_queries()
Initialization queries
def _run_init_queries(self): ''' Initialization queries ''' for obj in (Package, PackageCfgFile, PayloadFile, IgnoredDir, AllowedDir): self._db.create_table_from_object(obj())
Purge whole database.
def purge(self): ''' Purge whole database. ''' for table_name in self._db.list_tables(): self._db.flush(table_name) self._run_init_queries()
Helper function that returns a profile s configuration value based on the supplied configuration name.
def _get_config_value(profile, config_name): ''' Helper function that returns a profile's configuration value based on the supplied configuration name. profile The profile name that contains configuration information. config_name The configuration item's name to use to return confi...
Return the GitHub client cached into __context__ for performance
def _get_client(profile): ''' Return the GitHub client, cached into __context__ for performance ''' token = _get_config_value(profile, 'token') key = 'github.{0}:{1}'.format( token, _get_config_value(profile, 'org_name') ) if key not in __context__: __context__[key] ...
List all users within the organization.
def list_users(profile="github", ignore_cache=False): ''' List all users within the organization. profile The name of the profile configuration to use. Defaults to ``github``. ignore_cache Bypasses the use of cached users. .. versionadded:: 2016.11.0 CLI Example: .. ...
Get a GitHub user by name.
def get_user(name, profile='github', user_details=False): ''' Get a GitHub user by name. name The user for which to obtain information. profile The name of the profile configuration to use. Defaults to ``github``. user_details Prints user information details. Defaults to `...
Add a GitHub user.
def add_user(name, profile='github'): ''' Add a GitHub user. name The user for which to obtain information. profile The name of the profile configuration to use. Defaults to ``github``. CLI Example: .. code-block:: bash salt myminion github.add_user github-handle ...
Remove a Github user by name.
def remove_user(name, profile='github'): ''' Remove a Github user by name. name The user for which to obtain information. profile The name of the profile configuration to use. Defaults to ``github``. CLI Example: .. code-block:: bash salt myminion github.remove_user ...
Return information about a single issue in a named repository.
def get_issue(issue_number, repo_name=None, profile='github', output='min'): ''' Return information about a single issue in a named repository. .. versionadded:: 2016.11.0 issue_number The number of the issue to retrieve. repo_name The name of the repository from which to get the ...
Return information about the comments for a given issue in a named repository.
def get_issue_comments(issue_number, repo_name=None, profile='github', since=None, output='min'): ''' Return information about the comments for a given issue in a named repository. .. versionadded:: 2016.11.0 i...
Returns information for all issues in a given repository based on the search options.
def get_issues(repo_name=None, profile='github', milestone=None, state='open', assignee=None, creator=None, mentioned=None, labels=None, sort='created', direction='desc', ...
Return information about milestones for a given repository.
def get_milestones(repo_name=None, profile='github', state='open', sort='due_on', direction='asc', output='min', per_page=None): ''' Return information about milestones for a given repository. ...
Return information about a single milestone in a named repository.
def get_milestone(number=None, name=None, repo_name=None, profile='github', output='min'): ''' Return information about a single milestone in a named repository. .. versionadded:: 2016.11.0 number The number of the milesto...
Return information for a given repo.
def get_repo_info(repo_name, profile='github', ignore_cache=False): ''' Return information for a given repo. .. versionadded:: 2016.11.0 repo_name The name of the repository. profile The name of the profile configuration to use. Defaults to ``github``. CLI Example: .. co...
Return teams belonging to a repository.
def get_repo_teams(repo_name, profile='github'): ''' Return teams belonging to a repository. .. versionadded:: 2017.7.0 repo_name The name of the repository from which to retrieve teams. profile The name of the profile configuration to use. Defaults to ``github``. CLI Example...
List private repositories within the organization. Dependent upon the access rights of the profile token.
def list_private_repos(profile='github'): ''' List private repositories within the organization. Dependent upon the access rights of the profile token. .. versionadded:: 2016.11.0 profile The name of the profile configuration to use. Defaults to ``github``. CLI Example: .. code-b...
List public repositories within the organization.
def list_public_repos(profile='github'): ''' List public repositories within the organization. .. versionadded:: 2016.11.0 profile The name of the profile configuration to use. Defaults to ``github``. CLI Example: .. code-block:: bash salt myminion github.list_public_repos ...
Create a new github repository.
def add_repo(name, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, auto_init=None, gitignore_template=None, license_template=None, profile=...
Updates an existing Github repository.
def edit_repo(name, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, profile="github"): ''' Updates an existing Github repository. name The name of the...
Remove a Github repository.
def remove_repo(name, profile="github"): ''' Remove a Github repository. name The name of the repository to be removed. profile The name of the profile configuration to use. Defaults to ``github``. CLI Example: .. code-block:: bash salt myminion github.remove_repo 'm...
Create a new Github team within an organization.
def add_team(name, description=None, repo_names=None, privacy=None, permission=None, profile="github"): ''' Create a new Github team within an organization. name The name of the team to be created. description The descrip...
Updates an existing Github team.
def edit_team(name, description=None, privacy=None, permission=None, profile="github"): ''' Updates an existing Github team. name The name of the team to be edited. description The description of the team. privacy The...
Remove a github team.
def remove_team(name, profile="github"): ''' Remove a github team. name The name of the team to be removed. profile The name of the profile configuration to use. Defaults to ``github``. CLI Example: .. code-block:: bash salt myminion github.remove_team 'team_name' ...
Gets the repo details for a given team as a dict from repo_name to repo details. Note that repo names are always in lower case.
def list_team_repos(team_name, profile="github", ignore_cache=False): ''' Gets the repo details for a given team as a dict from repo_name to repo details. Note that repo names are always in lower case. team_name The name of the team from which to list repos. profile The name of the...
Adds a repository to a team with team_name.
def add_team_repo(repo_name, team_name, profile="github", permission=None): ''' Adds a repository to a team with team_name. repo_name The name of the repository to add. team_name The name of the team of which to add the repository. profile The name of the profile configura...
Removes a repository from a team with team_name.
def remove_team_repo(repo_name, team_name, profile="github"): ''' Removes a repository from a team with team_name. repo_name The name of the repository to remove. team_name The name of the team of which to remove the repository. profile The name of the profile configuratio...
Gets the names of team members in lower case.
def list_team_members(team_name, profile="github", ignore_cache=False): ''' Gets the names of team members in lower case. team_name The name of the team from which to list members. profile The name of the profile configuration to use. Defaults to ``github``. ignore_cache B...
List all members ( in lower case ) without MFA turned on.
def list_members_without_mfa(profile="github", ignore_cache=False): ''' List all members (in lower case) without MFA turned on. profile The name of the profile configuration to use. Defaults to ``github``. ignore_cache Bypasses the use of cached team repos. CLI Example: .. co...
Returns True if the github user is in the team with team_name or False otherwise.
def is_team_member(name, team_name, profile="github"): ''' Returns True if the github user is in the team with team_name, or False otherwise. name The name of the user whose membership to check. team_name The name of the team to check membership in. profile The name of...
Adds a team member to a team with team_name.
def add_team_member(name, team_name, profile="github"): ''' Adds a team member to a team with team_name. name The name of the team member to add. team_name The name of the team of which to add the user. profile The name of the profile configuration to use. Defaults to ``gi...
Removes a team member from a team with team_name.
def remove_team_member(name, team_name, profile="github"): ''' Removes a team member from a team with team_name. name The name of the team member to remove. team_name The name of the team from which to remove the user. profile The name of the profile configuration to use. ...
Lists all teams with the organization.
def list_teams(profile="github", ignore_cache=False): ''' Lists all teams with the organization. profile The name of the profile configuration to use. Defaults to ``github``. ignore_cache Bypasses the use of cached teams. CLI Example: .. code-block:: bash salt mymini...
Returns information for all pull requests in a given repository based on the search options provided.
def get_prs(repo_name=None, profile='github', state='open', head=None, base=None, sort='created', direction='desc', output='min', per_page=None): ''' Returns information for all pull requests in a given repository, b...
Helper function to format API return information into a more manageable and useful dictionary for pull request information.
def _format_pr(pr_): ''' Helper function to format API return information into a more manageable and useful dictionary for pull request information. pr_ The pull request to format. ''' ret = {'id': pr_.get('id'), 'pr_number': pr_.get('number'), 'state': pr_.get('st...
Helper function to format API return information into a more manageable and useful dictionary for issue information.
def _format_issue(issue): ''' Helper function to format API return information into a more manageable and useful dictionary for issue information. issue The issue to format. ''' ret = {'id': issue.get('id'), 'issue_number': issue.get('number'), 'state': issue.get('...
Make a web call to the GitHub API and deal with paginated results.
def _query(profile, action=None, command=None, args=None, method='GET', header_dict=None, data=None, url='https://api.github.com/', per_page=None): ''' Make a web call to the GitHub API and deal with paginated results. '...
Returns the last created baseline snapshot marked with tag
def _get_baseline_from_tag(config, tag): ''' Returns the last created baseline snapshot marked with `tag` ''' last_snapshot = None for snapshot in __salt__['snapper.list_snapshots'](config): if tag == snapshot['userdata'].get("baseline_tag"): if not last_snapshot or last_snapshot...
Enforces that no file is modified comparing against a previously defined snapshot identified by number.
def baseline_snapshot(name, number=None, tag=None, include_diff=True, config='root', ignore=None): ''' Enforces that no file is modified comparing against a previously defined snapshot identified by number. number Number of selected baseline snapshot. tag Tag of the selected baseli...
Crash to the log if command execution was not successful.
def _verify_run(out, cmd=None): ''' Crash to the log if command execution was not successful. ''' if out.get('retcode', 0) and out['stderr']: if cmd: log.debug('Command: \'%s\'', cmd) log.debug('Return code: %s', out.get('retcode')) log.debug('Error output:\n%s', out...
List mounted filesystems.
def _get_mounts(fs_type=None): ''' List mounted filesystems. ''' mounts = {} with salt.utils.files.fopen('/proc/mounts') as fhr: for line in fhr.readlines(): line = salt.utils.stringutils.to_unicode(line) device, mntpnt, fstype, options, fs_freq, fs_passno = line.stri...
Parse blkid output.
def _blkid_output(out, fs_type=None): ''' Parse blkid output. ''' flt = lambda data: [el for el in data if el.strip()] data = {} for dev_meta in flt(out.split('\n\n')): dev = {} for items in flt(dev_meta.strip().split('\n')): key, val = items.split('=', 1) ...
Return available media devices.
def _blkid(fs_type=None): ''' Return available media devices. :param fs_type: Filter only devices that are formatted by that file system. ''' flt = lambda data: [el for el in data if el.strip()] data = dict() for dev_meta in flt(os.popen("blkid -o full").read().split(os.linesep)): # No __s...
Return True if path is a physical device.
def _is_device(path): ''' Return True if path is a physical device. ''' out = __salt__['cmd.run_all']('file -i {0}'.format(path)) _verify_run(out) # Always [device, mime, charset]. See (file --help) return re.split(r'\s+', out['stdout'])[1][:-1] == 'inode/blockdevice'
Send an mattermost message with the data
def returner(ret): ''' Send an mattermost message with the data ''' _options = _get_options(ret) api_url = _options.get('api_url') channel = _options.get('channel') username = _options.get('username') hook = _options.get('hook') if not hook: log.error('mattermost.hook not ...
Send the events to a mattermost room.
def event_return(events): ''' Send the events to a mattermost room. :param events: List of events :return: Boolean if messages were sent successfully. ''' _options = _get_options() api_url = _options.get('api_url') channel = _options.get('channel') username = _optio...
Send a message to a mattermost room.
def post_message(channel, message, username, api_url, hook): ''' Send a message to a mattermost room. :param channel: The room name. :param message: The message to send to the mattermost room. :param username: Specify wh...
Create Znode
def create(path, value='', acls=None, ephemeral=False, sequence=False, makepath=False, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Create Znode path path of znode to create value value to assign to znode (Default: '') acls...
Ensure Znode path exists
def ensure_path(path, acls=None, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Ensure Znode path exists path Parent path to create acls list of acls dictionaries to be assigned (Default: None) profile Configured...
Check if path exists
def exists(path, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Check if path exists path path to check profile Configured Zookeeper profile to authenticate with (Default: None) hosts Lists of Zookeeper Hosts (Default: '127.0.0....
Get value saved in znode
def get(path, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Get value saved in znode path path to check profile Configured Zookeeper profile to authenticate with (Default: None) hosts Lists of Zookeeper Hosts (Default: '127.0.0...
Get children in znode path
def get_children(path, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Get children in znode path path path to check profile Configured Zookeeper profile to authenticate with (Default: None) hosts Lists of Zookeeper Hosts (Defaul...
Update znode with new value
def set(path, value, version=-1, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Update znode with new value path znode to update value value to set in znode version only update znode if version matches (Default: -1 (alwa...
Get acls on a znode
def get_acls(path, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Get acls on a znode path path to znode profile Configured Zookeeper profile to authenticate with (Default: None) hosts Lists of Zookeeper Hosts (Default: '127.0.0...
Set acls on a znode
def set_acls(path, acls, version=-1, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Set acls on a znode path path to znode acls list of acl dictionaries to set on the znode version only set acls if version matches (...
Delete znode
def delete(path, version=-1, recursive=False, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Delete znode path path to znode version only delete if version matches (Default: -1 (always matches)) profile Configured Zoo...
Generate acl object
def make_digest_acl(username, password, read=False, write=False, create=False, delete=False, admin=False, allperms=False): ''' Generate acl object .. note:: This is heavily used in the zookeeper state and probably is not useful as a cli module username username of acl ...
Mattermost object method function to construct and execute on the API URL.: param api_url: The Mattermost API URL: param hook: The Mattermost hook.: param data: The data to be sent for POST method.: return: The json response from the API call or False.
def query(hook=None, api_url=None, data=None): ''' Mattermost object method function to construct and execute on the API URL. :param api_url: The Mattermost API URL :param hook: The Mattermost hook. :param data: The data to be sent for POST method. :return: ...
Read pillar data from Confidant via its API.
def ext_pillar(minion_id, pillar, profile=None): ''' Read pillar data from Confidant via its API. ''' if profile is None: profile = {} # default to returning failure ret = { 'credentials_result': False, 'credentials': None, 'credentials_metadata': None } p...
Setup the temporary console logger
def setup_temp_logger(log_level='error'): ''' Setup the temporary console logger ''' if is_temp_logging_configured(): logging.getLogger(__name__).warning( 'Temporary logging is already configured' ) return if log_level is None: log_level = 'warning' ...
Setup the console logger
def setup_console_logger(log_level='error', log_format=None, date_format=None): ''' Setup the console logger ''' if is_console_configured(): logging.getLogger(__name__).warning('Console logging already configured') return # Remove the temporary logging handler __remove_temp_logg...
Setup the logfile logger
def setup_logfile_logger(log_path, log_level='error', log_format=None, date_format=None, max_bytes=0, backup_count=0): ''' Setup the logfile logger Since version 0.10.6 we support logging to syslog, some examples: tcp://localhost:514/LOG_USER tcp://localhost/LOG_DA...
Setup any additional logging handlers internal or external
def setup_extended_logging(opts): ''' Setup any additional logging handlers, internal or external ''' if is_extended_logging_configured() is True: # Don't re-configure external loggers return # Explicit late import of salt's loader import salt.loader # Let's keep a referenc...
This will set the multiprocessing logging level to the lowest logging level of all the types of logging that are configured.
def set_multiprocessing_logging_level_by_opts(opts): ''' This will set the multiprocessing logging level to the lowest logging level of all the types of logging that are configured. ''' global __MP_LOGGING_LEVEL log_levels = [ LOG_LEVELS.get(opts.get('log_level', '').lower(), logging.ER...
This code should be called from within a running multiprocessing process instance.
def setup_multiprocessing_logging(queue=None): ''' This code should be called from within a running multiprocessing process instance. ''' from salt.utils.platform import is_windows global __MP_LOGGING_CONFIGURED global __MP_LOGGING_QUEUE_HANDLER if __MP_IN_MAINPROCESS is True and not i...
Tweak a specific logger s logging level
def set_logger_level(logger_name, log_level='error'): ''' Tweak a specific logger's logging level ''' logging.getLogger(logger_name).setLevel( LOG_LEVELS.get(log_level.lower(), logging.ERROR) )
Patch the python logging handlers with out mixed - in classes
def patch_python_logging_handlers(): ''' Patch the python logging handlers with out mixed-in classes ''' logging.StreamHandler = StreamHandler logging.FileHandler = FileHandler logging.handlers.SysLogHandler = SysLogHandler logging.handlers.WatchedFileHandler = WatchedFileHandler logging...
This function will run once the temporary logging has been configured. It just removes the NullHandler from the logging handlers.
def __remove_null_logging_handler(): ''' This function will run once the temporary logging has been configured. It just removes the NullHandler from the logging handlers. ''' global LOGGING_NULL_HANDLER if LOGGING_NULL_HANDLER is None: # Already removed return root_logger = ...
This function will run once the additional loggers have been synchronized. It just removes the QueueLoggingHandler from the logging handlers.
def __remove_queue_logging_handler(): ''' This function will run once the additional loggers have been synchronized. It just removes the QueueLoggingHandler from the logging handlers. ''' global LOGGING_STORE_HANDLER if LOGGING_STORE_HANDLER is None: # Already removed return ...
This function will run once logging has been configured. It just removes the temporary stream Handler from the logging handlers.
def __remove_temp_logging_handler(): ''' This function will run once logging has been configured. It just removes the temporary stream Handler from the logging handlers. ''' if is_logging_configured(): # In this case, the temporary logging handler has been removed, return! return ...
This function will log all un - handled python exceptions.
def __global_logging_exception_handler(exc_type, exc_value, exc_traceback): ''' This function will log all un-handled python exceptions. ''' if exc_type.__name__ == "KeyboardInterrupt": # Do not log the exception or display the traceback on Keyboard Interrupt # Stop the logging queue lis...
Parse GRUB conf file
def conf(): ''' Parse GRUB conf file CLI Example: .. code-block:: bash salt '*' grub.conf ''' stanza = '' stanzas = [] in_stanza = False ret = {} pos = 0 try: with salt.utils.files.fopen(_detect_conf(), 'r') as _fp: for line in _fp: ...
Used by conf () to break config lines into name/ value pairs
def _parse_line(line=''): ''' Used by conf() to break config lines into name/value pairs ''' parts = line.split() key = parts.pop(0) value = ' '.join(parts) return key, value
Display upgrade impact information without actually upgrading the device.
def check_upgrade_impact(system_image, kickstart_image=None, issu=True, **kwargs): ''' Display upgrade impact information without actually upgrading the device. system_image (Mandatory Option) Path on bootflash: to system image upgrade file. kickstart_image Path on bootflash: to kickst...
Upgrade NX - OS switch.
def upgrade(system_image, kickstart_image=None, issu=True, **kwargs): ''' Upgrade NX-OS switch. system_image (Mandatory Option) Path on bootflash: to system image upgrade file. kickstart_image Path on bootflash: to kickstart image upgrade file. (Not required if using combined s...
Helper method that does the heavy lifting for upgrades.
def _upgrade(system_image, kickstart_image, issu, **kwargs): ''' Helper method that does the heavy lifting for upgrades. ''' si = system_image ki = kickstart_image dev = 'bootflash' cmd = 'terminal dont-ask ; install all' if ki is None: logmsg = 'Upgrading device using combined ...
Helper method to parse upgrade data from the NX - OS device.
def _parse_upgrade_data(data): ''' Helper method to parse upgrade data from the NX-OS device. ''' upgrade_result = {} upgrade_result['upgrade_data'] = None upgrade_result['succeeded'] = False upgrade_result['upgrade_required'] = False upgrade_result['upgrade_non_disruptive'] = False ...
Standardizes all responses
def __standardize_result(status, message, data=None, debug_msg=None): ''' Standardizes all responses :param status: :param message: :param data: :param debug_msg: :return: ''' result = { 'status': status, 'message': message } if data is not None: res...
Determines the filepath to use
def __get_docker_file_path(path): ''' Determines the filepath to use :param path: :return: ''' if os.path.isfile(path): return path for dc_filename in DEFAULT_DC_FILENAMES: file_path = os.path.join(path, dc_filename) if os.path.isfile(file_path): return f...
Read the compose file if it exists in the directory
def __read_docker_compose_file(file_path): ''' Read the compose file if it exists in the directory :param file_path: :return: ''' if not os.path.isfile(file_path): return __standardize_result(False, 'Path {} is not present'.format(file_path), ...
Read the compose file and load its contents
def __load_docker_compose(path): ''' Read the compose file and load its' contents :param path: :return: ''' file_path = __get_docker_file_path(path) if file_path is None: msg = 'Could not find docker-compose file at {0}'.format(path) return None, __standardize_result(False, ...
Dumps
def __dump_docker_compose(path, content, already_existed): ''' Dumps :param path: :param content: the not-yet dumped content :return: ''' try: dumped = yaml.safe_dump(content, indent=2, default_flow_style=False) return __write_docker_compose(path, dumped, already_existed) ...
Write docker - compose to a path in order to use it with docker - compose ( config check )
def __write_docker_compose(path, docker_compose, already_existed): ''' Write docker-compose to a path in order to use it with docker-compose ( config check ) :param path: docker_compose contains the docker-compose file :return: ''' if path.lower().endswith(('.yml', '.yaml')): ...
Load a docker - compose project from path
def __load_project(path): ''' Load a docker-compose project from path :param path: :return: ''' file_path = __get_docker_file_path(path) if file_path is None: msg = 'Could not find docker-compose file at {0}'.format(path) return __standardize_result(False, ...
Load a docker - compose project from file path
def __load_project_from_file_path(file_path): ''' Load a docker-compose project from file path :param path: :return: ''' try: project = get_project(project_dir=os.path.dirname(file_path), config_path=[os.path.basename(file_path)]) except Exception as in...
Will load the compose file located at path Then determines the format/ contents of the sent definition
def __load_compose_definitions(path, definition): ''' Will load the compose file located at path Then determines the format/contents of the sent definition err or results are only set if there were any :param path: :param definition: :return tuple(compose_result, loaded_definition, err): ...
Utility function to dump the compose result to a file.
def __dump_compose_file(path, compose_result, success_msg, already_existed): ''' Utility function to dump the compose result to a file. :param path: :param compose_result: :param success_msg: the message to give upon success :return: ''' ret = __dump_docker_compose(path, ...
Get action executed for each container
def _get_convergence_plans(project, service_names): ''' Get action executed for each container :param project: :param service_names: :return: ''' ret = {} plans = project._get_convergence_plans(project.get_services(service_names), ConvergenceSt...
Get the content of the docker - compose file into a directory
def get(path): ''' Get the content of the docker-compose file into a directory path Path where the docker-compose file is stored on the server CLI Example: .. code-block:: bash salt myminion dockercompose.get /path/where/docker-compose/stored ''' file_path = __get_docker_...
Create and validate a docker - compose file into a directory
def create(path, docker_compose): ''' Create and validate a docker-compose file into a directory path Path where the docker-compose file will be stored on the server docker_compose docker_compose file CLI Example: .. code-block:: bash salt myminion dockercompose.crea...
Pull image for containers in the docker - compose file service_names is a python list if omitted pull all images
def pull(path, service_names=None): ''' Pull image for containers in the docker-compose file, service_names is a python list, if omitted pull all images path Path where the docker-compose file is stored on the server service_names If specified will pull only the image for the specif...
Pause running containers in the docker - compose file service_names is a python list if omitted pause all containers
def pause(path, service_names=None): ''' Pause running containers in the docker-compose file, service_names is a python list, if omitted pause all containers path Path where the docker-compose file is stored on the server service_names If specified will pause only the specified serv...
Remove stopped containers in the docker - compose file service_names is a python list if omitted remove all stopped containers
def rm(path, service_names=None): ''' Remove stopped containers in the docker-compose file, service_names is a python list, if omitted remove all stopped containers path Path where the docker-compose file is stored on the server service_names If specified will remove only the specif...