text
stringlengths
81
112k
Fetch secret from pass based on pass_path. If there is any error, return back the original pass_path value def _fetch_secret(pass_path): ''' Fetch secret from pass based on pass_path. If there is any error, return back the original pass_path value ''' cmd = "pass show {0}".format(pass_path.stri...
Recursively try to find a pass path (string) that can be handed off to pass def _decrypt_object(obj): ''' Recursively try to find a pass path (string) that can be handed off to pass ''' if isinstance(obj, six.string_types): return _fetch_secret(obj) elif isinstance(obj, dict): for p...
Fetch secret from pass based on pass_path def render(pass_info, saltenv='base', sls='', argline='', **kwargs): ''' Fetch secret from pass based on pass_path ''' try: _get_pass_exec() except SaltRenderError: raise # Make sure environment variable HOME is set, since Pass looks fo...
Show list of available pkg upgrades using a specified format style CLI Example: .. code-block:: bash salt-run pkg.list_upgrades jid=20141120114114417719 style=group def list_upgrades(jid, style='group', outputter='nested', ext_source=None): '...
Return the firewall-cmd location def __firewall_cmd(cmd): ''' Return the firewall-cmd location ''' firewall_cmd = '{0} {1}'.format(salt.utils.path.which('firewall-cmd'), cmd) out = __salt__['cmd.run_all'](firewall_cmd) if out['retcode'] != 0: if not out['stderr']: msg = out...
Perform zone management def __mgmt(name, _type, action): ''' Perform zone management ''' # It's permanent because the 4 concerned functions need the permanent option, it's wrong without cmd = '--{0}-{1}={2} --permanent'.format(action, _type, name) return __firewall_cmd(cmd)
List everything added for or enabled in all zones CLI Example: .. code-block:: bash salt '*' firewalld.list_zones def list_zones(permanent=True): ''' List everything added for or enabled in all zones CLI Example: .. code-block:: bash salt '*' firewalld.list_zones ''' ...
Add a new zone CLI Example: .. code-block:: bash salt '*' firewalld.new_zone my_zone By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash salt '*' firewalld.new_zone my_zone False def new_zone(zone, re...
Delete an existing zone CLI Example: .. code-block:: bash salt '*' firewalld.delete_zone my_zone By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash salt '*' firewalld.delete_zone my_zone False def de...
Add a new service CLI Example: .. code-block:: bash salt '*' firewalld.new_service my_service By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash salt '*' firewalld.new_service my_service False def ne...
Delete an existing service CLI Example: .. code-block:: bash salt '*' firewalld.delete_service my_service By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash salt '*' firewalld.delete_service my_servic...
List everything added for or enabled in a zone CLI Example: .. code-block:: bash salt '*' firewalld.list_all List a specific zone .. code-block:: bash salt '*' firewalld.list_all my_zone def list_all(zone=None, permanent=True): ''' List everything added for or enabled in a...
List services added for zone as a space separated list. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.list_services List a specific zone .. code-block:: bash salt '*' firewalld.list_services my_zone def list_services(zone=N...
Add a service for zone. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.add_service ssh To assign a service to a specific zone: .. code-block:: bash salt '*' firewalld.add_service ssh my_zone def add_service(service, zone=None, p...
Remove a service from zone. This option can be specified multiple times. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.remove_service ssh To remove a service from a specific zone .. code-block:: bash salt '*' firewalld.remov...
Add a new port to the specified service. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_service_port zone 80 def add_service_port(service, port): ''' Add a new port to the specified service. .. versionadded:: 2016.11.0 CLI Example: .....
Show if masquerading is enabled on a zone. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.get_masquerade zone def get_masquerade(zone=None, permanent=True): ''' Show if masquerading is enabled on a zone. If zone is omitted, default...
Enable masquerade on a zone. If zone is omitted, default zone will be used. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_masquerade To enable masquerade on a specific zone .. code-block:: bash salt '*' firewalld.add_masquerade dmz de...
Remove masquerade on a zone. If zone is omitted, default zone will be used. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_masquerade To remove masquerade on a specific zone .. code-block:: bash salt '*' firewalld.remove_masquerade d...
Allow specific ports in a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_port internal 443/tcp def add_port(zone, port, permanent=True): ''' Allow specific ports in a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: ...
Remove a specific port from a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_port internal 443/tcp def remove_port(zone, port, permanent=True): ''' Remove a specific port from a zone. .. versionadded:: 2015.8.0 CLI Example: .....
List all ports in a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.list_ports def list_ports(zone, permanent=True): ''' List all ports in a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewall...
Add port forwarding. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_port_fwd public 80 443 tcp def add_port_fwd(zone, src, dest, proto='tcp', dstaddr='', permanent=True): ''' Add port forwarding. .. versionadded:: 2015.8.0 CLI Example: ...
List port forwarding .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.list_port_fwd public def list_port_fwd(zone, permanent=True): ''' List port forwarding .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firew...
Block a specific ICMP type on a zone .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.block_icmp zone echo-reply def block_icmp(zone, icmp, permanent=True): ''' Block a specific ICMP type on a zone .. versionadded:: 2015.8.0 CLI Example: .. ...
List ICMP blocks on a zone .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewlld.list_icmp_block zone def list_icmp_block(zone, permanent=True): ''' List ICMP blocks on a zone .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash s...
List interfaces bound to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' firewalld.get_interfaces zone def get_interfaces(zone, permanent=True): ''' List interfaces bound to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash ...
Bind an interface to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_interface zone eth0 def add_interface(zone, interface, permanent=True): ''' Bind an interface to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: ...
List sources bound to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' firewalld.get_sources zone def get_sources(zone, permanent=True): ''' List sources bound to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt...
Bind a source to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_source zone 192.168.1.0/24 def add_source(zone, source, permanent=True): ''' Bind a source to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash ...
List rich rules bound to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.get_rich_rules zone def get_rich_rules(zone, permanent=True): ''' List rich rules bound to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash...
Add a rich rule to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_rich_rule zone 'rule' def add_rich_rule(zone, rule, permanent=True): ''' Add a rich rule to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash ...
Add a rich rule to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_rich_rule zone 'rule' def remove_rich_rule(zone, rule, permanent=True): ''' Add a rich rule to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block::...
Return list of mdadm devices def mdadm(): ''' Return list of mdadm devices ''' devices = set() try: with salt.utils.files.fopen('/proc/mdstat', 'r') as mdstat: for line in mdstat: line = salt.utils.stringutils.to_unicode(line) if line.startswith('...
Returns the connection details of the following proxies: esxi def _get_proxy_connection_details(): ''' Returns the connection details of the following proxies: esxi ''' proxytype = get_proxy_type() if proxytype == 'esxi': details = __salt__['esxi.get_details']() elif proxytype == 'esxcl...
Decorator to specify which proxy types are supported by a function proxy_types: Arbitrary list of strings with the supported types of proxies def supports_proxies(*proxy_types): ''' Decorator to specify which proxy types are supported by a function proxy_types: Arbitrary list of strin...
Decorator that connects to a target system (vCenter or ESXi host) using the proxy details and passes the connection (vim.ServiceInstance) to the decorated function. Supported proxies: esxi, esxcluster, esxdatacenter. Notes: 1. The decorated function must have a ``service_instance`` parameter ...
Run an ESXCLI command directly on the host or list of hosts. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. cmd_str The ESXCLI command to run. Note: This should not inc...
Retrieve information on ESXi or vCenter network dump collection and format it into a dictionary. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally ...
Enable or disable ESXi core dump collection. Returns ``True`` if coredump is enabled and returns ``False`` if core dump is not enabled. If there was an error, the error will be the value printed in the ``Error`` key dictionary for the given host. host The location of the host. username ...
Enable or disable an ESXi firewall rule set. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. ruleset_enable True to enable the ruleset, false to disable. ruleset_na...
Set the specified syslog configuration parameter. By default, this function will reset the syslog service after the configuration is set. host ESXi or vCenter host to connect to. username User to connect as, usually root. password Password to connect with. syslog_config ...
Retrieve the syslog configuration. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if the host is not using the default ...
Reset the syslog service to its default settings. Valid syslog_config values are ``logdir``, ``loghost``, ``logdir-unique``, ``default-rotate``, ``default-size``, ``default-timeout``, or ``all`` for all of these. host The location of the host. username The username used to login t...
Upload an ssh key for root to an ESXi host via http PUT. This function only works for ESXi, not vCenter. Only one ssh key can be uploaded for root. Uploading a second key will replace any existing key. :param host: The location of the ESXi Host :param username: Username to connect as :param pa...
Retrieve the authorized_keys entry for root. This function only works for ESXi, not vCenter. :param host: The location of the ESXi Host :param username: Username to connect as :param password: Password for the ESXi web endpoint :param protocol: defaults to https, can be http if ssl is disabled on E...
Get the date/time information for a given host or list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if th...
Get the NTP configuration information for a given host or list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protoc...
Get the service name's policy for a given host or list of hosts. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. service_name The name of the service for which to retrie...
Get the VMotion enabled status for a given host or a list of host_names. Returns ``True`` if VMotion is enabled, ``False`` if it is not enabled. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to logi...
Get the VSAN enabled status for a given host or a list of host_names. Returns ``True`` if VSAN is enabled, ``False`` if it is not enabled, and ``None`` if a VSAN Host Config is unset, per host. host The location of the host. username The username used to login to the host, such as ``ro...
Returns a list of VSAN-eligible disks for a given host or list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protoc...
Return system information about a VMware environment. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if the host is not us...
Returns a list of datacenters for the the specified host. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if the host is no...
Returns a list of SSDs for the given host or list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if the hos...
Set NTP configuration for a given host of list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. ntp_servers A list of servers that should be added to and c...
Start the named service for the given host or list of hosts. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. service_name The name of the service for which to set the po...
Set the service name's policy for a given host or list of hosts. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. service_name The name of the service for which to set th...
Update the date/time on the given host or list of host_names. This function should be used with caution since network delays and execution delays can result in time skews. host The location of the host. username The username used to login to the host, such as ``root``. password ...
Update the password for a given host. .. note:: Currently only works with connections to ESXi hosts. Does not work with vCenter servers. host The location of the ESXi host. username The username used to login to the ESXi host, such as ``root``. password The password used to l...
Disable vMotion for a given host or list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if the host is not ...
Add any VSAN-eligible disks to the VSAN System for the given host or list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alter...
Disable VSAN for a given host or list of host_names. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if the host is not usi...
Returns the dict representation of the DVS config dvs_name The name of the DVS dvs_config The DVS config def _get_dvs_config_dict(dvs_name, dvs_config): ''' Returns the dict representation of the DVS config dvs_name The name of the DVS dvs_config The DVS conf...
Returns the dict representation of the DVS link discovery protocol dvs_name The name of the DVS dvs_link_disc_protocl The DVS link discovery protocol def _get_dvs_link_discovery_protocol(dvs_name, dvs_link_disc_protocol): ''' Returns the dict representation of the DVS link discovery p...
Returns the dict representation of the DVS product_info dvs_name The name of the DVS dvs_product_info The DVS product info def _get_dvs_product_info(dvs_name, dvs_product_info): ''' Returns the dict representation of the DVS product_info dvs_name The name of the DVS ...
Returns the dict representation of the DVS product_info dvs_name The name of the DVS dvs_capability The DVS capability def _get_dvs_capability(dvs_name, dvs_capability): ''' Returns the dict representation of the DVS product_info dvs_name The name of the DVS dvs_capa...
Returns a list of dict representations of the DVS infrastructure traffic resource dvs_name The name of the DVS dvs_infra_traffic_ress The DVS infrastructure traffic resources def _get_dvs_infrastructure_traffic_resources(dvs_name, dvs_infra_tr...
Returns a list of distributed virtual switches (DVSs). The list can be filtered by the datacenter or DVS names. datacenter The datacenter to look for DVSs in. Default value is None. dvs_names List of DVS names to look for. If None, all DVSs are returned. Default value is No...
Applies the values of the config dict dictionary to a config spec (vim.VMwareDVSConfigSpec) def _apply_dvs_config(config_spec, config_dict): ''' Applies the values of the config dict dictionary to a config spec (vim.VMwareDVSConfigSpec) ''' if config_dict.get('name'): config_spec.name =...
Applies the values of the product_info_dict dictionary to a product info spec (vim.DistributedVirtualSwitchProductSpec) def _apply_dvs_product_info(product_info_spec, product_info_dict): ''' Applies the values of the product_info_dict dictionary to a product info spec (vim.DistributedVirtualSwitchProdu...
Applies the values of the capability_dict dictionary to a DVS capability object (vim.vim.DVSCapability) def _apply_dvs_capability(capability_spec, capability_dict): ''' Applies the values of the capability_dict dictionary to a DVS capability object (vim.vim.DVSCapability) ''' if 'operation_supp...
Applies the values of the resource dictionaries to infra traffic resources, creating the infra traffic resource if required (vim.DistributedVirtualSwitchProductSpec) def _apply_dvs_infrastructure_traffic_resources(infra_traffic_resources, resource_dicts): '''...
Applies the values of the resource dictionaries to network resource pools, creating the resource pools if required (vim.DVSNetworkResourcePoolConfigSpec) def _apply_dvs_network_resource_pools(network_resource_pools, resource_dicts): ''' Applies the values of the resource dictionaries to network resourc...
Creates a distributed virtual switch (DVS). Note: The ``dvs_name`` param will override any name set in ``dvs_dict``. dvs_dict Dict representation of the new DVS (example in salt.states.dvs) dvs_name Name of the DVS to be created. service_instance Service instance (vim.Service...
Updates a distributed virtual switch (DVS). Note: Updating the product info, capability, uplinks of a DVS is not supported so the corresponding entries in ``dvs_dict`` will be ignored. dvs_dict Dictionary with the values the DVS should be update with (example in salt.states...
Returns the out shaping policy of a distributed virtual portgroup pg_name The name of the portgroup pg_default_port_config The dafault port config of the portgroup def _get_dvportgroup_out_shaping(pg_name, pg_default_port_config): ''' Returns the out shaping policy of a distributed vi...
Returns the security policy of a distributed virtual portgroup pg_name The name of the portgroup pg_default_port_config The dafault port config of the portgroup def _get_dvportgroup_security_policy(pg_name, pg_default_port_config): ''' Returns the security policy of a distributed virt...
Returns the teaming of a distributed virtual portgroup pg_name The name of the portgroup pg_default_port_config The dafault port config of the portgroup def _get_dvportgroup_teaming(pg_name, pg_default_port_config): ''' Returns the teaming of a distributed virtual portgroup pg_na...
Returns a dictionary with a distributed virutal portgroup data pg_ref Portgroup reference def _get_dvportgroup_dict(pg_ref): ''' Returns a dictionary with a distributed virutal portgroup data pg_ref Portgroup reference ''' props = salt.utils.vmware.get_properties_of_managed_...
Returns a list of distributed virtual switch portgroups. The list can be filtered by the portgroup names or by the DVS. dvs Name of the DVS containing the portgroups. Default value is None. portgroup_names List of portgroup names to look for. If None, all portgroups are ret...
Returns the uplink portgroup of a distributed virtual switch. dvs Name of the DVS containing the portgroup. service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. .. code-block:: bash salt '*' vsphere.list_uplink_dvportgroup dvs=dvs_name ...
Applies the values in out_shaping_conf to an out_shaping object pg_name The name of the portgroup out_shaping The vim.DVSTrafficShapingPolicy to apply the config to out_shaping_conf The out shaping config def _apply_dvportgroup_out_shaping(pg_name, out_shaping, out_shaping_conf):...
Applies the values in sec_policy_conf to a security policy object pg_name The name of the portgroup sec_policy The vim.DVSTrafficShapingPolicy to apply the config to sec_policy_conf The out shaping config def _apply_dvportgroup_security_policy(pg_name, sec_policy, sec_policy_conf...
Applies the values in teaming_conf to a teaming policy object pg_name The name of the portgroup teaming The vim.VmwareUplinkPortTeamingPolicy to apply the config to teaming_conf The teaming config def _apply_dvportgroup_teaming(pg_name, teaming, teaming_conf): ''' Applies...
Applies the values in conf to a distributed portgroup spec pg_name The name of the portgroup pg_spec The vim.DVPortgroupConfigSpec to apply the config to pg_conf The portgroup config def _apply_dvportgroup_config(pg_name, pg_spec, pg_conf): ''' Applies the values in conf ...
Creates a distributed virtual portgroup. Note: The ``portgroup_name`` param will override any name already set in ``portgroup_dict``. portgroup_dict Dictionary with the config values the portgroup should be created with (example in salt.states.dvs). portgroup_name Name of the ...
Updates a distributed virtual portgroup. portgroup_dict Dictionary with the values the portgroup should be update with (example in salt.states.dvs). portgroup Name of the portgroup to be updated. dvs Name of the DVS containing the portgroups. service_instance ...
Removes a distributed virtual portgroup. portgroup Name of the portgroup to be removed. dvs Name of the DVS containing the portgroups. service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. .. code-block:: bash salt '*' vsphe...
Returns a dictionary representation of a policy def _get_policy_dict(policy): '''Returns a dictionary representation of a policy''' profile_dict = {'name': policy.name, 'description': policy.description, 'resource_type': policy.resourceType.resourceType} subprofile_d...
Returns a list of storage policies. policy_names Names of policies to list. If None, all policies are listed. Default is None. service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. .. code-block:: bash salt '*' vsphere.list_stora...
Returns the default vsan storage policy. service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. .. code-block:: bash salt '*' vsphere.list_storage_policies salt '*' vsphere.list_storage_policy policy_names=[policy_name] def list_default_vsan...
Returns a list of the metadata of all capabilities in the vCenter. service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. .. code-block:: bash salt '*' vsphere.list_capabilities def list_capability_definitions(service_instance=None): ''' Retu...
Applies a policy dictionary to a policy spec def _apply_policy_config(policy_spec, policy_dict): '''Applies a policy dictionary to a policy spec''' log.trace('policy_dict = %s', policy_dict) if policy_dict.get('name'): policy_spec.name = policy_dict['name'] if policy_dict.get('description'): ...
Creates a storage policy. Supported capability types: scalar, set, range. policy_name Name of the policy to create. The value of the argument will override any existing name in ``policy_dict``. policy_dict Dictionary containing the changes to apply to the policy. (...
Updates a storage policy. Supported capability types: scalar, set, range. policy Name of the policy to update. policy_dict Dictionary containing the changes to apply to the policy. (example in salt.states.pbm) service_instance Service instance (vim.ServiceInstance) of...
Returns a list of datastores assign the the storage policies. datastore Name of the datastore to assign. The datastore needs to be visible to the VMware entity the proxy points to. service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. ...
Assigns a storage policy as the default policy to a datastore. policy Name of the policy to assign. datastore Name of the datastore to assign. The datastore needs to be visible to the VMware entity the proxy points to. service_instance Service instance (vim.Service...
Returns a list of dict representations of VMware datacenters. Connection is done via the proxy details. Supported proxies: esxdatacenter datacenter_names List of datacenter names. Default is None. service_instance Service instance (vim.ServiceInstance) of the vCenter. ...
Creates a datacenter. Supported proxies: esxdatacenter datacenter_name The datacenter name service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. .. code-block:: bash salt '*' vsphere.create_datacenter dc1 def create_datacenter(data...