INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
A function to list a specific virtual. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the virtual to list
def list_virtual(hostname, username, password, name): ''' A function to list a specific virtual. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the virtual to list ''' ...
Manage a virtual server. If a virtual does not exists it will be created, otherwise only the parameters specified will be enforced. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of...
def manage_virtual(hostname, username, password, name, destination, pool=None, address_status=None, auto_lasthop=None, bwc_policy=None, cmp_enabled=None, connection_limit=None, dhcp_relay...
Modify an virtual server. modify an existing virtual. Only parameters specified will be enforced. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the virtual to create destinatio...
def modify_virtual(hostname, username, password, name, destination, pool=None, address_status=None, auto_lasthop=None, bwc_policy=None, cmp_enabled=None, connection_limit=None, dhcp_relay...
A function to connect to a bigip device and create a monitor. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password monitor_type The type of monitor to create name The name of the monitor to crea...
def create_monitor(hostname, username, password, monitor_type, name, **kwargs): ''' A function to connect to a bigip device and create a monitor. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password monitor...
r''' A function to connect to a bigip device and create a profile. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password profile_type The type of profile to create name The name of the profil...
def create_profile(hostname, username, password, profile_type, name, **kwargs): r''' A function to connect to a bigip device and create a profile. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password profil...
Return a list of the images that are on the provider.
def avail_images(call=None): ''' Return a list of the images that are on the provider. ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --function, or with the --list-images option' ) items = query(method...
Return a list of the BareMetal servers that are on the provider.
def list_nodes(call=None): ''' Return a list of the BareMetal servers that are on the provider. ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) items = query(method='servers') ret = {} for node in...
Return a list of the BareMetal servers that are on the provider.
def list_nodes_full(call=None): ''' Return a list of the BareMetal servers that are on the provider. ''' if call == 'action': raise SaltCloudSystemExit( 'list_nodes_full must be called with -f or --function' ) items = query(method='servers') # For each server, iterate o...
Return the image object to use.
def get_image(server_): ''' Return the image object to use. ''' images = avail_images() server_image = six.text_type(config.get_cloud_config_value( 'image', server_, __opts__, search_global=False )) for image in images: if server_image in (images[image]['name'], images[image]['id...
Create a node.
def create_node(args): ''' Create a node. ''' node = query(method='servers', args=args, http_method='POST') action = query( method='servers', server_id=node['server']['id'], command='action', args={'action': 'poweron'}, http_method='POST' ) return node
Create a single BareMetal server from a data dict.
def create(server_): ''' Create a single BareMetal server from a data dict. ''' try: # Check for required profile parameters before sending any API calls. if server_['profile'] and config.is_profile_configured(__opts__, __act...
Make a call to the Scaleway API.
def query(method='servers', server_id=None, command=None, args=None, http_method='GET', root='api_root'): ''' Make a call to the Scaleway API. ''' if root == 'api_root': default_url = 'https://cp-par1.scaleway.com' else: default_url = 'https://api-marketplace.scaleway.com' ...
Return the script deployment object.
def script(server_): ''' Return the script deployment object. ''' return salt.utils.cloud.os_script( config.get_cloud_config_value('script', server_, __opts__), server_, __opts__, salt.utils.cloud.salt_config_to_yaml( salt.utils.cloud.minion_config(__opts__, serve...
Verifies that the specified SSH key is present for the specified user name The SSH key to manage user The user who owns the SSH authorized keys file to modify enc Defines what type of key is being used; can be ed25519, ecdsa, ssh-rsa or ssh-dss comment The com...
def present( name, user, enc='ssh-rsa', comment='', source='', options=None, config='.ssh/authorized_keys', fingerprint_hash_type=None, **kwargs): ''' Verifies that the specified SSH key is present for the specified user name T...
Verifies that the specified SSH key is absent name The SSH key to manage user The user who owns the SSH authorized keys file to modify enc Defines what type of key is being used; can be ed25519, ecdsa, ssh-rsa or ssh-dss comment The comment to be placed with t...
def absent(name, user, enc='ssh-rsa', comment='', source='', options=None, config='.ssh/authorized_keys', fingerprint_hash_type=None): ''' Verifies that the specified SSH key is absent name The SSH key to manage user ...
.. versionadded:: Neon Ensures that only the specified ssh_keys are present for the specified user ssh_keys The SSH key to manage user The user who owns the SSH authorized keys file to modify enc Defines what type of key is being used; can be ed25519, ecdsa, ssh-rsa o...
def manage( name, ssh_keys, user, enc='ssh-rsa', comment='', source='', options=None, config='.ssh/authorized_keys', fingerprint_hash_type=None, **kwargs): ''' .. versionadded:: Neon Ensures that only the specified ssh_keys are...
Multi action helper for start, stop, get, ...
def _action(action='get', search=None, one=True, force=False): ''' Multi action helper for start, stop, get, ... ''' vms = {} matched_vms = [] client = salt.client.get_local_client(__opts__['conf_file']) ## lookup vms try: vmadm_args = {} vmadm_args['order'] = 'uuid,alia...
List all compute nodes verbose : boolean print additional information about the node e.g. platform version, hvm capable, ... CLI Example: .. code-block:: bash salt-run vmadm.nodes salt-run vmadm.nodes verbose=True
def nodes(verbose=False): ''' List all compute nodes verbose : boolean print additional information about the node e.g. platform version, hvm capable, ... CLI Example: .. code-block:: bash salt-run vmadm.nodes salt-run vmadm.nodes verbose=True ''' ret = {}...
List all vms search : string filter vms, see the execution module verbose : boolean print additional information about the vm CLI Example: .. code-block:: bash salt-run vmadm.list salt-run vmadm.list search='type=KVM' salt-run vmadm.list verbose=True
def list_vms(search=None, verbose=False): ''' List all vms search : string filter vms, see the execution module verbose : boolean print additional information about the vm CLI Example: .. code-block:: bash salt-run vmadm.list salt-run vmadm.list search='type=K...
Reboot one or more vms search : string filter vms, see the execution module. one : boolean reboot only one vm force : boolean force reboot, faster but no graceful shutdown .. note:: If the search parameter does not contain an equal (=) symbol it will be assumed ...
def reboot(search, one=True, force=False): ''' Reboot one or more vms search : string filter vms, see the execution module. one : boolean reboot only one vm force : boolean force reboot, faster but no graceful shutdown .. note:: If the search parameter does not ...
Convert an XML tree into a dict
def _xml_to_dict(xmltree): ''' Convert an XML tree into a dict ''' if sys.version_info < (2, 7): children_len = len(xmltree.getchildren()) else: children_len = len(xmltree) if children_len < 1: name = xmltree.tag if '}' in name: comps = name.split('}'...
Return an optimized list of providers. We want to reduce the duplication of querying the same region. If a provider is using the same credentials for the same region the same data will be returned for each provider, thus causing un-wanted duplicate data and API calls to EC2.
def optimize_providers(providers): ''' Return an optimized list of providers. We want to reduce the duplication of querying the same region. If a provider is using the same credentials for the same region the same data will be returned for each provider, thus causing un-wanted duplicate da...
Helper function that waits for a spot instance request to become active for a specific maximum amount of time. :param update_callback: callback function which queries the cloud provider for spot instance request. It must return None if the required data, ...
def _wait_for_spot_instance(update_callback, update_args=None, update_kwargs=None, timeout=10 * 60, interval=30, interval_multiplier=1, max_failures=10)...
Return a dict of all available VM images on the cloud provider.
def avail_images(kwargs=None, call=None): ''' Return a dict of all available VM images on the cloud provider. ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --function, or with the --list-images option' ...
Return the ssh_interface type to connect to. Either 'public_ips' (default) or 'private_ips'.
def ssh_interface(vm_): ''' Return the ssh_interface type to connect to. Either 'public_ips' (default) or 'private_ips'. ''' ret = config.get_cloud_config_value( 'ssh_interface', vm_, __opts__, default='public_ips', search_global=False ) if ret not in ('public_ips', 'private_...
Return the ssh_gateway configuration.
def get_ssh_gateway_config(vm_): ''' Return the ssh_gateway configuration. ''' ssh_gateway = config.get_cloud_config_value( 'ssh_gateway', vm_, __opts__, default=None, search_global=False ) # Check to see if a SSH Gateway will be used. if not isinstance(ssh_gateway, six.stri...
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 = {} params = {'Action'...
Return the availability zone to use
def get_availability_zone(vm_): ''' Return the availability zone to use ''' avz = config.get_cloud_config_value( 'availability_zone', vm_, __opts__, search_global=False ) if avz is None: return None zones = _list_availability_zones(vm_) # Validate user-specified AZ ...
Returns the ImageId to use
def get_imageid(vm_): ''' Returns the ImageId to use ''' image = config.get_cloud_config_value( 'image', vm_, __opts__, search_global=False ) if image.startswith('ami-'): return image # a poor man's cache if not hasattr(get_imageid, 'images'): get_imageid.images =...
Returns the SubnetId of a SubnetName to use
def _get_subnetname_id(subnetname): ''' Returns the SubnetId of a SubnetName to use ''' params = {'Action': 'DescribeSubnets'} for subnet in aws.query(params, location=get_location(), provider=get_provider(), opts=__opts__, sigver='4'): tags = subnet.get('tagSet', {}).get('ite...
Returns the SubnetId to use
def get_subnetid(vm_): ''' Returns the SubnetId to use ''' subnetid = config.get_cloud_config_value( 'subnetid', vm_, __opts__, search_global=False ) if subnetid: return subnetid subnetname = config.get_cloud_config_value( 'subnetname', vm_, __opts__, search_global=F...
Returns the SecurityGroupId of a SecurityGroupName to use
def _get_securitygroupname_id(securitygroupname_list): ''' Returns the SecurityGroupId of a SecurityGroupName to use ''' securitygroupid_set = set() if not isinstance(securitygroupname_list, list): securitygroupname_list = [securitygroupname_list] params = {'Action': 'DescribeSecurityGro...
Extract the provider name from vm
def get_provider(vm_=None): ''' Extract the provider name from vm ''' if vm_ is None: provider = __active_provider_name__ or 'ec2' else: provider = vm_.get('provider', 'ec2') if ':' in provider: prov_comps = provider.split(':') provider = prov_comps[0] return...
Returns the SecurityGroupId
def securitygroupid(vm_): ''' Returns the SecurityGroupId ''' securitygroupid_set = set() securitygroupid_list = config.get_cloud_config_value( 'securitygroupid', vm_, __opts__, search_global=False ) # If the list is None, then the set will remain empty # ...
List all availability zones in the current region
def _list_availability_zones(vm_=None): ''' List all availability zones in the current region ''' ret = {} params = {'Action': 'DescribeAvailabilityZones', 'Filter.0.Name': 'region-name', 'Filter.0.Value.0': get_location(vm_)} result = aws.query(params, ...
Create an Elastic Interface if necessary and return a Network Interface Specification
def _create_eni_if_necessary(interface, vm_): ''' Create an Elastic Interface if necessary and return a Network Interface Specification ''' if 'NetworkInterfaceId' in interface and interface['NetworkInterfaceId'] is not None: return {'DeviceIndex': interface['DeviceIndex'], 'Netw...
Request and return Elastic IP
def _request_eip(interface, vm_): ''' Request and return Elastic IP ''' params = {'Action': 'AllocateAddress'} params['Domain'] = interface.setdefault('domain', 'vpc') eips = aws.query(params, return_root=True, location=get_location(vm_), ...
Returns a list of all of the private IP addresses attached to a network interface. The 'primary' address will be listed first.
def _list_interface_private_addrs(eni_desc): ''' Returns a list of all of the private IP addresses attached to a network interface. The 'primary' address will be listed first. ''' primary = eni_desc.get('privateIpAddress') if not primary: return None addresses = [primary] lst =...
Accept the id of a network interface, and the id of an elastic ip address, and associate the two of them, such that traffic sent to the elastic ip address will be forwarded (NATted) to this network interface. Optionally specify the private (10.x.x.x) IP address that traffic should be NATted to - useful...
def _associate_eip_with_interface(eni_id, eip_id, private_ip=None, vm_=None): ''' Accept the id of a network interface, and the id of an elastic ip address, and associate the two of them, such that traffic sent to the elastic ip address will be forwarded (NATted) to this network interface. Optional...
Change properties of the interface with id eni_id to the values in properties dict
def _modify_eni_properties(eni_id, properties=None, vm_=None): ''' Change properties of the interface with id eni_id to the values in properties dict ''' if not isinstance(properties, dict): raise SaltCloudException( 'ENI properties must be a dictionary' ) params = {...
Put together all of the information necessary to request an instance on EC2, 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 on EC2, and then fire off the request the instance. Returns data about the instance ''' if call == 'function': # Technically this function may be called other ways too, bu...
Query an instance upon creation from the EC2 API
def query_instance(vm_=None, call=None): ''' Query an instance upon creation from the EC2 API ''' if call == 'function': # Technically this function may be called other ways too, but it # definitely cannot be called with --function. raise SaltCloudSystemExit( 'The que...
Wait for an instance upon creation from the EC2 API, to become available
def wait_for_instance( vm_=None, data=None, ip_address=None, display_ssh_output=True, call=None, ): ''' Wait for an instance upon creation from the EC2 API, to become available ''' if call == 'function': # Technically this function may be called other ...
Create a single VM from a data dict
def create(vm_=None, call=None): ''' Create a single VM from a data dict ''' if call: raise SaltCloudSystemExit( 'You cannot create an instance with -a or -f.' ) try: # Check for required profile parameters before sending any API calls. if vm_['profile'] ...
Queue a set of instances to be provisioned later. Expects a list. Currently this only queries node data, and then places it in the cloud cache (if configured). If the salt-cloud-reactor is being used, these instances will be automatically provisioned using that. For more information about the salt-clo...
def queue_instances(instances): ''' Queue a set of instances to be provisioned later. Expects a list. Currently this only queries node data, and then places it in the cloud cache (if configured). If the salt-cloud-reactor is being used, these instances will be automatically provisioned using that. ...
Create and attach volumes to created node
def create_attach_volumes(name, kwargs, call=None, wait_to_finish=True): ''' Create and attach volumes to created node ''' if call != 'action': raise SaltCloudSystemExit( 'The create_attach_volumes action must be called with ' '-a or --action.' ) if 'instance...
Stop a node
def stop(name, call=None): ''' Stop a node ''' if call != 'action': raise SaltCloudSystemExit( 'The stop action must be called with -a or --action.' ) log.info('Stopping node %s', name) instance_id = _get_node(name)['instanceId'] __utils__['cloud.fire_event']( ...
Set tags for a resource. Normally a VM name or instance_id is passed in, but a resource_id may be passed instead. If both are passed in, the instance_id will be used. CLI Examples: .. code-block:: bash salt-cloud -a set_tags mymachine tag1=somestuff tag2='Other stuff' salt-cloud -a se...
def set_tags(name=None, tags=None, call=None, location=None, instance_id=None, resource_id=None, kwargs=None): # pylint: disable=W0613 ''' Set tags for a resource. Normally a VM name or instance_id is passed in, but a resource_id...
Retrieve tags for a resource. Normally a VM name or instance_id is passed in, but a resource_id may be passed instead. If both are passed in, the instance_id will be used. CLI Examples: .. code-block:: bash salt-cloud -a get_tags mymachine salt-cloud -a get_tags resource_id=vol-3267ab...
def get_tags(name=None, instance_id=None, call=None, location=None, kwargs=None, resource_id=None): # pylint: disable=W0613 ''' Retrieve tags for a resource. Normally a VM name or instance_id is passed in, but a resource_id may be passed inst...
Delete tags for a resource. Normally a VM name or instance_id is passed in, but a resource_id may be passed instead. If both are passed in, the instance_id will be used. CLI Examples: .. code-block:: bash salt-cloud -a del_tags mymachine tags=mytag, salt-cloud -a del_tags mymachine ta...
def del_tags(name=None, kwargs=None, call=None, instance_id=None, resource_id=None): # pylint: disable=W0613 ''' Delete tags for a resource. Normally a VM name or instance_id is passed in, but a resource_id may be passed instead. If both are passed in, th...
Properly rename a node. Pass in the new name as "new name". CLI Example: .. code-block:: bash salt-cloud -a rename mymachine newname=yourmachine
def rename(name, kwargs, call=None): ''' Properly rename a node. Pass in the new name as "new name". CLI Example: .. code-block:: bash salt-cloud -a rename mymachine newname=yourmachine ''' if call != 'action': raise SaltCloudSystemExit( 'The rename action must be ...
Destroy a node. Will check termination protection and warn if enabled. CLI Example: .. code-block:: bash salt-cloud --destroy mymachine
def destroy(name, call=None): ''' Destroy a node. Will check termination protection and warn if enabled. CLI Example: .. code-block:: bash salt-cloud --destroy mymachine ''' if call == 'function': raise SaltCloudSystemExit( 'The destroy action must be called with -...
Reboot a node. CLI Example: .. code-block:: bash salt-cloud -a reboot mymachine
def reboot(name, call=None): ''' Reboot a node. CLI Example: .. code-block:: bash salt-cloud -a reboot mymachine ''' instance_id = _get_node(name)['instanceId'] params = {'Action': 'RebootInstances', 'InstanceId.1': instance_id} result = aws.query(params, ...
Show the details from EC2 concerning an AMI
def show_image(kwargs, call=None): ''' Show the details from EC2 concerning an AMI ''' if call != 'function': raise SaltCloudSystemExit( 'The show_image action must be called with -f or --function.' ) params = {'ImageId.1': kwargs['image'], 'Action': 'Descr...
Show the details from EC2 concerning an AMI. Can be called as an action (which requires a name): .. code-block:: bash salt-cloud -a show_instance myinstance ...or as a function (which requires either a name or instance_id): .. code-block:: bash salt-cloud -f show_instance my-ec2 na...
def show_instance(name=None, instance_id=None, call=None, kwargs=None): ''' Show the details from EC2 concerning an AMI. Can be called as an action (which requires a name): .. code-block:: bash salt-cloud -a show_instance myinstance ...or as a function (which requires either a name or in...
Given an instance query, return a dict of all instance data
def _extract_instance_info(instances): ''' Given an instance query, return a dict of all instance data ''' ret = {} for instance in instances: # items could be type dict or list (for stopped EC2 instances) if isinstance(instance['instancesSet']['item'], list): for item in...
Return a list of the VMs that in this location
def _list_nodes_full(location=None): ''' Return a list of the VMs that in this location ''' provider = __active_provider_name__ or 'ec2' if ':' in provider: comps = provider.split(':') provider = comps[0] params = {'Action': 'DescribeInstances'} instances = aws.query(params,...
Return a list of the VMs that are on the provider. Only a list of VM names, and their state, is returned. This is the minimum amount of information needed to check for existing VMs.
def list_nodes_min(location=None, call=None): ''' Return a list of the VMs that are on the provider. Only a list of VM names, and their state, is returned. This is the minimum amount of information needed to check for existing VMs. ''' if call == 'action': raise SaltCloudSystemExit( ...
Return a list of the VMs that are on the provider, with select fields
def list_nodes_select(call=None): ''' Return a list of the VMs that are on the provider, with select fields ''' return salt.utils.cloud.list_nodes_select( list_nodes_full(get_location()), __opts__['query.selection'], call, )
Show the details from EC2 concerning an instance's termination protection state
def show_term_protect(name=None, instance_id=None, call=None, quiet=False): ''' Show the details from EC2 concerning an instance's termination protection state ''' if call != 'action': raise SaltCloudSystemExit( 'The show_term_protect action must be called with -a or --action.' ...
Show the details from EC2 regarding cloudwatch detailed monitoring.
def show_detailed_monitoring(name=None, instance_id=None, call=None, quiet=False): ''' Show the details from EC2 regarding cloudwatch detailed monitoring. ''' if call != 'action': raise SaltCloudSystemExit( 'The show_detailed_monitoring action must be called with -a or --action.' ...
Enable or Disable termination protection on a node
def _toggle_term_protect(name, value): ''' Enable or Disable termination protection on a node ''' instance_id = _get_node(name)['instanceId'] params = {'Action': 'ModifyInstanceAttribute', 'InstanceId': instance_id, 'DisableApiTermination.Value': value} result = aws...
Enable/disable detailed monitoring on a node CLI Example:
def disable_detailed_monitoring(name, call=None): ''' Enable/disable detailed monitoring on a node CLI Example: ''' if call != 'action': raise SaltCloudSystemExit( 'The enable_term_protect action must be called with ' '-a or --action.' ) instance_id = _g...
Do not delete all/specified EBS volumes upon instance termination CLI Example: .. code-block:: bash salt-cloud -a show_delvol_on_destroy mymachine
def show_delvol_on_destroy(name, kwargs=None, call=None): ''' Do not delete all/specified EBS volumes upon instance termination CLI Example: .. code-block:: bash salt-cloud -a show_delvol_on_destroy mymachine ''' if call != 'action': raise SaltCloudSystemExit( 'Th...
Do not delete all/specified EBS volumes upon instance termination CLI Example: .. code-block:: bash salt-cloud -a keepvol_on_destroy mymachine
def keepvol_on_destroy(name, kwargs=None, call=None): ''' Do not delete all/specified EBS volumes upon instance termination CLI Example: .. code-block:: bash salt-cloud -a keepvol_on_destroy mymachine ''' if call != 'action': raise SaltCloudSystemExit( 'The keepvol...
Create an ami from a snapshot CLI Example: .. code-block:: bash salt-cloud -f register_image my-ec2-config ami_name=my_ami description="my description" root_device_name=/dev/xvda snapshot_id=snap-xxxxxxxx
def register_image(kwargs=None, call=None): ''' Create an ami from a snapshot CLI Example: .. code-block:: bash salt-cloud -f register_image my-ec2-config ami_name=my_ami description="my description" root_device_name=/dev/xvda snapshot_id=snap-xxxxxxxx ''' if call != ...
Create a volume. zone The availability zone used to create the volume. Required. String. size The size of the volume, in GiBs. Defaults to ``10``. Integer. snapshot The snapshot-id from which to create the volume. Integer. type The volume type. This can be gp2 for Gen...
def create_volume(kwargs=None, call=None, wait_to_finish=False): ''' Create a volume. zone The availability zone used to create the volume. Required. String. size The size of the volume, in GiBs. Defaults to ``10``. Integer. snapshot The snapshot-id from which to create th...
Attach a volume to an instance
def attach_volume(name=None, kwargs=None, instance_id=None, call=None): ''' Attach a volume to an instance ''' if call != 'action': raise SaltCloudSystemExit( 'The attach_volume action must be called with -a or --action.' ) if not kwargs: kwargs = {} if 'ins...
Describe a volume (or volumes) volume_id One or more volume IDs. Multiple IDs must be separated by ",". TODO: Add all of the filters.
def describe_volumes(kwargs=None, call=None): ''' Describe a volume (or volumes) volume_id One or more volume IDs. Multiple IDs must be separated by ",". TODO: Add all of the filters. ''' if call != 'function': log.error( 'The describe_volumes function must be calle...
Create an SSH keypair
def create_keypair(kwargs=None, call=None): ''' Create an SSH keypair ''' if call != 'function': log.error( 'The create_keypair function must be called with -f or --function.' ) return False if not kwargs: kwargs = {} if 'keyname' not in kwargs: ...
Import an SSH public key. .. versionadded:: 2015.8.3
def import_keypair(kwargs=None, call=None): ''' Import an SSH public key. .. versionadded:: 2015.8.3 ''' if call != 'function': log.error( 'The import_keypair function must be called with -f or --function.' ) return False if not kwargs: kwargs = {} ...
Delete an SSH keypair
def delete_keypair(kwargs=None, call=None): ''' Delete an SSH keypair ''' if call != 'function': log.error( 'The delete_keypair function must be called with -f or --function.' ) return False if not kwargs: kwargs = {} if 'keyname' not in kwargs: ...
Create a snapshot. volume_id The ID of the Volume from which to create a snapshot. description The optional description of the snapshot. CLI Exampe: .. code-block:: bash salt-cloud -f create_snapshot my-ec2-config volume_id=vol-351d8826 salt-cloud -f create_snapshot ...
def create_snapshot(kwargs=None, call=None, wait_to_finish=False): ''' Create a snapshot. volume_id The ID of the Volume from which to create a snapshot. description The optional description of the snapshot. CLI Exampe: .. code-block:: bash salt-cloud -f create_snaps...
Copy a snapshot
def copy_snapshot(kwargs=None, call=None): ''' Copy a snapshot ''' if call != 'function': log.error( 'The copy_snapshot function must be called with -f or --function.' ) return False if 'source_region' not in kwargs: log.error('A source_region must be spe...
Describe a snapshot (or snapshots) snapshot_id One or more snapshot IDs. Multiple IDs must be separated by ",". owner Return the snapshots owned by the specified owner. Valid values include: self, amazon, <AWS Account ID>. Multiple values must be separated by ",". restorab...
def describe_snapshots(kwargs=None, call=None): ''' Describe a snapshot (or snapshots) snapshot_id One or more snapshot IDs. Multiple IDs must be separated by ",". owner Return the snapshots owned by the specified owner. Valid values include: self, amazon, <AWS Account ID>. Mul...
Show the console output from the instance. By default, returns decoded data, not the Base64-encoded data that is actually returned from the EC2 API.
def get_console_output( name=None, location=None, instance_id=None, call=None, kwargs=None, ): ''' Show the console output from the instance. By default, returns decoded data, not the Base64-encoded data that is actually returned from the EC2 API. ''' ...
Return password data for a Windows instance. By default only the encrypted password data will be returned. However, if a key_file is passed in, then a decrypted password will also be returned. Note that the key_file references the private key that was used to generate the keypair associated with this ...
def get_password_data( name=None, kwargs=None, instance_id=None, call=None, ): ''' Return password data for a Windows instance. By default only the encrypted password data will be returned. However, if a key_file is passed in, then a decrypted password will also be r...
Download most recent pricing information from AWS and convert to a local JSON file. CLI Examples: .. code-block:: bash salt-cloud -f update_pricing my-ec2-config salt-cloud -f update_pricing my-ec2-config type=linux .. versionadded:: 2015.8.0
def update_pricing(kwargs=None, call=None): ''' Download most recent pricing information from AWS and convert to a local JSON file. CLI Examples: .. code-block:: bash salt-cloud -f update_pricing my-ec2-config salt-cloud -f update_pricing my-ec2-config type=linux .. versionad...
Download and parse an individual pricing file from AWS .. versionadded:: 2015.8.0
def _parse_pricing(url, name): ''' Download and parse an individual pricing file from AWS .. versionadded:: 2015.8.0 ''' price_js = http.query(url, text=True) items = [] current_item = '' price_js = re.sub(JS_COMMENT_RE, '', price_js['text']) price_js = price_js.strip().rstrip(');...
Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my-ec2-config profile=my-profile If pricing sources have not been cached, they will be downloaded. Once they have been cache...
def show_pricing(kwargs=None, call=None): ''' Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my-ec2-config profile=my-profile If pricing sources have not been cached, ...
Associates the specified SSM document with the specified instance http://docs.aws.amazon.com/ssm/latest/APIReference/API_CreateAssociation.html CLI Examples: .. code-block:: bash salt-cloud -a ssm_create_association ec2-instance-name ssm_document=ssm-document-name
def ssm_create_association(name=None, kwargs=None, instance_id=None, call=None): ''' Associates the specified SSM document with the specified instance http://docs.aws.amazon.com/ssm/latest/APIReference/API_CreateAssociation.html CLI Examples: .. code-block:: bash salt-cloud -a ssm_create...
returns string used to fetch id names from the sdb store. the cwd and machine name are concatenated with '?' which should never collide with a Salt node id -- which is important since we will be storing both in the same table.
def _build_machine_uri(machine, cwd): ''' returns string used to fetch id names from the sdb store. the cwd and machine name are concatenated with '?' which should never collide with a Salt node id -- which is important since we will be storing both in the same table. ''' key = '{}?{}'.form...
store the vm_ information keyed by name
def _update_vm_info(name, vm_): ''' store the vm_ information keyed by name ''' __utils__['sdb.sdb_set'](_build_sdb_uri(name), vm_, __opts__) # store machine-to-name mapping, too if vm_['machine']: __utils__['sdb.sdb_set']( _build_machine_uri(vm_['machine'], vm_.get('cwd', '.')), ...
get the information for a VM. :param name: salt_id name :return: dictionary of {'machine': x, 'cwd': y, ...}.
def get_vm_info(name): ''' get the information for a VM. :param name: salt_id name :return: dictionary of {'machine': x, 'cwd': y, ...}. ''' try: vm_ = __utils__['sdb.sdb_get'](_build_sdb_uri(name), __opts__) except KeyError: raise SaltInvocationError( 'Probable ...
returns the salt_id name of the Vagrant VM :param machine: the Vagrant machine name :param cwd: the path to Vagrantfile :return: salt_id name
def get_machine_id(machine, cwd): ''' returns the salt_id name of the Vagrant VM :param machine: the Vagrant machine name :param cwd: the path to Vagrantfile :return: salt_id name ''' name = __utils__['sdb.sdb_get'](_build_machine_uri(machine, cwd), __opts__) return name
erase the information for a VM the we are destroying. some sdb drivers (such as the SQLite driver we expect to use) do not have a `delete` method, so if the delete fails, we have to replace the with a blank entry.
def _erase_vm_info(name): ''' erase the information for a VM the we are destroying. some sdb drivers (such as the SQLite driver we expect to use) do not have a `delete` method, so if the delete fails, we have to replace the with a blank entry. ''' try: # delete the machine record ...
get the information for ssh communication from the new VM :param vm_: the VM's info as we have it now :return: dictionary of ssh stuff
def _vagrant_ssh_config(vm_): ''' get the information for ssh communication from the new VM :param vm_: the VM's info as we have it now :return: dictionary of ssh stuff ''' machine = vm_['machine'] log.info('requesting vagrant ssh-config for VM %s', machine or '(default)') cmd = 'vagran...
Return a list of the salt_id names of all available Vagrant VMs on this host without regard to the path where they are defined. CLI Example: .. code-block:: bash salt '*' vagrant.list_domains --log-level=info The log shows information about all known Vagrant environments on this machine....
def list_domains(): ''' Return a list of the salt_id names of all available Vagrant VMs on this host without regard to the path where they are defined. CLI Example: .. code-block:: bash salt '*' vagrant.list_domains --log-level=info The log shows information about all known Vagrant e...
Return a list of machine names for active virtual machine on the host, which are defined in the Vagrantfile at the indicated path. CLI Example: .. code-block:: bash salt '*' vagrant.list_active_vms cwd=/projects/project_1
def list_active_vms(cwd=None): ''' Return a list of machine names for active virtual machine on the host, which are defined in the Vagrantfile at the indicated path. CLI Example: .. code-block:: bash salt '*' vagrant.list_active_vms cwd=/projects/project_1 ''' vms = [] cmd = ...
Return list of information for all the vms indicating their state. If you pass a VM name in as an argument then it will return info for just the named VM, otherwise it will return all VMs defined by the Vagrantfile in the `cwd` directory. CLI Example: .. code-block:: bash salt '*' vagran...
def vm_state(name='', cwd=None): ''' Return list of information for all the vms indicating their state. If you pass a VM name in as an argument then it will return info for just the named VM, otherwise it will return all VMs defined by the Vagrantfile in the `cwd` directory. CLI Example: ...
Initialize a new Vagrant VM. This inputs all the information needed to start a Vagrant VM. These settings are stored in a Salt sdb database on the Vagrant host minion and used to start, control, and query the guest VMs. The salt_id assigned here is the key field for that database and must be unique. ...
def init(name, # Salt_id for created VM cwd=None, # path to find Vagrantfile machine='', # name of machine in Vagrantfile runas=None, # username who owns Vagrant box start=False, # start the machine when initialized vagrant_provider='', # vagrant provider (default=virt...
Hard shutdown the virtual machine. (vagrant halt) CLI Example: .. code-block:: bash salt <host> vagrant.stop <salt_id>
def stop(name): ''' Hard shutdown the virtual machine. (vagrant halt) CLI Example: .. code-block:: bash salt <host> vagrant.stop <salt_id> ''' vm_ = get_vm_info(name) machine = vm_['machine'] cmd = 'vagrant halt {}'.format(machine) ret = __salt__['cmd.retcode'](cmd, ...
Reboot a VM. (vagrant reload) CLI Example: .. code-block:: bash salt <host> vagrant.reboot <salt_id> provision=True :param name: The salt_id name you will use to control this VM :param provision: (False) also re-run the Vagrant provisioning scripts.
def reboot(name, provision=False): ''' Reboot a VM. (vagrant reload) CLI Example: .. code-block:: bash salt <host> vagrant.reboot <salt_id> provision=True :param name: The salt_id name you will use to control this VM :param provision: (False) also re-run the Vagrant provisioning scri...
Destroy and delete a virtual machine. (vagrant destroy -f) This also removes the salt_id name defined by vagrant.init. CLI Example: .. code-block:: bash salt <host> vagrant.destroy <salt_id>
def destroy(name): ''' Destroy and delete a virtual machine. (vagrant destroy -f) This also removes the salt_id name defined by vagrant.init. CLI Example: .. code-block:: bash salt <host> vagrant.destroy <salt_id> ''' vm_ = get_vm_info(name) machine = vm_['machine'] cmd ...
r''' Retrieve hints of how you might connect to a Vagrant VM. :param name: the salt_id of the machine :param network_mask: a CIDR mask to search for the VM's address :param get_private_key: (default: False) return the key used for ssh login :return: a dict of ssh login information for the VM C...
def get_ssh_config(name, network_mask='', get_private_key=False): r''' Retrieve hints of how you might connect to a Vagrant VM. :param name: the salt_id of the machine :param network_mask: a CIDR mask to search for the VM's address :param get_private_key: (default: False) return the key used for ss...
Selects the correct operation to be executed on a virtual machine, non existing machines will be created, existing ones will be updated if the config differs.
def vm_configured(name, vm_name, cpu, memory, image, version, interfaces, disks, scsi_devices, serial_ports, datacenter, datastore, placement, cd_dvd_drives=None, sata_controllers=None, advanced_configs=None, template=None, tools=True, power_on=Fal...
Updates a virtual machine configuration if there is a difference between the given and deployed configuration.
def vm_updated(name, vm_name, cpu, memory, image, version, interfaces, disks, scsi_devices, serial_ports, datacenter, datastore, cd_dvd_drives=None, sata_controllers=None, advanced_configs=None, power_on=False): ''' Updates a virtual machine configuration if there is...
Registers a virtual machine if the machine files are available on the main datastore.
def vm_registered(vm_name, datacenter, placement, vm_file, power_on=False): ''' Registers a virtual machine if the machine files are available on the main datastore. ''' result = {'name': vm_name, 'result': None, 'changes': {}, 'comment': ''} vmx_path =...
Verify that the given package is not installed. dir The target directory in which to install the package, or None for global installation user The user to run NPM with .. versionadded:: 0.17.0
def removed(name, dir=None, user=None): ''' Verify that the given package is not installed. dir The target directory in which to install the package, or None for global installation user The user to run NPM with .. versionadded:: 0.17.0 ''' ret = {'name': name,...
Bootstraps a node.js application. Will execute 'npm install --json' on the specified directory. user The user to run NPM with .. versionadded:: 0.17.0
def bootstrap(name, user=None, silent=True): ''' Bootstraps a node.js application. Will execute 'npm install --json' on the specified directory. user The user to run NPM with .. versionadded:: 0.17.0 ''' ret = {'name': name, 'result': None, 'comment': '', 'changes': {}} i...