text
stringlengths
81
112k
Check if the specified service is enabled :param str name: The name of the service to look up :param str runas: User to run launchctl commands :return: True if the specified service enabled, otherwise False :rtype: bool CLI Example: .. code-block:: bash salt '*' service.enabled org...
Check if the specified service is not enabled. This is the opposite of ``service.enabled`` :param str name: The name to look up :param str runas: User to run launchctl commands :param str domain: domain to check for disabled services. Default is system. :return: True if the specified service is ...
Return a list of services that are enabled or available. Can be used to find the name of a service. :param str runas: User to run launchctl commands :return: A list of all the services available or enabled :rtype: list CLI Example: .. code-block:: bash salt '*' service.get_all def ...
Return a list of all services that are enabled. Can be used to find the name of a service. :param str runas: User to run launchctl commands :return: A list of all the services enabled on the system :rtype: list CLI Example: .. code-block:: bash salt '*' service.get_enabled def get_...
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() kwargs = vm_.copy() # pylint: disable=E1103 kwargs['username'] = vm_['user'] kwargs['project_id'] = vm_['tenant'] kwargs['auth_url'] = vm_['...
Return a list of locations def avail_locations(conn=None, call=None): ''' Return a list of locations ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locations function must be called with ' '-f or --function, or with the --list-locations option' ) ...
Return the image object to use def get_image(conn, vm_): ''' Return the image object to use ''' vm_image = config.get_cloud_config_value('image', vm_, __opts__, default='').encode( 'ascii', 'salt-cloud-force-ascii' ) if not vm_image: log.debug('No image set, must be boot from vo...
Show the details from the provider concerning an instance def show_instance(name, call=None): ''' Show the details from the provider concerning an instance ''' if call != 'action': raise SaltCloudSystemExit( 'The show_instance action must be called with -a or --action.' ) ...
Return the VM's size object def get_size(conn, vm_): ''' Return the VM's size object ''' sizes = conn.list_sizes() vm_size = config.get_cloud_config_value('size', vm_, __opts__) if not vm_size: return sizes[0] for size in sizes: if vm_size and six.text_type(vm_size) in (six...
Return True if we are to ignore the specified IP. Compatible with IPv4. def ignore_cidr(vm_, ip): ''' Return True if we are to ignore the specified IP. Compatible with IPv4. ''' if HAS_NETADDR is False: log.error('Error: netaddr is not installed') return 'Error: netaddr is not installed...
Determine if we should wait for rackconnect automation before running. Either 'False' (default) or 'True'. def rackconnect(vm_): ''' Determine if we should wait for rackconnect automation before running. Either 'False' (default) or 'True'. ''' return config.get_cloud_config_value( 'rack...
Determine if server is using rackconnectv3 or not Return the rackconnect network name or False def rackconnectv3(vm_): ''' Determine if server is using rackconnectv3 or not Return the rackconnect network name or False ''' return config.get_cloud_config_value( 'rackconnectv3', vm_, __opt...
Determine if we should use an extra network to bootstrap Either 'False' (default) or 'True'. def cloudnetwork(vm_): ''' Determine if we should use an extra network to bootstrap Either 'False' (default) or 'True'. ''' return config.get_cloud_config_value( 'cloudnetwork', vm_, __opts__, d...
Determine if we should wait for the managed cloud automation before running. Either 'False' (default) or 'True'. def managedcloud(vm_): ''' Determine if we should wait for the managed cloud automation before running. Either 'False' (default) or 'True'. ''' return config.get_cloud_config_value( ...
Delete a single VM def destroy(name, conn=None, call=None): ''' Delete a single VM ''' if call == 'function': raise SaltCloudSystemExit( 'The destroy action must be called with -d, --destroy, ' '-a or --action.' ) __utils__['cloud.fire_event']( 'even...
Put together all of the information necessary to request an instance through Novaclient and then fire off the request the instance. Returns data about the instance def request_instance(vm_=None, call=None): ''' Put together all of the information necessary to request an instance through Novaclient...
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__, ...
Return a list of the VMs that in this location def list_nodes(call=None, **kwargs): ''' Return a list of the VMs that in this location ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) ret = {} conn...
Return a list of the VMs that in this location def list_nodes_full(call=None, **kwargs): ''' Return a list of the VMs that in this location ''' if call == 'action': raise SaltCloudSystemExit( ( 'The list_nodes_full function must be called with' ' -f o...
Return a list of the VMs that in this location def list_nodes_min(call=None, **kwargs): ''' Return a list of the VMs that in this location ''' if call == 'action': raise SaltCloudSystemExit( ( 'The list_nodes_min function must be called with' ' -f or ...
Create block storage device def volume_create(name, size=100, snapshot=None, voltype=None, **kwargs): ''' Create block storage device ''' conn = get_conn() create_kwargs = {'name': name, 'size': size, 'snapshot': snapshot, 'voltype': vo...
Attach block volume def volume_attach(name, server_name, device='/dev/xvdb', **kwargs): ''' Attach block volume ''' conn = get_conn() return conn.volume_attach( name, server_name, device, timeout=300 )
Create and attach volumes to created node def volume_create_attach(name, call=None, **kwargs): ''' Create and attach volumes to created node ''' if call == 'function': raise SaltCloudSystemExit( 'The create_attach_volumes action must be called with ' '-a or --action.' ...
Create private networks def virtual_interface_create(name, net_name, **kwargs): ''' Create private networks ''' conn = get_conn() return conn.virtual_interface_create(name, net_name)
Allocate a floating IP .. versionadded:: 2016.3.0 def floating_ip_create(kwargs, call=None): ''' Allocate a floating IP .. versionadded:: 2016.3.0 ''' if call != 'function': raise SaltCloudSystemExit( 'The floating_ip_create action must be called with -f or --function' ...
Associate a floating IP address to a server .. versionadded:: 2016.3.0 def floating_ip_associate(name, kwargs, call=None): ''' Associate a floating IP address to a server .. versionadded:: 2016.3.0 ''' if call != 'action': raise SaltCloudSystemExit( 'The floating_ip_associ...
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__, ...
List of nodes, keeping only a brief listing CLI Example: .. code-block:: bash salt-cloud -Q def list_nodes(full=False, call=None): ''' List of nodes, keeping only a brief listing CLI Example: .. code-block:: bash salt-cloud -Q ''' if call == 'action': raise...
List nodes, with all available information CLI Example: .. code-block:: bash salt-cloud -F def list_nodes_full(call=None): ''' List nodes, with all available information CLI Example: .. code-block:: bash salt-cloud -F ''' response = _query('grid', 'server/list') ...
Available locations def avail_locations(): ''' Available locations ''' response = list_common_lookups(kwargs={'lookup': 'ip.datacenter'}) ret = {} for item in response['list']: name = item['name'] ret[name] = item return ret
Available sizes def avail_sizes(): ''' Available sizes ''' response = list_common_lookups(kwargs={'lookup': 'server.ram'}) ret = {} for item in response['list']: name = item['name'] ret[name] = item return ret
Available images def avail_images(): ''' Available images ''' response = _query('grid', 'image/list') ret = {} for item in response['list']: name = item['friendlyName'] ret[name] = item return ret
List all password on the account .. versionadded:: 2015.8.0 def list_passwords(kwargs=None, call=None): ''' List all password on the account .. versionadded:: 2015.8.0 ''' response = _query('support', 'password/list') ret = {} for item in response['list']: if 'server' in item...
List all available public IPs. CLI Example: .. code-block:: bash salt-cloud -f list_public_ips <provider> To list unavailable (assigned) IPs, use: CLI Example: .. code-block:: bash salt-cloud -f list_public_ips <provider> state=assigned .. versionadded:: 2015.8.0 def list_...
List common lookups for a particular type of item .. versionadded:: 2015.8.0 def list_common_lookups(kwargs=None, call=None): ''' List common lookups for a particular type of item .. versionadded:: 2015.8.0 ''' if kwargs is None: kwargs = {} args = {} if 'lookup' in kwargs: ...
Destroy a machine by name CLI Example: .. code-block:: bash salt-cloud -d vm_name def destroy(name, call=None): ''' Destroy a machine by name CLI Example: .. code-block:: bash salt-cloud -d vm_name ''' if call == 'function': raise SaltCloudSystemExit( ...
Start a machine by name CLI Example: .. code-block:: bash salt-cloud -a show_instance vm_name .. versionadded:: 2015.8.0 def show_instance(name, call=None): ''' Start a machine by name CLI Example: .. code-block:: bash salt-cloud -a show_instance vm_name .. versi...
Make a web call to GoGrid .. versionadded:: 2015.8.0 def _query(action=None, command=None, args=None, method='GET', header_dict=None, data=None): ''' Make a web call to GoGrid .. versionadded:: 2015.8.0 ''' vm_ = get_configured_provider()...
split the hive from the key def _parse_key(key): ''' split the hive from the key ''' splt = key.split("\\") hive = splt.pop(0) key = '\\'.join(splt) return hive, key
r''' Ensure a registry key or value is present. Args: name (str): A string value representing the full path of the key to include the HIVE, Key, and all Subkeys. For example: ``HKEY_LOCAL_MACHINE\\SOFTWARE\\Salt`` Valid hive values include: ...
r''' Ensure a registry value is removed. To remove a key use key_absent. Args: name (str): A string value representing the full path of the key to include the HIVE, Key, and all Subkeys. For example: ``HKEY_LOCAL_MACHINE\\SOFTWARE\\Salt`` Valid hive val...
r''' .. versionadded:: 2015.5.4 Ensure a registry key is removed. This will remove the key, subkeys, and all value entries. Args: name (str): A string representing the full path to the key to be removed to include the hive and the keypath. The hive can be any of the ...
Return salt-call source, based on configuration. This will include additional namespaces for another versions of Salt, if needed (e.g. older interpreters etc). :dirs: List of directories to include in the system path :namespaces: Dictionary of namespace :return: def _get_salt_call(*dirs, **namespa...
Add a dependency to the top list. :param obj: :param is_file: :return: def _add_dependency(container, obj): ''' Add a dependency to the top list. :param obj: :param is_file: :return: ''' if os.path.basename(obj.__file__).split('.')[0] == '__init__': container.append(os...
This function is called externally from the alternative Python interpreter from within _get_tops function. :param extra_mods: :param so_mods: :return: def gte(): ''' This function is called externally from the alternative Python interpreter from within _get_tops function. :param extra...
Get top directories for the dependencies, based on external configuration. :return: def get_ext_tops(config): ''' Get top directories for the dependencies, based on external configuration. :return: ''' config = copy.deepcopy(config) alternatives = {} required = ['jinja2', 'yaml', 'tor...
Get namespaces from the existing configuration. :param config: :return: def _get_ext_namespaces(config): ''' Get namespaces from the existing configuration. :param config: :return: ''' namespaces = {} if not config: return namespaces for ns in config: constrai...
Get top directories for the dependencies, based on Python interpreter. :param extra_mods: :param so_mods: :return: def get_tops(extra_mods='', so_mods=''): ''' Get top directories for the dependencies, based on Python interpreter. :param extra_mods: :param so_mods: :return: ''' ...
Based on the Salt SSH configuration, create a YAML configuration for the supported Python interpreter versions. This is then written into the thin.tgz archive and then verified by salt.client.ssh.ssh_py_shim.get_executable() Note: Minimum default of 2.x versions is 2.7 and 3.x is 3.0, unless specified in n...
Make sure thintar temporary name is concurrent and secure. :param tarname: name of the chosen tarball :return: prefixed tarname def _get_thintar_prefix(tarname): ''' Make sure thintar temporary name is concurrent and secure. :param tarname: name of the chosen tarball :return: prefixed tarname...
Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma delimited string. Permits forcing an overwrite of the output file as well. CLI Example: .. code-block:: bash salt-run thin.generate salt-run...
Return the checksum of the current thin tarball def thin_sum(cachedir, form='sha1'): ''' Return the checksum of the current thin tarball ''' thintar = gen_thin(cachedir) code_checksum_path = os.path.join(cachedir, 'thin', 'code-checksum') if os.path.isfile(code_checksum_path): with salt...
Generate the salt-min tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma delimited string. Permits forcing an overwrite of the output file as well. CLI Example: .. code-block:: bash salt-run min.generate salt-run m...
Return the checksum of the current thin tarball def min_sum(cachedir, form='sha1'): ''' Return the checksum of the current thin tarball ''' mintar = gen_min(cachedir) return salt.utils.hashutils.get_hash(mintar, form)
Updates the remote repos database. full : False Set to ``True`` to force a refresh of the pkg DB from all publishers, regardless of the last refresh time. CLI Example: .. code-block:: bash salt '*' pkg.refresh_db salt '*' pkg.refresh_db full=True def refresh_db(full=Fal...
Check if there is an upgrade available for a certain package Accepts full or partial FMRI. Returns all matches found. CLI Example: .. code-block:: bash salt '*' pkg.upgrade_available apache-22 def upgrade_available(name, **kwargs): ''' Check if there is an upgrade available for a certain...
Lists all packages available for update. When run in global zone, it reports only upgradable packages for the global zone. When run in non-global zone, it can report more upgradable packages than ``pkg update -vn``, because ``pkg update`` hides packages that require newer version of ``pkg://solari...
Upgrade all packages to the latest possible version. When run in global zone, it updates also all non-global zones. In non-global zones upgrade is limited by dependency constrains linked to the version of pkg://solaris/entire. Returns a dictionary containing the changes: .. code-block:: python ...
List the currently installed packages as a dict:: {'<package_name>': '<version>'} CLI Example: .. code-block:: bash salt '*' pkg.list_pkgs def list_pkgs(versions_as_list=False, **kwargs): ''' List the currently installed packages as a dict:: {'<package_name>': '<version>'} ...
Common interface for obtaining the version of installed packages. Accepts full or partial FMRI. If called using pkg_resource, full FMRI is required. Partial FMRI is returned if the package is not installed. CLI Example: .. code-block:: bash salt '*' pkg.version vim salt '*' pkg.versio...
Returns FMRI from partial name. Returns empty string ('') if not found. In case of multiple match, the function returns list of all matched packages. CLI Example: .. code-block:: bash salt '*' pkg.get_fmri bash def get_fmri(name, **kwargs): ''' Returns FMRI from partial name. Returns emp...
Internal function. Normalizes pkg name to full FMRI before running pkg.install. In case of multiple matches or no match, it returns the name without modifications. CLI Example: .. code-block:: bash salt '*' pkg.normalize_name vim def normalize_name(name, **kwargs): ''' Internal funct...
Searches the repository for given pkg name. The name can be full or partial FMRI. All matches are printed. Globs are also supported. CLI Example: .. code-block:: bash salt '*' pkg.search bash def search(name, versions_as_list=False, **kwargs): ''' Searches the repository for given pk...
Install the named package using the IPS pkg command. Accepts full or partial FMRI. Returns a dict containing the new package names and versions:: {'<package>': {'old': '<old-version>', 'new': '<new-version>'}} Multiple Package Installation Options: pkgs A list...
Remove specified package. Accepts full or partial FMRI. In case of multiple match, the command fails and won't modify the OS. name The name of the package to be deleted. Multiple Package Options: pkgs A list of packages to delete. Must be passed as a python list. The ``name``...
Execute a command and read the output as JSON def ext_pillar(minion_id, # pylint: disable=W0613 pillar, # pylint: disable=W0613 command): ''' Execute a command and read the output as JSON ''' try: command = command.replace('%s', minion_id) return salt.uti...
Add unofficial GitHub repos to the list of formulas that brew tracks, updates, and installs from. def _tap(tap, runas=None): ''' Add unofficial GitHub repos to the list of formulas that brew tracks, updates, and installs from. ''' if tap in _list_taps(): return True cmd = 'tap {0}'...
Calls the brew command with the user account of brew def _call_brew(cmd, failhard=True): ''' Calls the brew command with the user account of brew ''' user = __salt__['file.get_user'](_homebrew_bin()) runas = user if user != __opts__['user'] else None cmd = '{} {}'.format(salt.utils.path.which('...
List the packages currently installed in a dict:: {'<package_name>': '<version>'} CLI Example: .. code-block:: bash salt '*' pkg.list_pkgs def list_pkgs(versions_as_list=False, **kwargs): ''' List the packages currently installed in a dict:: {'<package_name>': '<version>'} ...
Removes packages with ``brew uninstall``. name The name of the package to be deleted. Multiple Package Options: pkgs A list of packages to delete. Must be passed as a python list. The ``name`` parameter will be ignored if this option is passed. .. versionadded:: 0.16.0 ...
Update the homebrew package repository. CLI Example: .. code-block:: bash salt '*' pkg.refresh_db def refresh_db(**kwargs): ''' Update the homebrew package repository. CLI Example: .. code-block:: bash salt '*' pkg.refresh_db ''' # Remove rtag file to keep multiple...
Get all info brew can provide about a list of packages. Does not do any kind of processing, so the format depends entirely on the output brew gives. This may change if a new version of the format is requested. On failure, returns an empty dict and logs failure. On success, returns a dict mapping e...
Install the passed package(s) with ``brew install`` name The name of the formula to be installed. Note that this parameter is ignored if "pkgs" is passed. CLI Example: .. code-block:: bash salt '*' pkg.install <package name> taps Unofficial GitHub repos t...
Check whether or not an upgrade is available for all packages CLI Example: .. code-block:: bash salt '*' pkg.list_upgrades def list_upgrades(refresh=True, **kwargs): # pylint: disable=W0613 ''' Check whether or not an upgrade is available for all packages CLI Example: .. code-bloc...
Upgrade outdated, unpinned brews. refresh Fetch the newest version of Homebrew and all formulae from GitHub before installing. Returns a dictionary containing the changes: .. code-block:: python {'<package>': {'old': '<old-version>', 'new': '<new-version>'}} ...
Ensure that the chronos job with the given name is present and is configured to match the given config values. :param name: The job name :param config: The configuration to apply (dict) :return: A standard Salt changes dictionary def config(name, config): ''' Ensure that the chronos job with t...
Ensure range record is present. infoblox_range.present: start_addr: '129.97.150.160', end_addr: '129.97.150.170', Verbose state example: .. code-block:: yaml infoblox_range.present: data: { 'always_update_dns': False, 'authority': False...
Ensure the range is removed Supplying the end of the range is optional. State example: .. code-block:: yaml infoblox_range.absent: - name: 'vlan10' infoblox_range.absent: - name: - start_addr: 127.0.1.20 def absent(name=None, start_addr=None, end_add...
Send this command to the server and return a tuple of the output and the stderr. The format for parameters is: cmd (string): The command to send to the sever. def sendline(self, cmd): ''' Send this command to the server and return a tuple of the output and the stderr. ...
Shell out and call the specified esxcli commmand, parse the result and return something sane. :param host: ESXi or vCenter host to connect to :param user: User to connect as, usually root :param pwd: Password to connect with :param port: TCP port :param cmd: esxcli command and arguments :pa...
Internal method to authenticate with a vCenter server or ESX/ESXi host and return the service instance object. def _get_service_instance(host, username, password, protocol, port, mechanism, principal, domain): ''' Internal method to authenticate with a vCenter server or ESX/ESXi h...
Get a reference to a VMware customization spec for the purposes of customizing a clone si ServiceInstance for the vSphere or ESXi server (see get_service_instance) customization_spec_name Name of the customization spec def get_customizationspec_ref(si, customization_spec_name): ''' Ge...
Authenticate with a vCenter server or ESX/ESXi host and return the service instance object. host The location of the vCenter server or ESX/ESXi host. username The username used to login to the vCenter server or ESX/ESXi host. Required if mechanism is ``userpass`` password ...
Returns a stub that points to a different path, created from an existing connection. service_instance The Service Instance. path Path of the new stub. ns Namespace of the new stub. Default value is None version Version of the new stub. Default valu...
Retrieves the service instance from a managed object. me_ref Reference to a managed object (of type vim.ManagedEntity). name Name of managed object. This field is optional. def get_service_instance_from_managed_object(mo_ref, name='<unnamed>'): ''' Retrieves the service instance from ...
Function that disconnects from the vCenter server or ESXi host service_instance The Service Instance from which to obtain managed object references. def disconnect(service_instance): ''' Function that disconnects from the vCenter server or ESXi host service_instance The Service Instan...
Function that returns True if the connection is made to a vCenter Server and False if the connection is made to an ESXi host service_instance The Service Instance from which to obtain managed object references. def is_connection_to_a_vcenter(service_instance): ''' Function that returns True if...
Returns information of the vCenter or ESXi host service_instance The Service Instance from which to obtain managed object references. def get_service_info(service_instance): ''' Returns information of the vCenter or ESXi host service_instance The Service Instance from which to obtain ...
Return a reference to a Distributed Virtual Switch object. :param service_instance: PyVmomi service instance :param dvs_name: Name of DVS to return :return: A PyVmomi DVS object def _get_dvs(service_instance, dvs_name): ''' Return a reference to a Distributed Virtual Switch object. :param ser...
Return a portgroup object corresponding to the portgroup name on the dvs :param dvs: DVS object :param portgroup_name: Name of portgroup to return :return: Portgroup object def _get_dvs_portgroup(dvs, portgroup_name): ''' Return a portgroup object corresponding to the portgroup name on the dvs ...
Return a portgroup object corresponding to the portgroup name on the dvs :param dvs: DVS object :param portgroup_name: Name of portgroup to return :return: Portgroup object def _get_dvs_uplink_portgroup(dvs, portgroup_name): ''' Return a portgroup object corresponding to the portgroup name on the ...
Get the gssapi token for Kerberos connection principal The service principal host Host url where we would like to authenticate domain Kerberos user domain def get_gssapi_token(principal, host, domain): ''' Get the gssapi token for Kerberos connection principal The ...
Return hardware info for standard minion grains if the service_instance is a HostAgent type service_instance The service instance object to get hardware info for .. versionadded:: 2016.11.0 def get_hardware_grains(service_instance): ''' Return hardware info for standard minion grains if the s...
Returns the root folder of a vCenter. service_instance The Service Instance Object for which to obtain the root folder. def get_root_folder(service_instance): ''' Returns the root folder of a vCenter. service_instance The Service Instance Object for which to obtain the root folder. ...
Returns the content of the specified type of object for a Service Instance. For more information, please see: http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.pg.doc_50%2FPG_Ch5_PropertyCollector.7.6.html service_instance The Service Instance from which to obtain content. ...
Returns the first managed object reference having the specified property value. service_instance The Service Instance from which to obtain managed object references. object_type The type of content for which to obtain managed object references. property_value The name of the prope...
Returns a list containing properties and managed object references for the managed object. service_instance The Service Instance from which to obtain managed object references. object_type The type of content for which to obtain managed object references. property_list An optional...
Returns specific properties of a managed object, retrieved in an optimally. mo_ref The managed object reference. properties List of properties of the managed object to retrieve. def get_properties_of_managed_object(mo_ref, properties): ''' Returns specific properties of a managed ...
Return the network adapter type. adpater_type The adapter type from which to obtain the network adapter type. def get_network_adapter_type(adapter_type): ''' Return the network adapter type. adpater_type The adapter type from which to obtain the network adapter type. ''' if ad...
Returns the network adapter type. adapter_object The adapter object from which to obtain the network adapter type. def get_network_adapter_object_type(adapter_object): ''' Returns the network adapter type. adapter_object The adapter object from which to obtain the network adapter type...