INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Stop the specified service
def stop(name): ''' Stop the specified service CLI Example: .. code-block:: bash salt '*' service.stop <service name> ''' if _service_is_upstart(name): cmd = 'stop {0}'.format(name) else: cmd = '/sbin/service {0} stop'.format(name) return not __salt__['cmd.retc...
Restart the named service
def restart(name): ''' Restart the named service CLI Example: .. code-block:: bash salt '*' service.restart <service name> ''' if _service_is_upstart(name): cmd = 'restart {0}'.format(name) else: cmd = '/sbin/service {0} restart'.format(name) return not __salt_...
Reload the named service
def reload_(name): ''' Reload the named service CLI Example: .. code-block:: bash salt '*' service.reload <service name> ''' if _service_is_upstart(name): cmd = 'reload {0}'.format(name) else: cmd = '/sbin/service {0} reload'.format(name) return not __salt__['c...
Check for specified command name in search path
def _check_repo_sign_utils_support(name): ''' Check for specified command name in search path ''' if salt.utils.path.which(name): return True else: raise CommandExecutionError( 'utility \'{0}\' needs to be installed or made available in search path'.format(name) )
Get build environment overrides dictionary to use in build process
def _get_build_env(env): ''' Get build environment overrides dictionary to use in build process ''' env_override = '' if env is None: return env_override if not isinstance(env, dict): raise SaltInvocationError( '\'env\' must be a Python dictionary' ) for k...
Get repo environment overrides dictionary to use in repo options process
def _get_repo_options_env(env): ''' Get repo environment overrides dictionary to use in repo options process env A dictionary of variables to define the repository options Example: .. code-block:: yaml - env: - OPTIONS : 'ask-passphrase' .. war...
Get repo environment overrides dictionary to use in repo distributions process
def _get_repo_dists_env(env): ''' Get repo environment overrides dictionary to use in repo distributions process env A dictionary of variables to define the repository distributions Example: .. code-block:: yaml - env: - ORIGIN : 'jessie' ...
Create the. pbuilder family of files in user s home directory
def _create_pbuilders(env, runas='root'): ''' Create the .pbuilder family of files in user's home directory env A list or dictionary of environment variables to be set prior to execution. Example: .. code-block:: yaml - env: - DEB_BUILD_OPTIONS: 'noche...
Get the named sources and place them into the tree_base
def _get_src(tree_base, source, saltenv='base'): ''' Get the named sources and place them into the tree_base ''' parsed = _urlparse(source) sbase = os.path.basename(source) dest = os.path.join(tree_base, sbase) if parsed.scheme: __salt__['cp.get_url'](source, dest, saltenv=saltenv) ...
Create a platform specific source package from the given platform spec/ control file and sources
def make_src_pkg(dest_dir, spec, sources, env=None, saltenv='base', runas='root'): ''' Create a platform specific source package from the given platform spec/control file and sources CLI Example: **Debian** .. code-block:: bash salt '*' pkgbuild.make_src_pkg /var/www/html/ ...
Given the package destination directory the tarball containing debian files ( e. g. control ) and package sources use pbuilder to safely build the platform package
def build(runas, tgt, dest_dir, spec, sources, deps, env, template, saltenv='base', log_dir='/var/log/salt/pkgbuild'): # pylint: disable=unused-argument ''' Given the package destination directory, the tarball containing ...
Make a package repository and optionally sign it and packages present
def make_repo(repodir, keyid=None, env=None, use_passphrase=False, gnupghome='/etc/salt/gpgkeys', runas='root', timeout=15.0): ''' Make a package repository and optionally sign it and packages present Given the repodir (dir...
Generate a Vault token for minion minion_id
def generate_token(minion_id, signature, impersonated_by_master=False): ''' Generate a Vault token for minion minion_id minion_id The id of the minion that requests a token signature Cryptographic signature which validates that the request is indeed sent by the minion (or the m...
Unseal Vault server
def unseal(): ''' Unseal Vault server This function uses the 'keys' from the 'vault' configuration to unseal vault server vault: keys: - n63/TbrQuL3xaIW7ZZpuXj/tIfnK1/MbVxO4vT3wYD2A - S9OwCvMRhErEA4NVVELYBs6w/Me6+urgUr24xGK44Uy3 - F1j4b7JKq850NS6Kboiy5laJ0xY8dWJvB3fcwA+Sr...
Validate that either minion with id minion_id or the master signed the request
def _validate_signature(minion_id, signature, impersonated_by_master): ''' Validate that either minion with id minion_id, or the master, signed the request ''' pki_dir = __opts__['pki_dir'] if impersonated_by_master: public_key = '{0}/master.pub'.format(pki_dir) else: public_...
Get the policies that should be applied to a token for minion_id
def _get_policies(minion_id, config): ''' Get the policies that should be applied to a token for minion_id ''' _, grains, _ = salt.utils.minions.get_minion_data(minion_id, __opts__) policy_patterns = config.get( 'policies', ['saltstac...
Expands the pattern for any list - valued mappings such that for any list of length N in the mappings present in the pattern N copies of the pattern are returned each with an element of the list substituted.
def _expand_pattern_lists(pattern, **mappings): ''' Expands the pattern for any list-valued mappings, such that for any list of length N in the mappings present in the pattern, N copies of the pattern are returned, each with an element of the list substituted. pattern: A pattern to expand, ...
Validate the current token exists and is still valid
def _selftoken_expired(): ''' Validate the current token exists and is still valid ''' try: verify = __opts__['vault'].get('verify', None) url = '{0}/v1/auth/token/lookup-self'.format(__opts__['vault']['url']) if 'token' not in __opts__['vault']['auth']: return True ...
Create Vault url for token creation
def _get_token_create_url(config): ''' Create Vault url for token creation ''' role_name = config.get('role_name', None) auth_path = '/v1/auth/token/create' base_url = config['url'] return '/'.join(x.strip('/') for x in (base_url, auth_path, role_name) if x)
Given function name find and return matching Lambda information.
def _find_function(name, region=None, key=None, keyid=None, profile=None): ''' Given function name, find and return matching Lambda information. ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) for funcs in __utils__['boto3.paged_call'](conn.list_functio...
Given a function name check to see if the given function name exists.
def function_exists(FunctionName, region=None, key=None, keyid=None, profile=None): ''' Given a function name, check to see if the given function name exists. Returns True if the given function exists and returns False if the given function does not exist. CLI Example: .. ...
.. versionadded:: 2017. 7. 0
def create_function(FunctionName, Runtime, Role, Handler, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Description="", Timeout=3, MemorySize=128, Publish=False, WaitForRole=False, RoleRetries=5, region=None, key=None, keyi...
Given a function name and optional version qualifier delete it.
def delete_function(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Given a function name and optional version qualifier, delete it. Returns {deleted: true} if the function was deleted and returns {deleted: false} if the function was not deleted. CLI Example: ...
Given a function name describe its properties.
def describe_function(FunctionName, region=None, key=None, keyid=None, profile=None): ''' Given a function name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_function myf...
.. versionadded:: 2017. 7. 0
def update_function_config(FunctionName, Role=None, Handler=None, Description=None, Timeout=None, MemorySize=None, region=None, key=None, keyid=None, profile=None, VpcConfig=None, WaitForRole=False, RoleRetries=5, ...
Upload the given code to the named lambda function.
def update_function_code(FunctionName, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Publish=False, region=None, key=None, keyid=None, profile=None): ''' Upload the given code to the named lambda function. Returns {updated: true} if the fun...
Add a permission to a lambda function.
def add_permission(FunctionName, StatementId, Action, Principal, SourceArn=None, SourceAccount=None, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Add a permission to a lambda function. Returns {added: true} if the permission was added and retur...
Remove a permission from a lambda function.
def remove_permission(FunctionName, StatementId, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Remove a permission from a lambda function. Returns {removed: true} if the permission was removed and returns {removed: False} if the permission was not removed. ...
Get resource permissions for the given lambda function
def get_permissions(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Get resource permissions for the given lambda function Returns dictionary of permissions, by statement ID CLI Example: .. code-block:: bash salt myminion boto_lamba...
List all Lambda functions visible in the current scope.
def list_functions(region=None, key=None, keyid=None, profile=None): ''' List all Lambda functions visible in the current scope. CLI Example: .. code-block:: bash salt myminion boto_lambda.list_functions ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
List the versions available for the given function.
def list_function_versions(FunctionName, region=None, key=None, keyid=None, profile=None): ''' List the versions available for the given function. Returns list of function versions CLI Example: .. code-block:: yaml versions: - {...} - {...} ...
Given a valid config create an alias to a function.
def create_alias(FunctionName, Name, FunctionVersion, Description="", region=None, key=None, keyid=None, profile=None): ''' Given a valid config, create an alias to a function. Returns {created: true} if the alias was created and returns {created: False} if the alias was not created. ...
Given function name and alias name find and return matching alias information.
def _find_alias(FunctionName, Name, FunctionVersion=None, region=None, key=None, keyid=None, profile=None): ''' Given function name and alias name, find and return matching alias information. ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) args = { ...
Given a function name and alias name check to see if the given alias exists.
def alias_exists(FunctionName, Name, region=None, key=None, keyid=None, profile=None): ''' Given a function name and alias name, check to see if the given alias exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .....
Given a function name and alias name describe the properties of the alias.
def describe_alias(FunctionName, Name, region=None, key=None, keyid=None, profile=None): ''' Given a function name and alias name describe the properties of the alias. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_...
Update the named alias to the configuration.
def update_alias(FunctionName, Name, FunctionVersion=None, Description=None, region=None, key=None, keyid=None, profile=None): ''' Update the named alias to the configuration. Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated. ...
Identifies a stream as an event source for a Lambda function. It can be either an Amazon Kinesis stream or an Amazon DynamoDB stream. AWS Lambda invokes the specified function when records are posted to the stream.
def create_event_source_mapping(EventSourceArn, FunctionName, StartingPosition, Enabled=True, BatchSize=100, region=None, key=None, keyid=None, profile=None): ''' Identifies a stream as an event source for a Lambda function. It can be either an...
Given an event source and function name return a list of mapping IDs
def get_event_source_mapping_ids(EventSourceArn, FunctionName, region=None, key=None, keyid=None, profile=None): ''' Given an event source and function name, return a list of mapping IDs CLI Example: .. code-block:: bash salt myminion boto_lambda.get_event_sou...
Given an event source mapping ID or an event source ARN and FunctionName delete the event source mapping
def delete_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None): ''' Given an event source mapping ID or an event source ARN and FunctionName, delete the event source mapping Returns {deleted: true} if t...
Given an event source mapping ID or an event source ARN and FunctionName check whether the mapping exists.
def event_source_mapping_exists(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None): ''' Given an event source mapping ID or an event source ARN and FunctionName, check whether the mapping exists....
Given an event source mapping ID or an event source ARN and FunctionName obtain the current settings of that mapping.
def describe_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None): ''' Given an event source mapping ID or an event source ARN and FunctionName, obtain the current settings...
Update the event source mapping identified by the UUID.
def update_event_source_mapping(UUID, FunctionName=None, Enabled=None, BatchSize=None, region=None, key=None, keyid=None, profile=None): ''' Update the event source mapping identified by the UUID. Returns {updated: true} if the alias was updat...
Update the cache file for the bucket.
def update(): ''' Update the cache file for the bucket. ''' metadata = _init() if S3_SYNC_ON_UPDATE: # sync the buckets to the local cache log.info('Syncing local cache from S3...') for saltenv, env_meta in six.iteritems(metadata): for bucket_files in _find_file...
Look through the buckets cache file for a match. If the field is found it is retrieved from S3 only if its cached version is missing or if the MD5 does not match.
def find_file(path, saltenv='base', **kwargs): ''' Look through the buckets cache file for a match. If the field is found, it is retrieved from S3 only if its cached version is missing, or if the MD5 does not match. ''' if 'env' in kwargs: # "env" is not supported; Use "saltenv". ...
Return an MD5 file hash
def file_hash(load, fnd): ''' Return an MD5 file hash ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {} if 'saltenv' not in load: return ret if 'path' not in fnd or 'bucket' not in fnd or not fnd['path']: return ret ...
Return a chunk from a file based on the data received
def serve_file(load, fnd): ''' Return a chunk from a file based on the data received ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {'data': '', 'dest': ''} if 'path' not in load or 'loc' not in load or 'saltenv' not in load: ...
Return a list of all files on the file server in a specified environment
def file_list(load): ''' Return a list of all files on the file server in a specified environment ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = [] if 'saltenv' not in load: return ret saltenv = load['saltenv'] metadata = _...
Return a list of all directories on the master
def dir_list(load): ''' Return a list of all directories on the master ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = [] if 'saltenv' not in load: return ret saltenv = load['saltenv'] metadata = _init() if not metadata...
Get AWS keys from pillar or config
def _get_s3_key(): ''' Get AWS keys from pillar or config ''' key = __opts__['s3.key'] if 's3.key' in __opts__ else None keyid = __opts__['s3.keyid'] if 's3.keyid' in __opts__ else None service_url = __opts__['s3.service_url'] \ if 's3.service_url' in __opts__ \ else None ve...
Connect to S3 and download the metadata for each file in all buckets specified and cache the data to disk.
def _init(): ''' Connect to S3 and download the metadata for each file in all buckets specified and cache the data to disk. ''' cache_file = _get_buckets_cache_filename() exp = time.time() - S3_CACHE_EXPIRE # check mtime of the buckets files cache metadata = None try: if os....
Return the cached file name for a bucket path file
def _get_cached_file_name(bucket_name, saltenv, path): ''' Return the cached file name for a bucket path file ''' file_path = os.path.join(_get_cache_dir(), saltenv, bucket_name, path) # make sure bucket and saltenv directories exist if not os.path.exists(os.path.dirname(file_path)): o...
Return the filename of the cache for bucket contents. Create the path if it does not exist.
def _get_buckets_cache_filename(): ''' Return the filename of the cache for bucket contents. Create the path if it does not exist. ''' cache_dir = _get_cache_dir() if not os.path.exists(cache_dir): os.makedirs(cache_dir) return os.path.join(cache_dir, 'buckets_files.cache')
Retrieve the content of all buckets and cache the metadata to the buckets cache file
def _refresh_buckets_cache_file(cache_file): ''' Retrieve the content of all buckets and cache the metadata to the buckets cache file ''' log.debug('Refreshing buckets cache file') key, keyid, service_url, verify_ssl, kms_keyid, location, path_style, https_enable = _get_s3_key() metadata =...
Return the contents of the buckets cache file
def _read_buckets_cache_file(cache_file): ''' Return the contents of the buckets cache file ''' log.debug('Reading buckets cache file') with salt.utils.files.fopen(cache_file, 'rb') as fp_: try: data = pickle.load(fp_) except (pickle.UnpicklingError, AttributeError, EOF...
Looks for all the files in the S3 bucket cache metadata
def _find_files(metadata): ''' Looks for all the files in the S3 bucket cache metadata ''' ret = [] found = {} for bucket_dict in metadata: for bucket_name, data in six.iteritems(bucket_dict): filepaths = [k['Key'] for k in data] filepaths = [k for k in filepath...
Looks for all the directories in the S3 bucket cache metadata.
def _find_dirs(metadata): ''' Looks for all the directories in the S3 bucket cache metadata. Supports trailing '/' keys (as created by S3 console) as well as directories discovered in the path of file keys. ''' ret = [] found = {} for bucket_dict in metadata: for bucket_name, ...
Looks for a file s metadata in the S3 bucket cache file
def _find_file_meta(metadata, bucket_name, saltenv, path): ''' Looks for a file's metadata in the S3 bucket cache file ''' env_meta = metadata[saltenv] if saltenv in metadata else {} bucket_meta = {} for bucket in env_meta: if bucket_name in bucket: bucket_meta = bucket[bucke...
Checks the local cache for the file if it s old or missing go grab the file from S3 and update the cache
def _get_file_from_s3(metadata, saltenv, bucket_name, path, cached_file_path): ''' Checks the local cache for the file, if it's old or missing go grab the file from S3 and update the cache ''' key, keyid, service_url, verify_ssl, kms_keyid, location, path_style, https_enable = _get_s3_key() # c...
Return a list of file paths with the saltenv directory removed
def _trim_env_off_path(paths, saltenv, trim_slash=False): ''' Return a list of file paths with the saltenv directory removed ''' env_len = None if _is_env_per_bucket() else len(saltenv) + 1 slash_len = -1 if trim_slash else None return [d[env_len:slash_len] for d in paths]
Return the configuration mode either buckets per environment or a list of buckets that have environment dirs in their root
def _is_env_per_bucket(): ''' Return the configuration mode, either buckets per environment or a list of buckets that have environment dirs in their root ''' buckets = _get_buckets() if isinstance(buckets, dict): return True elif isinstance(buckets, list): return False e...
Find a hosted zone with the given characteristics.
def find_hosted_zone(Id=None, Name=None, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Find a hosted zone with the given characteristics. Id The unique Zone Identifier for the Hosted Zone. Exclusive with Name. Name The domain name associa...
Return detailed info about the given zone.
def get_hosted_zone(Id, region=None, key=None, keyid=None, profile=None): ''' Return detailed info about the given zone. Id The unique Zone Identifier for the Hosted Zone. region Region to connect to. key Secret key to be used. keyid Access key to be used. ...
Find any zones with the given domain name and return detailed info about them. Note that this can return multiple Route53 zones since a domain name can be used in both public and private zones.
def get_hosted_zones_by_domain(Name, region=None, key=None, keyid=None, profile=None): ''' Find any zones with the given domain name and return detailed info about them. Note that this can return multiple Route53 zones, since a domain name can be used in both public and private zones. Name ...
Return detailed info about all zones in the bound account.
def list_hosted_zones(DelegationSetId=None, region=None, key=None, keyid=None, profile=None): ''' Return detailed info about all zones in the bound account. DelegationSetId If you're using reusable delegation sets and you want to list all of the hosted zones that are associated with a reusa...
Create a new Route53 Hosted Zone. Returns a Python data structure with information about the newly created Hosted Zone.
def create_hosted_zone(Name, VPCId=None, VPCName=None, VPCRegion=None, CallerReference=None, Comment='', PrivateZone=False, DelegationSetId=None, region=None, key=None, keyid=None, profile=None): ''' Create a new Route53 Hosted Zone. Returns a Python data structure ...
Update the comment on an existing Route 53 hosted zone.
def update_hosted_zone_comment(Id=None, Name=None, Comment=None, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Update the comment on an existing Route 53 hosted zone. Id The unique Zone Identifier for the Hosted Zone. Name The do...
Associates an Amazon VPC with a private hosted zone.
def associate_vpc_with_hosted_zone(HostedZoneId=None, Name=None, VPCId=None, VPCName=None, VPCRegion=None, Comment=None, region=None, key=None, keyid=None, profile=None): ''' Associates an Amazon VPC with a private hosted zone. To perfor...
Delete a Route53 hosted zone.
def delete_hosted_zone(Id, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone. CLI Example:: salt myminion boto3_route53.delete_hosted_zone Z1234567890 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: r = conn.delet...
Delete a Route53 hosted zone by domain name and PrivateZone status if provided.
def delete_hosted_zone_by_domain(Name, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone by domain name, and PrivateZone status if provided. CLI Example:: salt myminion boto3_route53.delete_hosted_zone_by_domain ex...
An implementation of the encoding required to suport AWS s domain name rules defined here__:
def aws_encode(x): ''' An implementation of the encoding required to suport AWS's domain name rules defined here__: .. __: http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DomainNameFormat.html While AWS's documentation specifies individual ASCII characters which need to be encoded, we...
helper method to process a change batch & encode the bits which need encoding.
def _aws_encode_changebatch(o): ''' helper method to process a change batch & encode the bits which need encoding. ''' change_idx = 0 while change_idx < len(o['Changes']): o['Changes'][change_idx]['ResourceRecordSet']['Name'] = aws_encode(o['Changes'][change_idx]['ResourceRecordSet']['Name']...
Get all resource records from a given zone matching the provided StartRecordName ( if given ) or all records in the zone ( if not ) optionally filtered by a specific StartRecordType. This will return any and all RRs matching regardless of their special AWS flavors ( weighted geolocation alias etc. ) so your code should...
def get_resource_records(HostedZoneId=None, Name=None, StartRecordName=None, StartRecordType=None, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Get all resource records from a given zone matching the provided StartRecordName (if given)...
See the AWS Route53 API docs __ as well as the Boto3 documentation __ for all the details...
def change_resource_record_sets(HostedZoneId=None, Name=None, PrivateZone=None, ChangeBatch=None, region=None, key=None, keyid=None, profile=None): ''' See the `AWS Route53 API docs`__ as well as the `Boto3 documentation`__ for all the details... ...
Mask a line in the data which matches mask.
def mask_args_value(data, mask): ''' Mask a line in the data, which matches "mask". This can be used for cases where values in your roster file may contain sensitive data such as IP addresses, passwords, user names, etc. Note that this works only when ``data`` is a single string (i.e. when the ...
Raise an exception if value is empty. Otherwise strip it down.: param value:: return:
def trim(value): ''' Raise an exception if value is empty. Otherwise strip it down. :param value: :return: ''' value = (value or '').strip() if not value: raise CommandExecutionError("Empty value during sanitation") return six.text_type(value)
Remove everything that would affect paths in the filename
def filename(value): ''' Remove everything that would affect paths in the filename :param value: :return: ''' return re.sub('[^a-zA-Z0-9.-_ ]', '', os.path.basename(InputSanitizer.trim(value)))
Get all EIP s associated with the current credentials.
def _get_all_eip_addresses(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None): ''' Get all EIP's associated with the current credentials. addresses (list) - Optional list of addresses. If provided, only those those in the list w...
Get public addresses of some or all EIPs associated with the current account.
def get_all_eip_addresses(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None): ''' Get public addresses of some, or all EIPs associated with the current account. addresses (list) - Optional list of addresses. If provided, only the addres...
Return the first unassociated EIP
def get_unassociated_eip_address(domain='standard', region=None, key=None, keyid=None, profile=None): ''' Return the first unassociated EIP domain Indicates whether the address is an EC2 address or a VPC address (standard|vpc). CLI Example: .. code...
Get interesting info about some or all EIPs associated with the current account.
def get_eip_address_info(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None): ''' Get 'interesting' info about some, or all EIPs associated with the current account. addresses (list) - Optional list of addresses. If provided, only the addr...
Allocate a new Elastic IP address and associate it with your account.
def allocate_eip_address(domain=None, region=None, key=None, keyid=None, profile=None): ''' Allocate a new Elastic IP address and associate it with your account. domain (string) Optional param - if set to exactly 'vpc', the address will be allocated to the VPC. The default simply maps the ...
Free an Elastic IP address. Pass either a public IP address to release an EC2 Classic EIP or an AllocationId to release a VPC EIP.
def release_eip_address(public_ip=None, allocation_id=None, region=None, key=None, keyid=None, profile=None): ''' Free an Elastic IP address. Pass either a public IP address to release an EC2 Classic EIP, or an AllocationId to release a VPC EIP. public_ip (string) - The...
Associate an Elastic IP address with a currently running instance or a network interface. This requires exactly one of either public_ip or allocation_id depending on whether you’re associating a VPC address or a plain EC2 address.
def associate_eip_address(instance_id=None, instance_name=None, public_ip=None, allocation_id=None, network_interface_id=None, network_interface_name=None, private_ip_address=None, allow_reassociation=False, region=None, key=None, ...
Disassociate an Elastic IP address from a currently running instance. This requires exactly one of either association_id or public_ip depending on whether you’re dealing with a VPC or EC2 Classic address.
def disassociate_eip_address(public_ip=None, association_id=None, region=None, key=None, keyid=None, profile=None): ''' Disassociate an Elastic IP address from a currently running instance. This requires exactly one of either 'association_id' or 'public_ip', depending on whe...
Assigns one or more secondary private IP addresses to a network interface.
def assign_private_ip_addresses(network_interface_name=None, network_interface_id=None, private_ip_addresses=None, secondary_private_ip_address_count=None, allow_reassignment=False, region=None, key=None, keyid=None, profile...
Get a list of AZs for the configured region.
def get_zones(region=None, key=None, keyid=None, profile=None): ''' Get a list of AZs for the configured region. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_zones ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) return [z.name for z in c...
Given instance properties find and return matching instance ids
def find_instances(instance_id=None, name=None, tags=None, region=None, key=None, keyid=None, profile=None, return_objs=False, in_states=None, filters=None): ''' Given instance properties, find and return matching instance ids CLI Examples: .. code-block:: bash ...
Given instance properties that define exactly one instance create AMI and return AMI - id.
def create_image(ami_name, instance_id=None, instance_name=None, tags=None, region=None, key=None, keyid=None, profile=None, description=None, no_reboot=False, dry_run=False, filters=None): ''' Given instance properties that define exactly one instance, create AMI and return AM...
Given image properties find and return matching AMI ids
def find_images(ami_name=None, executable_by=None, owners=None, image_ids=None, tags=None, region=None, key=None, keyid=None, profile=None, return_objs=False): ''' Given image properties, find and return matching AMI ids CLI Examples: .. code-block:: bash salt myminion boto_e...
Terminate the instance described by instance_id or name.
def terminate(instance_id=None, name=None, region=None, key=None, keyid=None, profile=None, filters=None): ''' Terminate the instance described by instance_id or name. CLI Example: .. code-block:: bash salt myminion boto_ec2.terminate name=myinstance salt myminion boto_e...
Given instance properties return the instance id if it exists.
def get_id(name=None, tags=None, region=None, key=None, keyid=None, profile=None, in_states=None, filters=None): ''' Given instance properties, return the instance id if it exists. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_id myinstance ''' instance_ids...
Given an instance_id return a list of tags associated with that instance.
def get_tags(instance_id=None, keyid=None, key=None, profile=None, region=None): ''' Given an instance_id, return a list of tags associated with that instance. returns (list) - list of tags as key/value pairs CLI Example: .. code-block:: bash salt myminion boto_ec2.g...
Given an instance id check to see if the given instance id exists.
def exists(instance_id=None, name=None, tags=None, region=None, key=None, keyid=None, profile=None, in_states=None, filters=None): ''' Given an instance id, check to see if the given instance id exists. Returns True if the given instance with the given id, name, or tags exists; otherwise, Fa...
Convert a string or a json payload or a dict in the right format into a boto. ec2. blockdevicemapping. BlockDeviceMapping as needed by instance_present (). The following YAML is a direct representation of what is expected by the underlying boto EC2 code.
def _to_blockdev_map(thing): ''' Convert a string, or a json payload, or a dict in the right format, into a boto.ec2.blockdevicemapping.BlockDeviceMapping as needed by instance_present(). The following YAML is a direct representation of what is expected by the underlying boto EC2 code. YAML ex...
Create and start an EC2 instance.
def run(image_id, name=None, tags=None, key_name=None, security_groups=None, user_data=None, instance_type='m1.small', placement=None, kernel_id=None, ramdisk_id=None, monitoring_enabled=None, vpc_id=None, vpc_name=None, subnet_id=None, subnet_name=None, private_ip_address=None, block_de...
Check to see if a key exists. Returns fingerprint and name if it does and False if it doesn t CLI Example:
def get_key(key_name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a key exists. Returns fingerprint and name if it does and False if it doesn't CLI Example: .. code-block:: bash salt myminion boto_ec2.get_key mykey ''' conn = _get_conn(region=region, key=k...
Creates a key and saves it to a given path. Returns the private key.
def create_key(key_name, save_path, region=None, key=None, keyid=None, profile=None): ''' Creates a key and saves it to a given path. Returns the private key. CLI Example: .. code-block:: bash salt myminion boto_ec2.create_key mykey /root/ ''' conn = _get_conn(regio...
Imports the public key from an RSA key pair that you created with a third - party tool. Supported formats: - OpenSSH public key format ( e. g. the format in ~/. ssh/ authorized_keys ) - Base64 encoded DER format - SSH public key file format as specified in RFC4716 - DSA keys are not supported. Make sure your key genera...
def import_key(key_name, public_key_material, region=None, key=None, keyid=None, profile=None): ''' Imports the public key from an RSA key pair that you created with a third-party tool. Supported formats: - OpenSSH public key format (e.g., the format in ~/.ssh/authorized_keys) - Base6...
Deletes a key. Always returns True
def delete_key(key_name, region=None, key=None, keyid=None, profile=None): ''' Deletes a key. Always returns True CLI Example: .. code-block:: bash salt myminion boto_ec2.delete_key mykey ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: key ...
Gets all keys or filters them by name and returns a list. keynames ( list ):: A list of the names of keypairs to retrieve. If not provided all key pairs will be returned. filters ( dict ):: Optional filters that can be used to limit the results returned. Filters are provided in the form of a dictionary consisting of fi...
def get_keys(keynames=None, filters=None, region=None, key=None, keyid=None, profile=None): ''' Gets all keys or filters them by name and returns a list. keynames (list):: A list of the names of keypairs to retrieve. If not provided, all key pairs will be returned. filters (dict) :: Opt...