INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Ensure a Route53 Alias exists and is pointing at the given CloudFront distribution. An A record is always created and if IPV6 is enabled on the given distribution an AAAA record will be created as well. Also be aware that Alias records for CloudFront distributions are only permitted in non - private zones.
def route53_alias_present(name, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Ensure a Route53 Alias exists and is pointing at the given CloudFront distribution. An ``A`` record is always created, and if IPV6 is enabled on the given distribution, an ``AAAA`` record will be created as w...
Ensure a distribution with the given Name tag does not exist.
def distribution_absent(name, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Ensure a distribution with the given Name tag does not exist. Note that CloudFront does not allow directly deleting an enabled Distribution. If such is requested, Salt will attempt to first update the dist...
Ensure a given CloudFront Origin Access Identity exists.
def origin_access_identity_present(name, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Ensure a given CloudFront Origin Access Identity exists. .. note:: Due to the unavailibity of ANY other way to store stateful idempotency information about Origin Access Identities (incl...
Ensure a given CloudFront Origin Access Identity is absent.
def origin_access_identity_absent(name, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Ensure a given CloudFront Origin Access Identity is absent. name The name of the state definition. Name (string) Name of the resource (for purposes of Salt's idempotency). If not ...
Install the specified snap package from the specified channel. Returns a dictionary of result and output.
def install(pkg, channel=None, refresh=False): ''' Install the specified snap package from the specified channel. Returns a dictionary of "result" and "output". pkg The snap package name channel Optional. The snap channel to install from, eg "beta" refresh : False If T...
Remove the specified snap package. Returns a dictionary of result and output.
def remove(pkg): ''' Remove the specified snap package. Returns a dictionary of "result" and "output". pkg The package name ''' ret = {'result': None, 'output': ""} try: ret['output'] = subprocess.check_output([SNAP_BINARY_NAME, 'remove', pkg]) ret['result'] = True e...
Query which version ( s ) of the specified snap package are installed. Returns a list of 0 or more dictionaries.
def versions_installed(pkg): ''' Query which version(s) of the specified snap package are installed. Returns a list of 0 or more dictionaries. pkg The package name ''' try: # Try to run it, merging stderr into output output = subprocess.check_output([SNAP_BINARY_NAME, '...
Create a virtualenv
def create(path, venv_bin=None, system_site_packages=False, distribute=False, clear=False, python=None, extra_search_dir=None, never_download=None, prompt=None, pip=False, symlinks=None, upgrade=None...
Return the path to the site - packages directory of a virtualenv
def get_site_packages(venv): ''' Return the path to the site-packages directory of a virtualenv venv Path to the virtualenv. CLI Example: .. code-block:: bash salt '*' virtualenv.get_site_packages /path/to/my/venv ''' bin_path = _verify_virtualenv(venv) ret = __salt_...
Return the path to a distribution installed inside a virtualenv
def get_distribution_path(venv, distribution): ''' Return the path to a distribution installed inside a virtualenv .. versionadded:: 2016.3.0 venv Path to the virtualenv. distribution Name of the distribution. Note, all non-alphanumeric characters will be converted to dashe...
Return the path to a package resource installed inside a virtualenv
def get_resource_path(venv, package=None, resource=None): ''' Return the path to a package resource installed inside a virtualenv .. versionadded:: 2015.5.0 venv Path to the virtualenv package Name of the package in which the resource re...
Return a list of the VMs
def list_nodes(call=None): ''' Return a list of the VMs id (str) image (str) size (str) state (str) private_ips (list) public_ips (list) ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called ' 'with -f or --f...
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 ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_select function must be called ' 'with -f or --function.' ) selection = __opts__.ge...
Provision a single machine
def create(vm_): ''' Provision a single machine ''' clone_strategy = vm_.get('clone_strategy') or 'full' if clone_strategy not in ('quick', 'full'): raise SaltCloudSystemExit("'clone_strategy' must be one of quick or full. Got '{0}'".format(clone_strategy)) ip_source = vm_.get('ip_sour...
Clean up clone domain leftovers as much as possible.
def do_cleanup(cleanup): ''' Clean up clone domain leftovers as much as possible. Extra robust clean up in order to deal with some small changes in libvirt behavior over time. Passed in volumes and domains are deleted, any errors are ignored. Used when cloning/provisioning a domain fails. :par...
This function irreversibly destroys a virtual machine on the cloud provider. Before doing so it should fire an event on the Salt event bus.
def destroy(name, call=None): """ This function irreversibly destroys a virtual machine on the cloud provider. Before doing so, it should fire an event on the Salt event bus. The tag for this event is `salt/cloud/<vm name>/destroying`. Once the virtual machine has been destroyed, another event is f...
Print out via pretty print
def output(data, **kwargs): # pylint: disable=unused-argument ''' Print out via pretty print ''' if isinstance(data, Exception): data = six.text_type(data) if 'output_indent' in __opts__ and __opts__['output_indent'] >= 0: return pprint.pformat(data, indent=__opts__['output_indent']...
Return the VM s size object
def get_size(vm_): ''' Return the VM's size object ''' vm_size = config.get_cloud_config_value( 'fixed_instance_size', vm_, __opts__, default=None, search_global=False ) sizes = avail_sizes() if not vm_size: size = next((item for item in sizes if item['name'] == 'S')...
Return the image object to use
def get_image(vm_): ''' Return the image object to use ''' vm_image = config.get_cloud_config_value('image', vm_, __opts__).encode( 'ascii', 'salt-cloud-force-ascii' ) images = avail_images() for key, value in six.iteritems(images): if vm_image and vm_image in (images[key]['...
List available locations/ datacenters for 1&1
def avail_locations(conn=None, call=None): ''' List available locations/datacenters for 1&1 ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locations function must be called with ' '-f or --function, or with the --list-locations option' ) datac...
Create a block storage
def create_block_storage(kwargs=None, call=None): ''' Create a block storage ''' if call == 'action': raise SaltCloudSystemExit( 'The create_block_storage function must be called with ' '-f or --function' ) conn = get_conn() # Assemble the composite bloc...
Construct a block storage instance from passed arguments
def _get_block_storage(kwargs): ''' Construct a block storage instance from passed arguments ''' if kwargs is None: kwargs = {} block_storage_name = kwargs.get('name', None) block_storage_size = kwargs.get('size', None) block_storage_description = kwargs.get('description', None) ...
Construct an SshKey instance from passed arguments
def _get_ssh_key(kwargs): ''' Construct an SshKey instance from passed arguments ''' ssh_key_name = kwargs.get('name', None) ssh_key_description = kwargs.get('description', None) public_key = kwargs.get('public_key', None) return SshKey( name=ssh_key_name, description=ssh_ke...
Create an ssh key
def create_ssh_key(kwargs=None, call=None): ''' Create an ssh key ''' if call == 'action': raise SaltCloudSystemExit( 'The create_ssh_key function must be called with ' '-f or --function' ) conn = get_conn() # Assemble the composite SshKey object. ss...
Construct FirewallPolicy and FirewallPolicy instances from passed arguments
def _get_firewall_policy(kwargs): ''' Construct FirewallPolicy and FirewallPolicy instances from passed arguments ''' fp_name = kwargs.get('name', None) fp_description = kwargs.get('description', None) firewallPolicy = FirewallPolicy( name=fp_name, description=fp_description ...
Create a firewall policy
def create_firewall_policy(kwargs=None, call=None): ''' Create a firewall policy ''' if call == 'action': raise SaltCloudSystemExit( 'The create_firewall_policy function must be called with ' '-f or --function' ) conn = get_conn() # Assemble the composit...
Return a list of the server appliances that are on the provider
def avail_images(conn=None, call=None): ''' Return a list of the server appliances 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' ) ...
Return a list of the baremetal server appliances that are on the provider
def avail_baremetal_images(conn=None, call=None): ''' Return a list of the baremetal server appliances that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_baremetal_images function must be called with ' '-f or --function' ) ...
Return a dict of all available VM sizes on the cloud provider with relevant data.
def avail_sizes(call=None): ''' Return a dict of all available VM sizes on the cloud provider with relevant data. ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_sizes function must be called with ' '-f or --function, or with the --list-sizes option' ...
Return a dict of all available baremetal models with relevant data.
def baremetal_models(call=None): ''' Return a dict of all available baremetal models with relevant data. ''' if call == 'action': raise SaltCloudSystemExit( 'The baremetal_models function must be called with ' '-f or --function' ) conn = get_conn() bmode...
Return a list of VMs that are on the provider
def list_nodes(conn=None, call=None): ''' Return a list of VMs that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) if not conn: conn = get_conn() ret = {} nodes = ...
Return a list of the VMs that are on the provider with all fields
def list_nodes_full(conn=None, call=None): ''' Return a list of the VMs that are on the provider, with all fields ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function must be called with -f or ' '--function.' ) if not conn: ...
Construct server instance from cloud profile config
def _get_server(vm_): ''' Construct server instance from cloud profile config ''' description = config.get_cloud_config_value( 'description', vm_, __opts__, default=None, search_global=False ) ssh_key = load_public_key(vm_) server_type = config.get_cloud_config_value( ...
Construct VM hdds from cloud profile config
def _get_hdds(vm_): ''' Construct VM hdds from cloud profile config ''' _hdds = config.get_cloud_config_value( 'hdds', vm_, __opts__, default=None, search_global=False ) hdds = [] for hdd in _hdds: hdds.append( Hdd( size=hdd['size'], ...
Create a single VM from a data dict
def create(vm_): ''' Create a single VM from a data dict ''' try: # Check for required profile parameters before sending any API calls. if (vm_['profile'] and config.is_profile_configured(__opts__, (__active_provider_name__ or ...
destroy a server by name
def destroy(name, call=None): ''' destroy a server by name :param name: name given to the server :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 server by name: param name: name given to the machine: param call: call value in this case is action: return: true if successful
def reboot(name, call=None): ''' reboot a server 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 ''' conn = get_conn() node = get_...
Return a node for the named VM
def get_node(conn, name): ''' Return a node for the named VM ''' for node in conn.list_servers(per_page=1000): if node['name'] == name: return node
Load the public key file if exists.
def load_public_key(vm_): ''' Load the public key file if exists. ''' public_key_filename = config.get_cloud_config_value( 'ssh_public_key', vm_, __opts__, search_global=False, default=None ) if public_key_filename is not None: public_key_filename = os.path.expanduser(public_key_...
Poll request status until resource is provisioned.
def _wait_for_completion(conn, wait_timeout, server_id): ''' Poll request status until resource is provisioned. ''' wait_timeout = time.time() + wait_timeout while wait_timeout > time.time(): time.sleep(5) server = conn.get_server(server_id) server_state = server['status']['...
format the results of listing functions
def _load_result(response, ret): ''' format the results of listing functions ''' #were we able to connect? if response['code'] is None: ret['comment'] = response['content'] #forbidden? elif response['code'] == 401: ret['comment'] = '401 Forbidden: Authentication required!' ...
look for a certain key within a dictionary and nullify ti s contents check within nested dictionaries and lists as well. Certain attributes such as generation will change even when there were no changes made to the entity.
def _strip_key(dictionary, keyword): ''' look for a certain key within a dictionary and nullify ti's contents, check within nested dictionaries and lists as well. Certain attributes such as "generation" will change even when there were no changes made to the entity. ''' for key, value in six.i...
take an existing entity and a modified entity and check for changes.
def _check_for_changes(entity_type, ret, existing, modified): ''' take an existing entity and a modified entity and check for changes. ''' ret['result'] = True #were there any changes? generation always changes, remove it. if isinstance(existing, dict) and isinstance(modified, dict): ...
Create a new node if it does not already exist.
def create_node(hostname, username, password, name, address): ''' Create a new node if it does not already exist. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the node to cr...
Manages a node of a given bigip device. If the node does not exist it will be created otherwise only the properties which are different than the existing will be updated.
def manage_node(hostname, username, password, name, address, connection_limit=None, description=None, dynamic_ratio=None, logging=None, monitor=None, rate_limit=None, ratio=None, session=None,...
Modify an existing node. Only a node which already exists will be modified and only the parameters specified will be enforced.
def modify_node(hostname, username, password, name, connection_limit=None, description=None, dynamic_ratio=None, logging=None, monitor=None, rate_limit=None, ratio=None, session=None, ...
Create a new node if it does not already exist.
def create_pool(hostname, username, password, name, members=None, allow_nat=None, allow_snat=None, description=None, gateway_failsafe_device=None, ignore_persisted_weight=None, ip_tos_to_client=None, ip_tos_t...
Create a new pool if it does not already exist. Pool members are managed separately. Only the parameters specified are enforced.
def manage_pool(hostname, username, password, name, allow_nat=None, allow_snat=None, description=None, gateway_failsafe_device=None, ignore_persisted_weight=None, ip_tos_to_client=None, ip_tos_to_server=None,...
Delete an existing pool.
def delete_pool(hostname, username, password, name): ''' Delete an existing pool. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the pool which will be deleted ''' re...
Manage the members of an existing pool. This function replaces all current pool members. Only the parameters specified are enforced.
def manage_pool_members(hostname, username, password, name, members): ''' Manage the members of an existing pool. This function replaces all current pool members. Only the parameters specified are enforced. hostname The host/address of the bigip device username The iControl REST us...
A function to connect to a bigip device and add a new member to an existing pool.
def add_pool_member(hostname, username, password, name, member): ''' A function to connect to a bigip device and add a new member to an existing pool. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password na...
A function to connect to a bigip device and modify a member of an existing pool.
def modify_pool_member(hostname, username, password, name, member, connection_limit=None, description=None, dynamic_ratio=None, inherit_profile=None, logging=None, monitor=None, ...
Delete an existing pool member.
def delete_pool_member(hostname, username, password, name, member): ''' Delete an existing pool member. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the pool to be modified ...
A function to list a specific virtual.
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.
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.
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.
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.
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
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
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
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
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
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
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.
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.
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...
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 # ...
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...
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, ...
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_), ...
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...
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 =...
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 = {...
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.
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...
Return EC2 API parameters based on the given config data.
def _param_from_config(key, data): ''' Return EC2 API parameters based on the given config data. Examples: 1. List of dictionaries >>> data = [ ... {'DeviceIndex': 0, 'SubnetId': 'subid0', ... 'AssociatePublicIpAddress': True}, ... {'DeviceIndex': 1, ... 'SubnetId'...
Put together all of the information necessary to request an instance on EC2 and then fire off the request 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.
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...