INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Scan the system.
def _scan_payload(self): ''' Scan the system. ''' # Get ignored points allowed = list() for allowed_dir in self.db.get(AllowedDir): if os.path.exists(allowed_dir.path): allowed.append(allowed_dir.path) ignored = list() if not a...
Prepare full system scan by setting up the database etc.
def _prepare_full_scan(self, **kwargs): ''' Prepare full system scan by setting up the database etc. ''' self.db.open(new=True) # Add ignored filesystems ignored_fs = set() ignored_fs |= set(self.IGNORE_PATHS) mounts = salt.utils.fsutils._get_mounts() ...
Initialize some Salt environment.
def _init_env(self): ''' Initialize some Salt environment. ''' from salt.config import minion_config from salt.grains import core as g_core g_core.__opts__ = minion_config(self.DEFAULT_MINION_CONFIG_PATH) self.grains_core = g_core
Take a snapshot of the system.
def snapshot(self, mode): ''' Take a snapshot of the system. ''' self._init_env() self._save_cfg_packages(self._get_changed_cfg_pkgs(self._get_cfg_pkgs())) self._save_payload(*self._scan_payload())
Take a snapshot of the system.
def request_snapshot(self, mode, priority=19, **kwargs): ''' Take a snapshot of the system. ''' if mode not in self.MODE: raise InspectorSnapshotException("Unknown mode: '{0}'".format(mode)) if is_alive(self.pidfile): raise CommandExecutionError('Inspecti...
Export description for Kiwi. :param local: :param path: :return:
def export(self, description, local=False, path='/tmp', format='qcow2'): ''' Export description for Kiwi. :param local: :param path: :return: ''' kiwiproc.__salt__ = __salt__ return kiwiproc.KiwiExporter(grains=__grains__, ...
Build an image using Kiwi. :param format: :param path: :return:
def build(self, format='qcow2', path='/tmp'): ''' Build an image using Kiwi. :param format: :param path: :return: ''' if kiwi is None: msg = 'Unable to build the image due to the missing dependencies: Kiwi module is not available.' log.err...
.. versionadded:: Neon Manages a given XML file name : string The location of the XML file to manage, as an absolute path. xpath : string xpath location to manage value : string value to ensure present .. code-block:: yaml ensure_value_true: xml.value_...
def value_present(name, xpath, value, **kwargs): ''' .. versionadded:: Neon Manages a given XML file name : string The location of the XML file to manage, as an absolute path. xpath : string xpath location to manage value : string value to ensure present .. code-...
Ensure thing type exists. .. versionadded:: 2016.11.0 name The name of the state definition thingTypeName Name of the thing type thingTypeDescription Description of the thing type searchableAttributesList List of string attributes that are searchable for ...
def thing_type_present(name, thingTypeName, thingTypeDescription, searchableAttributesList, region=None, key=None, keyid=None, profile=None): ''' Ensure thing type exists. .. versionadded:: 2016.11.0 name The name of the state definition thingTypeName Name of the thing typ...
Ensure thing type with passed properties is absent. .. versionadded:: 2016.11.0 name The name of the state definition. thingTypeName Name of the thing type. region Region to connect to. key Secret key to be used. keyid Access key to be used. pro...
def thing_type_absent(name, thingTypeName, region=None, key=None, keyid=None, profile=None): ''' Ensure thing type with passed properties is absent. .. versionadded:: 2016.11.0 name The name of the state definition. thingTypeName Name of the thing type. regi...
Ensure policy exists. name The name of the state definition policyName Name of the policy. policyDocument The JSON document that describes the policy. The length of the policyDocument must be a minimum length of 1, with a maximum length of 2048, excluding whitespac...
def policy_present(name, policyName, policyDocument, region=None, key=None, keyid=None, profile=None): ''' Ensure policy exists. name The name of the state definition policyName Name of the policy. policyDocument The JSON document that describes the policy. The...
Ensure policy is attached to the given principal. name The name of the state definition policyName Name of the policy. principal The principal which can be a certificate ARN or a Cognito ID. region Region to connect to. key Secret key to be used. key...
def policy_attached(name, policyName, principal, region=None, key=None, keyid=None, profile=None): ''' Ensure policy is attached to the given principal. name The name of the state definition policyName Name of the policy. principal The principal which can be a ...
Ensure topic rule exists. name The name of the state definition ruleName Name of the rule. sql The SQL statement used to query the topic. actions The actions associated with the rule. description The description of the rule. ruleDisable Speci...
def topic_rule_present(name, ruleName, sql, actions, description='', ruleDisabled=False, region=None, key=None, keyid=None, profile=None): ''' Ensure topic rule exists. name The name of the state definition ruleName Name of the rule. sql The SQL sta...
Ensure topic rule with passed properties is absent. name The name of the state definition. ruleName Name of the policy. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and k...
def topic_rule_absent(name, ruleName, region=None, key=None, keyid=None, profile=None): ''' Ensure topic rule with passed properties is absent. name The name of the state definition. ruleName Name of the policy. region Region to connect to. key ...
Usernames can only contain ascii chars, so make sure we return a str type
def _quote_username(name): ''' Usernames can only contain ascii chars, so make sure we return a str type ''' if not isinstance(name, six.string_types): return str(name) # future lint: disable=blacklisted-function else: return salt.utils.stringutils.to_str(name)
Common code to change a user's GECOS information
def _update_gecos(name, key, value, root=None): ''' Common code to change a user's GECOS information ''' if value is None: value = '' elif not isinstance(value, six.string_types): value = six.text_type(value) else: value = salt.utils.stringutils.to_unicode(value) pre_...
Add a user to the minion name Username LOGIN to add uid User ID of the new account gid Name or ID of the primary group of the new account groups List of supplementary groups of the new account home Home directory of the new account shell Logi...
def add(name, uid=None, gid=None, groups=None, home=None, shell=None, unique=True, system=False, fullname='', roomnumber='', workphone='', homephone='', other='', createhome=True, loginclass=None, nol...
Remove a user from the minion name Username to delete remove Remove home directory and mail spool force Force some actions that would fail otherwise root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.delete name remove=Tru...
def delete(name, remove=False, force=False, root=None): ''' Remove a user from the minion name Username to delete remove Remove home directory and mail spool force Force some actions that would fail otherwise root Directory to chroot into CLI Example: ...
Return the list of all info for all users refresh Force a refresh of user information root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.getent
def getent(refresh=False, root=None): ''' Return the list of all info for all users refresh Force a refresh of user information root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.getent ''' if 'user.getent' in __context__ and not re...
Change an attribute for a named user
def _chattrib(name, key, value, param, persist=False, root=None): ''' Change an attribute for a named user ''' pre_info = info(name, root=root) if not pre_info: raise CommandExecutionError('User \'{0}\' does not exist'.format(name)) if value == pre_info[key]: return True cm...
Change the home directory of the user, pass True for persist to move files to the new home directory if the old home directory exist. name User to modify home New home directory for the user account presist Move contents of the home directory to the new location root ...
def chhome(name, home, persist=False, root=None): ''' Change the home directory of the user, pass True for persist to move files to the new home directory if the old home directory exist. name User to modify home New home directory for the user account presist Move con...
Change the groups to which this user belongs name User to modify groups Groups to set for the user append : False If ``True``, append the specified group(s). Otherwise, this function will replace the user's groups with the specified group(s). root Directory to...
def chgroups(name, groups, append=False, root=None): ''' Change the groups to which this user belongs name User to modify groups Groups to set for the user append : False If ``True``, append the specified group(s). Otherwise, this function will replace the user's g...
Change the default login class of the user name User to modify loginclass Login class for the new account root Directory to chroot into .. note:: This function only applies to OpenBSD systems. CLI Example: .. code-block:: bash salt '*' user.chloginc...
def chloginclass(name, loginclass, root=None): ''' Change the default login class of the user name User to modify loginclass Login class for the new account root Directory to chroot into .. note:: This function only applies to OpenBSD systems. CLI Example...
Return user information name User to get the information root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.info root
def info(name, root=None): ''' Return user information name User to get the information root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.info root ''' # If root is provided, we use a less portable solution that # depends on an...
Get the login class of the user name User to get the information .. note:: This function only applies to OpenBSD systems. CLI Example: .. code-block:: bash salt '*' user.get_loginclass foo
def get_loginclass(name): ''' Get the login class of the user name User to get the information .. note:: This function only applies to OpenBSD systems. CLI Example: .. code-block:: bash salt '*' user.get_loginclass foo ''' if __grains__['kernel'] != 'OpenBSD'...
Return user information in a pretty way
def _format_info(data): ''' Return user information in a pretty way ''' # Put GECOS info into a list gecos_field = salt.utils.stringutils.to_unicode(data.pw_gecos).split(',', 4) # Make sure our list has at least five elements while len(gecos_field) < 5: gecos_field.append('') re...
Return a list of all users root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.list_users
def list_users(root=None): ''' Return a list of all users root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.list_users ''' if root is not None and __grains__['kernel'] != 'AIX': getpwall = functools.partial(_getpwall, root=root) els...
Change the username for a named user name User to modify new_name New value of the login name root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.rename name new_name
def rename(name, new_name, root=None): ''' Change the username for a named user name User to modify new_name New value of the login name root Directory to chroot into CLI Example: .. code-block:: bash salt '*' user.rename name new_name ''' if inf...
Alternative implementation for getpwnam, that use only /etc/passwd
def _getpwnam(name, root=None): ''' Alternative implementation for getpwnam, that use only /etc/passwd ''' root = '/' if not root else root passwd = os.path.join(root, 'etc/passwd') with salt.utils.files.fopen(passwd) as fp_: for line in fp_: line = salt.utils.stringutils.to_...
Add a range of subordinate gids to the user name User to modify first Begin of the range last End of the range CLI Examples: .. code-block:: bash salt '*' user.add_subgids foo salt '*' user.add_subgids foo first=105000 salt '*' user.add_subgids f...
def add_subgids(name, first=100000, last=110000): ''' Add a range of subordinate gids to the user name User to modify first Begin of the range last End of the range CLI Examples: .. code-block:: bash salt '*' user.add_subgids foo salt '*' user.ad...
Install a DISM capability Args: name (str): The capability to install source (str): The optional source of the capability limit_access (bool): Prevent DISM from contacting Windows Update for online images image (Optional[str]): The path to the root directory of an offlin...
def capability_installed(name, source=None, limit_access=False, image=None, restart=False): ''' Install a DISM capability Args: name (str): The capability to install source (str): The optiona...
Uninstall a package Args: name (str): The full path to the package. Can be either a .cab file or a folder. Should point to the original source of the package, not to where the file is installed. This can also be the name of a package as listed in ``dism.installed_package...
def package_removed(name, image=None, restart=False): ''' Uninstall a package Args: name (str): The full path to the package. Can be either a .cab file or a folder. Should point to the original source of the package, not to where the file is installed. This can also be the n...
Performs an ICMP ping to a host .. versionchanged:: 2015.8.0 Added support for SunOS CLI Example: .. code-block:: bash salt '*' network.ping archlinux.org .. versionadded:: 2015.5.0 Return a True or False instead of ping output. .. code-block:: bash salt '*' netwo...
def ping(host, timeout=False, return_boolean=False): ''' Performs an ICMP ping to a host .. versionchanged:: 2015.8.0 Added support for SunOS CLI Example: .. code-block:: bash salt '*' network.ping archlinux.org .. versionadded:: 2015.5.0 Return a True or False instead ...
Return netstat information for Linux distros
def _netstat_linux(): ''' Return netstat information for Linux distros ''' ret = [] cmd = 'netstat -tulpnea' out = __salt__['cmd.run'](cmd) for line in out.splitlines(): comps = line.split() if line.startswith('tcp'): ret.append({ 'proto': comps[0]...
Return ss information for Linux distros (netstat is deprecated and may not be available)
def _ss_linux(): ''' Return ss information for Linux distros (netstat is deprecated and may not be available) ''' ret = [] cmd = 'ss -tulpnea' out = __salt__['cmd.run'](cmd) for line in out.splitlines(): comps = line.split() ss_user = 0 ss_inode = 0 ss_pro...
Get process information for network connections using fstat
def _netinfo_openbsd(): ''' Get process information for network connections using fstat ''' ret = {} _fstat_re = re.compile( r'internet(6)? (?:stream tcp 0x\S+ (\S+)|dgram udp (\S+))' r'(?: [<>=-]+ (\S+))?$' ) out = __salt__['cmd.run']('fstat') for line in out.splitlines(...
Get process information for network connections using sockstat
def _netinfo_freebsd_netbsd(): ''' Get process information for network connections using sockstat ''' ret = {} # NetBSD requires '-n' to disable port-to-service resolution out = __salt__['cmd.run']( 'sockstat -46 {0} | tail -n+2'.format( '-n' if __grains__['kernel'] == 'NetBS...
Return a dict of pid to ppid mappings
def _ppid(): ''' Return a dict of pid to ppid mappings ''' ret = {} if __grains__['kernel'] == 'SunOS': cmd = 'ps -a -o pid,ppid | tail +2' else: cmd = 'ps -ax -o pid,ppid | tail -n+2' out = __salt__['cmd.run'](cmd, python_shell=True) for line in out.splitlines(): ...
Return netstat information for BSD flavors
def _netstat_bsd(): ''' Return netstat information for BSD flavors ''' ret = [] if __grains__['kernel'] == 'NetBSD': for addr_family in ('inet', 'inet6'): cmd = 'netstat -f {0} -an | tail -n+3'.format(addr_family) out = __salt__['cmd.run'](cmd, python_shell=True) ...
Return netstat information for SunOS flavors
def _netstat_sunos(): ''' Return netstat information for SunOS flavors ''' log.warning('User and program not (yet) supported on SunOS') ret = [] for addr_family in ('inet', 'inet6'): # Lookup TCP connections cmd = 'netstat -f {0} -P tcp -an | tail +5'.format(addr_family) ...
Return netstat information for SunOS flavors
def _netstat_aix(): ''' Return netstat information for SunOS flavors ''' ret = [] ## AIX 6.1 - 7.2, appears to ignore addr_family field contents ## for addr_family in ('inet', 'inet6'): for addr_family in ('inet',): # Lookup connections cmd = 'netstat -n -a -f {0} | tail -n +...
Return ip routing information for Linux distros (netstat is deprecated and may not be available)
def _ip_route_linux(): ''' Return ip routing information for Linux distros (netstat is deprecated and may not be available) ''' # table main closest to old netstat inet output ret = [] cmd = 'ip -4 route show table main' out = __salt__['cmd.run'](cmd, python_shell=True) for line in o...
Return netstat routing information for FreeBSD and macOS
def _netstat_route_freebsd(): ''' Return netstat routing information for FreeBSD and macOS ''' ret = [] cmd = 'netstat -f inet -rn | tail -n+5' out = __salt__['cmd.run'](cmd, python_shell=True) for line in out.splitlines(): comps = line.split() if __grains__['os'] == 'FreeBSD...
Return netstat routing information for NetBSD
def _netstat_route_netbsd(): ''' Return netstat routing information for NetBSD ''' ret = [] cmd = 'netstat -f inet -rn | tail -n+5' out = __salt__['cmd.run'](cmd, python_shell=True) for line in out.splitlines(): comps = line.split() ret.append({ 'addr_family': 'in...
Return netstat routing information for SunOS
def _netstat_route_sunos(): ''' Return netstat routing information for SunOS ''' ret = [] cmd = 'netstat -f inet -rn | tail +5' out = __salt__['cmd.run'](cmd, python_shell=True) for line in out.splitlines(): comps = line.split() ret.append({ 'addr_family': 'inet',...
Return information on open ports and states .. note:: On BSD minions, the output contains PID info (where available) for each netstat entry, fetched from sockstat/fstat output. .. versionchanged:: 2014.1.4 Added support for OpenBSD, FreeBSD, and NetBSD .. versionchanged:: 2015.8.0...
def netstat(): ''' Return information on open ports and states .. note:: On BSD minions, the output contains PID info (where available) for each netstat entry, fetched from sockstat/fstat output. .. versionchanged:: 2014.1.4 Added support for OpenBSD, FreeBSD, and NetBSD ....
Return a dict containing information on all of the running TCP connections (currently linux and solaris only) .. versionchanged:: 2015.8.4 Added support for SunOS CLI Example: .. code-block:: bash salt '*' network.active_tcp
def active_tcp(): ''' Return a dict containing information on all of the running TCP connections (currently linux and solaris only) .. versionchanged:: 2015.8.4 Added support for SunOS CLI Example: .. code-block:: bash salt '*' network.active_tcp ''' if __grains__['kerne...
Performs a traceroute to a 3rd party host .. versionchanged:: 2015.8.0 Added support for SunOS .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' network.traceroute archlinux.org
def traceroute(host): ''' Performs a traceroute to a 3rd party host .. versionchanged:: 2015.8.0 Added support for SunOS .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' network.traceroute archlinux.org ''' ret = ...
Performs a DNS lookup with dig CLI Example: .. code-block:: bash salt '*' network.dig archlinux.org
def dig(host): ''' Performs a DNS lookup with dig CLI Example: .. code-block:: bash salt '*' network.dig archlinux.org ''' cmd = 'dig {0}'.format(salt.utils.network.sanitize_host(host)) return __salt__['cmd.run'](cmd)
Return the arp table from the minion .. versionchanged:: 2015.8.0 Added support for SunOS CLI Example: .. code-block:: bash salt '*' network.arp
def arp(): ''' Return the arp table from the minion .. versionchanged:: 2015.8.0 Added support for SunOS CLI Example: .. code-block:: bash salt '*' network.arp ''' ret = {} out = __salt__['cmd.run']('arp -an') for line in out.splitlines(): comps = line.spl...
returns the network address, subnet mask and broadcast address of a cidr address .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' network.convert_cidr 172.31.0.0/16
def convert_cidr(cidr): ''' returns the network address, subnet mask and broadcast address of a cidr address .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' network.convert_cidr 172.31.0.0/16 ''' ret = {'network': None, 'netmask': None, ...
Modify hostname .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) CLI Example: .. code-block:: bash salt '*' network.mod_hostname master.saltstack.com
def mod_hostname(hostname): ''' Modify hostname .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) CLI Example: .. code-block:: bash salt '*' network.mod_hostname master.saltstack.com ''' # # SunOS tested on SmartOS and OmniOS (Solaris...
Return network interface buffer information using ethtool
def _get_bufsize_linux(iface): ''' Return network interface buffer information using ethtool ''' ret = {'result': False} cmd = '/sbin/ethtool -g {0}'.format(iface) out = __salt__['cmd.run'](cmd) pat = re.compile(r'^(.+):\s+(\d+)$') suffix = 'max-' for line in out.splitlines(): ...
Modify network interface buffer sizes using ethtool
def _mod_bufsize_linux(iface, *args, **kwargs): ''' Modify network interface buffer sizes using ethtool ''' ret = {'result': False, 'comment': 'Requires rx=<val> tx==<val> rx-mini=<val> and/or rx-jumbo=<val>'} cmd = '/sbin/ethtool -G ' + iface if not kwargs: return ret if ...
Modify network interface buffers (currently linux only) CLI Example: .. code-block:: bash salt '*' network.mod_bufsize tx=<val> rx=<val> rx-mini=<val> rx-jumbo=<val>
def mod_bufsize(iface, *args, **kwargs): ''' Modify network interface buffers (currently linux only) CLI Example: .. code-block:: bash salt '*' network.mod_bufsize tx=<val> rx=<val> rx-mini=<val> rx-jumbo=<val> ''' if __grains__['kernel'] == 'Linux': if os.path.exists('/sbin/e...
Return currently configured routes from routing table .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' network.routes
def routes(family=None): ''' Return currently configured routes from routing table .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' netwo...
Return default route(s) from routing table .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' network.default_route
def default_route(family=None): ''' Return default route(s) from routing table .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' network.d...
Return routing information for given destination ip .. versionadded:: 2015.5.3 .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) Added support for OpenBSD .. versionchanged:: 2016.11.4 Added support for AIX CLI Example:: salt '*' net...
def get_route(ip): ''' Return routing information for given destination ip .. versionadded:: 2015.5.3 .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) Added support for OpenBSD .. versionchanged:: 2016.11.4 Added support for AIX CLI ...
Retrieve the interface name from a specific CIDR .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' network.ifacestartswith 10.0
def ifacestartswith(cidr): ''' Retrieve the interface name from a specific CIDR .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' network.ifacestartswith 10.0 ''' net_list = interfaces() intfnames = [] pattern = six.text_type(cidr) size = len(patt...
Retrieve the hexadecimal representation of an IP address .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' network.iphexval 10.0.0.1
def iphexval(ip): ''' Retrieve the hexadecimal representation of an IP address .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' network.iphexval 10.0.0.1 ''' a = ip.split('.') hexval = ['%02X' % int(x) for x in a] # pylint: disable=E1321 return ''.j...
Ensure trail exists. name The name of the state definition Name Name of the event rule. Defaults to the value of the 'name' param if not provided. ScheduleExpression The scheduling expression. For example, ``cron(0 20 * * ? *)``, "rate(5 minutes)" EventPatter...
def present(name, Name=None, ScheduleExpression=None, EventPattern=None, Description=None, RoleArn=None, State=None, Targets=None, region=None, key=None, keyid=None, profile=None): ''' Ensure trail exists. name The name of...
Ensure CloudWatch event rule with passed properties is absent. name The name of the state definition. Name Name of the event rule. Defaults to the value of the 'name' param if not provided. region Region to connect to. key Secret key to be used. keyid ...
def absent(name, Name=None, region=None, key=None, keyid=None, profile=None): ''' Ensure CloudWatch event rule with passed properties is absent. name The name of the state definition. Name Name of the event rule. Defaults to the value of the 'name' param if not provided. ...
Return a list of nodes :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_nodes method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash salt myminion libcloud_compute.list_nodes profile1
def list_nodes(profile, **libcloud_kwargs): ''' Return a list of nodes :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_nodes method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash salt m...
Return a list of node sizes :param profile: The profile key :type profile: ``str`` :param location_id: The location key, from list_locations :type location_id: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_sizes method :type libcloud_kwargs: ``dict`` CLI Exampl...
def list_sizes(profile, location_id=None, **libcloud_kwargs): ''' Return a list of node sizes :param profile: The profile key :type profile: ``str`` :param location_id: The location key, from list_locations :type location_id: ``str`` :param libcloud_kwargs: Extra arguments for the drive...
Return a list of locations for this cloud :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_locations method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash salt myminion libcloud_compute.list_loc...
def list_locations(profile, **libcloud_kwargs): ''' Return a list of locations for this cloud :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_locations method :type libcloud_kwargs: ``dict`` CLI Example: .. code-b...
Reboot a node in the cloud :param node_id: Unique ID of the node to reboot :type node_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's reboot_node method :type libcloud_kwargs: ``dict`` CLI Example: .. cod...
def reboot_node(node_id, profile, **libcloud_kwargs): ''' Reboot a node in the cloud :param node_id: Unique ID of the node to reboot :type node_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's reboot_node method ...
Return a list of storage volumes for this cloud :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_volumes method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash salt myminion libcloud_compute.list...
def list_volumes(profile, **libcloud_kwargs): ''' Return a list of storage volumes for this cloud :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_volumes method :type libcloud_kwargs: ``dict`` CLI Example: .. code...
Return a list of storage volumes snapshots for this cloud :param volume_id: The volume identifier :type volume_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_volume_snapshots method :type libcloud_kwargs: ``d...
def list_volume_snapshots(volume_id, profile, **libcloud_kwargs): ''' Return a list of storage volumes snapshots for this cloud :param volume_id: The volume identifier :type volume_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments...
Create a storage volume :param size: Size of volume in gigabytes (required) :type size: ``int`` :param name: Name of the volume to be created :type name: ``str`` :param location_id: Which data center to create a volume in. If empty, undefined behavior will be selected....
def create_volume(size, name, profile, location_id=None, **libcloud_kwargs): ''' Create a storage volume :param size: Size of volume in gigabytes (required) :type size: ``int`` :param name: Name of the volume to be created :type name: ``str`` :param location_id: Which data center to creat...
Create a storage volume snapshot :param volume_id: Volume ID from which to create the new snapshot. :type volume_id: ``str`` :param profile: The profile key :type profile: ``str`` :param name: Name of the snapshot to be created (optional) :type name: ``str`` :p...
def create_volume_snapshot(volume_id, profile, name=None, **libcloud_kwargs): ''' Create a storage volume snapshot :param volume_id: Volume ID from which to create the new snapshot. :type volume_id: ``str`` :param profile: The profile key :type profile: ``str`` ...
Attaches volume to node. :param node_id: Node ID to target :type node_id: ``str`` :param volume_id: Volume ID from which to attach :type volume_id: ``str`` :param profile: The profile key :type profile: ``str`` :param device: Where the device is exposed, e.g. '/dev/sdb' :type de...
def attach_volume(node_id, volume_id, profile, device=None, **libcloud_kwargs): ''' Attaches volume to node. :param node_id: Node ID to target :type node_id: ``str`` :param volume_id: Volume ID from which to attach :type volume_id: ``str`` :param profile: The profile key :type pr...
Detaches a volume from a node. :param volume_id: Volume ID from which to detach :type volume_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's detach_volume method :type libcloud_kwargs: ``dict`` CLI Example: ...
def detach_volume(volume_id, profile, **libcloud_kwargs): ''' Detaches a volume from a node. :param volume_id: Volume ID from which to detach :type volume_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's detach_...
Destroy a volume snapshot. :param volume_id: Volume ID from which the snapshot belongs :type volume_id: ``str`` :param snapshot_id: Volume Snapshot ID from which to destroy :type snapshot_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extr...
def destroy_volume_snapshot(volume_id, snapshot_id, profile, **libcloud_kwargs): ''' Destroy a volume snapshot. :param volume_id: Volume ID from which the snapshot belongs :type volume_id: ``str`` :param snapshot_id: Volume Snapshot ID from which to destroy :type snapshot_id: ``str`` ...
Return a list of images for this cloud :param profile: The profile key :type profile: ``str`` :param location_id: The location key, from list_locations :type location_id: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_images method :type libcloud_kwargs: ``dict`` ...
def list_images(profile, location_id=None, **libcloud_kwargs): ''' Return a list of images for this cloud :param profile: The profile key :type profile: ``str`` :param location_id: The location key, from list_locations :type location_id: ``str`` :param libcloud_kwargs: Extra arguments f...
Create an image from a node :param node_id: Node to run the task on. :type node_id: ``str`` :param name: name for new image. :type name: ``str`` :param profile: The profile key :type profile: ``str`` :param description: description for new image. :type description: ``description`` ...
def create_image(node_id, name, profile, description=None, **libcloud_kwargs): ''' Create an image from a node :param node_id: Node to run the task on. :type node_id: ``str`` :param name: name for new image. :type name: ``str`` :param profile: The profile key :type profile: ``str`` ...
Delete an image of a node :param image_id: Image to delete :type image_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's delete_image method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash ...
def delete_image(image_id, profile, **libcloud_kwargs): ''' Delete an image of a node :param image_id: Image to delete :type image_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's delete_image method :type li...
Get an image of a node :param image_id: Image to fetch :type image_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's delete_image method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash ...
def get_image(image_id, profile, **libcloud_kwargs): ''' Get an image of a node :param image_id: Image to fetch :type image_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's delete_image method :type libcloud_...
Copies an image from a source region to the current region. :param source_region: Region to copy the node from. :type source_region: ``str`` :param image_id: Image to copy. :type image_id: ``str`` :param name: name for new image. :type name: ``str`` :param profile: The profile key :t...
def copy_image(source_region, image_id, name, profile, description=None, **libcloud_kwargs): ''' Copies an image from a source region to the current region. :param source_region: Region to copy the node from. :type source_region: ``str`` :param image_id: Image to copy. :type image_id: ``str`` ...
List all the available key pair objects. :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_key_pairs method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash salt myminion libcloud_compute.list_key_...
def list_key_pairs(profile, **libcloud_kwargs): ''' List all the available key pair objects. :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_key_pairs method :type libcloud_kwargs: ``dict`` CLI Example: .. code-bl...
Get a single key pair by name :param name: Name of the key pair to retrieve. :type name: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's get_key_pair method :type libcloud_kwargs: ``dict`` CLI Example: .. code...
def get_key_pair(name, profile, **libcloud_kwargs): ''' Get a single key pair by name :param name: Name of the key pair to retrieve. :type name: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's get_key_pair method ...
Import a new public key from string or a file path :param name: Key pair name. :type name: ``str`` :param key: Public key material, the string or a path to a file :type key: ``str`` or path ``str`` :param profile: The profile key :type profile: ``str`` :param key_type: The key pair typ...
def import_key_pair(name, key, profile, key_type=None, **libcloud_kwargs): ''' Import a new public key from string or a file path :param name: Key pair name. :type name: ``str`` :param key: Public key material, the string or a path to a file :type key: ``str`` or path ``str`` :param prof...
Delete a key pair :param name: Key pair name. :type name: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's import_key_pair_from_xxx method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash ...
def delete_key_pair(name, profile, **libcloud_kwargs): ''' Delete a key pair :param name: Key pair name. :type name: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's import_key_pair_from_xxx method :type libclou...
Get item from a list by the id field
def _get_by_id(collection, id): ''' Get item from a list by the id field ''' matches = [item for item in collection if item.id == id] if not matches: raise ValueError('Could not find a matching item') elif len(matches) > 1: raise ValueError('The id matched {0} items, not 1'.forma...
Get the summary from module monit and try to see if service is being monitored. If not then monitor the service.
def monitor(name): ''' Get the summary from module monit and try to see if service is being monitored. If not then monitor the service. ''' ret = {'result': None, 'name': name, 'comment': '', 'changes': {} } result = __salt__['monit.summary'](name) ...
Get status of running jboss instance. jboss_config Configuration dictionary with properties specified above. host The name of the host. JBoss domain mode only - and required if running in domain mode. The host name is the "name" attribute of the "host" element in host.xml server_con...
def status(jboss_config, host=None, server_config=None): ''' Get status of running jboss instance. jboss_config Configuration dictionary with properties specified above. host The name of the host. JBoss domain mode only - and required if running in domain mode. The host name is ...
Stop running jboss instance jboss_config Configuration dictionary with properties specified above. host The name of the host. JBoss domain mode only - and required if running in domain mode. The host name is the "name" attribute of the "host" element in host.xml CLI Example: ....
def stop_server(jboss_config, host=None): ''' Stop running jboss instance jboss_config Configuration dictionary with properties specified above. host The name of the host. JBoss domain mode only - and required if running in domain mode. The host name is the "name" attribute of t...
Reload running jboss instance jboss_config Configuration dictionary with properties specified above. host The name of the host. JBoss domain mode only - and required if running in domain mode. The host name is the "name" attribute of the "host" element in host.xml CLI Example: ...
def reload_(jboss_config, host=None): ''' Reload running jboss instance jboss_config Configuration dictionary with properties specified above. host The name of the host. JBoss domain mode only - and required if running in domain mode. The host name is the "name" attribute of the...
Create datasource in running jboss instance jboss_config Configuration dictionary with properties specified above. name Datasource name datasource_properties A dictionary of datasource properties to be created: - driver-name: mysql - connection-url: 'jdbc:mysql:/...
def create_datasource(jboss_config, name, datasource_properties, profile=None): ''' Create datasource in running jboss instance jboss_config Configuration dictionary with properties specified above. name Datasource name datasource_properties A dictionary of datasource proper...
Update an existing datasource in running jboss instance. If the property doesn't exist if will be created, if it does, it will be updated with the new value jboss_config Configuration dictionary with properties specified above. name Datasource name new_properties A dictionary of...
def update_datasource(jboss_config, name, new_properties, profile=None): ''' Update an existing datasource in running jboss instance. If the property doesn't exist if will be created, if it does, it will be updated with the new value jboss_config Configuration dictionary with properties specifi...
Read datasource properties in the running jboss instance. jboss_config Configuration dictionary with properties specified above. name Datasource name profile Profile name (JBoss domain mode only) CLI Example: .. code-block:: bash salt '*' jboss7.read_datasource '{...
def read_datasource(jboss_config, name, profile=None): ''' Read datasource properties in the running jboss instance. jboss_config Configuration dictionary with properties specified above. name Datasource name profile Profile name (JBoss domain mode only) CLI Example: ...
Create a simple jndi binding in the running jboss instance jboss_config Configuration dictionary with properties specified above. binding_name Binding name to be created value Binding value profile The profile name (JBoss domain mode only) CLI Example: .. code-...
def create_simple_binding(jboss_config, binding_name, value, profile=None): ''' Create a simple jndi binding in the running jboss instance jboss_config Configuration dictionary with properties specified above. binding_name Binding name to be created value Binding value p...
Read jndi binding in the running jboss instance jboss_config Configuration dictionary with properties specified above. binding_name Binding name to be created profile The profile name (JBoss domain mode only) CLI Example: .. code-block:: bash salt '*' jboss7.r...
def read_simple_binding(jboss_config, binding_name, profile=None): ''' Read jndi binding in the running jboss instance jboss_config Configuration dictionary with properties specified above. binding_name Binding name to be created profile The profile name (JBoss domain mode o...
Remove an existing datasource from the running jboss instance. jboss_config Configuration dictionary with properties specified above. name Datasource name profile The profile (JBoss domain mode only) CLI Example: .. code-block:: bash salt '*' jboss7.remove_datasou...
def remove_datasource(jboss_config, name, profile=None): ''' Remove an existing datasource from the running jboss instance. jboss_config Configuration dictionary with properties specified above. name Datasource name profile The profile (JBoss domain mode only) CLI Examp...
Deploy the application on the jboss instance from the local file system where minion is running. jboss_config Configuration dictionary with properties specified above. source_file Source file to deploy from CLI Example: .. code-block:: bash salt '*' jboss7.deploy '{"cli_path"...
def deploy(jboss_config, source_file): ''' Deploy the application on the jboss instance from the local file system where minion is running. jboss_config Configuration dictionary with properties specified above. source_file Source file to deploy from CLI Example: .. code-block:...
List all deployments on the jboss instance jboss_config Configuration dictionary with properties specified above. CLI Example: .. code-block:: bash salt '*' jboss7.list_deployments '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:999...
def list_deployments(jboss_config): ''' List all deployments on the jboss instance jboss_config Configuration dictionary with properties specified above. CLI Example: .. code-block:: bash salt '*' jboss7.list_deployments '{"cli_path": "integration.modules.sysmod.SysModuleTest....
Undeploy the application from jboss instance jboss_config Configuration dictionary with properties specified above. deployment Deployment name to undeploy CLI Example: .. code-block:: bash salt '*' jboss7.undeploy '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_v...
def undeploy(jboss_config, deployment): ''' Undeploy the application from jboss instance jboss_config Configuration dictionary with properties specified above. deployment Deployment name to undeploy CLI Example: .. code-block:: bash salt '*' jboss7.undeploy '{"cli_pat...
Computes the timestamp for a future event that may occur in ``time_in`` time or at ``time_at``.
def get_timestamp_at(time_in=None, time_at=None): ''' Computes the timestamp for a future event that may occur in ``time_in`` time or at ``time_at``. ''' if time_in: if isinstance(time_in, int): hours = 0 minutes = time_in else: time_in = time_in.r...
Return the time in human readable format for a future event that may occur in ``time_in`` time, or at ``time_at``.
def get_time_at(time_in=None, time_at=None, out_fmt='%Y-%m-%dT%H:%M:%S'): ''' Return the time in human readable format for a future event that may occur in ``time_in`` time, or at ``time_at``. ''' dt = get_timestamp_at(time_in=time_in, time_at=time_at) return time.strftime(out_fmt, time.localtim...
Return a bool telling whether or ``path`` is absolute. If ``path`` is None, return ``True``. This function is designed to validate variables which optionally contain a file path.
def _path_is_abs(path): ''' Return a bool telling whether or ``path`` is absolute. If ``path`` is None, return ``True``. This function is designed to validate variables which optionally contain a file path. ''' if path is None: return True try: return os.path.isabs(path) ...
.. versionadded:: 2014.1.0 .. versionchanged:: 2016.11.0 This state has been rewritten. Some arguments are new to this release and will not be available in the 2016.3 release cycle (and earlier). Additionally, the **ZIP Archive Handling** section below applies specifically to the 201...
def extracted(name, source, source_hash=None, source_hash_name=None, source_hash_update=False, skip_verify=False, password=None, options=None, list_options=None, force=False, overw...