INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Trigger alternatives to set the path for <name> as specified by priority. CLI Example: .. code-block:: bash salt '*' alternatives.auto name
def auto(name): ''' Trigger alternatives to set the path for <name> as specified by priority. CLI Example: .. code-block:: bash salt '*' alternatives.auto name ''' cmd = [_get_cmd(), '--auto', name] out = __salt__['cmd.run_all'](cmd, python_shell=False) if out['retcode'] >...
Read the link from /etc/alternatives Throws an OSError if the link does not exist
def _read_link(name): ''' Read the link from /etc/alternatives Throws an OSError if the link does not exist ''' alt_link_path = '/etc/alternatives/{0}'.format(name) return salt.utils.path.readlink(alt_link_path)
Returns a placement solver service_instance Service instance to the host or vCenter
def get_placement_solver(service_instance): ''' Returns a placement solver service_instance Service instance to the host or vCenter ''' stub = salt.utils.vmware.get_new_service_instance_stub( service_instance, ns='pbm/2.0', path='/pbm/sdk') pbm_si = pbm.ServiceInstance('ServiceI...
Returns a list of all capability definitions. profile_manager Reference to the profile manager.
def get_capability_definitions(profile_manager): ''' Returns a list of all capability definitions. profile_manager Reference to the profile manager. ''' res_type = pbm.profile.ResourceType( resourceType=pbm.profile.ResourceTypeEnum.STORAGE) try: cap_categories = profile_...
Returns a list of policies with the specified ids. profile_manager Reference to the profile manager. policy_ids List of policy ids to retrieve.
def get_policies_by_id(profile_manager, policy_ids): ''' Returns a list of policies with the specified ids. profile_manager Reference to the profile manager. policy_ids List of policy ids to retrieve. ''' try: return profile_manager.RetrieveContent(policy_ids) excep...
Returns a list of the storage policies, filtered by name. profile_manager Reference to the profile manager. policy_names List of policy names to filter by. Default is None. get_all_policies Flag specifying to return all policies, regardless of the specified filter.
def get_storage_policies(profile_manager, policy_names=None, get_all_policies=False): ''' Returns a list of the storage policies, filtered by name. profile_manager Reference to the profile manager. policy_names List of policy names to filter by. Default...
Creates a storage policy. profile_manager Reference to the profile manager. policy_spec Policy update spec.
def create_storage_policy(profile_manager, policy_spec): ''' Creates a storage policy. profile_manager Reference to the profile manager. policy_spec Policy update spec. ''' try: profile_manager.Create(policy_spec) except vim.fault.NoPermission as exc: log.ex...
Updates a storage policy. profile_manager Reference to the profile manager. policy Reference to the policy to be updated. policy_spec Policy update spec.
def update_storage_policy(profile_manager, policy, policy_spec): ''' Updates a storage policy. profile_manager Reference to the profile manager. policy Reference to the policy to be updated. policy_spec Policy update spec. ''' try: profile_manager.Update(po...
Returns the default storage policy reference assigned to a datastore. profile_manager Reference to the profile manager. datastore Reference to the datastore.
def get_default_storage_policy_of_datastore(profile_manager, datastore): ''' Returns the default storage policy reference assigned to a datastore. profile_manager Reference to the profile manager. datastore Reference to the datastore. ''' # Retrieve all datastores visible h...
Assigns a storage policy as the default policy to a datastore. profile_manager Reference to the profile manager. policy Reference to the policy to assigned. datastore Reference to the datastore.
def assign_default_storage_policy_to_datastore(profile_manager, policy, datastore): ''' Assigns a storage policy as the default policy to a datastore. profile_manager Reference to the profile manager. policy Reference to the policy to assi...
Set a value into the Redis SDB.
def set_(key, value, profile=None): ''' Set a value into the Redis SDB. ''' if not profile: return False redis_kwargs = profile.copy() redis_kwargs.pop('driver') redis_conn = redis.StrictRedis(**redis_kwargs) return redis_conn.set(key, value)
Get a value from the Redis SDB.
def get(key, profile=None): ''' Get a value from the Redis SDB. ''' if not profile: return False redis_kwargs = profile.copy() redis_kwargs.pop('driver') redis_conn = redis.StrictRedis(**redis_kwargs) return redis_conn.get(key)
Ensures a load balancer is present. :param name: Load Balancer name :type name: ``str`` :param port: Port the load balancer should listen on, defaults to 80 :type port: ``str`` :param protocol: Loadbalancer protocol, defaults to http. :type protocol: ``str`` :param profile: The profil...
def balancer_present(name, port, protocol, profile, algorithm=None, members=None, **libcloud_kwargs): ''' Ensures a load balancer is present. :param name: Load Balancer name :type name: ``str`` :param port: Port the load balancer should listen on, defaults to 80 :type port: ``str`` :par...
Ensures a load balancer is absent. :param name: Load Balancer name :type name: ``str`` :param profile: The profile key :type profile: ``str``
def balancer_absent(name, profile, **libcloud_kwargs): ''' Ensures a load balancer is absent. :param name: Load Balancer name :type name: ``str`` :param profile: The profile key :type profile: ``str`` ''' balancers = __salt__['libcloud_loadbalancer.list_balancers'](profile) match...
Ensure a load balancer member is present :param ip: IP address for the new member :type ip: ``str`` :param port: Port for the new member :type port: ``int`` :param balancer_id: id of a load balancer you want to attach the member to :type balancer_id: ``str`` :param profile: The profil...
def member_present(ip, port, balancer_id, profile, **libcloud_kwargs): ''' Ensure a load balancer member is present :param ip: IP address for the new member :type ip: ``str`` :param port: Port for the new member :type port: ``int`` :param balancer_id: id of a load balancer you want to a...
Ensure a load balancer member is absent, based on IP and Port :param ip: IP address for the member :type ip: ``str`` :param port: Port for the member :type port: ``int`` :param balancer_id: id of a load balancer you want to detach the member from :type balancer_id: ``str`` :param prof...
def member_absent(ip, port, balancer_id, profile, **libcloud_kwargs): ''' Ensure a load balancer member is absent, based on IP and Port :param ip: IP address for the member :type ip: ``str`` :param port: Port for the member :type port: ``int`` :param balancer_id: id of a load balancer y...
parses the output into a dictionary
def _parser(result): ''' parses the output into a dictionary ''' # regexes to match _total_time = re.compile(r'total time:\s*(\d*.\d*s)') _total_execution = re.compile(r'event execution:\s*(\d*.\d*s?)') _min_response_time = re.compile(r'min:\s*(\d*.\d*ms)') _max_response_time = re.compi...
Tests for the CPU performance of minions. CLI Examples: .. code-block:: bash salt '*' sysbench.cpu
def cpu(): ''' Tests for the CPU performance of minions. CLI Examples: .. code-block:: bash salt '*' sysbench.cpu ''' # Test data max_primes = [500, 1000, 2500, 5000] # Initializing the test variables test_command = 'sysbench --test=cpu --cpu-max-prime={0} run' resul...
This tests the performance of the processor's scheduler CLI Example: .. code-block:: bash salt '*' sysbench.threads
def threads(): ''' This tests the performance of the processor's scheduler CLI Example: .. code-block:: bash salt '*' sysbench.threads ''' # Test data thread_yields = [100, 200, 500, 1000] thread_locks = [2, 4, 8, 16] # Initializing the test variables test_command = ...
Tests the implementation of mutex CLI Examples: .. code-block:: bash salt '*' sysbench.mutex
def mutex(): ''' Tests the implementation of mutex CLI Examples: .. code-block:: bash salt '*' sysbench.mutex ''' # Test options and the values they take # --mutex-num = [50,500,1000] # --mutex-locks = [10000,25000,50000] # --mutex-loops = [2500,5000,10000] # Test da...
This tests the memory for read and write operations. CLI Examples: .. code-block:: bash salt '*' sysbench.memory
def memory(): ''' This tests the memory for read and write operations. CLI Examples: .. code-block:: bash salt '*' sysbench.memory ''' # test defaults # --memory-block-size = 10M # --memory-total-size = 1G # We test memory read / write against global / local scope of mem...
This tests for the file read and write operations Various modes of operations are * sequential write * sequential rewrite * sequential read * random read * random write * random read and write The test works with 32 files with each file being 1Gb in size The test consumes a lot of ...
def fileio(): ''' This tests for the file read and write operations Various modes of operations are * sequential write * sequential rewrite * sequential read * random read * random write * random read and write The test works with 32 files with each file being 1Gb in size T...
Return LVM version from lvm version CLI Example: .. code-block:: bash salt '*' lvm.version
def version(): ''' Return LVM version from lvm version CLI Example: .. code-block:: bash salt '*' lvm.version ''' cmd = 'lvm version' out = __salt__['cmd.run'](cmd).splitlines() ret = out[0].split(': ') return ret[1].strip()
Return all version info from lvm version CLI Example: .. code-block:: bash salt '*' lvm.fullversion
def fullversion(): ''' Return all version info from lvm version CLI Example: .. code-block:: bash salt '*' lvm.fullversion ''' ret = {} cmd = 'lvm version' out = __salt__['cmd.run'](cmd).splitlines() for line in out: comps = line.split(':') ret[comps[0].str...
Return information about the physical volume(s) pvname physical device name real dereference any symlinks and report the real device .. versionadded:: 2015.8.7 quiet if the physical volume is not present, do not show any error CLI Examples: .. code-block:: bash...
def pvdisplay(pvname='', real=False, quiet=False): ''' Return information about the physical volume(s) pvname physical device name real dereference any symlinks and report the real device .. versionadded:: 2015.8.7 quiet if the physical volume is not present, do n...
Return information about the volume group(s) vgname volume group name quiet if the volume group is not present, do not show any error CLI Examples: .. code-block:: bash salt '*' lvm.vgdisplay salt '*' lvm.vgdisplay nova-volumes
def vgdisplay(vgname='', quiet=False): ''' Return information about the volume group(s) vgname volume group name quiet if the volume group is not present, do not show any error CLI Examples: .. code-block:: bash salt '*' lvm.vgdisplay salt '*' lvm.vgdisplay n...
Return information about the logical volume(s) lvname logical device name quiet if the logical volume is not present, do not show any error CLI Examples: .. code-block:: bash salt '*' lvm.lvdisplay salt '*' lvm.lvdisplay /dev/vg_myserver/root
def lvdisplay(lvname='', quiet=False): ''' Return information about the logical volume(s) lvname logical device name quiet if the logical volume is not present, do not show any error CLI Examples: .. code-block:: bash salt '*' lvm.lvdisplay salt '*' lvm.lvdis...
Set a physical device to be used as an LVM physical volume override Skip devices, if they are already LVM physical volumes CLI Examples: .. code-block:: bash salt mymachine lvm.pvcreate /dev/sdb1,/dev/sdb2 salt mymachine lvm.pvcreate /dev/sdb1 dataalignmentoffset=7s
def pvcreate(devices, override=True, **kwargs): ''' Set a physical device to be used as an LVM physical volume override Skip devices, if they are already LVM physical volumes CLI Examples: .. code-block:: bash salt mymachine lvm.pvcreate /dev/sdb1,/dev/sdb2 salt mymachine...
Remove a physical device being used as an LVM physical volume override Skip devices, if they are already not used as LVM physical volumes CLI Examples: .. code-block:: bash salt mymachine lvm.pvremove /dev/sdb1,/dev/sdb2
def pvremove(devices, override=True): ''' Remove a physical device being used as an LVM physical volume override Skip devices, if they are already not used as LVM physical volumes CLI Examples: .. code-block:: bash salt mymachine lvm.pvremove /dev/sdb1,/dev/sdb2 ''' if is...
Create an LVM volume group CLI Examples: .. code-block:: bash salt mymachine lvm.vgcreate my_vg /dev/sdb1,/dev/sdb2 salt mymachine lvm.vgcreate my_vg /dev/sdb1 clustered=y
def vgcreate(vgname, devices, **kwargs): ''' Create an LVM volume group CLI Examples: .. code-block:: bash salt mymachine lvm.vgcreate my_vg /dev/sdb1,/dev/sdb2 salt mymachine lvm.vgcreate my_vg /dev/sdb1 clustered=y ''' if not vgname or not devices: return 'Error: vgn...
Add physical volumes to an LVM volume group CLI Examples: .. code-block:: bash salt mymachine lvm.vgextend my_vg /dev/sdb1,/dev/sdb2 salt mymachine lvm.vgextend my_vg /dev/sdb1
def vgextend(vgname, devices): ''' Add physical volumes to an LVM volume group CLI Examples: .. code-block:: bash salt mymachine lvm.vgextend my_vg /dev/sdb1,/dev/sdb2 salt mymachine lvm.vgextend my_vg /dev/sdb1 ''' if not vgname or not devices: return 'Error: vgname a...
Create a new logical volume, with option for which physical volume to be used CLI Examples: .. code-block:: bash salt '*' lvm.lvcreate new_volume_name vg_name size=10G salt '*' lvm.lvcreate new_volume_name vg_name extents=100 pv=/dev/sdb salt '*' lvm.lvcreate new_snapshot ...
def lvcreate(lvname, vgname, size=None, extents=None, snapshot=None, pv=None, thinvolume=False, thinpool=False, force=False, **kwargs): ''' Create a new logical volume, with option for which phys...
Remove an LVM volume group CLI Examples: .. code-block:: bash salt mymachine lvm.vgremove vgname salt mymachine lvm.vgremove vgname force=True
def vgremove(vgname): ''' Remove an LVM volume group CLI Examples: .. code-block:: bash salt mymachine lvm.vgremove vgname salt mymachine lvm.vgremove vgname force=True ''' cmd = ['vgremove', '-f', vgname] out = __salt__['cmd.run'](cmd, python_shell=False) return out.s...
Remove a given existing logical volume from a named existing volume group CLI Example: .. code-block:: bash salt '*' lvm.lvremove lvname vgname force=True
def lvremove(lvname, vgname): ''' Remove a given existing logical volume from a named existing volume group CLI Example: .. code-block:: bash salt '*' lvm.lvremove lvname vgname force=True ''' cmd = ['lvremove', '-f', '{0}/{1}'.format(vgname, lvname)] out = __salt__['cmd.run'](cmd...
Return information about the logical volume(s) CLI Examples: .. code-block:: bash salt '*' lvm.lvresize +12M /dev/mapper/vg1-test salt '*' lvm.lvresize lvpath=/dev/mapper/vg1-test extents=+100%FREE
def lvresize(size=None, lvpath=None, extents=None): ''' Return information about the logical volume(s) CLI Examples: .. code-block:: bash salt '*' lvm.lvresize +12M /dev/mapper/vg1-test salt '*' lvm.lvresize lvpath=/dev/mapper/vg1-test extents=+100%FREE ''' if size and exten...
.. versionadded:: 2019.2.0 List all resource groups within a subscription. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_groups_list
def resource_groups_list(**kwargs): ''' .. versionadded:: 2019.2.0 List all resource groups within a subscription. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_groups_list ''' result = {} resconn = __utils__['azurearm.get_client']('resource', **kwar...
.. versionadded:: 2019.2.0 Check for the existence of a named resource group in the current subscription. :param name: The resource group name to check. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_group_check_existence testgroup
def resource_group_check_existence(name, **kwargs): ''' .. versionadded:: 2019.2.0 Check for the existence of a named resource group in the current subscription. :param name: The resource group name to check. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_gro...
.. versionadded:: 2019.2.0 Get a dictionary representing a resource group's properties. :param name: The resource group name to get. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_group_get testgroup
def resource_group_get(name, **kwargs): ''' .. versionadded:: 2019.2.0 Get a dictionary representing a resource group's properties. :param name: The resource group name to get. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_group_get testgroup ''' re...
.. versionadded:: 2019.2.0 Create or update a resource group in a given location. :param name: The name of the resource group to create or update. :param location: The location of the resource group. This value is not able to be updated once the resource group is created. CLI Example: ....
def resource_group_create_or_update(name, location, **kwargs): # pylint: disable=invalid-name ''' .. versionadded:: 2019.2.0 Create or update a resource group in a given location. :param name: The name of the resource group to create or update. :param location: The location of the resource group...
.. versionadded:: 2019.2.0 Delete a resource group from the subscription. :param name: The resource group name to delete. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_group_delete testgroup
def resource_group_delete(name, **kwargs): ''' .. versionadded:: 2019.2.0 Delete a resource group from the subscription. :param name: The resource group name to delete. CLI Example: .. code-block:: bash salt-call azurearm_resource.resource_group_delete testgroup ''' result ...
.. versionadded:: 2019.2.0 Get a deployment operation within a deployment. :param operation: The operation ID of the operation within the deployment. :param deployment: The name of the deployment containing the operation. :param resource_group: The resource group name assigned to the deploym...
def deployment_operation_get(operation, deployment, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Get a deployment operation within a deployment. :param operation: The operation ID of the operation within the deployment. :param deployment: The name of the deployment containing the ope...
.. versionadded:: 2019.2.0 List all deployment operations within a deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. :param result_limit: (Default: 10) The limit on the list of deployment operation...
def deployment_operations_list(name, resource_group, result_limit=10, **kwargs): ''' .. versionadded:: 2019.2.0 List all deployment operations within a deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. ...
.. versionadded:: 2019.2.0 Delete a deployment. :param name: The name of the deployment to delete. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-block:: bash salt-call azurearm_resource.deployment_delete testdeploy testgroup
def deployment_delete(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Delete a deployment. :param name: The name of the deployment to delete. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-block:: bash sal...
.. versionadded:: 2019.2.0 Check the existence of a deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-block:: bash salt-call azurearm_resource.deployment_check_existence ...
def deployment_check_existence(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Check the existence of a deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-b...
.. versionadded:: 2019.2.0 Get details about a specific deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-block:: bash salt-call azurearm_resource.deployment_get testdepl...
def deployment_get(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Get details about a specific deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-block:: b...
.. versionadded:: 2019.2.0 Cancel a deployment if in 'Accepted' or 'Running' state. :param name: The name of the deployment to cancel. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-block:: bash salt-call azurearm_resource.deploy...
def deployment_cancel(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Cancel a deployment if in 'Accepted' or 'Running' state. :param name: The name of the deployment to cancel. :param resource_group: The resource group name assigned to the deployment. CLI Example: ...
.. versionadded:: 2019.2.0 Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager. :param name: The name of the deployment to validate. :param resource_group: The resource group name assigned to the deployment. :param deploy_mode:...
def deployment_validate(name, resource_group, deploy_mode=None, debug_setting=None, deploy_params=None, parameters_link=None, deploy_template=None, template_link=None, **kwargs): ''' .. versionadded:: 2019.2.0 Validates whether the spe...
.. versionadded:: 2019.2.0 Exports the template used for the specified deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. CLI Example: .. code-block:: bash salt-call azurearm_resource.deployme...
def deployment_export_template(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Exports the template used for the specified deployment. :param name: The name of the deployment to query. :param resource_group: The resource group name assigned to the deployment. CLI Exam...
.. versionadded:: 2019.2.0 List all deployments within a resource group. CLI Example: .. code-block:: bash salt-call azurearm_resource.deployments_list testgroup
def deployments_list(resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 List all deployments within a resource group. CLI Example: .. code-block:: bash salt-call azurearm_resource.deployments_list testgroup ''' result = {} resconn = __utils__['azurearm.get_client']('r...
.. versionadded:: 2019.2.0 List all locations for a subscription. :param subscription_id: The ID of the subscription to query. CLI Example: .. code-block:: bash salt-call azurearm_resource.subscriptions_list_locations XXXXXXXX
def subscriptions_list_locations(subscription_id=None, **kwargs): ''' .. versionadded:: 2019.2.0 List all locations for a subscription. :param subscription_id: The ID of the subscription to query. CLI Example: .. code-block:: bash salt-call azurearm_resource.subscriptions_list_locat...
.. versionadded:: 2019.2.0 Get details about a subscription. :param subscription_id: The ID of the subscription to query. CLI Example: .. code-block:: bash salt-call azurearm_resource.subscription_get XXXXXXXX
def subscription_get(subscription_id=None, **kwargs): ''' .. versionadded:: 2019.2.0 Get details about a subscription. :param subscription_id: The ID of the subscription to query. CLI Example: .. code-block:: bash salt-call azurearm_resource.subscription_get XXXXXXXX ''' re...
.. versionadded:: 2019.2.0 List all subscriptions for a tenant. CLI Example: .. code-block:: bash salt-call azurearm_resource.subscriptions_list
def subscriptions_list(**kwargs): ''' .. versionadded:: 2019.2.0 List all subscriptions for a tenant. CLI Example: .. code-block:: bash salt-call azurearm_resource.subscriptions_list ''' result = {} subconn = __utils__['azurearm.get_client']('subscription', **kwargs) try...
.. versionadded:: 2019.2.0 List all tenants for your account. CLI Example: .. code-block:: bash salt-call azurearm_resource.tenants_list
def tenants_list(**kwargs): ''' .. versionadded:: 2019.2.0 List all tenants for your account. CLI Example: .. code-block:: bash salt-call azurearm_resource.tenants_list ''' result = {} subconn = __utils__['azurearm.get_client']('subscription', **kwargs) try: tena...
.. versionadded:: 2019.2.0 Delete a policy assignment. :param name: The name of the policy assignment to delete. :param scope: The scope of the policy assignment. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_assignment_delete testassign \ /subscriptions/...
def policy_assignment_delete(name, scope, **kwargs): ''' .. versionadded:: 2019.2.0 Delete a policy assignment. :param name: The name of the policy assignment to delete. :param scope: The scope of the policy assignment. CLI Example: .. code-block:: bash salt-call azurearm_resou...
.. versionadded:: 2019.2.0 Create a policy assignment. :param name: The name of the policy assignment to create. :param scope: The scope of the policy assignment. :param definition_name: The name of the policy definition to assign. CLI Example: .. code-block:: bash salt-call azure...
def policy_assignment_create(name, scope, definition_name, **kwargs): ''' .. versionadded:: 2019.2.0 Create a policy assignment. :param name: The name of the policy assignment to create. :param scope: The scope of the policy assignment. :param definition_name: The name of the policy definiti...
.. versionadded:: 2019.2.0 Get details about a specific policy assignment. :param name: The name of the policy assignment to query. :param scope: The scope of the policy assignment. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_assignment_get testassign \ ...
def policy_assignment_get(name, scope, **kwargs): ''' .. versionadded:: 2019.2.0 Get details about a specific policy assignment. :param name: The name of the policy assignment to query. :param scope: The scope of the policy assignment. CLI Example: .. code-block:: bash salt-cal...
.. versionadded:: 2019.2.0 List all policy assignments for a resource group. :param resource_group: The resource group name to list policy assignments within. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_assignments_list_for_resource_group testgroup
def policy_assignments_list_for_resource_group(resource_group, **kwargs): # pylint: disable=invalid-name ''' .. versionadded:: 2019.2.0 List all policy assignments for a resource group. :param resource_group: The resource group name to list policy assignments within. CLI Example: .. code-bl...
.. versionadded:: 2019.2.0 List all policy assignments for a subscription. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_assignments_list
def policy_assignments_list(**kwargs): ''' .. versionadded:: 2019.2.0 List all policy assignments for a subscription. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_assignments_list ''' result = {} polconn = __utils__['azurearm.get_client']('policy', **...
.. versionadded:: 2019.2.0 Create or update a policy definition. :param name: The name of the policy definition to create or update. :param policy_rule: A dictionary defining the `policy rule <https://docs.microsoft.com/en-us/azure/azure-policy/policy-definition#policy-rule>`_. CLI Example: ...
def policy_definition_create_or_update(name, policy_rule, **kwargs): # pylint: disable=invalid-name ''' .. versionadded:: 2019.2.0 Create or update a policy definition. :param name: The name of the policy definition to create or update. :param policy_rule: A dictionary defining the `poli...
.. versionadded:: 2019.2.0 Delete a policy definition. :param name: The name of the policy definition to delete. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_definition_delete testpolicy
def policy_definition_delete(name, **kwargs): ''' .. versionadded:: 2019.2.0 Delete a policy definition. :param name: The name of the policy definition to delete. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_definition_delete testpolicy ''' result = ...
.. versionadded:: 2019.2.0 Get details about a specific policy definition. :param name: The name of the policy definition to query. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_definition_get testpolicy
def policy_definition_get(name, **kwargs): ''' .. versionadded:: 2019.2.0 Get details about a specific policy definition. :param name: The name of the policy definition to query. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_definition_get testpolicy ''' ...
.. versionadded:: 2019.2.0 List all policy definitions for a subscription. :param hide_builtin: Boolean which will filter out BuiltIn policy definitions from the result. CLI Example: .. code-block:: bash salt-call azurearm_resource.policy_definitions_list
def policy_definitions_list(hide_builtin=False, **kwargs): ''' .. versionadded:: 2019.2.0 List all policy definitions for a subscription. :param hide_builtin: Boolean which will filter out BuiltIn policy definitions from the result. CLI Example: .. code-block:: bash salt-call azurea...
Query an instance upon creation from the Joyent API
def query_instance(vm_=None, call=None): ''' Query an instance upon creation from the Joyent API ''' if isinstance(vm_, six.string_types) and call == 'action': vm_ = {'name': vm_, 'provider': 'joyent'} if call == 'function': # Technically this function may be called other ways too, ...
Create a single VM from a data dict CLI Example: .. code-block:: bash salt-cloud -p profile_name vm_name
def create(vm_): ''' Create a single VM from a data dict CLI Example: .. code-block:: bash salt-cloud -p profile_name vm_name ''' try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, ...
convenience function to make the rest api call for node creation.
def create_node(**kwargs): ''' convenience function to make the rest api call for node creation. ''' name = kwargs['name'] size = kwargs['size'] image = kwargs['image'] location = kwargs['location'] networks = kwargs.get('networks') tag = kwargs.get('tag') locality = kwargs.get('...
destroy a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: array of booleans , true if successfully stopped and true if successfully removed CLI Example: .. code-block:: bash salt-cloud -d vm_name
def destroy(name, call=None): ''' destroy a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: array of booleans , true if successfully stopped and true if successfully removed CLI Example: .. code-block:: bash ...
reboot a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful CLI Example: .. code-block:: bash salt-cloud -a reboot vm_name
def reboot(name, call=None): ''' reboot a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful CLI Example: .. code-block:: bash salt-cloud -a reboot vm_name ''' node = get_node(name) ret = ...
take action call used by start,stop, reboot :param name: name given to the machine :param call: call value in this case is 'action' :command: api path :data: any data to be passed to the api, must be in json format :method: GET,POST,or DELETE :location: data center to execute the command on ...
def take_action(name=None, call=None, command=None, data=None, method='GET', location=DEFAULT_LOCATION): ''' take action call used by start,stop, reboot :param name: name given to the machine :param call: call value in this case is 'action' :command: api path :data: any data to ...
Return the joyent data center to use, in this order: - CLI parameter - VM parameter - Cloud profile setting
def get_location(vm_=None): ''' Return the joyent data center to use, in this order: - CLI parameter - VM parameter - Cloud profile setting ''' return __opts__.get( 'location', config.get_cloud_config_value( 'location', vm_ or get_configure...
List all available locations
def avail_locations(call=None): ''' List all available locations ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locations function must be called with ' '-f or --function, or with the --list-locations option' ) ret = {} for key in JOYENT_L...
Find if the provided object has a specific method
def has_method(obj, method_name): ''' Find if the provided object has a specific method ''' if method_name in dir(obj): return True log.error('Method \'%s\' not yet supported!', method_name) return False
convert list to dictionary using the key as the identifier :param items: array to iterate over :return: dictionary
def key_list(items=None): ''' convert list to dictionary using the key as the identifier :param items: array to iterate over :return: dictionary ''' if items is None: items = [] ret = {} if items and isinstance(items, list): for item in items: if 'name' in it...
get details about a machine :param name: name given to the machine :param call: call value in this case is 'action' :return: machine information CLI Example: .. code-block:: bash salt-cloud -a show_instance vm_name
def show_instance(name, call=None): ''' get details about a machine :param name: name given to the machine :param call: call value in this case is 'action' :return: machine information CLI Example: .. code-block:: bash salt-cloud -a show_instance vm_name ''' node = get_nod...
Reformat the returned data from joyent, determine public/private IPs and strip out fields if necessary to provide either full or brief content. :param item: node dictionary :param full: full or brief output :return: dict
def reformat_node(item=None, full=False): ''' Reformat the returned data from joyent, determine public/private IPs and strip out fields if necessary to provide either full or brief content. :param item: node dictionary :param full: full or brief output :return: dict ''' desired_keys = [...
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 SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) ...
Get list of available images CLI Example: .. code-block:: bash salt-cloud --list-images Can use a custom URL for images. Default is: .. code-block:: yaml image_url: images.joyent.com/images
def avail_images(call=None): ''' Get list of available images CLI Example: .. code-block:: bash salt-cloud --list-images Can use a custom URL for images. Default is: .. code-block:: yaml image_url: images.joyent.com/images ''' if call == 'action': raise Salt...
get list of available packages CLI Example: .. code-block:: bash salt-cloud --list-sizes
def avail_sizes(call=None): ''' get list of available packages CLI Example: .. code-block:: bash salt-cloud --list-sizes ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_sizes function must be called with ' '-f or --function, or with the -...
List the keys available
def list_keys(kwargs=None, call=None): ''' List the keys available ''' if call != 'function': log.error( 'The list_keys function must be called with -f or --function.' ) return False if not kwargs: kwargs = {} ret = {} rcode, data = query(command...
List the keys available CLI Example: .. code-block:: bash salt-cloud -f import_key joyent keyname=mykey keyfile=/tmp/mykey.pub
def import_key(kwargs=None, call=None): ''' List the keys available CLI Example: .. code-block:: bash salt-cloud -f import_key joyent keyname=mykey keyfile=/tmp/mykey.pub ''' if call != 'function': log.error( 'The import_key function must be called with -f or --fun...
List the keys available
def show_key(kwargs=None, call=None): ''' List the keys available ''' if call != 'function': log.error( 'The list_keys function must be called with -f or --function.' ) return False if not kwargs: kwargs = {} if 'keyname' not in kwargs: log.e...
Make a web call to Joyent
def query(action=None, command=None, args=None, method='GET', location=None, data=None): ''' Make a web call to Joyent ''' user = config.get_cloud_config_value( 'user', get_configured_provider(), __opts__, search_global=False ) if not us...
Figure out which utmp file to use when determining runlevel. Sometimes /var/run/utmp doesn't exist, /run/utmp is the new hotness.
def _find_utmp(): ''' Figure out which utmp file to use when determining runlevel. Sometimes /var/run/utmp doesn't exist, /run/utmp is the new hotness. ''' result = {} # These are the likely locations for the file on Ubuntu for utmp in '/var/run/utmp', '/run/utmp': try: r...
Return the current runlevel
def _runlevel(): ''' Return the current runlevel ''' if 'upstart._runlevel' in __context__: return __context__['upstart._runlevel'] ret = _default_runlevel() utmp = _find_utmp() if utmp: out = __salt__['cmd.run'](['runlevel', '{0}'.format(utmp)], python_shell=False) t...
A System-V style service will have a control script in /etc/init.d. We make sure to skip over symbolic links that point to Upstart's /lib/init/upstart-job, and anything that isn't an executable, like README or skeleton.
def _service_is_sysv(name): ''' A System-V style service will have a control script in /etc/init.d. We make sure to skip over symbolic links that point to Upstart's /lib/init/upstart-job, and anything that isn't an executable, like README or skeleton. ''' script = '/etc/init.d/{0}'.format(na...
An Upstart service is assumed disabled if a manual stanza is placed in /etc/init/[name].override. NOTE: An Upstart service can also be disabled by placing "manual" in /etc/init/[name].conf.
def _upstart_is_disabled(name): ''' An Upstart service is assumed disabled if a manual stanza is placed in /etc/init/[name].override. NOTE: An Upstart service can also be disabled by placing "manual" in /etc/init/[name].conf. ''' files = ['/etc/init/{0}.conf'.format(name), '/etc/init/{0}.ove...
Detect all of the service names available to upstart via init configuration files and via classic sysv init scripts
def _iter_service_names(): ''' Detect all of the service names available to upstart via init configuration files and via classic sysv init scripts ''' found = set() for line in glob.glob('/etc/init.d/*'): name = os.path.basename(line) found.add(name) yield name # Thi...
Return the enabled services CLI Example: .. code-block:: bash salt '*' service.get_enabled
def get_enabled(): ''' Return the enabled services CLI Example: .. code-block:: bash salt '*' service.get_enabled ''' ret = set() for name in _iter_service_names(): if _service_is_upstart(name): if _upstart_is_enabled(name): ret.add(name) ...
Return the disabled services CLI Example: .. code-block:: bash salt '*' service.get_disabled
def get_disabled(): ''' Return the disabled services CLI Example: .. code-block:: bash salt '*' service.get_disabled ''' ret = set() for name in _iter_service_names(): if _service_is_upstart(name): if _upstart_is_disabled(name): ret.add(name) ...
Disable an Upstart service.
def _upstart_disable(name): ''' Disable an Upstart service. ''' if _upstart_is_disabled(name): return _upstart_is_disabled(name) override = '/etc/init/{0}.override'.format(name) with salt.utils.files.fopen(override, 'a') as ofile: ofile.write(salt.utils.stringutils.to_str('manual...
Enable an Upstart service.
def _upstart_enable(name): ''' Enable an Upstart service. ''' if _upstart_is_enabled(name): return _upstart_is_enabled(name) override = '/etc/init/{0}.override'.format(name) files = ['/etc/init/{0}.conf'.format(name), override] for file_name in filter(os.path.isfile, files): ...
Enable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.enable <service name>
def enable(name, **kwargs): ''' Enable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.enable <service name> ''' if _service_is_upstart(name): return _upstart_enable(name) executable = _get_service_exec() cmd = '{0} -f {1} defaults...
Disable the named service from starting on boot CLI Example: .. code-block:: bash salt '*' service.disable <service name>
def disable(name, **kwargs): ''' Disable the named service from starting on boot CLI Example: .. code-block:: bash salt '*' service.disable <service name> ''' if _service_is_upstart(name): return _upstart_disable(name) executable = _get_service_exec() cmd = [executable...
Check to see if the named service is enabled to start on boot CLI Example: .. code-block:: bash salt '*' service.enabled <service name>
def enabled(name, **kwargs): ''' Check to see if the named service is enabled to start on boot CLI Example: .. code-block:: bash salt '*' service.enabled <service name> ''' if _service_is_upstart(name): return _upstart_is_enabled(name) else: if _service_is_sysv(nam...
Check to see if the named service is disabled to start on boot CLI Example: .. code-block:: bash salt '*' service.disabled <service name>
def disabled(name): ''' Check to see if the named service is disabled to start on boot CLI Example: .. code-block:: bash salt '*' service.disabled <service name> ''' if _service_is_upstart(name): return _upstart_is_disabled(name) else: if _service_is_sysv(name): ...
Grab the YubiKey Client ID & Secret Key
def __get_yubico_users(username): ''' Grab the YubiKey Client ID & Secret Key ''' user = {} try: if __opts__['yubico_users'].get(username, None): (user['id'], user['key']) = list(__opts__['yubico_users'][username].values()) else: return None except KeyErr...
Authenticate against yubico server
def auth(username, password): ''' Authenticate against yubico server ''' _cred = __get_yubico_users(username) client = Yubico(_cred['id'], _cred['key']) try: return client.verify(password) except yubico_exceptions.StatusCodeError as e: log.info('Unable to verify YubiKey `%s...
Format the log record to include exc_info if the handler is enabled for a specific log level
def format(self, record): ''' Format the log record to include exc_info if the handler is enabled for a specific log level ''' formatted_record = super(ExcInfoOnLogLevelFormatMixIn, self).format(record) exc_info_on_loglevel = getattr(record, 'exc_info_on_loglevel', None) ...
Delete a bucket, or delete an object from a bucket. CLI Example to delete a bucket:: salt myminion s3.delete mybucket CLI Example to delete an object from a bucket:: salt myminion s3.delete mybucket remoteobject
def delete(bucket, path=None, action=None, key=None, keyid=None, service_url=None, verify_ssl=None, kms_keyid=None, location=None, role_arn=None, path_style=None, https_enable=None): ''' Delete a bucket, or delete an object from a bucket. CLI Example to delete a bucket:: salt...
List the contents of a bucket, or return an object from a bucket. Set return_bin to True in order to retrieve an object wholesale. Otherwise, Salt will attempt to parse an XML response. CLI Example to list buckets: .. code-block:: bash salt myminion s3.get CLI Example to list the content...
def get(bucket='', path='', return_bin=False, action=None, local_file=None, key=None, keyid=None, service_url=None, verify_ssl=None, kms_keyid=None, location=None, role_arn=None, path_style=None, https_enable=None): ''' List the contents of a bucket, or return an object from a bucket. Se...
Return the metadata for a bucket, or an object in a bucket. CLI Examples: .. code-block:: bash salt myminion s3.head mybucket salt myminion s3.head mybucket myfile.png
def head(bucket, path='', key=None, keyid=None, service_url=None, verify_ssl=None, kms_keyid=None, location=None, role_arn=None, path_style=None, https_enable=None): ''' Return the metadata for a bucket, or an object in a bucket. CLI Examples: .. code-block:: bash salt mymin...