text
stringlengths
81
112k
Modify a service's parameters. Changes will not be made for parameters that are not passed. .. versionadded:: 2016.11.0 Args: name (str): The name of the service. Can be found using the ``service.get_service_name`` function bin_path (str): The path to t...
Enable the named service to start at boot Args: name (str): The name of the service to enable. start_type (str): Specifies the service start type. Valid options are as follows: - boot: Device driver that is loaded by the boot loader - system: Device driver that...
Create the named service. .. versionadded:: 2015.8.0 Args: name (str): Specifies the service name. This is not the display_name bin_path (str): Specifies the path to the service binary file. Backslashes must be escaped, eg: ``C:\\path\\to\\binary.exe`` ...
Delete the named service Args: name (str): The name of the service to delete timeout (int): The time in seconds to wait for the service to be deleted before returning. This is necessary because a service must be stopped before it can be deleted. Default is 90 s...
Return a conn object for the passed VM data def get_conn(): ''' Return a conn object for the passed VM data ''' driver = get_driver(Provider.CLOUDSTACK) verify_ssl_cert = config.get_cloud_config_value('verify_ssl_cert', get_configured_provider(), __opts__, defau...
Return the node location to use def get_location(conn, vm_): ''' Return the node location to use ''' locations = conn.list_locations() # Default to Dallas if not otherwise set loc = config.get_cloud_config_value('location', vm_, __opts__, default=2) for location in locations: if six...
Return a list of security groups to use, defaulting to ['default'] def get_security_groups(conn, vm_): ''' Return a list of security groups to use, defaulting to ['default'] ''' securitygroup_enabled = config.get_cloud_config_value( 'securitygroup_enabled', vm_, __opts__, default=True ) ...
Return the keypair to use def get_keypair(vm_): ''' Return the keypair to use ''' keypair = config.get_cloud_config_value('keypair', vm_, __opts__) if keypair: return keypair else: return False
Return the IP address of the VM If the VM has public IP as defined by libcloud module then use it Otherwise try to extract the private IP and use that one. def get_ip(data): ''' Return the IP address of the VM If the VM has public IP as defined by libcloud module then use it Otherwise try to ...
Return the networkid to use, only valid for Advanced Zone def get_networkid(vm_): ''' Return the networkid to use, only valid for Advanced Zone ''' networkid = config.get_cloud_config_value('networkid', vm_, __opts__) if networkid is not None: return networkid else: return Fals...
Return the project to use. def get_project(conn, vm_): ''' Return the project to use. ''' try: projects = conn.ex_list_projects() except AttributeError: # with versions <0.15 of libcloud this is causing an AttributeError. log.warning('Cannot get projects, you may need to upd...
Create a single VM from a data dict def create(vm_): ''' Create a single VM from a data dict ''' try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, ...
Delete a single VM, and all of its volumes def destroy(name, conn=None, call=None): ''' Delete a single VM, and all of its volumes ''' if call == 'function': raise SaltCloudSystemExit( 'The destroy action must be called with -d, --destroy, ' '-a or --action.' ) ...
Return system rc configuration variables CLI Example: .. code-block:: bash salt '*' sysrc.get includeDefaults=True def get(**kwargs): ''' Return system rc configuration variables CLI Example: .. code-block:: bash salt '*' sysrc.get includeDefaults=True ''' cmd...
Set system rc configuration variables CLI Example: .. code-block:: bash salt '*' sysrc.set name=sshd_flags value="-p 2222" def set_(name, value, **kwargs): ''' Set system rc configuration variables CLI Example: .. code-block:: bash salt '*' sysrc.set name=sshd_flags va...
Remove system rc configuration variables CLI Example: .. code-block:: bash salt '*' sysrc.remove name=sshd_enable def remove(name, **kwargs): ''' Remove system rc configuration variables CLI Example: .. code-block:: bash salt '*' sysrc.remove name=sshd_enable ''' ...
Create a single VM from a data dict def create(vm_): ''' Create a single VM from a data dict ''' try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured( __opts__, __active_provider_nam...
r''' Create a load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f create_lb dimensiondata \ name=dev-lb port=80 protocol=http \ members=w1,w2,w3 algorithm=ROUND_ROBIN def create_lb(kwargs=None, call=None): r''' Create a load-balancer config...
Stop a VM in DimensionData. name: The name of the VM to stop. CLI Example: .. code-block:: bash salt-cloud -a stop vm_name def stop(name, call=None): ''' Stop a VM in DimensionData. name: The name of the VM to stop. CLI Example: .. code-block:: bash ...
Stop a VM in DimensionData. :param str name: The name of the VM to stop. CLI Example: .. code-block:: bash salt-cloud -a stop vm_name def start(name, call=None): ''' Stop a VM in DimensionData. :param str name: The name of the VM to stop. CLI Example: .. c...
Return a conn object for the passed VM data def get_conn(): ''' Return a conn object for the passed VM data ''' vm_ = get_configured_provider() driver = get_driver(Provider.DIMENSIONDATA) region = config.get_cloud_config_value( 'region', vm_, __opts__ ) user_id = config.get_c...
Return a load-balancer conn object def get_lb_conn(dd_driver=None): ''' Return a load-balancer conn object ''' vm_ = get_configured_provider() region = config.get_cloud_config_value( 'region', vm_, __opts__ ) user_id = config.get_cloud_config_value( 'user_id', vm_, __opts__...
Convert the specified object into a form that can be serialised by msgpack as event data. :param obj: The object to convert. def _to_event_data(obj): ''' Convert the specified object into a form that can be serialised by msgpack as event data. :param obj: The object to convert. ''' if obj is...
Install a "package" on the REST server def package_install(name, **kwargs): ''' Install a "package" on the REST server ''' DETAILS = _load_state() if kwargs.get('version', False): version = kwargs['version'] else: version = '1.0' DETAILS['packages'][name] = version _save...
"Upgrade" packages def upgrade(): ''' "Upgrade" packages ''' DETAILS = _load_state() pkgs = uptodate() DETAILS['packages'] = pkgs _save_state(DETAILS) return pkgs
Call the REST endpoint to see if the packages on the "server" are up to date. def uptodate(): ''' Call the REST endpoint to see if the packages on the "server" are up to date. ''' DETAILS = _load_state() for p in DETAILS['packages']: version_float = float(DETAILS['packages'][p]) ver...
Remove a "package" on the REST server def package_remove(name): ''' Remove a "package" on the REST server ''' DETAILS = _load_state() DETAILS['packages'].pop(name) _save_state(DETAILS) return DETAILS['packages']
For this proxy shutdown is a no-op def shutdown(opts): ''' For this proxy shutdown is a no-op ''' log.debug('dummy proxy shutdown() called...') DETAILS = _load_state() if 'filename' in DETAILS: os.unlink(DETAILS['filename'])
Opens archive. :return: def open(self): ''' Opens archive. :return: ''' if self.__arch is not None: raise salt.exceptions.SaltException('Archive already opened.') self.__arch = tarfile.TarFile.bz2open(self.archive_path, 'w')
Closes the archive. :return: def close(self): ''' Closes the archive. :return: ''' if self.__arch is None: raise salt.exceptions.SaltException('Archive already closed') self._flush_content() self.__arch.close() self.__arch = None
Flush content to the archive :return: def _flush_content(self): ''' Flush content to the archive :return: ''' if self.__current_section is not None: buff = BytesIO() buff._dirty = False for action_return in self.__current_section: ...
Start a new section. :param name: :return: def add(self, name): ''' Start a new section. :param name: :return: ''' if self.__current_section: self._flush_content() self.discard_current(name)
Use salt outputter to printout content. :return: def _printout(self, data, output): ''' Use salt outputter to printout content. :return: ''' opts = {'extension_modules': '', 'color': False} try: printout = salt.output.get_printout(output, opts)(data...
Add a data to the current opened section. :return: def write(self, title, data, output=None): ''' Add a data to the current opened section. :return: ''' if not isinstance(data, (dict, list, tuple)): data = {'raw-content': str(data)} output = output or...
Add a static file on the file system. :param title: :param path: :return: def link(self, title, path): ''' Add a static file on the file system. :param title: :param path: :return: ''' # The filehandler needs to be explicitly passed here...
Setup function configuration. :param conf: :return: def _setup_fun_config(self, fun_conf): ''' Setup function configuration. :param conf: :return: ''' conf = copy.deepcopy(self.config) conf['file_client'] = 'local' conf['fun'] = '' ...
Get & setup runner. :param conf: :return: def _get_runner(self, conf): ''' Get & setup runner. :param conf: :return: ''' conf = self._setup_fun_config(copy.deepcopy(conf)) if not getattr(self, '_runner', None): self._runner = salt.cl...
Get & setup caller from the factory. :param conf: :return: def _get_caller(self, conf): ''' Get & setup caller from the factory. :param conf: :return: ''' conf = self._setup_fun_config(copy.deepcopy(conf)) if not getattr(self, '_caller', None): ...
Execute local call def _local_call(self, call_conf): ''' Execute local call ''' try: ret = self._get_caller(call_conf).call() except SystemExit: ret = 'Data is not available at this moment' self.out.error(ret) except Exception as ex: ...
Execute local runner :param run_conf: :return: def _local_run(self, run_conf): ''' Execute local runner :param run_conf: :return: ''' try: ret = self._get_runner(run_conf).run() except SystemExit: ret = 'Runner is not ava...
Call internal function. :param call_conf: :return: def _internal_function_call(self, call_conf): ''' Call internal function. :param call_conf: :return: ''' def stub(*args, **kwargs): message = 'Function {} is not available'.format(call_conf[...
Parse action and turn into a calling point. :param action_meta: :return: def _get_action(self, action_meta): ''' Parse action and turn into a calling point. :param action_meta: :return: ''' conf = { 'fun': list(action_meta.keys())[0], ...
Dumps current running pillars, configuration etc. :return: def collect_internal_data(self): ''' Dumps current running pillars, configuration etc. :return: ''' section = 'configuration' self.out.put(section) self.collector.add(section) self.out.put...
Extracts return data from the results. :param data: :return: def _extract_return(self, data): ''' Extracts return data from the results. :param data: :return: ''' if isinstance(data, dict): data = data.get('return', data) return dat...
Collects master system data. :return: def collect_local_data(self, profile=None, profile_source=None): ''' Collects master system data. :return: ''' def call(func, *args, **kwargs): ''' Call wrapper for templates :param func: ...
Get action type. :param action: :return: def _get_action_type(self, action): ''' Get action type. :param action: :return: ''' action_name = next(iter(action or {'': None})) if ':' not in action_name: action_name = '{}:{}'.format(self.C...
Cleanup if crash/exception :return: def _cleanup(self): ''' Cleanup if crash/exception :return: ''' if (hasattr(self, 'config') and self.config.get('support_archive') and os.path.exists(self.config['support_archive'])): self.out.warning(...
Check if archive exists or not. If exists and --force was not specified, bail out. Otherwise remove it and move on. :return: def _check_existing_archive(self): ''' Check if archive exists or not. If exists and --force was not specified, bail out. Otherwise remove it and move on...
Run the SPM command def run(self, args): ''' Run the SPM command ''' command = args[0] try: if command == 'install': self._install(args) elif command == 'local': self._local(args) elif command == 'repo': ...
Process local commands def _list(self, args): ''' Process local commands ''' args.pop(0) command = args[0] if command == 'packages': self._list_packages(args) elif command == 'files': self._list_files(args) elif command == 'repos':...
Process local commands def _local(self, args): ''' Process local commands ''' args.pop(0) command = args[0] if command == 'install': self._local_install(args) elif command == 'files': self._local_list_files(args) elif command == 'i...
Process repo commands def _repo(self, args): ''' Process repo commands ''' args.pop(0) command = args[0] if command == 'list': self._repo_list(args) elif command == 'packages': self._repo_packages(args) elif command == 'search': ...
List packages for one or more configured repos def _repo_packages(self, args, search=False): ''' List packages for one or more configured repos ''' packages = [] repo_metadata = self._get_repo_metadata() for repo in repo_metadata: for pkg in repo_metadata[rep...
List configured repos This can be called either as a ``repo`` command or a ``list`` command def _repo_list(self, args): ''' List configured repos This can be called either as a ``repo`` command or a ``list`` command ''' repo_metadata = self._get_repo_metadata() ...
Install a package from a repo def _install(self, args): ''' Install a package from a repo ''' if len(args) < 2: raise SPMInvocationError('A package must be specified') caller_opts = self.opts.copy() caller_opts['file_client'] = 'local' self.caller = ...
Install a package from a file def _local_install(self, args, pkg_name=None): ''' Install a package from a file ''' if len(args) < 2: raise SPMInvocationError('A package file must be specified') self._install(args)
Starting with one package, check all packages for dependencies def _check_all_deps(self, pkg_name=None, pkg_file=None, formula_def=None): ''' Starting with one package, check all packages for dependencies ''' if pkg_file and not os.path.exists(pkg_file): raise SPMInvocationE...
Install one individual package def _install_indv_pkg(self, pkg_name, pkg_file): ''' Install one individual package ''' self.ui.status('... installing {0}'.format(pkg_name)) formula_tar = tarfile.open(pkg_file, 'r:bz2') formula_ref = formula_tar.extractfile('{0}/FORMULA'....
Return a list of packages which need to be installed, to resolve all dependencies def _resolve_deps(self, formula_def): ''' Return a list of packages which need to be installed, to resolve all dependencies ''' pkg_info = self.pkgdb['{0}.info'.format(self.db_prov)](formul...
Traverse through all repo files and apply the functionality provided in the callback to them def _traverse_repos(self, callback, repo_name=None): ''' Traverse through all repo files and apply the functionality provided in the callback to them ''' repo_files = [] ...
Download files via http def _query_http(self, dl_path, repo_info): ''' Download files via http ''' query = None response = None try: if 'username' in repo_info: try: if 'password' in repo_info: quer...
Connect to all repos and download metadata def _download_repo_metadata(self, args): ''' Connect to all repos and download metadata ''' cache = salt.cache.Cache(self.opts, self.opts['spm_cache_dir']) def _update_metadata(repo, repo_info): dl_path = '{0}/SPM-METADATA'...
Return cached repo metadata def _get_repo_metadata(self): ''' Return cached repo metadata ''' cache = salt.cache.Cache(self.opts, self.opts['spm_cache_dir']) metadata = {} def _read_metadata(repo, repo_info): if cache.updated('.', repo) is None: ...
Scan a directory and create an SPM-METADATA file which describes all of the SPM files in that directory. def _create_repo(self, args): ''' Scan a directory and create an SPM-METADATA file which describes all of the SPM files in that directory. ''' if len(args) < 2: ...
Remove a package def _remove(self, args): ''' Remove a package ''' if len(args) < 2: raise SPMInvocationError('A package must be specified') packages = args[1:] msg = 'Removing packages:\n\t{0}'.format('\n\t'.join(packages)) if not self.opts['assume...
Display verbose information def _verbose(self, msg, level=log.debug): ''' Display verbose information ''' if self.opts.get('verbose', False) is True: self.ui.status(msg) level(msg)
List info for a package file def _local_info(self, args): ''' List info for a package file ''' if len(args) < 2: raise SPMInvocationError('A package filename must be specified') pkg_file = args[1] if not os.path.exists(pkg_file): raise SPMInvoca...
List info for a package def _info(self, args): ''' List info for a package ''' if len(args) < 2: raise SPMInvocationError('A package must be specified') package = args[1] pkg_info = self._pkgdb_fun('info', package, self.db_conn) if pkg_info is None:...
Get package info def _get_info(self, formula_def): ''' Get package info ''' fields = ( 'name', 'os', 'os_family', 'release', 'version', 'dependencies', 'os_dependencies', 'os_family_dependenc...
List files for a package file def _local_list_files(self, args): ''' List files for a package file ''' if len(args) < 2: raise SPMInvocationError('A package filename must be specified') pkg_file = args[1] if not os.path.exists(pkg_file): raise SP...
List files for an installed package def _list_packages(self, args): ''' List files for an installed package ''' packages = self._pkgdb_fun('list_packages', self.db_conn) for package in packages: if self.opts['verbose']: status_msg = ','.join(package) ...
List files for an installed package def _list_files(self, args): ''' List files for an installed package ''' if len(args) < 2: raise SPMInvocationError('A package name must be specified') package = args[-1] files = self._pkgdb_fun('list_files', package, sel...
Build a package def _build(self, args): ''' Build a package ''' if len(args) < 2: raise SPMInvocationError('A path to a formula must be specified') self.abspath = args[1].rstrip('/') comps = self.abspath.split('/') self.relpath = comps[-1] f...
Exclude based on opts def _exclude(self, member): ''' Exclude based on opts ''' if isinstance(member, string_types): return None for item in self.opts['spm_build_exclude']: if member.name.startswith('{0}/{1}'.format(self.formula_conf['name'], item)): ...
Render a [pre|post]_local_state or [pre|post]_tgt_state script def _render(self, data, formula_def): ''' Render a [pre|post]_local_state or [pre|post]_tgt_state script ''' # FORMULA can contain a renderer option renderer = formula_def.get('renderer', self.opts.get('renderer', 'j...
Pre-process incoming queue attributes before setting them def _preprocess_attributes(attributes): ''' Pre-process incoming queue attributes before setting them ''' if isinstance(attributes, six.string_types): attributes = salt.utils.json.loads(attributes) def stringified(val): # So...
Check to see if a queue exists. CLI Example: .. code-block:: bash salt myminion boto_sqs.exists myqueue region=us-east-1 def exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a queue exists. CLI Example: .. code-block:: bash salt myminion b...
Create an SQS queue. CLI Example: .. code-block:: bash salt myminion boto_sqs.create myqueue region=us-east-1 def create( name, attributes=None, region=None, key=None, keyid=None, profile=None, ): ''' Create an SQS queue. CLI Example: .. code-block:: bash ...
Delete an SQS queue. CLI Example: .. code-block:: bash salt myminion boto_sqs.delete myqueue region=us-east-1 def delete(name, region=None, key=None, keyid=None, profile=None): ''' Delete an SQS queue. CLI Example: .. code-block:: bash salt myminion boto_sqs.delete myqueue...
Return a list of the names of all visible queues. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt myminion boto_sqs.list region=us-east-1 def list_(prefix='', region=None, key=None, keyid=None, profile=None): ''' Return a list of the names of all visible queues. ...
Return attributes currently set on an SQS queue. CLI Example: .. code-block:: bash salt myminion boto_sqs.get_attributes myqueue def get_attributes(name, region=None, key=None, keyid=None, profile=None): ''' Return attributes currently set on an SQS queue. CLI Example: .. code-bloc...
Set attributes on an SQS queue. CLI Example: .. code-block:: bash salt myminion boto_sqs.set_attributes myqueue '{ReceiveMessageWaitTimeSeconds: 20}' region=us-east-1 def set_attributes( name, attributes, region=None, key=None, keyid=None, profile=None, ): ''' Set att...
Call the necessary functions in order to execute the state. For the moment this only calls the ``net.load_template`` function from the :mod:`Network-related basic features execution module <salt.modules.napalm_network>`, but this may change in time. def _update_config(template_name, template...
.. versionadded:: 2019.2.0 Replace occurrences of a pattern in the configuration source. If ``show_changes`` is ``True``, then a diff of what changed will be returned, otherwise a ``True`` will be returned when changes are made, and ``False`` when no changes are made. This is a pure Python implemen...
.. versionadded:: 2019.2.0 Save the configuration to a file on the local file system. name Absolute path to file where to save the configuration. To push the files to the Master, use :mod:`cp.push <salt.modules.cp.push>` Execution function. source: ``running`` The configur...
Manages the configuration on network devices. By default this state will commit the changes on the device. If there are no changes required, it does not commit and the field ``already_configured`` from the output dictionary will be set as ``True`` to notify that. To avoid committing the configuration, set...
.. versionadded:: 2019.2.0 Cancel a commit scheduled to be executed via the ``commit_in`` and ``commit_at`` arguments from the :py:func:`net.load_template <salt.modules.napalm_network.load_template>` or :py:func:`net.load_config <salt.modules.napalm_network.load_config>` execution functions. The co...
.. versionadded:: 2019.2.0 Confirm a commit scheduled to be reverted via the ``revert_in`` and ``revert_at`` arguments from the :mod:`net.load_template <salt.modules.napalm_network.load_template>` or :mod:`net.load_config <salt.modules.napalm_network.load_config>` execution functions. The commit ID...
Serialize Python data to a Python string representation (via pprint.format) :param obj: the data structure to serialize :param options: options given to pprint.format def serialize(obj, **options): ''' Serialize Python data to a Python string representation (via pprint.format) :param obj: the dat...
Required. Can be used to initialize the server connection. def init(opts): ''' Required. Can be used to initialize the server connection. ''' try: DETAILS['server'] = SSHConnection(host=__opts__['proxy']['host'], username=__opts__['proxy']['user...
Get the grains from the proxied device def grains(): ''' Get the grains from the proxied device ''' if not DETAILS.get('grains_cache', {}): cmd = 'info' # Send the command to execute out, err = DETAILS['server'].sendline(cmd) # "scrape" the output and return the right...
Required. Ping the device on the other end of the connection def ping(): ''' Required. Ping the device on the other end of the connection ''' try: out, err = DETAILS['server'].sendline('help') return True except TerminalException as e: log.error(e) return Fal...
Extract json from out. Parameter out: Type string. The data returned by the ssh command. def parse(out): ''' Extract json from out. Parameter out: Type string. The data returned by the ssh command. ''' jsonret = [] in_json = False for ln_ in out.split('...
Install a "package" on the ssh server def package_install(name, **kwargs): ''' Install a "package" on the ssh server ''' cmd = 'pkg_install ' + name if kwargs.get('version', False): cmd += ' ' + kwargs['version'] # Send the command to execute out, err = DETAILS['server'].sendline(c...
Remove a "package" on the ssh server def package_remove(name): ''' Remove a "package" on the ssh server ''' cmd = 'pkg_remove ' + name # Send the command to execute out, err = DETAILS['server'].sendline(cmd) # "scrape" the output and return the right fields as a dict return parse(out)
Start a "service" on the ssh server .. versionadded:: 2015.8.2 def service_start(name): ''' Start a "service" on the ssh server .. versionadded:: 2015.8.2 ''' cmd = 'start ' + name # Send the command to execute out, err = DETAILS['server'].sendline(cmd) # "scrape" the output and...
Stop a "service" on the ssh server .. versionadded:: 2015.8.2 def service_stop(name): ''' Stop a "service" on the ssh server .. versionadded:: 2015.8.2 ''' cmd = 'stop ' + name # Send the command to execute out, err = DETAILS['server'].sendline(cmd) # "scrape" the output and ret...
Restart a "service" on the ssh server .. versionadded:: 2015.8.2 def service_restart(name): ''' Restart a "service" on the ssh server .. versionadded:: 2015.8.2 ''' cmd = 'restart ' + name # Send the command to execute out, err = DETAILS['server'].sendline(cmd) # "scrape" the ou...
Execute a command against jboss instance through the CLI interface. jboss_config Configuration dictionary with properties specified above. command Command to execute against jboss instance fail_on_error (default=True) Is true, raise CommandExecutionError exception if execut...
Execute an operation against jboss instance through the CLI interface. jboss_config Configuration dictionary with properties specified above. operation An operation to execute against jboss instance fail_on_error (default=True) Is true, raise CommandExecutionError exceptio...