repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
saltstack/salt
salt/cloud/clouds/gce.py
__get_size
def __get_size(conn, vm_): ''' Need to override libcloud to find the machine type in the proper zone. ''' size = config.get_cloud_config_value( 'size', vm_, __opts__, default='n1-standard-1', search_global=False) return conn.ex_get_size(size, __get_location(conn, vm_))
python
def __get_size(conn, vm_): ''' Need to override libcloud to find the machine type in the proper zone. ''' size = config.get_cloud_config_value( 'size', vm_, __opts__, default='n1-standard-1', search_global=False) return conn.ex_get_size(size, __get_location(conn, vm_))
[ "def", "__get_size", "(", "conn", ",", "vm_", ")", ":", "size", "=", "config", ".", "get_cloud_config_value", "(", "'size'", ",", "vm_", ",", "__opts__", ",", "default", "=", "'n1-standard-1'", ",", "search_global", "=", "False", ")", "return", "conn", "."...
Need to override libcloud to find the machine type in the proper zone.
[ "Need", "to", "override", "libcloud", "to", "find", "the", "machine", "type", "in", "the", "proper", "zone", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L398-L404
train
saltstack/salt
salt/cloud/clouds/gce.py
__get_tags
def __get_tags(vm_): ''' Get configured tags. ''' t = config.get_cloud_config_value( 'tags', vm_, __opts__, default='[]', search_global=False) # Consider warning the user that the tags in the cloud profile # could not be interpreted, bad formatting? try: tags = literal_eval(t) except Exception: # pylint: disable=W0703 tags = None if not tags or not isinstance(tags, list): tags = None return tags
python
def __get_tags(vm_): ''' Get configured tags. ''' t = config.get_cloud_config_value( 'tags', vm_, __opts__, default='[]', search_global=False) # Consider warning the user that the tags in the cloud profile # could not be interpreted, bad formatting? try: tags = literal_eval(t) except Exception: # pylint: disable=W0703 tags = None if not tags or not isinstance(tags, list): tags = None return tags
[ "def", "__get_tags", "(", "vm_", ")", ":", "t", "=", "config", ".", "get_cloud_config_value", "(", "'tags'", ",", "vm_", ",", "__opts__", ",", "default", "=", "'[]'", ",", "search_global", "=", "False", ")", "# Consider warning the user that the tags in the cloud ...
Get configured tags.
[ "Get", "configured", "tags", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L407-L422
train
saltstack/salt
salt/cloud/clouds/gce.py
__get_metadata
def __get_metadata(vm_): ''' Get configured metadata and add 'salt-cloud-profile'. ''' md = config.get_cloud_config_value( 'metadata', vm_, __opts__, default='{}', search_global=False) # Consider warning the user that the metadata in the cloud profile # could not be interpreted, bad formatting? try: metadata = literal_eval(md) except Exception: # pylint: disable=W0703 metadata = None if not metadata or not isinstance(metadata, dict): metadata = {'items': [{ 'key': 'salt-cloud-profile', 'value': vm_['profile'] }]} else: metadata['salt-cloud-profile'] = vm_['profile'] items = [] for k, v in six.iteritems(metadata): items.append({'key': k, 'value': v}) metadata = {'items': items} return metadata
python
def __get_metadata(vm_): ''' Get configured metadata and add 'salt-cloud-profile'. ''' md = config.get_cloud_config_value( 'metadata', vm_, __opts__, default='{}', search_global=False) # Consider warning the user that the metadata in the cloud profile # could not be interpreted, bad formatting? try: metadata = literal_eval(md) except Exception: # pylint: disable=W0703 metadata = None if not metadata or not isinstance(metadata, dict): metadata = {'items': [{ 'key': 'salt-cloud-profile', 'value': vm_['profile'] }]} else: metadata['salt-cloud-profile'] = vm_['profile'] items = [] for k, v in six.iteritems(metadata): items.append({'key': k, 'value': v}) metadata = {'items': items} return metadata
[ "def", "__get_metadata", "(", "vm_", ")", ":", "md", "=", "config", ".", "get_cloud_config_value", "(", "'metadata'", ",", "vm_", ",", "__opts__", ",", "default", "=", "'{}'", ",", "search_global", "=", "False", ")", "# Consider warning the user that the metadata ...
Get configured metadata and add 'salt-cloud-profile'.
[ "Get", "configured", "metadata", "and", "add", "salt", "-", "cloud", "-", "profile", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L425-L449
train
saltstack/salt
salt/cloud/clouds/gce.py
__get_host
def __get_host(node, vm_): ''' Return public IP, private IP, or hostname for the libcloud 'node' object ''' if __get_ssh_interface(vm_) == 'private_ips' or vm_['external_ip'] is None: ip_address = node.private_ips[0] log.info('Salt node data. Private_ip: %s', ip_address) else: ip_address = node.public_ips[0] log.info('Salt node data. Public_ip: %s', ip_address) if ip_address: return ip_address return node.name
python
def __get_host(node, vm_): ''' Return public IP, private IP, or hostname for the libcloud 'node' object ''' if __get_ssh_interface(vm_) == 'private_ips' or vm_['external_ip'] is None: ip_address = node.private_ips[0] log.info('Salt node data. Private_ip: %s', ip_address) else: ip_address = node.public_ips[0] log.info('Salt node data. Public_ip: %s', ip_address) if ip_address: return ip_address return node.name
[ "def", "__get_host", "(", "node", ",", "vm_", ")", ":", "if", "__get_ssh_interface", "(", "vm_", ")", "==", "'private_ips'", "or", "vm_", "[", "'external_ip'", "]", "is", "None", ":", "ip_address", "=", "node", ".", "private_ips", "[", "0", "]", "log", ...
Return public IP, private IP, or hostname for the libcloud 'node' object
[ "Return", "public", "IP", "private", "IP", "or", "hostname", "for", "the", "libcloud", "node", "object" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L452-L466
train
saltstack/salt
salt/cloud/clouds/gce.py
__get_network
def __get_network(conn, vm_): ''' Return a GCE libcloud network object with matching name ''' network = config.get_cloud_config_value( 'network', vm_, __opts__, default='default', search_global=False) return conn.ex_get_network(network)
python
def __get_network(conn, vm_): ''' Return a GCE libcloud network object with matching name ''' network = config.get_cloud_config_value( 'network', vm_, __opts__, default='default', search_global=False) return conn.ex_get_network(network)
[ "def", "__get_network", "(", "conn", ",", "vm_", ")", ":", "network", "=", "config", ".", "get_cloud_config_value", "(", "'network'", ",", "vm_", ",", "__opts__", ",", "default", "=", "'default'", ",", "search_global", "=", "False", ")", "return", "conn", ...
Return a GCE libcloud network object with matching name
[ "Return", "a", "GCE", "libcloud", "network", "object", "with", "matching", "name" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L469-L476
train
saltstack/salt
salt/cloud/clouds/gce.py
__get_subnetwork
def __get_subnetwork(vm_): ''' Get configured subnetwork. ''' ex_subnetwork = config.get_cloud_config_value( 'subnetwork', vm_, __opts__, search_global=False) return ex_subnetwork
python
def __get_subnetwork(vm_): ''' Get configured subnetwork. ''' ex_subnetwork = config.get_cloud_config_value( 'subnetwork', vm_, __opts__, search_global=False) return ex_subnetwork
[ "def", "__get_subnetwork", "(", "vm_", ")", ":", "ex_subnetwork", "=", "config", ".", "get_cloud_config_value", "(", "'subnetwork'", ",", "vm_", ",", "__opts__", ",", "search_global", "=", "False", ")", "return", "ex_subnetwork" ]
Get configured subnetwork.
[ "Get", "configured", "subnetwork", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L479-L487
train
saltstack/salt
salt/cloud/clouds/gce.py
__get_region
def __get_region(conn, vm_): ''' Return a GCE libcloud region object with matching name. ''' location = __get_location(conn, vm_) region = '-'.join(location.name.split('-')[:2]) return conn.ex_get_region(region)
python
def __get_region(conn, vm_): ''' Return a GCE libcloud region object with matching name. ''' location = __get_location(conn, vm_) region = '-'.join(location.name.split('-')[:2]) return conn.ex_get_region(region)
[ "def", "__get_region", "(", "conn", ",", "vm_", ")", ":", "location", "=", "__get_location", "(", "conn", ",", "vm_", ")", "region", "=", "'-'", ".", "join", "(", "location", ".", "name", ".", "split", "(", "'-'", ")", "[", ":", "2", "]", ")", "r...
Return a GCE libcloud region object with matching name.
[ "Return", "a", "GCE", "libcloud", "region", "object", "with", "matching", "name", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L490-L497
train
saltstack/salt
salt/cloud/clouds/gce.py
__create_orget_address
def __create_orget_address(conn, name, region): ''' Reuse or create a static IP address. Returns a native GCEAddress construct to use with libcloud. ''' try: addy = conn.ex_get_address(name, region) except ResourceNotFoundError: # pylint: disable=W0703 addr_kwargs = { 'name': name, 'region': region } new_addy = create_address(addr_kwargs, "function") addy = conn.ex_get_address(new_addy['name'], new_addy['region']) return addy
python
def __create_orget_address(conn, name, region): ''' Reuse or create a static IP address. Returns a native GCEAddress construct to use with libcloud. ''' try: addy = conn.ex_get_address(name, region) except ResourceNotFoundError: # pylint: disable=W0703 addr_kwargs = { 'name': name, 'region': region } new_addy = create_address(addr_kwargs, "function") addy = conn.ex_get_address(new_addy['name'], new_addy['region']) return addy
[ "def", "__create_orget_address", "(", "conn", ",", "name", ",", "region", ")", ":", "try", ":", "addy", "=", "conn", ".", "ex_get_address", "(", "name", ",", "region", ")", "except", "ResourceNotFoundError", ":", "# pylint: disable=W0703", "addr_kwargs", "=", ...
Reuse or create a static IP address. Returns a native GCEAddress construct to use with libcloud.
[ "Reuse", "or", "create", "a", "static", "IP", "address", ".", "Returns", "a", "native", "GCEAddress", "construct", "to", "use", "with", "libcloud", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L511-L526
train
saltstack/salt
salt/cloud/clouds/gce.py
_parse_allow
def _parse_allow(allow): ''' Convert firewall rule allowed user-string to specified REST API format. ''' # input=> tcp:53,tcp:80,tcp:443,icmp,tcp:4201,udp:53 # output<= [ # {"IPProtocol": "tcp", "ports": ["53","80","443","4201"]}, # {"IPProtocol": "icmp"}, # {"IPProtocol": "udp", "ports": ["53"]}, # ] seen_protos = {} allow_dict = [] protocols = allow.split(',') for p in protocols: pairs = p.split(':') if pairs[0].lower() not in ['tcp', 'udp', 'icmp']: raise SaltCloudSystemExit( 'Unsupported protocol {0}. Must be tcp, udp, or icmp.'.format( pairs[0] ) ) if len(pairs) == 1 or pairs[0].lower() == 'icmp': seen_protos[pairs[0]] = [] else: if pairs[0] not in seen_protos: seen_protos[pairs[0]] = [pairs[1]] else: seen_protos[pairs[0]].append(pairs[1]) for k in seen_protos: d = {'IPProtocol': k} if seen_protos[k]: d['ports'] = seen_protos[k] allow_dict.append(d) log.debug("firewall allowed protocols/ports: %s", allow_dict) return allow_dict
python
def _parse_allow(allow): ''' Convert firewall rule allowed user-string to specified REST API format. ''' # input=> tcp:53,tcp:80,tcp:443,icmp,tcp:4201,udp:53 # output<= [ # {"IPProtocol": "tcp", "ports": ["53","80","443","4201"]}, # {"IPProtocol": "icmp"}, # {"IPProtocol": "udp", "ports": ["53"]}, # ] seen_protos = {} allow_dict = [] protocols = allow.split(',') for p in protocols: pairs = p.split(':') if pairs[0].lower() not in ['tcp', 'udp', 'icmp']: raise SaltCloudSystemExit( 'Unsupported protocol {0}. Must be tcp, udp, or icmp.'.format( pairs[0] ) ) if len(pairs) == 1 or pairs[0].lower() == 'icmp': seen_protos[pairs[0]] = [] else: if pairs[0] not in seen_protos: seen_protos[pairs[0]] = [pairs[1]] else: seen_protos[pairs[0]].append(pairs[1]) for k in seen_protos: d = {'IPProtocol': k} if seen_protos[k]: d['ports'] = seen_protos[k] allow_dict.append(d) log.debug("firewall allowed protocols/ports: %s", allow_dict) return allow_dict
[ "def", "_parse_allow", "(", "allow", ")", ":", "# input=> tcp:53,tcp:80,tcp:443,icmp,tcp:4201,udp:53", "# output<= [", "# {\"IPProtocol\": \"tcp\", \"ports\": [\"53\",\"80\",\"443\",\"4201\"]},", "# {\"IPProtocol\": \"icmp\"},", "# {\"IPProtocol\": \"udp\", \"ports\": [\"53\"]},", ...
Convert firewall rule allowed user-string to specified REST API format.
[ "Convert", "firewall", "rule", "allowed", "user", "-", "string", "to", "specified", "REST", "API", "format", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L529-L563
train
saltstack/salt
salt/cloud/clouds/gce.py
__get_ssh_credentials
def __get_ssh_credentials(vm_): ''' Get configured SSH credentials. ''' ssh_user = config.get_cloud_config_value( 'ssh_username', vm_, __opts__, default=os.getenv('USER')) ssh_key = config.get_cloud_config_value( 'ssh_keyfile', vm_, __opts__, default=os.path.expanduser('~/.ssh/google_compute_engine')) return ssh_user, ssh_key
python
def __get_ssh_credentials(vm_): ''' Get configured SSH credentials. ''' ssh_user = config.get_cloud_config_value( 'ssh_username', vm_, __opts__, default=os.getenv('USER')) ssh_key = config.get_cloud_config_value( 'ssh_keyfile', vm_, __opts__, default=os.path.expanduser('~/.ssh/google_compute_engine')) return ssh_user, ssh_key
[ "def", "__get_ssh_credentials", "(", "vm_", ")", ":", "ssh_user", "=", "config", ".", "get_cloud_config_value", "(", "'ssh_username'", ",", "vm_", ",", "__opts__", ",", "default", "=", "os", ".", "getenv", "(", "'USER'", ")", ")", "ssh_key", "=", "config", ...
Get configured SSH credentials.
[ "Get", "configured", "SSH", "credentials", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L566-L575
train
saltstack/salt
salt/cloud/clouds/gce.py
create_network
def create_network(kwargs=None, call=None): ''' ... versionchanged:: 2017.7.0 Create a GCE network. Must specify name and cidr. CLI Example: .. code-block:: bash salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24 mode=legacy description=optional salt-cloud -f create_network gce name=mynet description=optional ''' if call != 'function': raise SaltCloudSystemExit( 'The create_network function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a network.' ) return False mode = kwargs.get('mode', 'legacy') cidr = kwargs.get('cidr', None) if cidr is None and mode == 'legacy': log.error( 'A network CIDR range must be specified when creating a legacy network.' ) return False name = kwargs['name'] desc = kwargs.get('description', None) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'creating network', 'salt/cloud/net/creating', args={ 'name': name, 'cidr': cidr, 'description': desc, 'mode': mode }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) network = conn.ex_create_network(name, cidr, desc, mode) __utils__['cloud.fire_event']( 'event', 'created network', 'salt/cloud/net/created', args={ 'name': name, 'cidr': cidr, 'description': desc, 'mode': mode }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(network)
python
def create_network(kwargs=None, call=None): ''' ... versionchanged:: 2017.7.0 Create a GCE network. Must specify name and cidr. CLI Example: .. code-block:: bash salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24 mode=legacy description=optional salt-cloud -f create_network gce name=mynet description=optional ''' if call != 'function': raise SaltCloudSystemExit( 'The create_network function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a network.' ) return False mode = kwargs.get('mode', 'legacy') cidr = kwargs.get('cidr', None) if cidr is None and mode == 'legacy': log.error( 'A network CIDR range must be specified when creating a legacy network.' ) return False name = kwargs['name'] desc = kwargs.get('description', None) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'creating network', 'salt/cloud/net/creating', args={ 'name': name, 'cidr': cidr, 'description': desc, 'mode': mode }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) network = conn.ex_create_network(name, cidr, desc, mode) __utils__['cloud.fire_event']( 'event', 'created network', 'salt/cloud/net/created', args={ 'name': name, 'cidr': cidr, 'description': desc, 'mode': mode }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(network)
[ "def", "create_network", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_network function must be called with -f or --function.'", ")", "if", "not", "kwargs", "o...
... versionchanged:: 2017.7.0 Create a GCE network. Must specify name and cidr. CLI Example: .. code-block:: bash salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24 mode=legacy description=optional salt-cloud -f create_network gce name=mynet description=optional
[ "...", "versionchanged", "::", "2017", ".", "7", ".", "0", "Create", "a", "GCE", "network", ".", "Must", "specify", "name", "and", "cidr", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L578-L642
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_network
def delete_network(kwargs=None, call=None): ''' Permanently delete a network. CLI Example: .. code-block:: bash salt-cloud -f delete_network gce name=mynet ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_network function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a network.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'deleting network', 'salt/cloud/net/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_network( conn.ex_get_network(name) ) except ResourceNotFoundError as exc: log.error( 'Nework %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted network', 'salt/cloud/net/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def delete_network(kwargs=None, call=None): ''' Permanently delete a network. CLI Example: .. code-block:: bash salt-cloud -f delete_network gce name=mynet ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_network function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a network.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'deleting network', 'salt/cloud/net/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_network( conn.ex_get_network(name) ) except ResourceNotFoundError as exc: log.error( 'Nework %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted network', 'salt/cloud/net/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "delete_network", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_network function must be called with -f or --function.'", ")", "if", "not", "kwargs", "o...
Permanently delete a network. CLI Example: .. code-block:: bash salt-cloud -f delete_network gce name=mynet
[ "Permanently", "delete", "a", "network", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L645-L701
train
saltstack/salt
salt/cloud/clouds/gce.py
show_network
def show_network(kwargs=None, call=None): ''' Show the details of an existing network. CLI Example: .. code-block:: bash salt-cloud -f show_network gce name=mynet ''' if call != 'function': raise SaltCloudSystemExit( 'The show_network function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of network.' ) return False conn = get_conn() return _expand_item(conn.ex_get_network(kwargs['name']))
python
def show_network(kwargs=None, call=None): ''' Show the details of an existing network. CLI Example: .. code-block:: bash salt-cloud -f show_network gce name=mynet ''' if call != 'function': raise SaltCloudSystemExit( 'The show_network function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of network.' ) return False conn = get_conn() return _expand_item(conn.ex_get_network(kwargs['name']))
[ "def", "show_network", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The show_network function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", ...
Show the details of an existing network. CLI Example: .. code-block:: bash salt-cloud -f show_network gce name=mynet
[ "Show", "the", "details", "of", "an", "existing", "network", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L704-L725
train
saltstack/salt
salt/cloud/clouds/gce.py
create_subnetwork
def create_subnetwork(kwargs=None, call=None): ''' ... versionadded:: 2017.7.0 Create a GCE Subnetwork. Must specify name, cidr, network, and region. CLI Example: .. code-block:: bash salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 description=optional ''' if call != 'function': raise SaltCloudSystemExit( 'The create_subnetwork function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of subnet.' ) return False if 'network' not in kwargs: log.errror( 'Must specify name of network to create subnet under.' ) return False if 'cidr' not in kwargs: log.errror( 'A network CIDR range must be specified when creating a subnet.' ) return False if 'region' not in kwargs: log.error( 'A region must be specified when creating a subnetwork.' ) return False name = kwargs['name'] cidr = kwargs['cidr'] network = kwargs['network'] region = kwargs['region'] desc = kwargs.get('description', None) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create subnetwork', 'salt/cloud/subnet/creating', args={ 'name': name, 'network': network, 'cidr': cidr, 'region': region, 'description': desc }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) subnet = conn.ex_create_subnetwork(name, cidr, network, region, desc) __utils__['cloud.fire_event']( 'event', 'created subnetwork', 'salt/cloud/subnet/created', args={ 'name': name, 'network': network, 'cidr': cidr, 'region': region, 'description': desc }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(subnet)
python
def create_subnetwork(kwargs=None, call=None): ''' ... versionadded:: 2017.7.0 Create a GCE Subnetwork. Must specify name, cidr, network, and region. CLI Example: .. code-block:: bash salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 description=optional ''' if call != 'function': raise SaltCloudSystemExit( 'The create_subnetwork function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of subnet.' ) return False if 'network' not in kwargs: log.errror( 'Must specify name of network to create subnet under.' ) return False if 'cidr' not in kwargs: log.errror( 'A network CIDR range must be specified when creating a subnet.' ) return False if 'region' not in kwargs: log.error( 'A region must be specified when creating a subnetwork.' ) return False name = kwargs['name'] cidr = kwargs['cidr'] network = kwargs['network'] region = kwargs['region'] desc = kwargs.get('description', None) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create subnetwork', 'salt/cloud/subnet/creating', args={ 'name': name, 'network': network, 'cidr': cidr, 'region': region, 'description': desc }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) subnet = conn.ex_create_subnetwork(name, cidr, network, region, desc) __utils__['cloud.fire_event']( 'event', 'created subnetwork', 'salt/cloud/subnet/created', args={ 'name': name, 'network': network, 'cidr': cidr, 'region': region, 'description': desc }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(subnet)
[ "def", "create_subnetwork", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_subnetwork function must be called with -f or --function.'", ")", "if", "not", "kwargs"...
... versionadded:: 2017.7.0 Create a GCE Subnetwork. Must specify name, cidr, network, and region. CLI Example: .. code-block:: bash salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 description=optional
[ "...", "versionadded", "::", "2017", ".", "7", ".", "0", "Create", "a", "GCE", "Subnetwork", ".", "Must", "specify", "name", "cidr", "network", "and", "region", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L728-L807
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_subnetwork
def delete_subnetwork(kwargs=None, call=None): ''' ... versionadded:: 2017.7.0 Delete a GCE Subnetwork. Must specify name and region. CLI Example: .. code-block:: bash salt-cloud -f delete_subnetwork gce name=mysubnet network=mynet1 region=us-west1 ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_subnet function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of subnet.' ) return False if 'region' not in kwargs: log.error( 'Must specify region of subnet.' ) return False name = kwargs['name'] region = kwargs['region'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'deleting subnetwork', 'salt/cloud/subnet/deleting', args={ 'name': name, 'region': region }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_subnetwork(name, region) except ResourceNotFoundError as exc: log.error( 'Subnetwork %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted subnetwork', 'salt/cloud/subnet/deleted', args={ 'name': name, 'region': region }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def delete_subnetwork(kwargs=None, call=None): ''' ... versionadded:: 2017.7.0 Delete a GCE Subnetwork. Must specify name and region. CLI Example: .. code-block:: bash salt-cloud -f delete_subnetwork gce name=mysubnet network=mynet1 region=us-west1 ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_subnet function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of subnet.' ) return False if 'region' not in kwargs: log.error( 'Must specify region of subnet.' ) return False name = kwargs['name'] region = kwargs['region'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'deleting subnetwork', 'salt/cloud/subnet/deleting', args={ 'name': name, 'region': region }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_subnetwork(name, region) except ResourceNotFoundError as exc: log.error( 'Subnetwork %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted subnetwork', 'salt/cloud/subnet/deleted', args={ 'name': name, 'region': region }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "delete_subnetwork", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_subnet function must be called with -f or --function.'", ")", "if", "not", "kwargs", ...
... versionadded:: 2017.7.0 Delete a GCE Subnetwork. Must specify name and region. CLI Example: .. code-block:: bash salt-cloud -f delete_subnetwork gce name=mysubnet network=mynet1 region=us-west1
[ "...", "versionadded", "::", "2017", ".", "7", ".", "0", "Delete", "a", "GCE", "Subnetwork", ".", "Must", "specify", "name", "and", "region", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L810-L874
train
saltstack/salt
salt/cloud/clouds/gce.py
show_subnetwork
def show_subnetwork(kwargs=None, call=None): ''' ... versionadded:: 2017.7.0 Show details of an existing GCE Subnetwork. Must specify name and region. CLI Example: .. code-block:: bash salt-cloud -f show_subnetwork gce name=mysubnet region=us-west1 ''' if call != 'function': raise SaltCloudSystemExit( 'The show_subnetwork function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of subnet.' ) return False if 'region' not in kwargs: log.error( 'Must specify region of subnet.' ) return False name = kwargs['name'] region = kwargs['region'] conn = get_conn() return _expand_item(conn.ex_get_subnetwork(name, region))
python
def show_subnetwork(kwargs=None, call=None): ''' ... versionadded:: 2017.7.0 Show details of an existing GCE Subnetwork. Must specify name and region. CLI Example: .. code-block:: bash salt-cloud -f show_subnetwork gce name=mysubnet region=us-west1 ''' if call != 'function': raise SaltCloudSystemExit( 'The show_subnetwork function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of subnet.' ) return False if 'region' not in kwargs: log.error( 'Must specify region of subnet.' ) return False name = kwargs['name'] region = kwargs['region'] conn = get_conn() return _expand_item(conn.ex_get_subnetwork(name, region))
[ "def", "show_subnetwork", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The show_subnetwork function must be called with -f or --function.'", ")", "if", "not", "kwargs", ...
... versionadded:: 2017.7.0 Show details of an existing GCE Subnetwork. Must specify name and region. CLI Example: .. code-block:: bash salt-cloud -f show_subnetwork gce name=mysubnet region=us-west1
[ "...", "versionadded", "::", "2017", ".", "7", ".", "0", "Show", "details", "of", "an", "existing", "GCE", "Subnetwork", ".", "Must", "specify", "name", "and", "region", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L877-L909
train
saltstack/salt
salt/cloud/clouds/gce.py
create_fwrule
def create_fwrule(kwargs=None, call=None): ''' Create a GCE firewall rule. The 'default' network is used if not specified. CLI Example: .. code-block:: bash salt-cloud -f create_fwrule gce name=allow-http allow=tcp:80 ''' if call != 'function': raise SaltCloudSystemExit( 'The create_fwrule function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a firewall rule.' ) return False if 'allow' not in kwargs: log.error( 'Must use "allow" to specify allowed protocols/ports.' ) return False name = kwargs['name'] network_name = kwargs.get('network', 'default') allow = _parse_allow(kwargs['allow']) src_range = kwargs.get('src_range', '0.0.0.0/0') src_tags = kwargs.get('src_tags', None) dst_tags = kwargs.get('dst_tags', None) if src_range: src_range = src_range.split(',') if src_tags: src_tags = src_tags.split(',') if dst_tags: dst_tags = dst_tags.split(',') conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create firewall', 'salt/cloud/firewall/creating', args={ 'name': name, 'network': network_name, 'allow': kwargs['allow'], }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) fwrule = conn.ex_create_firewall( name, allow, network=network_name, source_ranges=src_range, source_tags=src_tags, target_tags=dst_tags ) __utils__['cloud.fire_event']( 'event', 'created firewall', 'salt/cloud/firewall/created', args={ 'name': name, 'network': network_name, 'allow': kwargs['allow'], }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(fwrule)
python
def create_fwrule(kwargs=None, call=None): ''' Create a GCE firewall rule. The 'default' network is used if not specified. CLI Example: .. code-block:: bash salt-cloud -f create_fwrule gce name=allow-http allow=tcp:80 ''' if call != 'function': raise SaltCloudSystemExit( 'The create_fwrule function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a firewall rule.' ) return False if 'allow' not in kwargs: log.error( 'Must use "allow" to specify allowed protocols/ports.' ) return False name = kwargs['name'] network_name = kwargs.get('network', 'default') allow = _parse_allow(kwargs['allow']) src_range = kwargs.get('src_range', '0.0.0.0/0') src_tags = kwargs.get('src_tags', None) dst_tags = kwargs.get('dst_tags', None) if src_range: src_range = src_range.split(',') if src_tags: src_tags = src_tags.split(',') if dst_tags: dst_tags = dst_tags.split(',') conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create firewall', 'salt/cloud/firewall/creating', args={ 'name': name, 'network': network_name, 'allow': kwargs['allow'], }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) fwrule = conn.ex_create_firewall( name, allow, network=network_name, source_ranges=src_range, source_tags=src_tags, target_tags=dst_tags ) __utils__['cloud.fire_event']( 'event', 'created firewall', 'salt/cloud/firewall/created', args={ 'name': name, 'network': network_name, 'allow': kwargs['allow'], }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(fwrule)
[ "def", "create_fwrule", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_fwrule function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or"...
Create a GCE firewall rule. The 'default' network is used if not specified. CLI Example: .. code-block:: bash salt-cloud -f create_fwrule gce name=allow-http allow=tcp:80
[ "Create", "a", "GCE", "firewall", "rule", ".", "The", "default", "network", "is", "used", "if", "not", "specified", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L912-L986
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_fwrule
def delete_fwrule(kwargs=None, call=None): ''' Permanently delete a firewall rule. CLI Example: .. code-block:: bash salt-cloud -f delete_fwrule gce name=allow-http ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_fwrule function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a firewall rule.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete firewall', 'salt/cloud/firewall/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_firewall( conn.ex_get_firewall(name) ) except ResourceNotFoundError as exc: log.error( 'Rule %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted firewall', 'salt/cloud/firewall/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def delete_fwrule(kwargs=None, call=None): ''' Permanently delete a firewall rule. CLI Example: .. code-block:: bash salt-cloud -f delete_fwrule gce name=allow-http ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_fwrule function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a firewall rule.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete firewall', 'salt/cloud/firewall/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_firewall( conn.ex_get_firewall(name) ) except ResourceNotFoundError as exc: log.error( 'Rule %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted firewall', 'salt/cloud/firewall/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "delete_fwrule", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_fwrule function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or"...
Permanently delete a firewall rule. CLI Example: .. code-block:: bash salt-cloud -f delete_fwrule gce name=allow-http
[ "Permanently", "delete", "a", "firewall", "rule", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L989-L1045
train
saltstack/salt
salt/cloud/clouds/gce.py
show_fwrule
def show_fwrule(kwargs=None, call=None): ''' Show the details of an existing firewall rule. CLI Example: .. code-block:: bash salt-cloud -f show_fwrule gce name=allow-http ''' if call != 'function': raise SaltCloudSystemExit( 'The show_fwrule function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of network.' ) return False conn = get_conn() return _expand_item(conn.ex_get_firewall(kwargs['name']))
python
def show_fwrule(kwargs=None, call=None): ''' Show the details of an existing firewall rule. CLI Example: .. code-block:: bash salt-cloud -f show_fwrule gce name=allow-http ''' if call != 'function': raise SaltCloudSystemExit( 'The show_fwrule function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of network.' ) return False conn = get_conn() return _expand_item(conn.ex_get_firewall(kwargs['name']))
[ "def", "show_fwrule", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The show_fwrule function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", ...
Show the details of an existing firewall rule. CLI Example: .. code-block:: bash salt-cloud -f show_fwrule gce name=allow-http
[ "Show", "the", "details", "of", "an", "existing", "firewall", "rule", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1048-L1069
train
saltstack/salt
salt/cloud/clouds/gce.py
create_hc
def create_hc(kwargs=None, call=None): ''' Create an HTTP health check configuration. CLI Example: .. code-block:: bash salt-cloud -f create_hc gce name=hc path=/healthy port=80 ''' if call != 'function': raise SaltCloudSystemExit( 'The create_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a health check.' ) return False name = kwargs['name'] host = kwargs.get('host', None) path = kwargs.get('path', None) port = kwargs.get('port', None) interval = kwargs.get('interval', None) timeout = kwargs.get('timeout', None) unhealthy_threshold = kwargs.get('unhealthy_threshold', None) healthy_threshold = kwargs.get('healthy_threshold', None) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create health_check', 'salt/cloud/healthcheck/creating', args={ 'name': name, 'host': host, 'path': path, 'port': port, 'interval': interval, 'timeout': timeout, 'unhealthy_threshold': unhealthy_threshold, 'healthy_threshold': healthy_threshold, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) hc = conn.ex_create_healthcheck( name, host=host, path=path, port=port, interval=interval, timeout=timeout, unhealthy_threshold=unhealthy_threshold, healthy_threshold=healthy_threshold ) __utils__['cloud.fire_event']( 'event', 'created health_check', 'salt/cloud/healthcheck/created', args={ 'name': name, 'host': host, 'path': path, 'port': port, 'interval': interval, 'timeout': timeout, 'unhealthy_threshold': unhealthy_threshold, 'healthy_threshold': healthy_threshold, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(hc)
python
def create_hc(kwargs=None, call=None): ''' Create an HTTP health check configuration. CLI Example: .. code-block:: bash salt-cloud -f create_hc gce name=hc path=/healthy port=80 ''' if call != 'function': raise SaltCloudSystemExit( 'The create_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a health check.' ) return False name = kwargs['name'] host = kwargs.get('host', None) path = kwargs.get('path', None) port = kwargs.get('port', None) interval = kwargs.get('interval', None) timeout = kwargs.get('timeout', None) unhealthy_threshold = kwargs.get('unhealthy_threshold', None) healthy_threshold = kwargs.get('healthy_threshold', None) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create health_check', 'salt/cloud/healthcheck/creating', args={ 'name': name, 'host': host, 'path': path, 'port': port, 'interval': interval, 'timeout': timeout, 'unhealthy_threshold': unhealthy_threshold, 'healthy_threshold': healthy_threshold, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) hc = conn.ex_create_healthcheck( name, host=host, path=path, port=port, interval=interval, timeout=timeout, unhealthy_threshold=unhealthy_threshold, healthy_threshold=healthy_threshold ) __utils__['cloud.fire_event']( 'event', 'created health_check', 'salt/cloud/healthcheck/created', args={ 'name': name, 'host': host, 'path': path, 'port': port, 'interval': interval, 'timeout': timeout, 'unhealthy_threshold': unhealthy_threshold, 'healthy_threshold': healthy_threshold, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(hc)
[ "def", "create_hc", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_hc function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'na...
Create an HTTP health check configuration. CLI Example: .. code-block:: bash salt-cloud -f create_hc gce name=hc path=/healthy port=80
[ "Create", "an", "HTTP", "health", "check", "configuration", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1072-L1145
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_hc
def delete_hc(kwargs=None, call=None): ''' Permanently delete a health check. CLI Example: .. code-block:: bash salt-cloud -f delete_hc gce name=hc ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a health check.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete health_check', 'salt/cloud/healthcheck/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_healthcheck( conn.ex_get_healthcheck(name) ) except ResourceNotFoundError as exc: log.error( 'Health check %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted health_check', 'salt/cloud/healthcheck/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def delete_hc(kwargs=None, call=None): ''' Permanently delete a health check. CLI Example: .. code-block:: bash salt-cloud -f delete_hc gce name=hc ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a health check.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete health_check', 'salt/cloud/healthcheck/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_healthcheck( conn.ex_get_healthcheck(name) ) except ResourceNotFoundError as exc: log.error( 'Health check %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted health_check', 'salt/cloud/healthcheck/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "delete_hc", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_hc function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'na...
Permanently delete a health check. CLI Example: .. code-block:: bash salt-cloud -f delete_hc gce name=hc
[ "Permanently", "delete", "a", "health", "check", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1148-L1204
train
saltstack/salt
salt/cloud/clouds/gce.py
show_hc
def show_hc(kwargs=None, call=None): ''' Show the details of an existing health check. CLI Example: .. code-block:: bash salt-cloud -f show_hc gce name=hc ''' if call != 'function': raise SaltCloudSystemExit( 'The show_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of health check.' ) return False conn = get_conn() return _expand_item(conn.ex_get_healthcheck(kwargs['name']))
python
def show_hc(kwargs=None, call=None): ''' Show the details of an existing health check. CLI Example: .. code-block:: bash salt-cloud -f show_hc gce name=hc ''' if call != 'function': raise SaltCloudSystemExit( 'The show_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of health check.' ) return False conn = get_conn() return _expand_item(conn.ex_get_healthcheck(kwargs['name']))
[ "def", "show_hc", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The show_hc function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'name'"...
Show the details of an existing health check. CLI Example: .. code-block:: bash salt-cloud -f show_hc gce name=hc
[ "Show", "the", "details", "of", "an", "existing", "health", "check", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1207-L1228
train
saltstack/salt
salt/cloud/clouds/gce.py
create_address
def create_address(kwargs=None, call=None): ''' Create a static address in a region. CLI Example: .. code-block:: bash salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP ''' if call != 'function': raise SaltCloudSystemExit( 'The create_address function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating an address.' ) return False if 'region' not in kwargs: log.error( 'A region must be specified for the address.' ) return False name = kwargs['name'] ex_region = kwargs['region'] ex_address = kwargs.get("address", None) kwargs['region'] = _expand_region(kwargs['region']) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create address', 'salt/cloud/address/creating', args=salt.utils.data.simple_types_filter(kwargs), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) addy = conn.ex_create_address(name, ex_region, ex_address) __utils__['cloud.fire_event']( 'event', 'created address', 'salt/cloud/address/created', args=salt.utils.data.simple_types_filter(kwargs), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) log.info('Created GCE Address %s', name) return _expand_address(addy)
python
def create_address(kwargs=None, call=None): ''' Create a static address in a region. CLI Example: .. code-block:: bash salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP ''' if call != 'function': raise SaltCloudSystemExit( 'The create_address function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating an address.' ) return False if 'region' not in kwargs: log.error( 'A region must be specified for the address.' ) return False name = kwargs['name'] ex_region = kwargs['region'] ex_address = kwargs.get("address", None) kwargs['region'] = _expand_region(kwargs['region']) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'create address', 'salt/cloud/address/creating', args=salt.utils.data.simple_types_filter(kwargs), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) addy = conn.ex_create_address(name, ex_region, ex_address) __utils__['cloud.fire_event']( 'event', 'created address', 'salt/cloud/address/created', args=salt.utils.data.simple_types_filter(kwargs), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) log.info('Created GCE Address %s', name) return _expand_address(addy)
[ "def", "create_address", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_address function must be called with -f or --function.'", ")", "if", "not", "kwargs", "o...
Create a static address in a region. CLI Example: .. code-block:: bash salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP
[ "Create", "a", "static", "address", "in", "a", "region", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1231-L1286
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_address
def delete_address(kwargs=None, call=None): ''' Permanently delete a static address. CLI Example: .. code-block:: bash salt-cloud -f delete_address gce name=my-ip ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_address function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting an address.' ) return False if not kwargs or 'region' not in kwargs: log.error( 'A region must be specified when deleting an address.' ) return False name = kwargs['name'] ex_region = kwargs['region'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete address', 'salt/cloud/address/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_address( conn.ex_get_address(name, ex_region) ) except ResourceNotFoundError as exc: log.error( 'Address %s in region %s was not found. Exception was: %s', name, ex_region, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted address', 'salt/cloud/address/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) log.info('Deleted GCE Address %s', name) return result
python
def delete_address(kwargs=None, call=None): ''' Permanently delete a static address. CLI Example: .. code-block:: bash salt-cloud -f delete_address gce name=my-ip ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_address function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting an address.' ) return False if not kwargs or 'region' not in kwargs: log.error( 'A region must be specified when deleting an address.' ) return False name = kwargs['name'] ex_region = kwargs['region'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete address', 'salt/cloud/address/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.ex_destroy_address( conn.ex_get_address(name, ex_region) ) except ResourceNotFoundError as exc: log.error( 'Address %s in region %s was not found. Exception was: %s', name, ex_region, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted address', 'salt/cloud/address/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) log.info('Deleted GCE Address %s', name) return result
[ "def", "delete_address", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_address function must be called with -f or --function.'", ")", "if", "not", "kwargs", "o...
Permanently delete a static address. CLI Example: .. code-block:: bash salt-cloud -f delete_address gce name=my-ip
[ "Permanently", "delete", "a", "static", "address", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1289-L1356
train
saltstack/salt
salt/cloud/clouds/gce.py
show_address
def show_address(kwargs=None, call=None): ''' Show the details of an existing static address. CLI Example: .. code-block:: bash salt-cloud -f show_address gce name=mysnapshot region=us-central1 ''' if call != 'function': raise SaltCloudSystemExit( 'The show_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name.' ) return False if not kwargs or 'region' not in kwargs: log.error( 'Must specify region.' ) return False conn = get_conn() return _expand_address(conn.ex_get_address(kwargs['name'], kwargs['region']))
python
def show_address(kwargs=None, call=None): ''' Show the details of an existing static address. CLI Example: .. code-block:: bash salt-cloud -f show_address gce name=mysnapshot region=us-central1 ''' if call != 'function': raise SaltCloudSystemExit( 'The show_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name.' ) return False if not kwargs or 'region' not in kwargs: log.error( 'Must specify region.' ) return False conn = get_conn() return _expand_address(conn.ex_get_address(kwargs['name'], kwargs['region']))
[ "def", "show_address", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The show_snapshot function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or",...
Show the details of an existing static address. CLI Example: .. code-block:: bash salt-cloud -f show_address gce name=mysnapshot region=us-central1
[ "Show", "the", "details", "of", "an", "existing", "static", "address", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1359-L1386
train
saltstack/salt
salt/cloud/clouds/gce.py
create_lb
def create_lb(kwargs=None, call=None): ''' Create a load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f create_lb gce name=lb region=us-central1 ports=80 ''' if call != 'function': raise SaltCloudSystemExit( 'The create_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a health check.' ) return False if 'ports' not in kwargs: log.error( 'A port or port-range must be specified for the load-balancer.' ) return False if 'region' not in kwargs: log.error( 'A region must be specified for the load-balancer.' ) return False if 'members' not in kwargs: log.error( 'A comma-separated list of members must be specified.' ) return False name = kwargs['name'] ports = kwargs['ports'] ex_region = kwargs['region'] members = kwargs.get('members').split(',') protocol = kwargs.get('protocol', 'tcp') algorithm = kwargs.get('algorithm', None) ex_healthchecks = kwargs.get('healthchecks', None) # pylint: disable=W0511 conn = get_conn() lb_conn = get_lb_conn(conn) ex_address = kwargs.get('address', None) if ex_address is not None: ex_address = __create_orget_address(conn, ex_address, ex_region) if ex_healthchecks: ex_healthchecks = ex_healthchecks.split(',') __utils__['cloud.fire_event']( 'event', 'create load_balancer', 'salt/cloud/loadbalancer/creating', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) lb = lb_conn.create_balancer( name, ports, protocol, algorithm, members, ex_region=ex_region, ex_healthchecks=ex_healthchecks, ex_address=ex_address ) __utils__['cloud.fire_event']( 'event', 'created load_balancer', 'salt/cloud/loadbalancer/created', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_balancer(lb)
python
def create_lb(kwargs=None, call=None): ''' Create a load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f create_lb gce name=lb region=us-central1 ports=80 ''' if call != 'function': raise SaltCloudSystemExit( 'The create_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a health check.' ) return False if 'ports' not in kwargs: log.error( 'A port or port-range must be specified for the load-balancer.' ) return False if 'region' not in kwargs: log.error( 'A region must be specified for the load-balancer.' ) return False if 'members' not in kwargs: log.error( 'A comma-separated list of members must be specified.' ) return False name = kwargs['name'] ports = kwargs['ports'] ex_region = kwargs['region'] members = kwargs.get('members').split(',') protocol = kwargs.get('protocol', 'tcp') algorithm = kwargs.get('algorithm', None) ex_healthchecks = kwargs.get('healthchecks', None) # pylint: disable=W0511 conn = get_conn() lb_conn = get_lb_conn(conn) ex_address = kwargs.get('address', None) if ex_address is not None: ex_address = __create_orget_address(conn, ex_address, ex_region) if ex_healthchecks: ex_healthchecks = ex_healthchecks.split(',') __utils__['cloud.fire_event']( 'event', 'create load_balancer', 'salt/cloud/loadbalancer/creating', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) lb = lb_conn.create_balancer( name, ports, protocol, algorithm, members, ex_region=ex_region, ex_healthchecks=ex_healthchecks, ex_address=ex_address ) __utils__['cloud.fire_event']( 'event', 'created load_balancer', 'salt/cloud/loadbalancer/created', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_balancer(lb)
[ "def", "create_lb", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_lb function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'na...
Create a load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f create_lb gce name=lb region=us-central1 ports=80
[ "Create", "a", "load", "-", "balancer", "configuration", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1389-L1469
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_lb
def delete_lb(kwargs=None, call=None): ''' Permanently delete a load-balancer. CLI Example: .. code-block:: bash salt-cloud -f delete_lb gce name=lb ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a health check.' ) return False name = kwargs['name'] lb_conn = get_lb_conn(get_conn()) __utils__['cloud.fire_event']( 'event', 'delete load_balancer', 'salt/cloud/loadbalancer/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = lb_conn.destroy_balancer( lb_conn.get_balancer(name) ) except ResourceNotFoundError as exc: log.error( 'Load balancer %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted load_balancer', 'salt/cloud/loadbalancer/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def delete_lb(kwargs=None, call=None): ''' Permanently delete a load-balancer. CLI Example: .. code-block:: bash salt-cloud -f delete_lb gce name=lb ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_hc function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a health check.' ) return False name = kwargs['name'] lb_conn = get_lb_conn(get_conn()) __utils__['cloud.fire_event']( 'event', 'delete load_balancer', 'salt/cloud/loadbalancer/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = lb_conn.destroy_balancer( lb_conn.get_balancer(name) ) except ResourceNotFoundError as exc: log.error( 'Load balancer %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted load_balancer', 'salt/cloud/loadbalancer/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "delete_lb", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_hc function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'na...
Permanently delete a load-balancer. CLI Example: .. code-block:: bash salt-cloud -f delete_lb gce name=lb
[ "Permanently", "delete", "a", "load", "-", "balancer", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1472-L1528
train
saltstack/salt
salt/cloud/clouds/gce.py
show_lb
def show_lb(kwargs=None, call=None): ''' Show the details of an existing load-balancer. CLI Example: .. code-block:: bash salt-cloud -f show_lb gce name=lb ''' if call != 'function': raise SaltCloudSystemExit( 'The show_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of load-balancer.' ) return False lb_conn = get_lb_conn(get_conn()) return _expand_balancer(lb_conn.get_balancer(kwargs['name']))
python
def show_lb(kwargs=None, call=None): ''' Show the details of an existing load-balancer. CLI Example: .. code-block:: bash salt-cloud -f show_lb gce name=lb ''' if call != 'function': raise SaltCloudSystemExit( 'The show_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name of load-balancer.' ) return False lb_conn = get_lb_conn(get_conn()) return _expand_balancer(lb_conn.get_balancer(kwargs['name']))
[ "def", "show_lb", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The show_lb function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'name'"...
Show the details of an existing load-balancer. CLI Example: .. code-block:: bash salt-cloud -f show_lb gce name=lb
[ "Show", "the", "details", "of", "an", "existing", "load", "-", "balancer", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1531-L1552
train
saltstack/salt
salt/cloud/clouds/gce.py
attach_lb
def attach_lb(kwargs=None, call=None): ''' Add an existing node/member to an existing load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f attach_lb gce name=lb member=myinstance ''' if call != 'function': raise SaltCloudSystemExit( 'The attach_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A load-balancer name must be specified.' ) return False if 'member' not in kwargs: log.error( 'A node name name must be specified.' ) return False conn = get_conn() node = conn.ex_get_node(kwargs['member']) lb_conn = get_lb_conn(conn) lb = lb_conn.get_balancer(kwargs['name']) __utils__['cloud.fire_event']( 'event', 'attach load_balancer', 'salt/cloud/loadbalancer/attaching', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = lb_conn.balancer_attach_compute_node(lb, node) __utils__['cloud.fire_event']( 'event', 'attached load_balancer', 'salt/cloud/loadbalancer/attached', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(result)
python
def attach_lb(kwargs=None, call=None): ''' Add an existing node/member to an existing load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f attach_lb gce name=lb member=myinstance ''' if call != 'function': raise SaltCloudSystemExit( 'The attach_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A load-balancer name must be specified.' ) return False if 'member' not in kwargs: log.error( 'A node name name must be specified.' ) return False conn = get_conn() node = conn.ex_get_node(kwargs['member']) lb_conn = get_lb_conn(conn) lb = lb_conn.get_balancer(kwargs['name']) __utils__['cloud.fire_event']( 'event', 'attach load_balancer', 'salt/cloud/loadbalancer/attaching', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = lb_conn.balancer_attach_compute_node(lb, node) __utils__['cloud.fire_event']( 'event', 'attached load_balancer', 'salt/cloud/loadbalancer/attached', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(result)
[ "def", "attach_lb", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The attach_lb function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'na...
Add an existing node/member to an existing load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f attach_lb gce name=lb member=myinstance
[ "Add", "an", "existing", "node", "/", "member", "to", "an", "existing", "load", "-", "balancer", "configuration", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1555-L1606
train
saltstack/salt
salt/cloud/clouds/gce.py
detach_lb
def detach_lb(kwargs=None, call=None): ''' Remove an existing node/member from an existing load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f detach_lb gce name=lb member=myinstance ''' if call != 'function': raise SaltCloudSystemExit( 'The detach_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A load-balancer name must be specified.' ) return False if 'member' not in kwargs: log.error( 'A node name name must be specified.' ) return False conn = get_conn() lb_conn = get_lb_conn(conn) lb = lb_conn.get_balancer(kwargs['name']) member_list = lb_conn.balancer_list_members(lb) remove_member = None for member in member_list: if member.id == kwargs['member']: remove_member = member break if not remove_member: log.error( 'The specified member %s was not a member of LB %s.', kwargs['member'], kwargs['name'] ) return False __utils__['cloud.fire_event']( 'event', 'detach load_balancer', 'salt/cloud/loadbalancer/detaching', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = lb_conn.balancer_detach_member(lb, remove_member) __utils__['cloud.fire_event']( 'event', 'detached load_balancer', 'salt/cloud/loadbalancer/detached', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def detach_lb(kwargs=None, call=None): ''' Remove an existing node/member from an existing load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f detach_lb gce name=lb member=myinstance ''' if call != 'function': raise SaltCloudSystemExit( 'The detach_lb function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A load-balancer name must be specified.' ) return False if 'member' not in kwargs: log.error( 'A node name name must be specified.' ) return False conn = get_conn() lb_conn = get_lb_conn(conn) lb = lb_conn.get_balancer(kwargs['name']) member_list = lb_conn.balancer_list_members(lb) remove_member = None for member in member_list: if member.id == kwargs['member']: remove_member = member break if not remove_member: log.error( 'The specified member %s was not a member of LB %s.', kwargs['member'], kwargs['name'] ) return False __utils__['cloud.fire_event']( 'event', 'detach load_balancer', 'salt/cloud/loadbalancer/detaching', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = lb_conn.balancer_detach_member(lb, remove_member) __utils__['cloud.fire_event']( 'event', 'detached load_balancer', 'salt/cloud/loadbalancer/detached', args=kwargs, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "detach_lb", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The detach_lb function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", "'na...
Remove an existing node/member from an existing load-balancer configuration. CLI Example: .. code-block:: bash salt-cloud -f detach_lb gce name=lb member=myinstance
[ "Remove", "an", "existing", "node", "/", "member", "from", "an", "existing", "load", "-", "balancer", "configuration", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1609-L1672
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_snapshot
def delete_snapshot(kwargs=None, call=None): ''' Permanently delete a disk snapshot. CLI Example: .. code-block:: bash salt-cloud -f delete_snapshot gce name=disk-snap-1 ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a snapshot.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete snapshot', 'salt/cloud/snapshot/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.destroy_volume_snapshot( conn.ex_get_snapshot(name) ) except ResourceNotFoundError as exc: log.error( 'Snapshot %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted snapshot', 'salt/cloud/snapshot/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def delete_snapshot(kwargs=None, call=None): ''' Permanently delete a disk snapshot. CLI Example: .. code-block:: bash salt-cloud -f delete_snapshot gce name=disk-snap-1 ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when deleting a snapshot.' ) return False name = kwargs['name'] conn = get_conn() __utils__['cloud.fire_event']( 'event', 'delete snapshot', 'salt/cloud/snapshot/deleting', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.destroy_volume_snapshot( conn.ex_get_snapshot(name) ) except ResourceNotFoundError as exc: log.error( 'Snapshot %s was not found. Exception was: %s', name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted snapshot', 'salt/cloud/snapshot/deleted', args={ 'name': name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "delete_snapshot", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_snapshot function must be called with -f or --function.'", ")", "if", "not", "kwargs", ...
Permanently delete a disk snapshot. CLI Example: .. code-block:: bash salt-cloud -f delete_snapshot gce name=disk-snap-1
[ "Permanently", "delete", "a", "disk", "snapshot", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1675-L1731
train
saltstack/salt
salt/cloud/clouds/gce.py
delete_disk
def delete_disk(kwargs=None, call=None): ''' Permanently delete a persistent disk. CLI Example: .. code-block:: bash salt-cloud -f delete_disk gce disk_name=pd ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_disk function must be called with -f or --function.' ) if not kwargs or 'disk_name' not in kwargs: log.error( 'A disk_name must be specified when deleting a disk.' ) return False conn = get_conn() disk = conn.ex_get_volume(kwargs.get('disk_name')) __utils__['cloud.fire_event']( 'event', 'delete disk', 'salt/cloud/disk/deleting', args={ 'name': disk.name, 'location': disk.extra['zone'].name, 'size': disk.size, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.destroy_volume(disk) except ResourceInUseError as exc: log.error( 'Disk %s is in use and must be detached before deleting.\n' 'The following exception was thrown by libcloud:\n%s', disk.name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted disk', 'salt/cloud/disk/deleted', args={ 'name': disk.name, 'location': disk.extra['zone'].name, 'size': disk.size, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def delete_disk(kwargs=None, call=None): ''' Permanently delete a persistent disk. CLI Example: .. code-block:: bash salt-cloud -f delete_disk gce disk_name=pd ''' if call != 'function': raise SaltCloudSystemExit( 'The delete_disk function must be called with -f or --function.' ) if not kwargs or 'disk_name' not in kwargs: log.error( 'A disk_name must be specified when deleting a disk.' ) return False conn = get_conn() disk = conn.ex_get_volume(kwargs.get('disk_name')) __utils__['cloud.fire_event']( 'event', 'delete disk', 'salt/cloud/disk/deleting', args={ 'name': disk.name, 'location': disk.extra['zone'].name, 'size': disk.size, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: result = conn.destroy_volume(disk) except ResourceInUseError as exc: log.error( 'Disk %s is in use and must be detached before deleting.\n' 'The following exception was thrown by libcloud:\n%s', disk.name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'deleted disk', 'salt/cloud/disk/deleted', args={ 'name': disk.name, 'location': disk.extra['zone'].name, 'size': disk.size, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "delete_disk", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_disk function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or", ...
Permanently delete a persistent disk. CLI Example: .. code-block:: bash salt-cloud -f delete_disk gce disk_name=pd
[ "Permanently", "delete", "a", "persistent", "disk", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1734-L1794
train
saltstack/salt
salt/cloud/clouds/gce.py
create_disk
def create_disk(kwargs=None, call=None): ''' Create a new persistent disk. Must specify `disk_name` and `location`, and optionally can specify 'disk_type' as pd-standard or pd-ssd, which defaults to pd-standard. Can also specify an `image` or `snapshot` but if neither of those are specified, a `size` (in GB) is required. CLI Example: .. code-block:: bash salt-cloud -f create_disk gce disk_name=pd size=300 location=us-central1-b ''' if call != 'function': raise SaltCloudSystemExit( 'The create_disk function must be called with -f or --function.' ) if kwargs is None: kwargs = {} name = kwargs.get('disk_name', None) image = kwargs.get('image', None) location = kwargs.get('location', None) size = kwargs.get('size', None) snapshot = kwargs.get('snapshot', None) disk_type = kwargs.get('type', 'pd-standard') if location is None: log.error( 'A location (zone) must be specified when creating a disk.' ) return False if name is None: log.error( 'A disk_name must be specified when creating a disk.' ) return False if size is None and image is None and snapshot is None: log.error( 'Must specify image, snapshot, or size.' ) return False conn = get_conn() location = conn.ex_get_zone(kwargs['location']) use_existing = True __utils__['cloud.fire_event']( 'event', 'create disk', 'salt/cloud/disk/creating', args={ 'name': name, 'location': location.name, 'image': image, 'snapshot': snapshot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) disk = conn.create_volume( size, name, location, snapshot, image, use_existing, disk_type ) __utils__['cloud.fire_event']( 'event', 'created disk', 'salt/cloud/disk/created', args={ 'name': name, 'location': location.name, 'image': image, 'snapshot': snapshot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_disk(disk)
python
def create_disk(kwargs=None, call=None): ''' Create a new persistent disk. Must specify `disk_name` and `location`, and optionally can specify 'disk_type' as pd-standard or pd-ssd, which defaults to pd-standard. Can also specify an `image` or `snapshot` but if neither of those are specified, a `size` (in GB) is required. CLI Example: .. code-block:: bash salt-cloud -f create_disk gce disk_name=pd size=300 location=us-central1-b ''' if call != 'function': raise SaltCloudSystemExit( 'The create_disk function must be called with -f or --function.' ) if kwargs is None: kwargs = {} name = kwargs.get('disk_name', None) image = kwargs.get('image', None) location = kwargs.get('location', None) size = kwargs.get('size', None) snapshot = kwargs.get('snapshot', None) disk_type = kwargs.get('type', 'pd-standard') if location is None: log.error( 'A location (zone) must be specified when creating a disk.' ) return False if name is None: log.error( 'A disk_name must be specified when creating a disk.' ) return False if size is None and image is None and snapshot is None: log.error( 'Must specify image, snapshot, or size.' ) return False conn = get_conn() location = conn.ex_get_zone(kwargs['location']) use_existing = True __utils__['cloud.fire_event']( 'event', 'create disk', 'salt/cloud/disk/creating', args={ 'name': name, 'location': location.name, 'image': image, 'snapshot': snapshot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) disk = conn.create_volume( size, name, location, snapshot, image, use_existing, disk_type ) __utils__['cloud.fire_event']( 'event', 'created disk', 'salt/cloud/disk/created', args={ 'name': name, 'location': location.name, 'image': image, 'snapshot': snapshot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_disk(disk)
[ "def", "create_disk", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_disk function must be called with -f or --function.'", ")", "if", "kwargs", "is", "None", ...
Create a new persistent disk. Must specify `disk_name` and `location`, and optionally can specify 'disk_type' as pd-standard or pd-ssd, which defaults to pd-standard. Can also specify an `image` or `snapshot` but if neither of those are specified, a `size` (in GB) is required. CLI Example: .. code-block:: bash salt-cloud -f create_disk gce disk_name=pd size=300 location=us-central1-b
[ "Create", "a", "new", "persistent", "disk", ".", "Must", "specify", "disk_name", "and", "location", "and", "optionally", "can", "specify", "disk_type", "as", "pd", "-", "standard", "or", "pd", "-", "ssd", "which", "defaults", "to", "pd", "-", "standard", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1797-L1880
train
saltstack/salt
salt/cloud/clouds/gce.py
create_snapshot
def create_snapshot(kwargs=None, call=None): ''' Create a new disk snapshot. Must specify `name` and `disk_name`. CLI Example: .. code-block:: bash salt-cloud -f create_snapshot gce name=snap1 disk_name=pd ''' if call != 'function': raise SaltCloudSystemExit( 'The create_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a snapshot.' ) return False if 'disk_name' not in kwargs: log.error( 'A disk_name must be specified when creating a snapshot.' ) return False conn = get_conn() name = kwargs.get('name') disk_name = kwargs.get('disk_name') try: disk = conn.ex_get_volume(disk_name) except ResourceNotFoundError as exc: log.error( 'Disk %s was not found. Exception was: %s', disk_name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'create snapshot', 'salt/cloud/snapshot/creating', args={ 'name': name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) snapshot = conn.create_volume_snapshot(disk, name) __utils__['cloud.fire_event']( 'event', 'created snapshot', 'salt/cloud/snapshot/created', args={ 'name': name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(snapshot)
python
def create_snapshot(kwargs=None, call=None): ''' Create a new disk snapshot. Must specify `name` and `disk_name`. CLI Example: .. code-block:: bash salt-cloud -f create_snapshot gce name=snap1 disk_name=pd ''' if call != 'function': raise SaltCloudSystemExit( 'The create_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'A name must be specified when creating a snapshot.' ) return False if 'disk_name' not in kwargs: log.error( 'A disk_name must be specified when creating a snapshot.' ) return False conn = get_conn() name = kwargs.get('name') disk_name = kwargs.get('disk_name') try: disk = conn.ex_get_volume(disk_name) except ResourceNotFoundError as exc: log.error( 'Disk %s was not found. Exception was: %s', disk_name, exc, exc_info_on_loglevel=logging.DEBUG ) return False __utils__['cloud.fire_event']( 'event', 'create snapshot', 'salt/cloud/snapshot/creating', args={ 'name': name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) snapshot = conn.create_volume_snapshot(disk, name) __utils__['cloud.fire_event']( 'event', 'created snapshot', 'salt/cloud/snapshot/created', args={ 'name': name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return _expand_item(snapshot)
[ "def", "create_snapshot", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_snapshot function must be called with -f or --function.'", ")", "if", "not", "kwargs", ...
Create a new disk snapshot. Must specify `name` and `disk_name`. CLI Example: .. code-block:: bash salt-cloud -f create_snapshot gce name=snap1 disk_name=pd
[ "Create", "a", "new", "disk", "snapshot", ".", "Must", "specify", "name", "and", "disk_name", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1883-L1949
train
saltstack/salt
salt/cloud/clouds/gce.py
show_disk
def show_disk(name=None, kwargs=None, call=None): # pylint: disable=W0613 ''' Show the details of an existing disk. CLI Example: .. code-block:: bash salt-cloud -a show_disk myinstance disk_name=mydisk salt-cloud -f show_disk gce disk_name=mydisk ''' if not kwargs or 'disk_name' not in kwargs: log.error( 'Must specify disk_name.' ) return False conn = get_conn() return _expand_disk(conn.ex_get_volume(kwargs['disk_name']))
python
def show_disk(name=None, kwargs=None, call=None): # pylint: disable=W0613 ''' Show the details of an existing disk. CLI Example: .. code-block:: bash salt-cloud -a show_disk myinstance disk_name=mydisk salt-cloud -f show_disk gce disk_name=mydisk ''' if not kwargs or 'disk_name' not in kwargs: log.error( 'Must specify disk_name.' ) return False conn = get_conn() return _expand_disk(conn.ex_get_volume(kwargs['disk_name']))
[ "def", "show_disk", "(", "name", "=", "None", ",", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "# pylint: disable=W0613", "if", "not", "kwargs", "or", "'disk_name'", "not", "in", "kwargs", ":", "log", ".", "error", "(", "'Must specify disk_n...
Show the details of an existing disk. CLI Example: .. code-block:: bash salt-cloud -a show_disk myinstance disk_name=mydisk salt-cloud -f show_disk gce disk_name=mydisk
[ "Show", "the", "details", "of", "an", "existing", "disk", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1952-L1970
train
saltstack/salt
salt/cloud/clouds/gce.py
show_snapshot
def show_snapshot(kwargs=None, call=None): ''' Show the details of an existing snapshot. CLI Example: .. code-block:: bash salt-cloud -f show_snapshot gce name=mysnapshot ''' if call != 'function': raise SaltCloudSystemExit( 'The show_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name.' ) return False conn = get_conn() return _expand_item(conn.ex_get_snapshot(kwargs['name']))
python
def show_snapshot(kwargs=None, call=None): ''' Show the details of an existing snapshot. CLI Example: .. code-block:: bash salt-cloud -f show_snapshot gce name=mysnapshot ''' if call != 'function': raise SaltCloudSystemExit( 'The show_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs: log.error( 'Must specify name.' ) return False conn = get_conn() return _expand_item(conn.ex_get_snapshot(kwargs['name']))
[ "def", "show_snapshot", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The show_snapshot function must be called with -f or --function.'", ")", "if", "not", "kwargs", "or"...
Show the details of an existing snapshot. CLI Example: .. code-block:: bash salt-cloud -f show_snapshot gce name=mysnapshot
[ "Show", "the", "details", "of", "an", "existing", "snapshot", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1973-L1994
train
saltstack/salt
salt/cloud/clouds/gce.py
detach_disk
def detach_disk(name=None, kwargs=None, call=None): ''' Detach a disk from an instance. CLI Example: .. code-block:: bash salt-cloud -a detach_disk myinstance disk_name=mydisk ''' if call != 'action': raise SaltCloudSystemExit( 'The detach_Disk action must be called with -a or --action.' ) if not name: log.error( 'Must specify an instance name.' ) return False if not kwargs or 'disk_name' not in kwargs: log.error( 'Must specify a disk_name to detach.' ) return False node_name = name disk_name = kwargs['disk_name'] conn = get_conn() node = conn.ex_get_node(node_name) disk = conn.ex_get_volume(disk_name) __utils__['cloud.fire_event']( 'event', 'detach disk', 'salt/cloud/disk/detaching', args={ 'name': node_name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.detach_volume(disk, node) __utils__['cloud.fire_event']( 'event', 'detached disk', 'salt/cloud/disk/detached', args={ 'name': node_name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def detach_disk(name=None, kwargs=None, call=None): ''' Detach a disk from an instance. CLI Example: .. code-block:: bash salt-cloud -a detach_disk myinstance disk_name=mydisk ''' if call != 'action': raise SaltCloudSystemExit( 'The detach_Disk action must be called with -a or --action.' ) if not name: log.error( 'Must specify an instance name.' ) return False if not kwargs or 'disk_name' not in kwargs: log.error( 'Must specify a disk_name to detach.' ) return False node_name = name disk_name = kwargs['disk_name'] conn = get_conn() node = conn.ex_get_node(node_name) disk = conn.ex_get_volume(disk_name) __utils__['cloud.fire_event']( 'event', 'detach disk', 'salt/cloud/disk/detaching', args={ 'name': node_name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.detach_volume(disk, node) __utils__['cloud.fire_event']( 'event', 'detached disk', 'salt/cloud/disk/detached', args={ 'name': node_name, 'disk_name': disk_name, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "detach_disk", "(", "name", "=", "None", ",", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The detach_Disk action must be called with -a or --action.'", ")", "if", "...
Detach a disk from an instance. CLI Example: .. code-block:: bash salt-cloud -a detach_disk myinstance disk_name=mydisk
[ "Detach", "a", "disk", "from", "an", "instance", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1997-L2055
train
saltstack/salt
salt/cloud/clouds/gce.py
attach_disk
def attach_disk(name=None, kwargs=None, call=None): ''' Attach an existing disk to an existing instance. CLI Example: .. code-block:: bash salt-cloud -a attach_disk myinstance disk_name=mydisk mode=READ_WRITE ''' if call != 'action': raise SaltCloudSystemExit( 'The attach_disk action must be called with -a or --action.' ) if not name: log.error( 'Must specify an instance name.' ) return False if not kwargs or 'disk_name' not in kwargs: log.error( 'Must specify a disk_name to attach.' ) return False node_name = name disk_name = kwargs['disk_name'] mode = kwargs.get('mode', 'READ_WRITE').upper() boot = kwargs.get('boot', False) auto_delete = kwargs.get('auto_delete', False) if boot and boot.lower() in ['true', 'yes', 'enabled']: boot = True else: boot = False if mode not in ['READ_WRITE', 'READ_ONLY']: log.error( 'Mode must be either READ_ONLY or (default) READ_WRITE.' ) return False conn = get_conn() node = conn.ex_get_node(node_name) disk = conn.ex_get_volume(disk_name) __utils__['cloud.fire_event']( 'event', 'attach disk', 'salt/cloud/disk/attaching', args={ 'name': node_name, 'disk_name': disk_name, 'mode': mode, 'boot': boot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.attach_volume(node, disk, ex_mode=mode, ex_boot=boot, ex_auto_delete=auto_delete) __utils__['cloud.fire_event']( 'event', 'attached disk', 'salt/cloud/disk/attached', args={ 'name': node_name, 'disk_name': disk_name, 'mode': mode, 'boot': boot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def attach_disk(name=None, kwargs=None, call=None): ''' Attach an existing disk to an existing instance. CLI Example: .. code-block:: bash salt-cloud -a attach_disk myinstance disk_name=mydisk mode=READ_WRITE ''' if call != 'action': raise SaltCloudSystemExit( 'The attach_disk action must be called with -a or --action.' ) if not name: log.error( 'Must specify an instance name.' ) return False if not kwargs or 'disk_name' not in kwargs: log.error( 'Must specify a disk_name to attach.' ) return False node_name = name disk_name = kwargs['disk_name'] mode = kwargs.get('mode', 'READ_WRITE').upper() boot = kwargs.get('boot', False) auto_delete = kwargs.get('auto_delete', False) if boot and boot.lower() in ['true', 'yes', 'enabled']: boot = True else: boot = False if mode not in ['READ_WRITE', 'READ_ONLY']: log.error( 'Mode must be either READ_ONLY or (default) READ_WRITE.' ) return False conn = get_conn() node = conn.ex_get_node(node_name) disk = conn.ex_get_volume(disk_name) __utils__['cloud.fire_event']( 'event', 'attach disk', 'salt/cloud/disk/attaching', args={ 'name': node_name, 'disk_name': disk_name, 'mode': mode, 'boot': boot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.attach_volume(node, disk, ex_mode=mode, ex_boot=boot, ex_auto_delete=auto_delete) __utils__['cloud.fire_event']( 'event', 'attached disk', 'salt/cloud/disk/attached', args={ 'name': node_name, 'disk_name': disk_name, 'mode': mode, 'boot': boot, }, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "attach_disk", "(", "name", "=", "None", ",", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The attach_disk action must be called with -a or --action.'", ")", "if", "...
Attach an existing disk to an existing instance. CLI Example: .. code-block:: bash salt-cloud -a attach_disk myinstance disk_name=mydisk mode=READ_WRITE
[ "Attach", "an", "existing", "disk", "to", "an", "existing", "instance", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2058-L2134
train
saltstack/salt
salt/cloud/clouds/gce.py
reboot
def reboot(vm_name, call=None): ''' Call GCE 'reset' on the instance. CLI Example: .. code-block:: bash salt-cloud -a reboot myinstance ''' if call != 'action': raise SaltCloudSystemExit( 'The reboot action must be called with -a or --action.' ) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'reboot instance', 'salt/cloud/{0}/rebooting'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.reboot_node( conn.ex_get_node(vm_name) ) __utils__['cloud.fire_event']( 'event', 'reboot instance', 'salt/cloud/{0}/rebooted'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def reboot(vm_name, call=None): ''' Call GCE 'reset' on the instance. CLI Example: .. code-block:: bash salt-cloud -a reboot myinstance ''' if call != 'action': raise SaltCloudSystemExit( 'The reboot action must be called with -a or --action.' ) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'reboot instance', 'salt/cloud/{0}/rebooting'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.reboot_node( conn.ex_get_node(vm_name) ) __utils__['cloud.fire_event']( 'event', 'reboot instance', 'salt/cloud/{0}/rebooted'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "reboot", "(", "vm_name", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The reboot action must be called with -a or --action.'", ")", "conn", "=", "get_conn", "(", ")", "__utils__", "[", "'...
Call GCE 'reset' on the instance. CLI Example: .. code-block:: bash salt-cloud -a reboot myinstance
[ "Call", "GCE", "reset", "on", "the", "instance", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2137-L2176
train
saltstack/salt
salt/cloud/clouds/gce.py
start
def start(vm_name, call=None): ''' Call GCE 'start on the instance. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt-cloud -a start myinstance ''' if call != 'action': raise SaltCloudSystemExit( 'The start action must be called with -a or --action.' ) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'start instance', 'salt/cloud/{0}/starting'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.ex_start_node( conn.ex_get_node(vm_name) ) __utils__['cloud.fire_event']( 'event', 'start instance', 'salt/cloud/{0}/started'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def start(vm_name, call=None): ''' Call GCE 'start on the instance. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt-cloud -a start myinstance ''' if call != 'action': raise SaltCloudSystemExit( 'The start action must be called with -a or --action.' ) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'start instance', 'salt/cloud/{0}/starting'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.ex_start_node( conn.ex_get_node(vm_name) ) __utils__['cloud.fire_event']( 'event', 'start instance', 'salt/cloud/{0}/started'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "start", "(", "vm_name", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The start action must be called with -a or --action.'", ")", "conn", "=", "get_conn", "(", ")", "__utils__", "[", "'cl...
Call GCE 'start on the instance. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt-cloud -a start myinstance
[ "Call", "GCE", "start", "on", "the", "instance", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2179-L2220
train
saltstack/salt
salt/cloud/clouds/gce.py
stop
def stop(vm_name, call=None): ''' Call GCE 'stop' on the instance. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt-cloud -a stop myinstance ''' if call != 'action': raise SaltCloudSystemExit( 'The stop action must be called with -a or --action.' ) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'stop instance', 'salt/cloud/{0}/stopping'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.ex_stop_node( conn.ex_get_node(vm_name) ) __utils__['cloud.fire_event']( 'event', 'stop instance', 'salt/cloud/{0}/stopped'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
python
def stop(vm_name, call=None): ''' Call GCE 'stop' on the instance. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt-cloud -a stop myinstance ''' if call != 'action': raise SaltCloudSystemExit( 'The stop action must be called with -a or --action.' ) conn = get_conn() __utils__['cloud.fire_event']( 'event', 'stop instance', 'salt/cloud/{0}/stopping'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) result = conn.ex_stop_node( conn.ex_get_node(vm_name) ) __utils__['cloud.fire_event']( 'event', 'stop instance', 'salt/cloud/{0}/stopped'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return result
[ "def", "stop", "(", "vm_name", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The stop action must be called with -a or --action.'", ")", "conn", "=", "get_conn", "(", ")", "__utils__", "[", "'clou...
Call GCE 'stop' on the instance. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt-cloud -a stop myinstance
[ "Call", "GCE", "stop", "on", "the", "instance", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2223-L2264
train
saltstack/salt
salt/cloud/clouds/gce.py
destroy
def destroy(vm_name, call=None): ''' Call 'destroy' on the instance. Can be called with "-a destroy" or -d CLI Example: .. code-block:: bash salt-cloud -a destroy myinstance1 myinstance2 ... salt-cloud -d myinstance1 myinstance2 ... ''' if call and call != 'action': raise SaltCloudSystemExit( 'The destroy action must be called with -d or "-a destroy".' ) conn = get_conn() try: node = conn.ex_get_node(vm_name) except Exception as exc: # pylint: disable=W0703 log.error( 'Could not locate instance %s\n\n' 'The following exception was thrown by libcloud when trying to ' 'run the initial deployment: \n%s', vm_name, exc, exc_info_on_loglevel=logging.DEBUG ) raise SaltCloudSystemExit( 'Could not find instance {0}.'.format(vm_name) ) __utils__['cloud.fire_event']( 'event', 'delete instance', 'salt/cloud/{0}/deleting'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) # Use the instance metadata to see if its salt cloud profile was # preserved during instance create. If so, use the profile value # to see if the 'delete_boot_pd' value is set to delete the disk # along with the instance. profile = None if node.extra['metadata'] and 'items' in node.extra['metadata']: for md in node.extra['metadata']['items']: if md['key'] == 'salt-cloud-profile': profile = md['value'] vm_ = get_configured_provider() delete_boot_pd = False if profile and profile in vm_['profiles'] and 'delete_boot_pd' in vm_['profiles'][profile]: delete_boot_pd = vm_['profiles'][profile]['delete_boot_pd'] try: inst_deleted = conn.destroy_node(node) except Exception as exc: # pylint: disable=W0703 log.error( 'Could not destroy instance %s\n\n' 'The following exception was thrown by libcloud when trying to ' 'run the initial deployment: \n%s', vm_name, exc, exc_info_on_loglevel=logging.DEBUG ) raise SaltCloudSystemExit( 'Could not destroy instance {0}.'.format(vm_name) ) __utils__['cloud.fire_event']( 'event', 'delete instance', 'salt/cloud/{0}/deleted'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) if delete_boot_pd: log.info( 'delete_boot_pd is enabled for the instance profile, ' 'attempting to delete disk' ) __utils__['cloud.fire_event']( 'event', 'delete disk', 'salt/cloud/disk/deleting', args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: conn.destroy_volume(conn.ex_get_volume(vm_name)) except Exception as exc: # pylint: disable=W0703 # Note that we don't raise a SaltCloudSystemExit here in order # to allow completion of instance deletion. Just log the error # and keep going. log.error( 'Could not destroy disk %s\n\n' 'The following exception was thrown by libcloud when trying ' 'to run the initial deployment: \n%s', vm_name, exc, exc_info_on_loglevel=logging.DEBUG ) __utils__['cloud.fire_event']( 'event', 'deleted disk', 'salt/cloud/disk/deleted', args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) if __opts__.get('update_cachedir', False) is True: __utils__['cloud.delete_minion_cachedir'](vm_name, __active_provider_name__.split(':')[0], __opts__) return inst_deleted
python
def destroy(vm_name, call=None): ''' Call 'destroy' on the instance. Can be called with "-a destroy" or -d CLI Example: .. code-block:: bash salt-cloud -a destroy myinstance1 myinstance2 ... salt-cloud -d myinstance1 myinstance2 ... ''' if call and call != 'action': raise SaltCloudSystemExit( 'The destroy action must be called with -d or "-a destroy".' ) conn = get_conn() try: node = conn.ex_get_node(vm_name) except Exception as exc: # pylint: disable=W0703 log.error( 'Could not locate instance %s\n\n' 'The following exception was thrown by libcloud when trying to ' 'run the initial deployment: \n%s', vm_name, exc, exc_info_on_loglevel=logging.DEBUG ) raise SaltCloudSystemExit( 'Could not find instance {0}.'.format(vm_name) ) __utils__['cloud.fire_event']( 'event', 'delete instance', 'salt/cloud/{0}/deleting'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) # Use the instance metadata to see if its salt cloud profile was # preserved during instance create. If so, use the profile value # to see if the 'delete_boot_pd' value is set to delete the disk # along with the instance. profile = None if node.extra['metadata'] and 'items' in node.extra['metadata']: for md in node.extra['metadata']['items']: if md['key'] == 'salt-cloud-profile': profile = md['value'] vm_ = get_configured_provider() delete_boot_pd = False if profile and profile in vm_['profiles'] and 'delete_boot_pd' in vm_['profiles'][profile]: delete_boot_pd = vm_['profiles'][profile]['delete_boot_pd'] try: inst_deleted = conn.destroy_node(node) except Exception as exc: # pylint: disable=W0703 log.error( 'Could not destroy instance %s\n\n' 'The following exception was thrown by libcloud when trying to ' 'run the initial deployment: \n%s', vm_name, exc, exc_info_on_loglevel=logging.DEBUG ) raise SaltCloudSystemExit( 'Could not destroy instance {0}.'.format(vm_name) ) __utils__['cloud.fire_event']( 'event', 'delete instance', 'salt/cloud/{0}/deleted'.format(vm_name), args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) if delete_boot_pd: log.info( 'delete_boot_pd is enabled for the instance profile, ' 'attempting to delete disk' ) __utils__['cloud.fire_event']( 'event', 'delete disk', 'salt/cloud/disk/deleting', args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: conn.destroy_volume(conn.ex_get_volume(vm_name)) except Exception as exc: # pylint: disable=W0703 # Note that we don't raise a SaltCloudSystemExit here in order # to allow completion of instance deletion. Just log the error # and keep going. log.error( 'Could not destroy disk %s\n\n' 'The following exception was thrown by libcloud when trying ' 'to run the initial deployment: \n%s', vm_name, exc, exc_info_on_loglevel=logging.DEBUG ) __utils__['cloud.fire_event']( 'event', 'deleted disk', 'salt/cloud/disk/deleted', args={'name': vm_name}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) if __opts__.get('update_cachedir', False) is True: __utils__['cloud.delete_minion_cachedir'](vm_name, __active_provider_name__.split(':')[0], __opts__) return inst_deleted
[ "def", "destroy", "(", "vm_name", ",", "call", "=", "None", ")", ":", "if", "call", "and", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The destroy action must be called with -d or \"-a destroy\".'", ")", "conn", "=", "get_conn", "(", ")",...
Call 'destroy' on the instance. Can be called with "-a destroy" or -d CLI Example: .. code-block:: bash salt-cloud -a destroy myinstance1 myinstance2 ... salt-cloud -d myinstance1 myinstance2 ...
[ "Call", "destroy", "on", "the", "instance", ".", "Can", "be", "called", "with", "-", "a", "destroy", "or", "-", "d" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2267-L2380
train
saltstack/salt
salt/cloud/clouds/gce.py
create_attach_volumes
def create_attach_volumes(name, kwargs, call=None): ''' .. versionadded:: 2017.7.0 Create and attach multiple volumes to a node. The 'volumes' and 'node' arguments are required, where 'node' is a libcloud node, and 'volumes' is a list of maps, where each map contains: size The size of the new disk in GB. Required. type The disk type, either pd-standard or pd-ssd. Optional, defaults to pd-standard. image An image to use for this new disk. Optional. snapshot A snapshot to use for this new disk. Optional. auto_delete An option(bool) to keep or remove the disk upon instance deletion. Optional, defaults to False. Volumes are attached in the order in which they are given, thus on a new node the first volume will be /dev/sdb, the second /dev/sdc, and so on. ''' if call != 'action': raise SaltCloudSystemExit( 'The create_attach_volumes action must be called with ' '-a or --action.' ) volumes = literal_eval(kwargs['volumes']) node = kwargs['node'] conn = get_conn() node_data = _expand_node(conn.ex_get_node(node)) letter = ord('a') - 1 for idx, volume in enumerate(volumes): volume_name = '{0}-sd{1}'.format(name, chr(letter + 2 + idx)) volume_dict = { 'disk_name': volume_name, 'location': node_data['extra']['zone']['name'], 'size': volume['size'], 'type': volume.get('type', 'pd-standard'), 'image': volume.get('image', None), 'snapshot': volume.get('snapshot', None), 'auto_delete': volume.get('auto_delete', False) } create_disk(volume_dict, 'function') attach_disk(name, volume_dict, 'action')
python
def create_attach_volumes(name, kwargs, call=None): ''' .. versionadded:: 2017.7.0 Create and attach multiple volumes to a node. The 'volumes' and 'node' arguments are required, where 'node' is a libcloud node, and 'volumes' is a list of maps, where each map contains: size The size of the new disk in GB. Required. type The disk type, either pd-standard or pd-ssd. Optional, defaults to pd-standard. image An image to use for this new disk. Optional. snapshot A snapshot to use for this new disk. Optional. auto_delete An option(bool) to keep or remove the disk upon instance deletion. Optional, defaults to False. Volumes are attached in the order in which they are given, thus on a new node the first volume will be /dev/sdb, the second /dev/sdc, and so on. ''' if call != 'action': raise SaltCloudSystemExit( 'The create_attach_volumes action must be called with ' '-a or --action.' ) volumes = literal_eval(kwargs['volumes']) node = kwargs['node'] conn = get_conn() node_data = _expand_node(conn.ex_get_node(node)) letter = ord('a') - 1 for idx, volume in enumerate(volumes): volume_name = '{0}-sd{1}'.format(name, chr(letter + 2 + idx)) volume_dict = { 'disk_name': volume_name, 'location': node_data['extra']['zone']['name'], 'size': volume['size'], 'type': volume.get('type', 'pd-standard'), 'image': volume.get('image', None), 'snapshot': volume.get('snapshot', None), 'auto_delete': volume.get('auto_delete', False) } create_disk(volume_dict, 'function') attach_disk(name, volume_dict, 'action')
[ "def", "create_attach_volumes", "(", "name", ",", "kwargs", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_attach_volumes action must be called with '", "'-a or --action.'", ")", "volumes", "=...
.. versionadded:: 2017.7.0 Create and attach multiple volumes to a node. The 'volumes' and 'node' arguments are required, where 'node' is a libcloud node, and 'volumes' is a list of maps, where each map contains: size The size of the new disk in GB. Required. type The disk type, either pd-standard or pd-ssd. Optional, defaults to pd-standard. image An image to use for this new disk. Optional. snapshot A snapshot to use for this new disk. Optional. auto_delete An option(bool) to keep or remove the disk upon instance deletion. Optional, defaults to False. Volumes are attached in the order in which they are given, thus on a new node the first volume will be /dev/sdb, the second /dev/sdc, and so on.
[ "..", "versionadded", "::", "2017", ".", "7", ".", "0" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2383-L2436
train
saltstack/salt
salt/cloud/clouds/gce.py
request_instance
def request_instance(vm_): ''' Request a single GCE instance from a data dict. .. versionchanged: 2017.7.0 ''' if not GCE_VM_NAME_REGEX.match(vm_['name']): raise SaltCloudSystemExit( 'VM names must start with a letter, only contain letters, numbers, or dashes ' 'and cannot end in a dash.' ) try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, __active_provider_name__ or 'gce', vm_['profile'], vm_=vm_) is False: return False except AttributeError: pass __utils__['cloud.fire_event']( 'event', 'create instance', 'salt/cloud/{0}/creating'.format(vm_['name']), args=__utils__['cloud.filter_event']('creating', vm_, ['name', 'profile', 'provider', 'driver']), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) conn = get_conn() kwargs = { 'name': vm_['name'], 'size': __get_size(conn, vm_), 'image': __get_image(conn, vm_), 'location': __get_location(conn, vm_), 'ex_network': __get_network(conn, vm_), 'ex_subnetwork': __get_subnetwork(vm_), 'ex_tags': __get_tags(vm_), 'ex_metadata': __get_metadata(vm_), } external_ip = config.get_cloud_config_value( 'external_ip', vm_, __opts__, default='ephemeral' ) if external_ip.lower() == 'ephemeral': external_ip = 'ephemeral' vm_['external_ip'] = external_ip elif external_ip == 'None': external_ip = None vm_['external_ip'] = external_ip else: region = __get_region(conn, vm_) external_ip = __create_orget_address(conn, external_ip, region) vm_['external_ip'] = { 'name': external_ip.name, 'address': external_ip.address, 'region': external_ip.region.name } kwargs['external_ip'] = external_ip if LIBCLOUD_VERSION_INFO > (0, 15, 1): kwargs.update({ 'ex_disk_type': config.get_cloud_config_value( 'ex_disk_type', vm_, __opts__, default='pd-standard'), 'ex_disk_auto_delete': config.get_cloud_config_value( 'ex_disk_auto_delete', vm_, __opts__, default=True), 'ex_disks_gce_struct': config.get_cloud_config_value( 'ex_disks_gce_struct', vm_, __opts__, default=None), 'ex_service_accounts': config.get_cloud_config_value( 'ex_service_accounts', vm_, __opts__, default=None), 'ex_can_ip_forward': config.get_cloud_config_value( 'ip_forwarding', vm_, __opts__, default=False), 'ex_preemptible': config.get_cloud_config_value( 'preemptible', vm_, __opts__, default=False) }) if kwargs.get('ex_disk_type') not in ('pd-standard', 'pd-ssd'): raise SaltCloudSystemExit( 'The value of \'ex_disk_type\' needs to be one of: ' '\'pd-standard\', \'pd-ssd\'' ) # GCE accelerator options are only supported as of libcloud >= 2.3.0 # and Python 3+ is required so that libcloud will detect a type of # 'string' rather than 'unicode' if LIBCLOUD_VERSION_INFO >= (2, 3, 0) and isinstance(u'test', str): kwargs.update({ 'ex_accelerator_type': config.get_cloud_config_value( 'ex_accelerator_type', vm_, __opts__, default=None), 'ex_accelerator_count': config.get_cloud_config_value( 'ex_accelerator_count', vm_, __opts__, default=None) }) if kwargs.get('ex_accelerator_type'): log.warning( 'An accelerator is being attached to this instance, ' 'the ex_on_host_maintenance setting is being set to ' '\'TERMINATE\' as a result' ) kwargs.update({ 'ex_on_host_maintenance': 'TERMINATE' }) log.info( 'Creating GCE instance %s in %s', vm_['name'], kwargs['location'].name ) log.debug('Create instance kwargs %s', kwargs) __utils__['cloud.fire_event']( 'event', 'requesting instance', 'salt/cloud/{0}/requesting'.format(vm_['name']), args=__utils__['cloud.filter_event']('requesting', vm_, ['name', 'profile', 'provider', 'driver']), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: node_data = conn.create_node(**kwargs) except Exception as exc: # pylint: disable=W0703 log.error( 'Error creating %s on GCE\n\n' 'The following exception was thrown by libcloud when trying to ' 'run the initial deployment: \n%s', vm_['name'], exc, exc_info_on_loglevel=logging.DEBUG ) return False volumes = config.get_cloud_config_value( 'volumes', vm_, __opts__, search_global=True ) if volumes: __utils__['cloud.fire_event']( 'event', 'attaching volumes', 'salt/cloud/{0}/attaching_volumes'.format(vm_['name']), args={'volumes': volumes}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) log.info('Create and attach volumes to node %s', vm_['name']) create_attach_volumes( vm_['name'], { 'volumes': volumes, 'node': node_data }, call='action' ) try: node_dict = show_instance(node_data['name'], 'action') except TypeError: # node_data is a libcloud Node which is unsubscriptable node_dict = show_instance(node_data.name, 'action') return node_dict, node_data
python
def request_instance(vm_): ''' Request a single GCE instance from a data dict. .. versionchanged: 2017.7.0 ''' if not GCE_VM_NAME_REGEX.match(vm_['name']): raise SaltCloudSystemExit( 'VM names must start with a letter, only contain letters, numbers, or dashes ' 'and cannot end in a dash.' ) try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, __active_provider_name__ or 'gce', vm_['profile'], vm_=vm_) is False: return False except AttributeError: pass __utils__['cloud.fire_event']( 'event', 'create instance', 'salt/cloud/{0}/creating'.format(vm_['name']), args=__utils__['cloud.filter_event']('creating', vm_, ['name', 'profile', 'provider', 'driver']), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) conn = get_conn() kwargs = { 'name': vm_['name'], 'size': __get_size(conn, vm_), 'image': __get_image(conn, vm_), 'location': __get_location(conn, vm_), 'ex_network': __get_network(conn, vm_), 'ex_subnetwork': __get_subnetwork(vm_), 'ex_tags': __get_tags(vm_), 'ex_metadata': __get_metadata(vm_), } external_ip = config.get_cloud_config_value( 'external_ip', vm_, __opts__, default='ephemeral' ) if external_ip.lower() == 'ephemeral': external_ip = 'ephemeral' vm_['external_ip'] = external_ip elif external_ip == 'None': external_ip = None vm_['external_ip'] = external_ip else: region = __get_region(conn, vm_) external_ip = __create_orget_address(conn, external_ip, region) vm_['external_ip'] = { 'name': external_ip.name, 'address': external_ip.address, 'region': external_ip.region.name } kwargs['external_ip'] = external_ip if LIBCLOUD_VERSION_INFO > (0, 15, 1): kwargs.update({ 'ex_disk_type': config.get_cloud_config_value( 'ex_disk_type', vm_, __opts__, default='pd-standard'), 'ex_disk_auto_delete': config.get_cloud_config_value( 'ex_disk_auto_delete', vm_, __opts__, default=True), 'ex_disks_gce_struct': config.get_cloud_config_value( 'ex_disks_gce_struct', vm_, __opts__, default=None), 'ex_service_accounts': config.get_cloud_config_value( 'ex_service_accounts', vm_, __opts__, default=None), 'ex_can_ip_forward': config.get_cloud_config_value( 'ip_forwarding', vm_, __opts__, default=False), 'ex_preemptible': config.get_cloud_config_value( 'preemptible', vm_, __opts__, default=False) }) if kwargs.get('ex_disk_type') not in ('pd-standard', 'pd-ssd'): raise SaltCloudSystemExit( 'The value of \'ex_disk_type\' needs to be one of: ' '\'pd-standard\', \'pd-ssd\'' ) # GCE accelerator options are only supported as of libcloud >= 2.3.0 # and Python 3+ is required so that libcloud will detect a type of # 'string' rather than 'unicode' if LIBCLOUD_VERSION_INFO >= (2, 3, 0) and isinstance(u'test', str): kwargs.update({ 'ex_accelerator_type': config.get_cloud_config_value( 'ex_accelerator_type', vm_, __opts__, default=None), 'ex_accelerator_count': config.get_cloud_config_value( 'ex_accelerator_count', vm_, __opts__, default=None) }) if kwargs.get('ex_accelerator_type'): log.warning( 'An accelerator is being attached to this instance, ' 'the ex_on_host_maintenance setting is being set to ' '\'TERMINATE\' as a result' ) kwargs.update({ 'ex_on_host_maintenance': 'TERMINATE' }) log.info( 'Creating GCE instance %s in %s', vm_['name'], kwargs['location'].name ) log.debug('Create instance kwargs %s', kwargs) __utils__['cloud.fire_event']( 'event', 'requesting instance', 'salt/cloud/{0}/requesting'.format(vm_['name']), args=__utils__['cloud.filter_event']('requesting', vm_, ['name', 'profile', 'provider', 'driver']), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) try: node_data = conn.create_node(**kwargs) except Exception as exc: # pylint: disable=W0703 log.error( 'Error creating %s on GCE\n\n' 'The following exception was thrown by libcloud when trying to ' 'run the initial deployment: \n%s', vm_['name'], exc, exc_info_on_loglevel=logging.DEBUG ) return False volumes = config.get_cloud_config_value( 'volumes', vm_, __opts__, search_global=True ) if volumes: __utils__['cloud.fire_event']( 'event', 'attaching volumes', 'salt/cloud/{0}/attaching_volumes'.format(vm_['name']), args={'volumes': volumes}, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) log.info('Create and attach volumes to node %s', vm_['name']) create_attach_volumes( vm_['name'], { 'volumes': volumes, 'node': node_data }, call='action' ) try: node_dict = show_instance(node_data['name'], 'action') except TypeError: # node_data is a libcloud Node which is unsubscriptable node_dict = show_instance(node_data.name, 'action') return node_dict, node_data
[ "def", "request_instance", "(", "vm_", ")", ":", "if", "not", "GCE_VM_NAME_REGEX", ".", "match", "(", "vm_", "[", "'name'", "]", ")", ":", "raise", "SaltCloudSystemExit", "(", "'VM names must start with a letter, only contain letters, numbers, or dashes '", "'and cannot e...
Request a single GCE instance from a data dict. .. versionchanged: 2017.7.0
[ "Request", "a", "single", "GCE", "instance", "from", "a", "data", "dict", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2439-L2601
train
saltstack/salt
salt/cloud/clouds/gce.py
create
def create(vm_=None, call=None): ''' Create a single GCE instance from a data dict. ''' if call: raise SaltCloudSystemExit( 'You cannot create an instance with -a or -f.' ) node_info = request_instance(vm_) if isinstance(node_info, bool): raise SaltCloudSystemExit( 'There was an error creating the GCE instance.' ) node_dict = node_info[0] node_data = node_info[1] ssh_user, ssh_key = __get_ssh_credentials(vm_) vm_['ssh_host'] = __get_host(node_data, vm_) vm_['key_filename'] = ssh_key ret = __utils__['cloud.bootstrap'](vm_, __opts__) ret.update(node_dict) log.info('Created Cloud VM \'%s\'', vm_['name']) log.trace( '\'%s\' VM creation details:\n%s', vm_['name'], pprint.pformat(node_dict) ) __utils__['cloud.fire_event']( 'event', 'created instance', 'salt/cloud/{0}/created'.format(vm_['name']), args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return ret
python
def create(vm_=None, call=None): ''' Create a single GCE instance from a data dict. ''' if call: raise SaltCloudSystemExit( 'You cannot create an instance with -a or -f.' ) node_info = request_instance(vm_) if isinstance(node_info, bool): raise SaltCloudSystemExit( 'There was an error creating the GCE instance.' ) node_dict = node_info[0] node_data = node_info[1] ssh_user, ssh_key = __get_ssh_credentials(vm_) vm_['ssh_host'] = __get_host(node_data, vm_) vm_['key_filename'] = ssh_key ret = __utils__['cloud.bootstrap'](vm_, __opts__) ret.update(node_dict) log.info('Created Cloud VM \'%s\'', vm_['name']) log.trace( '\'%s\' VM creation details:\n%s', vm_['name'], pprint.pformat(node_dict) ) __utils__['cloud.fire_event']( 'event', 'created instance', 'salt/cloud/{0}/created'.format(vm_['name']), args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']), sock_dir=__opts__['sock_dir'], transport=__opts__['transport'] ) return ret
[ "def", "create", "(", "vm_", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", ":", "raise", "SaltCloudSystemExit", "(", "'You cannot create an instance with -a or -f.'", ")", "node_info", "=", "request_instance", "(", "vm_", ")", "if", "isinstance"...
Create a single GCE instance from a data dict.
[ "Create", "a", "single", "GCE", "instance", "from", "a", "data", "dict", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2604-L2644
train
saltstack/salt
salt/cloud/clouds/gce.py
update_pricing
def update_pricing(kwargs=None, call=None): ''' Download most recent pricing information from GCE and save locally CLI Examples: .. code-block:: bash salt-cloud -f update_pricing my-gce-config .. versionadded:: 2015.8.0 ''' url = 'https://cloudpricingcalculator.appspot.com/static/data/pricelist.json' price_json = salt.utils.http.query(url, decode=True, decode_type='json') outfile = os.path.join( __opts__['cachedir'], 'gce-pricing.p' ) with salt.utils.files.fopen(outfile, 'w') as fho: salt.utils.msgpack.dump(price_json['dict'], fho) return True
python
def update_pricing(kwargs=None, call=None): ''' Download most recent pricing information from GCE and save locally CLI Examples: .. code-block:: bash salt-cloud -f update_pricing my-gce-config .. versionadded:: 2015.8.0 ''' url = 'https://cloudpricingcalculator.appspot.com/static/data/pricelist.json' price_json = salt.utils.http.query(url, decode=True, decode_type='json') outfile = os.path.join( __opts__['cachedir'], 'gce-pricing.p' ) with salt.utils.files.fopen(outfile, 'w') as fho: salt.utils.msgpack.dump(price_json['dict'], fho) return True
[ "def", "update_pricing", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "url", "=", "'https://cloudpricingcalculator.appspot.com/static/data/pricelist.json'", "price_json", "=", "salt", ".", "utils", ".", "http", ".", "query", "(", "url", ",", "...
Download most recent pricing information from GCE and save locally CLI Examples: .. code-block:: bash salt-cloud -f update_pricing my-gce-config .. versionadded:: 2015.8.0
[ "Download", "most", "recent", "pricing", "information", "from", "GCE", "and", "save", "locally" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2647-L2668
train
saltstack/salt
salt/cloud/clouds/gce.py
show_pricing
def show_pricing(kwargs=None, call=None): ''' Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my-gce-config profile=my-profile ''' profile = __opts__['profiles'].get(kwargs['profile'], {}) if not profile: return {'Error': 'The requested profile was not found'} # Make sure the profile belongs to DigitalOcean provider = profile.get('provider', '0:0') comps = provider.split(':') if len(comps) < 2 or comps[1] != 'gce': return {'Error': 'The requested profile does not belong to GCE'} comps = profile.get('location', 'us').split('-') region = comps[0] size = 'CP-COMPUTEENGINE-VMIMAGE-{0}'.format(profile['size'].upper()) pricefile = os.path.join( __opts__['cachedir'], 'gce-pricing.p' ) if not os.path.exists(pricefile): update_pricing() with salt.utils.files.fopen(pricefile, 'r') as fho: sizes = salt.utils.msgpack.load(fho) per_hour = float(sizes['gcp_price_list'][size][region]) week1_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.25']) week2_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.50']) week3_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.75']) week4_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['1.0']) week1 = per_hour * (730/4) * week1_discount week2 = per_hour * (730/4) * week2_discount week3 = per_hour * (730/4) * week3_discount week4 = per_hour * (730/4) * week4_discount raw = sizes ret = {} ret['per_hour'] = per_hour ret['per_day'] = ret['per_hour'] * 24 ret['per_week'] = ret['per_day'] * 7 ret['per_month'] = week1 + week2 + week3 + week4 ret['per_year'] = ret['per_month'] * 12 if kwargs.get('raw', False): ret['_raw'] = raw return {profile['profile']: ret}
python
def show_pricing(kwargs=None, call=None): ''' Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my-gce-config profile=my-profile ''' profile = __opts__['profiles'].get(kwargs['profile'], {}) if not profile: return {'Error': 'The requested profile was not found'} # Make sure the profile belongs to DigitalOcean provider = profile.get('provider', '0:0') comps = provider.split(':') if len(comps) < 2 or comps[1] != 'gce': return {'Error': 'The requested profile does not belong to GCE'} comps = profile.get('location', 'us').split('-') region = comps[0] size = 'CP-COMPUTEENGINE-VMIMAGE-{0}'.format(profile['size'].upper()) pricefile = os.path.join( __opts__['cachedir'], 'gce-pricing.p' ) if not os.path.exists(pricefile): update_pricing() with salt.utils.files.fopen(pricefile, 'r') as fho: sizes = salt.utils.msgpack.load(fho) per_hour = float(sizes['gcp_price_list'][size][region]) week1_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.25']) week2_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.50']) week3_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.75']) week4_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['1.0']) week1 = per_hour * (730/4) * week1_discount week2 = per_hour * (730/4) * week2_discount week3 = per_hour * (730/4) * week3_discount week4 = per_hour * (730/4) * week4_discount raw = sizes ret = {} ret['per_hour'] = per_hour ret['per_day'] = ret['per_hour'] * 24 ret['per_week'] = ret['per_day'] * 7 ret['per_month'] = week1 + week2 + week3 + week4 ret['per_year'] = ret['per_month'] * 12 if kwargs.get('raw', False): ret['_raw'] = raw return {profile['profile']: ret}
[ "def", "show_pricing", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "profile", "=", "__opts__", "[", "'profiles'", "]", ".", "get", "(", "kwargs", "[", "'profile'", "]", ",", "{", "}", ")", "if", "not", "profile", ":", "return", ...
Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my-gce-config profile=my-profile
[ "Show", "pricing", "for", "a", "particular", "profile", ".", "This", "is", "only", "an", "estimate", "based", "on", "unofficial", "pricing", "sources", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L2671-L2730
train
saltstack/salt
salt/engines/http_logstash.py
_logstash
def _logstash(url, data): ''' Issues HTTP queries to the logstash server. ''' result = salt.utils.http.query( url, 'POST', header_dict=_HEADERS, data=salt.utils.json.dumps(data), decode=True, status=True, opts=__opts__ ) return result
python
def _logstash(url, data): ''' Issues HTTP queries to the logstash server. ''' result = salt.utils.http.query( url, 'POST', header_dict=_HEADERS, data=salt.utils.json.dumps(data), decode=True, status=True, opts=__opts__ ) return result
[ "def", "_logstash", "(", "url", ",", "data", ")", ":", "result", "=", "salt", ".", "utils", ".", "http", ".", "query", "(", "url", ",", "'POST'", ",", "header_dict", "=", "_HEADERS", ",", "data", "=", "salt", ".", "utils", ".", "json", ".", "dumps"...
Issues HTTP queries to the logstash server.
[ "Issues", "HTTP", "queries", "to", "the", "logstash", "server", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/http_logstash.py#L57-L70
train
saltstack/salt
salt/engines/http_logstash.py
start
def start(url, funs=None, tags=None): ''' Listen to salt events and forward them to logstash. url The Logstash endpoint. funs: ``None`` A list of functions to be compared against, looking into the ``fun`` field from the event data. This option helps to select the events generated by one or more functions. If an event does not have the ``fun`` field in the data section, it will be published. For a better selection, consider using the ``tags`` option. By default, this option accepts any event to be submitted to Logstash. tags: ``None`` A list of pattern to compare the event tag against. By default, this option accepts any event to be submitted to Logstash. ''' if __opts__.get('id').endswith('_master'): instance = 'master' else: instance = 'minion' event_bus = salt.utils.event.get_event(instance, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'], opts=__opts__) while True: event = event_bus.get_event(full=True) if event: publish = True if tags and isinstance(tags, list): found_match = False for tag in tags: if fnmatch.fnmatch(event['tag'], tag): found_match = True publish = found_match if funs and 'fun' in event['data']: if not event['data']['fun'] in funs: publish = False if publish: _logstash(url, event['data'])
python
def start(url, funs=None, tags=None): ''' Listen to salt events and forward them to logstash. url The Logstash endpoint. funs: ``None`` A list of functions to be compared against, looking into the ``fun`` field from the event data. This option helps to select the events generated by one or more functions. If an event does not have the ``fun`` field in the data section, it will be published. For a better selection, consider using the ``tags`` option. By default, this option accepts any event to be submitted to Logstash. tags: ``None`` A list of pattern to compare the event tag against. By default, this option accepts any event to be submitted to Logstash. ''' if __opts__.get('id').endswith('_master'): instance = 'master' else: instance = 'minion' event_bus = salt.utils.event.get_event(instance, sock_dir=__opts__['sock_dir'], transport=__opts__['transport'], opts=__opts__) while True: event = event_bus.get_event(full=True) if event: publish = True if tags and isinstance(tags, list): found_match = False for tag in tags: if fnmatch.fnmatch(event['tag'], tag): found_match = True publish = found_match if funs and 'fun' in event['data']: if not event['data']['fun'] in funs: publish = False if publish: _logstash(url, event['data'])
[ "def", "start", "(", "url", ",", "funs", "=", "None", ",", "tags", "=", "None", ")", ":", "if", "__opts__", ".", "get", "(", "'id'", ")", ".", "endswith", "(", "'_master'", ")", ":", "instance", "=", "'master'", "else", ":", "instance", "=", "'mini...
Listen to salt events and forward them to logstash. url The Logstash endpoint. funs: ``None`` A list of functions to be compared against, looking into the ``fun`` field from the event data. This option helps to select the events generated by one or more functions. If an event does not have the ``fun`` field in the data section, it will be published. For a better selection, consider using the ``tags`` option. By default, this option accepts any event to be submitted to Logstash. tags: ``None`` A list of pattern to compare the event tag against. By default, this option accepts any event to be submitted to Logstash.
[ "Listen", "to", "salt", "events", "and", "forward", "them", "to", "logstash", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/http_logstash.py#L77-L119
train
saltstack/salt
salt/states/mysql_grants.py
present
def present(name, grant=None, database=None, user=None, host='localhost', grant_option=False, escape=True, revoke_first=False, ssl_option=False, **connection_args): ''' Ensure that the grant is present with the specified properties name The name (key) of the grant to add grant The grant priv_type (i.e. select,insert,update OR all privileges) database The database priv_level (i.e. db.tbl OR db.*) user The user to apply the grant to host The network/host that the grant should apply to grant_option Adds the WITH GRANT OPTION to the defined grant. Default is ``False`` escape Defines if the database value gets escaped or not. Default is ``True`` revoke_first By default, MySQL will not do anything if you issue a command to grant privileges that are more restrictive than what's already in place. This effectively means that you cannot downgrade permissions without first revoking permissions applied to a db.table/user pair first. To have Salt forcibly revoke perms before applying a new grant, enable the 'revoke_first options. WARNING: This will *remove* permissions for a database before attempting to apply new permissions. There is no guarantee that new permissions will be applied correctly which can leave your database security in an unknown and potentially dangerous state. Use with caution! Default is ``False`` ssl_option Adds the specified ssl options for the connecting user as requirements for this grant. Value is a list of single-element dicts corresponding to the list of ssl options to use. Possible key/value pairings for the dicts in the value: .. code-block:: text - SSL: True - X509: True - SUBJECT: <subject> - ISSUER: <issuer> - CIPHER: <cipher> The non-boolean ssl options take a string as their values, which should be an appropriate value as specified by the MySQL documentation for these options. Default is ``False`` (no ssl options will be used) ''' comment = 'Grant {0} on {1} to {2}@{3} is already present' ret = {'name': name, 'changes': {}, 'result': True, 'comment': comment.format(grant, database, user, host) } # check if grant exists if __salt__['mysql.grant_exists']( grant, database, user, host, grant_option, escape, **connection_args ): return ret else: err = _get_mysql_error() if err is not None: ret['comment'] = err ret['result'] = False return ret if revoke_first and not __opts__['test']: # for each grant, break into tokens and see if its on the same # user/db/table as ours. (there is probably only one) user_grants = __salt__['mysql.user_grants'](user, host, **connection_args) if not user_grants: user_grants = [] for user_grant in user_grants: token_grants = __salt__['mysql.tokenize_grant'](user_grant) db_part = database.rpartition('.') my_db = db_part[0] my_table = db_part[2] my_db = __salt__['mysql.quote_identifier'](my_db, (my_table is '*')) my_table = __salt__['mysql.quote_identifier'](my_table) # Removing per table grants in case of database level grant !!! if token_grants['database'] == my_db: grant_to_revoke = ','.join(token_grants['grant']).rstrip(',') __salt__['mysql.grant_revoke']( grant=grant_to_revoke, database=database, user=user, host=host, grant_option=grant_option, escape=escape, **connection_args) # The grant is not present, make it! if __opts__['test']: # there is probably better things to make in test mode ret['result'] = None ret['comment'] = ('MySQL grant {0} is set to be created').format(name) return ret if __salt__['mysql.grant_add']( grant, database, user, host, grant_option, escape, ssl_option, **connection_args ): ret['comment'] = 'Grant {0} on {1} to {2}@{3} has been added' ret['comment'] = ret['comment'].format(grant, database, user, host) ret['changes'][name] = 'Present' else: ret['comment'] = 'Failed to execute: "GRANT {0} ON {1} TO {2}@{3}"' ret['comment'] = ret['comment'].format(grant, database, user, host) err = _get_mysql_error() if err is not None: ret['comment'] += ' ({0})'.format(err) ret['result'] = False return ret
python
def present(name, grant=None, database=None, user=None, host='localhost', grant_option=False, escape=True, revoke_first=False, ssl_option=False, **connection_args): ''' Ensure that the grant is present with the specified properties name The name (key) of the grant to add grant The grant priv_type (i.e. select,insert,update OR all privileges) database The database priv_level (i.e. db.tbl OR db.*) user The user to apply the grant to host The network/host that the grant should apply to grant_option Adds the WITH GRANT OPTION to the defined grant. Default is ``False`` escape Defines if the database value gets escaped or not. Default is ``True`` revoke_first By default, MySQL will not do anything if you issue a command to grant privileges that are more restrictive than what's already in place. This effectively means that you cannot downgrade permissions without first revoking permissions applied to a db.table/user pair first. To have Salt forcibly revoke perms before applying a new grant, enable the 'revoke_first options. WARNING: This will *remove* permissions for a database before attempting to apply new permissions. There is no guarantee that new permissions will be applied correctly which can leave your database security in an unknown and potentially dangerous state. Use with caution! Default is ``False`` ssl_option Adds the specified ssl options for the connecting user as requirements for this grant. Value is a list of single-element dicts corresponding to the list of ssl options to use. Possible key/value pairings for the dicts in the value: .. code-block:: text - SSL: True - X509: True - SUBJECT: <subject> - ISSUER: <issuer> - CIPHER: <cipher> The non-boolean ssl options take a string as their values, which should be an appropriate value as specified by the MySQL documentation for these options. Default is ``False`` (no ssl options will be used) ''' comment = 'Grant {0} on {1} to {2}@{3} is already present' ret = {'name': name, 'changes': {}, 'result': True, 'comment': comment.format(grant, database, user, host) } # check if grant exists if __salt__['mysql.grant_exists']( grant, database, user, host, grant_option, escape, **connection_args ): return ret else: err = _get_mysql_error() if err is not None: ret['comment'] = err ret['result'] = False return ret if revoke_first and not __opts__['test']: # for each grant, break into tokens and see if its on the same # user/db/table as ours. (there is probably only one) user_grants = __salt__['mysql.user_grants'](user, host, **connection_args) if not user_grants: user_grants = [] for user_grant in user_grants: token_grants = __salt__['mysql.tokenize_grant'](user_grant) db_part = database.rpartition('.') my_db = db_part[0] my_table = db_part[2] my_db = __salt__['mysql.quote_identifier'](my_db, (my_table is '*')) my_table = __salt__['mysql.quote_identifier'](my_table) # Removing per table grants in case of database level grant !!! if token_grants['database'] == my_db: grant_to_revoke = ','.join(token_grants['grant']).rstrip(',') __salt__['mysql.grant_revoke']( grant=grant_to_revoke, database=database, user=user, host=host, grant_option=grant_option, escape=escape, **connection_args) # The grant is not present, make it! if __opts__['test']: # there is probably better things to make in test mode ret['result'] = None ret['comment'] = ('MySQL grant {0} is set to be created').format(name) return ret if __salt__['mysql.grant_add']( grant, database, user, host, grant_option, escape, ssl_option, **connection_args ): ret['comment'] = 'Grant {0} on {1} to {2}@{3} has been added' ret['comment'] = ret['comment'].format(grant, database, user, host) ret['changes'][name] = 'Present' else: ret['comment'] = 'Failed to execute: "GRANT {0} ON {1} TO {2}@{3}"' ret['comment'] = ret['comment'].format(grant, database, user, host) err = _get_mysql_error() if err is not None: ret['comment'] += ' ({0})'.format(err) ret['result'] = False return ret
[ "def", "present", "(", "name", ",", "grant", "=", "None", ",", "database", "=", "None", ",", "user", "=", "None", ",", "host", "=", "'localhost'", ",", "grant_option", "=", "False", ",", "escape", "=", "True", ",", "revoke_first", "=", "False", ",", ...
Ensure that the grant is present with the specified properties name The name (key) of the grant to add grant The grant priv_type (i.e. select,insert,update OR all privileges) database The database priv_level (i.e. db.tbl OR db.*) user The user to apply the grant to host The network/host that the grant should apply to grant_option Adds the WITH GRANT OPTION to the defined grant. Default is ``False`` escape Defines if the database value gets escaped or not. Default is ``True`` revoke_first By default, MySQL will not do anything if you issue a command to grant privileges that are more restrictive than what's already in place. This effectively means that you cannot downgrade permissions without first revoking permissions applied to a db.table/user pair first. To have Salt forcibly revoke perms before applying a new grant, enable the 'revoke_first options. WARNING: This will *remove* permissions for a database before attempting to apply new permissions. There is no guarantee that new permissions will be applied correctly which can leave your database security in an unknown and potentially dangerous state. Use with caution! Default is ``False`` ssl_option Adds the specified ssl options for the connecting user as requirements for this grant. Value is a list of single-element dicts corresponding to the list of ssl options to use. Possible key/value pairings for the dicts in the value: .. code-block:: text - SSL: True - X509: True - SUBJECT: <subject> - ISSUER: <issuer> - CIPHER: <cipher> The non-boolean ssl options take a string as their values, which should be an appropriate value as specified by the MySQL documentation for these options. Default is ``False`` (no ssl options will be used)
[ "Ensure", "that", "the", "grant", "is", "present", "with", "the", "specified", "properties" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/mysql_grants.py#L70-L203
train
saltstack/salt
salt/states/mysql_grants.py
absent
def absent(name, grant=None, database=None, user=None, host='localhost', grant_option=False, escape=True, **connection_args): ''' Ensure that the grant is absent name The name (key) of the grant to add grant The grant priv_type (i.e. select,insert,update OR all privileges) database The database priv_level (i.e. db.tbl OR db.*) user The user to apply the grant to host The network/host that the grant should apply to ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} # Check if grant exists, and if so, remove it if __salt__['mysql.grant_exists']( grant, database, user, host, grant_option, escape, **connection_args): if __opts__['test']: ret['result'] = None ret['comment'] = 'MySQL grant {0} is set to be ' \ 'revoked'.format(name) return ret if __salt__['mysql.grant_revoke']( grant, database, user, host, grant_option, **connection_args): ret['comment'] = 'Grant {0} on {1} for {2}@{3} has been ' \ 'revoked'.format(grant, database, user, host) ret['changes'][name] = 'Absent' return ret else: err = _get_mysql_error() if err is not None: ret['comment'] = 'Unable to revoke grant {0} on {1} for ' \ '{2}@{3} ({4})'.format(grant, database, user, host, err) ret['result'] = False return ret else: err = _get_mysql_error() if err is not None: ret['comment'] = 'Unable to determine if grant {0} on {1} for ' \ '{2}@{3} exists ({4})'.format(grant, database, user, host, err) ret['result'] = False return ret # fallback ret['comment'] = ('Grant {0} on {1} to {2}@{3} is not present, so it' ' cannot be revoked').format( grant, database, user, host ) return ret
python
def absent(name, grant=None, database=None, user=None, host='localhost', grant_option=False, escape=True, **connection_args): ''' Ensure that the grant is absent name The name (key) of the grant to add grant The grant priv_type (i.e. select,insert,update OR all privileges) database The database priv_level (i.e. db.tbl OR db.*) user The user to apply the grant to host The network/host that the grant should apply to ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} # Check if grant exists, and if so, remove it if __salt__['mysql.grant_exists']( grant, database, user, host, grant_option, escape, **connection_args): if __opts__['test']: ret['result'] = None ret['comment'] = 'MySQL grant {0} is set to be ' \ 'revoked'.format(name) return ret if __salt__['mysql.grant_revoke']( grant, database, user, host, grant_option, **connection_args): ret['comment'] = 'Grant {0} on {1} for {2}@{3} has been ' \ 'revoked'.format(grant, database, user, host) ret['changes'][name] = 'Absent' return ret else: err = _get_mysql_error() if err is not None: ret['comment'] = 'Unable to revoke grant {0} on {1} for ' \ '{2}@{3} ({4})'.format(grant, database, user, host, err) ret['result'] = False return ret else: err = _get_mysql_error() if err is not None: ret['comment'] = 'Unable to determine if grant {0} on {1} for ' \ '{2}@{3} exists ({4})'.format(grant, database, user, host, err) ret['result'] = False return ret # fallback ret['comment'] = ('Grant {0} on {1} to {2}@{3} is not present, so it' ' cannot be revoked').format( grant, database, user, host ) return ret
[ "def", "absent", "(", "name", ",", "grant", "=", "None", ",", "database", "=", "None", ",", "user", "=", "None", ",", "host", "=", "'localhost'", ",", "grant_option", "=", "False", ",", "escape", "=", "True", ",", "*", "*", "connection_args", ")", ":...
Ensure that the grant is absent name The name (key) of the grant to add grant The grant priv_type (i.e. select,insert,update OR all privileges) database The database priv_level (i.e. db.tbl OR db.*) user The user to apply the grant to host The network/host that the grant should apply to
[ "Ensure", "that", "the", "grant", "is", "absent" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/mysql_grants.py#L206-L287
train
saltstack/salt
salt/modules/cassandra.py
_nodetool
def _nodetool(cmd): ''' Internal cassandra nodetool wrapper. Some functions are not available via pycassa so we must rely on nodetool. ''' nodetool = __salt__['config.option']('cassandra.nodetool') host = __salt__['config.option']('cassandra.host') return __salt__['cmd.run_stdout']('{0} -h {1} {2}'.format(nodetool, host, cmd))
python
def _nodetool(cmd): ''' Internal cassandra nodetool wrapper. Some functions are not available via pycassa so we must rely on nodetool. ''' nodetool = __salt__['config.option']('cassandra.nodetool') host = __salt__['config.option']('cassandra.host') return __salt__['cmd.run_stdout']('{0} -h {1} {2}'.format(nodetool, host, cmd))
[ "def", "_nodetool", "(", "cmd", ")", ":", "nodetool", "=", "__salt__", "[", "'config.option'", "]", "(", "'cassandra.nodetool'", ")", "host", "=", "__salt__", "[", "'config.option'", "]", "(", "'cassandra.host'", ")", "return", "__salt__", "[", "'cmd.run_stdout'...
Internal cassandra nodetool wrapper. Some functions are not available via pycassa so we must rely on nodetool.
[ "Internal", "cassandra", "nodetool", "wrapper", ".", "Some", "functions", "are", "not", "available", "via", "pycassa", "so", "we", "must", "rely", "on", "nodetool", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cassandra.py#L44-L51
train
saltstack/salt
salt/modules/cassandra.py
_sys_mgr
def _sys_mgr(): ''' Return a pycassa system manager connection object ''' thrift_port = six.text_type(__salt__['config.option']('cassandra.THRIFT_PORT')) host = __salt__['config.option']('cassandra.host') return SystemManager('{0}:{1}'.format(host, thrift_port))
python
def _sys_mgr(): ''' Return a pycassa system manager connection object ''' thrift_port = six.text_type(__salt__['config.option']('cassandra.THRIFT_PORT')) host = __salt__['config.option']('cassandra.host') return SystemManager('{0}:{1}'.format(host, thrift_port))
[ "def", "_sys_mgr", "(", ")", ":", "thrift_port", "=", "six", ".", "text_type", "(", "__salt__", "[", "'config.option'", "]", "(", "'cassandra.THRIFT_PORT'", ")", ")", "host", "=", "__salt__", "[", "'config.option'", "]", "(", "'cassandra.host'", ")", "return",...
Return a pycassa system manager connection object
[ "Return", "a", "pycassa", "system", "manager", "connection", "object" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cassandra.py#L54-L60
train
saltstack/salt
salt/modules/cassandra.py
column_families
def column_families(keyspace=None): ''' Return existing column families for all keyspaces or just the provided one. CLI Example: .. code-block:: bash salt '*' cassandra.column_families salt '*' cassandra.column_families <keyspace> ''' sys = _sys_mgr() ksps = sys.list_keyspaces() if keyspace: if keyspace in ksps: return list(sys.get_keyspace_column_families(keyspace).keys()) else: return None else: ret = {} for kspace in ksps: ret[kspace] = list(sys.get_keyspace_column_families(kspace).keys()) return ret
python
def column_families(keyspace=None): ''' Return existing column families for all keyspaces or just the provided one. CLI Example: .. code-block:: bash salt '*' cassandra.column_families salt '*' cassandra.column_families <keyspace> ''' sys = _sys_mgr() ksps = sys.list_keyspaces() if keyspace: if keyspace in ksps: return list(sys.get_keyspace_column_families(keyspace).keys()) else: return None else: ret = {} for kspace in ksps: ret[kspace] = list(sys.get_keyspace_column_families(kspace).keys()) return ret
[ "def", "column_families", "(", "keyspace", "=", "None", ")", ":", "sys", "=", "_sys_mgr", "(", ")", "ksps", "=", "sys", ".", "list_keyspaces", "(", ")", "if", "keyspace", ":", "if", "keyspace", "in", "ksps", ":", "return", "list", "(", "sys", ".", "g...
Return existing column families for all keyspaces or just the provided one. CLI Example: .. code-block:: bash salt '*' cassandra.column_families salt '*' cassandra.column_families <keyspace>
[ "Return", "existing", "column", "families", "for", "all", "keyspaces", "or", "just", "the", "provided", "one", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cassandra.py#L155-L180
train
saltstack/salt
salt/modules/cassandra.py
column_family_definition
def column_family_definition(keyspace, column_family): ''' Return a dictionary of column family definitions for the given keyspace/column_family CLI Example: .. code-block:: bash salt '*' cassandra.column_family_definition <keyspace> <column_family> ''' sys = _sys_mgr() try: return vars(sys.get_keyspace_column_families(keyspace)[column_family]) except Exception: log.debug('Invalid Keyspace/CF combination') return None
python
def column_family_definition(keyspace, column_family): ''' Return a dictionary of column family definitions for the given keyspace/column_family CLI Example: .. code-block:: bash salt '*' cassandra.column_family_definition <keyspace> <column_family> ''' sys = _sys_mgr() try: return vars(sys.get_keyspace_column_families(keyspace)[column_family]) except Exception: log.debug('Invalid Keyspace/CF combination') return None
[ "def", "column_family_definition", "(", "keyspace", ",", "column_family", ")", ":", "sys", "=", "_sys_mgr", "(", ")", "try", ":", "return", "vars", "(", "sys", ".", "get_keyspace_column_families", "(", "keyspace", ")", "[", "column_family", "]", ")", "except",...
Return a dictionary of column family definitions for the given keyspace/column_family CLI Example: .. code-block:: bash salt '*' cassandra.column_family_definition <keyspace> <column_family>
[ "Return", "a", "dictionary", "of", "column", "family", "definitions", "for", "the", "given", "keyspace", "/", "column_family" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cassandra.py#L183-L201
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_quota
def update_quota(self, tenant_id, subnet=None, router=None, network=None, floatingip=None, port=None, sec_grp=None, sec_grp_rule=None): ''' Update a tenant's quota ''' body = {} if subnet: body['subnet'] = subnet if router: body['router'] = router if network: body['network'] = network if floatingip: body['floatingip'] = floatingip if port: body['port'] = port if sec_grp: body['security_group'] = sec_grp if sec_grp_rule: body['security_group_rule'] = sec_grp_rule return self.network_conn.update_quota(tenant_id=tenant_id, body={'quota': body})
python
def update_quota(self, tenant_id, subnet=None, router=None, network=None, floatingip=None, port=None, sec_grp=None, sec_grp_rule=None): ''' Update a tenant's quota ''' body = {} if subnet: body['subnet'] = subnet if router: body['router'] = router if network: body['network'] = network if floatingip: body['floatingip'] = floatingip if port: body['port'] = port if sec_grp: body['security_group'] = sec_grp if sec_grp_rule: body['security_group_rule'] = sec_grp_rule return self.network_conn.update_quota(tenant_id=tenant_id, body={'quota': body})
[ "def", "update_quota", "(", "self", ",", "tenant_id", ",", "subnet", "=", "None", ",", "router", "=", "None", ",", "network", "=", "None", ",", "floatingip", "=", "None", ",", "port", "=", "None", ",", "sec_grp", "=", "None", ",", "sec_grp_rule", "=", ...
Update a tenant's quota
[ "Update", "a", "tenant", "s", "quota" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L272-L294
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_quota
def delete_quota(self, tenant_id): ''' Delete the specified tenant's quota value ''' ret = self.network_conn.delete_quota(tenant_id=tenant_id) return ret if ret else True
python
def delete_quota(self, tenant_id): ''' Delete the specified tenant's quota value ''' ret = self.network_conn.delete_quota(tenant_id=tenant_id) return ret if ret else True
[ "def", "delete_quota", "(", "self", ",", "tenant_id", ")", ":", "ret", "=", "self", ".", "network_conn", ".", "delete_quota", "(", "tenant_id", "=", "tenant_id", ")", "return", "ret", "if", "ret", "else", "True" ]
Delete the specified tenant's quota value
[ "Delete", "the", "specified", "tenant", "s", "quota", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L296-L301
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_port
def create_port(self, name, network, device_id=None, admin_state_up=True): ''' Creates a new port ''' net_id = self._find_network_id(network) body = {'admin_state_up': admin_state_up, 'name': name, 'network_id': net_id} if device_id: body['device_id'] = device_id return self.network_conn.create_port(body={'port': body})
python
def create_port(self, name, network, device_id=None, admin_state_up=True): ''' Creates a new port ''' net_id = self._find_network_id(network) body = {'admin_state_up': admin_state_up, 'name': name, 'network_id': net_id} if device_id: body['device_id'] = device_id return self.network_conn.create_port(body={'port': body})
[ "def", "create_port", "(", "self", ",", "name", ",", "network", ",", "device_id", "=", "None", ",", "admin_state_up", "=", "True", ")", ":", "net_id", "=", "self", ".", "_find_network_id", "(", "network", ")", "body", "=", "{", "'admin_state_up'", ":", "...
Creates a new port
[ "Creates", "a", "new", "port" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L321-L331
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_port
def update_port(self, port, name, admin_state_up=True): ''' Updates a port ''' port_id = self._find_port_id(port) body = {'name': name, 'admin_state_up': admin_state_up} return self.network_conn.update_port(port=port_id, body={'port': body})
python
def update_port(self, port, name, admin_state_up=True): ''' Updates a port ''' port_id = self._find_port_id(port) body = {'name': name, 'admin_state_up': admin_state_up} return self.network_conn.update_port(port=port_id, body={'port': body})
[ "def", "update_port", "(", "self", ",", "port", ",", "name", ",", "admin_state_up", "=", "True", ")", ":", "port_id", "=", "self", ".", "_find_port_id", "(", "port", ")", "body", "=", "{", "'name'", ":", "name", ",", "'admin_state_up'", ":", "admin_state...
Updates a port
[ "Updates", "a", "port" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L333-L341
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_port
def delete_port(self, port): ''' Deletes the specified port ''' port_id = self._find_port_id(port) ret = self.network_conn.delete_port(port=port_id) return ret if ret else True
python
def delete_port(self, port): ''' Deletes the specified port ''' port_id = self._find_port_id(port) ret = self.network_conn.delete_port(port=port_id) return ret if ret else True
[ "def", "delete_port", "(", "self", ",", "port", ")", ":", "port_id", "=", "self", ".", "_find_port_id", "(", "port", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_port", "(", "port", "=", "port_id", ")", "return", "ret", "if", "ret", "else...
Deletes the specified port
[ "Deletes", "the", "specified", "port" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L343-L349
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_network
def create_network(self, name, admin_state_up=True, router_ext=None, network_type=None, physical_network=None, segmentation_id=None, shared=None, vlan_transparent=None): ''' Creates a new network ''' body = {'name': name, 'admin_state_up': admin_state_up} if router_ext: body['router:external'] = router_ext if network_type: body['provider:network_type'] = network_type if physical_network: body['provider:physical_network'] = physical_network if segmentation_id: body['provider:segmentation_id'] = segmentation_id if shared: body['shared'] = shared if vlan_transparent: body['vlan_transparent'] = vlan_transparent return self.network_conn.create_network(body={'network': body})
python
def create_network(self, name, admin_state_up=True, router_ext=None, network_type=None, physical_network=None, segmentation_id=None, shared=None, vlan_transparent=None): ''' Creates a new network ''' body = {'name': name, 'admin_state_up': admin_state_up} if router_ext: body['router:external'] = router_ext if network_type: body['provider:network_type'] = network_type if physical_network: body['provider:physical_network'] = physical_network if segmentation_id: body['provider:segmentation_id'] = segmentation_id if shared: body['shared'] = shared if vlan_transparent: body['vlan_transparent'] = vlan_transparent return self.network_conn.create_network(body={'network': body})
[ "def", "create_network", "(", "self", ",", "name", ",", "admin_state_up", "=", "True", ",", "router_ext", "=", "None", ",", "network_type", "=", "None", ",", "physical_network", "=", "None", ",", "segmentation_id", "=", "None", ",", "shared", "=", "None", ...
Creates a new network
[ "Creates", "a", "new", "network" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L363-L381
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_network
def update_network(self, network, name): ''' Updates a network ''' net_id = self._find_network_id(network) return self.network_conn.update_network( network=net_id, body={'network': {'name': name}})
python
def update_network(self, network, name): ''' Updates a network ''' net_id = self._find_network_id(network) return self.network_conn.update_network( network=net_id, body={'network': {'name': name}})
[ "def", "update_network", "(", "self", ",", "network", ",", "name", ")", ":", "net_id", "=", "self", ".", "_find_network_id", "(", "network", ")", "return", "self", ".", "network_conn", ".", "update_network", "(", "network", "=", "net_id", ",", "body", "=",...
Updates a network
[ "Updates", "a", "network" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L383-L389
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_network
def delete_network(self, network): ''' Deletes the specified network ''' net_id = self._find_network_id(network) ret = self.network_conn.delete_network(network=net_id) return ret if ret else True
python
def delete_network(self, network): ''' Deletes the specified network ''' net_id = self._find_network_id(network) ret = self.network_conn.delete_network(network=net_id) return ret if ret else True
[ "def", "delete_network", "(", "self", ",", "network", ")", ":", "net_id", "=", "self", ".", "_find_network_id", "(", "network", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_network", "(", "network", "=", "net_id", ")", "return", "ret", "if", ...
Deletes the specified network
[ "Deletes", "the", "specified", "network" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L391-L397
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_subnet
def create_subnet(self, network, cidr, name=None, ip_version=4): ''' Creates a new subnet ''' net_id = self._find_network_id(network) body = {'cidr': cidr, 'ip_version': ip_version, 'network_id': net_id, 'name': name} return self.network_conn.create_subnet(body={'subnet': body})
python
def create_subnet(self, network, cidr, name=None, ip_version=4): ''' Creates a new subnet ''' net_id = self._find_network_id(network) body = {'cidr': cidr, 'ip_version': ip_version, 'network_id': net_id, 'name': name} return self.network_conn.create_subnet(body={'subnet': body})
[ "def", "create_subnet", "(", "self", ",", "network", ",", "cidr", ",", "name", "=", "None", ",", "ip_version", "=", "4", ")", ":", "net_id", "=", "self", ".", "_find_network_id", "(", "network", ")", "body", "=", "{", "'cidr'", ":", "cidr", ",", "'ip...
Creates a new subnet
[ "Creates", "a", "new", "subnet" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L411-L420
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_subnet
def update_subnet(self, subnet, name=None): ''' Updates a subnet ''' subnet_id = self._find_subnet_id(subnet) return self.network_conn.update_subnet( subnet=subnet_id, body={'subnet': {'name': name}})
python
def update_subnet(self, subnet, name=None): ''' Updates a subnet ''' subnet_id = self._find_subnet_id(subnet) return self.network_conn.update_subnet( subnet=subnet_id, body={'subnet': {'name': name}})
[ "def", "update_subnet", "(", "self", ",", "subnet", ",", "name", "=", "None", ")", ":", "subnet_id", "=", "self", ".", "_find_subnet_id", "(", "subnet", ")", "return", "self", ".", "network_conn", ".", "update_subnet", "(", "subnet", "=", "subnet_id", ",",...
Updates a subnet
[ "Updates", "a", "subnet" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L422-L428
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_subnet
def delete_subnet(self, subnet): ''' Deletes the specified subnet ''' subnet_id = self._find_subnet_id(subnet) ret = self.network_conn.delete_subnet(subnet=subnet_id) return ret if ret else True
python
def delete_subnet(self, subnet): ''' Deletes the specified subnet ''' subnet_id = self._find_subnet_id(subnet) ret = self.network_conn.delete_subnet(subnet=subnet_id) return ret if ret else True
[ "def", "delete_subnet", "(", "self", ",", "subnet", ")", ":", "subnet_id", "=", "self", ".", "_find_subnet_id", "(", "subnet", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_subnet", "(", "subnet", "=", "subnet_id", ")", "return", "ret", "if", ...
Deletes the specified subnet
[ "Deletes", "the", "specified", "subnet" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L430-L436
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_router
def create_router(self, name, ext_network=None, admin_state_up=True): ''' Creates a new router ''' body = {'name': name, 'admin_state_up': admin_state_up} if ext_network: net_id = self._find_network_id(ext_network) body['external_gateway_info'] = {'network_id': net_id} return self.network_conn.create_router(body={'router': body})
python
def create_router(self, name, ext_network=None, admin_state_up=True): ''' Creates a new router ''' body = {'name': name, 'admin_state_up': admin_state_up} if ext_network: net_id = self._find_network_id(ext_network) body['external_gateway_info'] = {'network_id': net_id} return self.network_conn.create_router(body={'router': body})
[ "def", "create_router", "(", "self", ",", "name", ",", "ext_network", "=", "None", ",", "admin_state_up", "=", "True", ")", ":", "body", "=", "{", "'name'", ":", "name", ",", "'admin_state_up'", ":", "admin_state_up", "}", "if", "ext_network", ":", "net_id...
Creates a new router
[ "Creates", "a", "new", "router" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L450-L459
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_router
def update_router(self, router, name=None, admin_state_up=None, **kwargs): ''' Updates a router ''' router_id = self._find_router_id(router) body = {} if 'ext_network' in kwargs: if kwargs.get('ext_network') is None: body['external_gateway_info'] = None else: net_id = self._find_network_id(kwargs.get('ext_network')) body['external_gateway_info'] = {'network_id': net_id} if name is not None: body['name'] = name if admin_state_up is not None: body['admin_state_up'] = admin_state_up return self.network_conn.update_router( router=router_id, body={'router': body})
python
def update_router(self, router, name=None, admin_state_up=None, **kwargs): ''' Updates a router ''' router_id = self._find_router_id(router) body = {} if 'ext_network' in kwargs: if kwargs.get('ext_network') is None: body['external_gateway_info'] = None else: net_id = self._find_network_id(kwargs.get('ext_network')) body['external_gateway_info'] = {'network_id': net_id} if name is not None: body['name'] = name if admin_state_up is not None: body['admin_state_up'] = admin_state_up return self.network_conn.update_router( router=router_id, body={'router': body})
[ "def", "update_router", "(", "self", ",", "router", ",", "name", "=", "None", ",", "admin_state_up", "=", "None", ",", "*", "*", "kwargs", ")", ":", "router_id", "=", "self", ".", "_find_router_id", "(", "router", ")", "body", "=", "{", "}", "if", "'...
Updates a router
[ "Updates", "a", "router" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L461-L479
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_router
def delete_router(self, router): ''' Delete the specified router ''' router_id = self._find_router_id(router) ret = self.network_conn.delete_router(router=router_id) return ret if ret else True
python
def delete_router(self, router): ''' Delete the specified router ''' router_id = self._find_router_id(router) ret = self.network_conn.delete_router(router=router_id) return ret if ret else True
[ "def", "delete_router", "(", "self", ",", "router", ")", ":", "router_id", "=", "self", ".", "_find_router_id", "(", "router", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_router", "(", "router", "=", "router_id", ")", "return", "ret", "if", ...
Delete the specified router
[ "Delete", "the", "specified", "router" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L481-L487
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.add_interface_router
def add_interface_router(self, router, subnet): ''' Adds an internal network interface to the specified router ''' router_id = self._find_router_id(router) subnet_id = self._find_subnet_id(subnet) return self.network_conn.add_interface_router( router=router_id, body={'subnet_id': subnet_id})
python
def add_interface_router(self, router, subnet): ''' Adds an internal network interface to the specified router ''' router_id = self._find_router_id(router) subnet_id = self._find_subnet_id(subnet) return self.network_conn.add_interface_router( router=router_id, body={'subnet_id': subnet_id})
[ "def", "add_interface_router", "(", "self", ",", "router", ",", "subnet", ")", ":", "router_id", "=", "self", ".", "_find_router_id", "(", "router", ")", "subnet_id", "=", "self", ".", "_find_subnet_id", "(", "subnet", ")", "return", "self", ".", "network_co...
Adds an internal network interface to the specified router
[ "Adds", "an", "internal", "network", "interface", "to", "the", "specified", "router" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L489-L496
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.add_gateway_router
def add_gateway_router(self, router, network): ''' Adds an external network gateway to the specified router ''' router_id = self._find_router_id(router) net_id = self._find_network_id(network) return self.network_conn.add_gateway_router( router=router_id, body={'network_id': net_id})
python
def add_gateway_router(self, router, network): ''' Adds an external network gateway to the specified router ''' router_id = self._find_router_id(router) net_id = self._find_network_id(network) return self.network_conn.add_gateway_router( router=router_id, body={'network_id': net_id})
[ "def", "add_gateway_router", "(", "self", ",", "router", ",", "network", ")", ":", "router_id", "=", "self", ".", "_find_router_id", "(", "router", ")", "net_id", "=", "self", ".", "_find_network_id", "(", "network", ")", "return", "self", ".", "network_conn...
Adds an external network gateway to the specified router
[ "Adds", "an", "external", "network", "gateway", "to", "the", "specified", "router" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L507-L514
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.remove_gateway_router
def remove_gateway_router(self, router): ''' Removes an external network gateway from the specified router ''' router_id = self._find_router_id(router) return self.network_conn.remove_gateway_router(router=router_id)
python
def remove_gateway_router(self, router): ''' Removes an external network gateway from the specified router ''' router_id = self._find_router_id(router) return self.network_conn.remove_gateway_router(router=router_id)
[ "def", "remove_gateway_router", "(", "self", ",", "router", ")", ":", "router_id", "=", "self", ".", "_find_router_id", "(", "router", ")", "return", "self", ".", "network_conn", ".", "remove_gateway_router", "(", "router", "=", "router_id", ")" ]
Removes an external network gateway from the specified router
[ "Removes", "an", "external", "network", "gateway", "from", "the", "specified", "router" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L516-L521
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_floatingip
def create_floatingip(self, floating_network, port=None): ''' Creates a new floatingip ''' net_id = self._find_network_id(floating_network) body = {'floating_network_id': net_id} if port: port_id = self._find_port_id(port) body['port_id'] = port_id return self.network_conn.create_floatingip(body={'floatingip': body})
python
def create_floatingip(self, floating_network, port=None): ''' Creates a new floatingip ''' net_id = self._find_network_id(floating_network) body = {'floating_network_id': net_id} if port: port_id = self._find_port_id(port) body['port_id'] = port_id return self.network_conn.create_floatingip(body={'floatingip': body})
[ "def", "create_floatingip", "(", "self", ",", "floating_network", ",", "port", "=", "None", ")", ":", "net_id", "=", "self", ".", "_find_network_id", "(", "floating_network", ")", "body", "=", "{", "'floating_network_id'", ":", "net_id", "}", "if", "port", "...
Creates a new floatingip
[ "Creates", "a", "new", "floatingip" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L535-L545
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_floatingip
def update_floatingip(self, floatingip_id, port=None): ''' Updates a floatingip, disassociates the floating ip if port is set to `None` ''' if port is None: body = {'floatingip': {}} else: port_id = self._find_port_id(port) body = {'floatingip': {'port_id': port_id}} return self.network_conn.update_floatingip( floatingip=floatingip_id, body=body)
python
def update_floatingip(self, floatingip_id, port=None): ''' Updates a floatingip, disassociates the floating ip if port is set to `None` ''' if port is None: body = {'floatingip': {}} else: port_id = self._find_port_id(port) body = {'floatingip': {'port_id': port_id}} return self.network_conn.update_floatingip( floatingip=floatingip_id, body=body)
[ "def", "update_floatingip", "(", "self", ",", "floatingip_id", ",", "port", "=", "None", ")", ":", "if", "port", "is", "None", ":", "body", "=", "{", "'floatingip'", ":", "{", "}", "}", "else", ":", "port_id", "=", "self", ".", "_find_port_id", "(", ...
Updates a floatingip, disassociates the floating ip if port is set to `None`
[ "Updates", "a", "floatingip", "disassociates", "the", "floating", "ip", "if", "port", "is", "set", "to", "None" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L547-L558
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_floatingip
def delete_floatingip(self, floatingip_id): ''' Deletes the specified floatingip ''' ret = self.network_conn.delete_floatingip(floatingip_id) return ret if ret else True
python
def delete_floatingip(self, floatingip_id): ''' Deletes the specified floatingip ''' ret = self.network_conn.delete_floatingip(floatingip_id) return ret if ret else True
[ "def", "delete_floatingip", "(", "self", ",", "floatingip_id", ")", ":", "ret", "=", "self", ".", "network_conn", ".", "delete_floatingip", "(", "floatingip_id", ")", "return", "ret", "if", "ret", "else", "True" ]
Deletes the specified floatingip
[ "Deletes", "the", "specified", "floatingip" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L560-L565
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_security_group
def create_security_group(self, name, desc=None): ''' Creates a new security group ''' body = {'security_group': {'name': name, 'description': desc}} return self.network_conn.create_security_group(body=body)
python
def create_security_group(self, name, desc=None): ''' Creates a new security group ''' body = {'security_group': {'name': name, 'description': desc}} return self.network_conn.create_security_group(body=body)
[ "def", "create_security_group", "(", "self", ",", "name", ",", "desc", "=", "None", ")", ":", "body", "=", "{", "'security_group'", ":", "{", "'name'", ":", "name", ",", "'description'", ":", "desc", "}", "}", "return", "self", ".", "network_conn", ".", ...
Creates a new security group
[ "Creates", "a", "new", "security", "group" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L579-L585
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_security_group
def update_security_group(self, sec_grp, name=None, desc=None): ''' Updates a security group ''' sec_grp_id = self._find_security_group_id(sec_grp) body = {'security_group': {}} if name: body['security_group']['name'] = name if desc: body['security_group']['description'] = desc return self.network_conn.update_security_group(sec_grp_id, body=body)
python
def update_security_group(self, sec_grp, name=None, desc=None): ''' Updates a security group ''' sec_grp_id = self._find_security_group_id(sec_grp) body = {'security_group': {}} if name: body['security_group']['name'] = name if desc: body['security_group']['description'] = desc return self.network_conn.update_security_group(sec_grp_id, body=body)
[ "def", "update_security_group", "(", "self", ",", "sec_grp", ",", "name", "=", "None", ",", "desc", "=", "None", ")", ":", "sec_grp_id", "=", "self", ".", "_find_security_group_id", "(", "sec_grp", ")", "body", "=", "{", "'security_group'", ":", "{", "}", ...
Updates a security group
[ "Updates", "a", "security", "group" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L587-L598
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_security_group
def delete_security_group(self, sec_grp): ''' Deletes the specified security group ''' sec_grp_id = self._find_security_group_id(sec_grp) ret = self.network_conn.delete_security_group(sec_grp_id) return ret if ret else True
python
def delete_security_group(self, sec_grp): ''' Deletes the specified security group ''' sec_grp_id = self._find_security_group_id(sec_grp) ret = self.network_conn.delete_security_group(sec_grp_id) return ret if ret else True
[ "def", "delete_security_group", "(", "self", ",", "sec_grp", ")", ":", "sec_grp_id", "=", "self", ".", "_find_security_group_id", "(", "sec_grp", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_security_group", "(", "sec_grp_id", ")", "return", "ret",...
Deletes the specified security group
[ "Deletes", "the", "specified", "security", "group" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L600-L606
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_security_group_rule
def create_security_group_rule( self, sec_grp, remote_grp_id=None, direction='ingress', protocol=None, port_range_min=None, port_range_max=None, ether=None): ''' Creates a new security group rule ''' sec_grp_id = self._find_security_group_id(sec_grp) body = {'security_group_id': sec_grp_id, 'remote_group_id': remote_grp_id, 'direction': direction, 'protocol': protocol, 'port_range_min': port_range_min, 'port_range_max': port_range_max, 'ethertype': ether} return self.network_conn.create_security_group_rule( body={'security_group_rule': body})
python
def create_security_group_rule( self, sec_grp, remote_grp_id=None, direction='ingress', protocol=None, port_range_min=None, port_range_max=None, ether=None): ''' Creates a new security group rule ''' sec_grp_id = self._find_security_group_id(sec_grp) body = {'security_group_id': sec_grp_id, 'remote_group_id': remote_grp_id, 'direction': direction, 'protocol': protocol, 'port_range_min': port_range_min, 'port_range_max': port_range_max, 'ethertype': ether} return self.network_conn.create_security_group_rule( body={'security_group_rule': body})
[ "def", "create_security_group_rule", "(", "self", ",", "sec_grp", ",", "remote_grp_id", "=", "None", ",", "direction", "=", "'ingress'", ",", "protocol", "=", "None", ",", "port_range_min", "=", "None", ",", "port_range_max", "=", "None", ",", "ether", "=", ...
Creates a new security group rule
[ "Creates", "a", "new", "security", "group", "rule" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L621-L636
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_security_group_rule
def delete_security_group_rule(self, sec_grp_rule_id): ''' Deletes the specified security group rule ''' ret = self.network_conn.delete_security_group_rule( security_group_rule=sec_grp_rule_id) return ret if ret else True
python
def delete_security_group_rule(self, sec_grp_rule_id): ''' Deletes the specified security group rule ''' ret = self.network_conn.delete_security_group_rule( security_group_rule=sec_grp_rule_id) return ret if ret else True
[ "def", "delete_security_group_rule", "(", "self", ",", "sec_grp_rule_id", ")", ":", "ret", "=", "self", ".", "network_conn", ".", "delete_security_group_rule", "(", "security_group_rule", "=", "sec_grp_rule_id", ")", "return", "ret", "if", "ret", "else", "True" ]
Deletes the specified security group rule
[ "Deletes", "the", "specified", "security", "group", "rule" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L638-L644
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.list_vpnservices
def list_vpnservices(self, retrieve_all=True, **kwargs): ''' Fetches a list of all configured VPN services for a tenant ''' return self.network_conn.list_vpnservices(retrieve_all, **kwargs)
python
def list_vpnservices(self, retrieve_all=True, **kwargs): ''' Fetches a list of all configured VPN services for a tenant ''' return self.network_conn.list_vpnservices(retrieve_all, **kwargs)
[ "def", "list_vpnservices", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "network_conn", ".", "list_vpnservices", "(", "retrieve_all", ",", "*", "*", "kwargs", ")" ]
Fetches a list of all configured VPN services for a tenant
[ "Fetches", "a", "list", "of", "all", "configured", "VPN", "services", "for", "a", "tenant" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L646-L650
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.show_vpnservice
def show_vpnservice(self, vpnservice, **kwargs): ''' Fetches information of a specific VPN service ''' vpnservice_id = self._find_vpnservice_id(vpnservice) return self.network_conn.show_vpnservice(vpnservice_id, **kwargs)
python
def show_vpnservice(self, vpnservice, **kwargs): ''' Fetches information of a specific VPN service ''' vpnservice_id = self._find_vpnservice_id(vpnservice) return self.network_conn.show_vpnservice(vpnservice_id, **kwargs)
[ "def", "show_vpnservice", "(", "self", ",", "vpnservice", ",", "*", "*", "kwargs", ")", ":", "vpnservice_id", "=", "self", ".", "_find_vpnservice_id", "(", "vpnservice", ")", "return", "self", ".", "network_conn", ".", "show_vpnservice", "(", "vpnservice_id", ...
Fetches information of a specific VPN service
[ "Fetches", "information", "of", "a", "specific", "VPN", "service" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L652-L657
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_vpnservice
def create_vpnservice(self, subnet, router, name, admin_state_up=True): ''' Creates a new VPN service ''' subnet_id = self._find_subnet_id(subnet) router_id = self._find_router_id(router) body = {'subnet_id': subnet_id, 'router_id': router_id, 'name': name, 'admin_state_up': admin_state_up} return self.network_conn.create_vpnservice(body={'vpnservice': body})
python
def create_vpnservice(self, subnet, router, name, admin_state_up=True): ''' Creates a new VPN service ''' subnet_id = self._find_subnet_id(subnet) router_id = self._find_router_id(router) body = {'subnet_id': subnet_id, 'router_id': router_id, 'name': name, 'admin_state_up': admin_state_up} return self.network_conn.create_vpnservice(body={'vpnservice': body})
[ "def", "create_vpnservice", "(", "self", ",", "subnet", ",", "router", ",", "name", ",", "admin_state_up", "=", "True", ")", ":", "subnet_id", "=", "self", ".", "_find_subnet_id", "(", "subnet", ")", "router_id", "=", "self", ".", "_find_router_id", "(", "...
Creates a new VPN service
[ "Creates", "a", "new", "VPN", "service" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L659-L669
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_vpnservice
def update_vpnservice(self, vpnservice, desc): ''' Updates a VPN service ''' vpnservice_id = self._find_vpnservice_id(vpnservice) body = {'description': desc} return self.network_conn.update_vpnservice(vpnservice_id, body={'vpnservice': body})
python
def update_vpnservice(self, vpnservice, desc): ''' Updates a VPN service ''' vpnservice_id = self._find_vpnservice_id(vpnservice) body = {'description': desc} return self.network_conn.update_vpnservice(vpnservice_id, body={'vpnservice': body})
[ "def", "update_vpnservice", "(", "self", ",", "vpnservice", ",", "desc", ")", ":", "vpnservice_id", "=", "self", ".", "_find_vpnservice_id", "(", "vpnservice", ")", "body", "=", "{", "'description'", ":", "desc", "}", "return", "self", ".", "network_conn", "...
Updates a VPN service
[ "Updates", "a", "VPN", "service" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L671-L678
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_vpnservice
def delete_vpnservice(self, vpnservice): ''' Deletes the specified VPN service ''' vpnservice_id = self._find_vpnservice_id(vpnservice) ret = self.network_conn.delete_vpnservice(vpnservice_id) return ret if ret else True
python
def delete_vpnservice(self, vpnservice): ''' Deletes the specified VPN service ''' vpnservice_id = self._find_vpnservice_id(vpnservice) ret = self.network_conn.delete_vpnservice(vpnservice_id) return ret if ret else True
[ "def", "delete_vpnservice", "(", "self", ",", "vpnservice", ")", ":", "vpnservice_id", "=", "self", ".", "_find_vpnservice_id", "(", "vpnservice", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_vpnservice", "(", "vpnservice_id", ")", "return", "ret",...
Deletes the specified VPN service
[ "Deletes", "the", "specified", "VPN", "service" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L680-L686
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_ipsec_site_connection
def create_ipsec_site_connection(self, name, ipsecpolicy, ikepolicy, vpnservice, peer_cidrs, peer_address, peer_id, psk, admin_state_up=True, **kwargs): ''' Creates a new IPsecSiteConnection ''' ipsecpolicy_id = self._find_ipsecpolicy_id(ipsecpolicy) ikepolicy_id = self._find_ikepolicy_id(ikepolicy) vpnservice_id = self._find_vpnservice_id(vpnservice) body = {'psk': psk, 'ipsecpolicy_id': ipsecpolicy_id, 'admin_state_up': admin_state_up, 'peer_cidrs': [peer_cidrs], 'ikepolicy_id': ikepolicy_id, 'vpnservice_id': vpnservice_id, 'peer_address': peer_address, 'peer_id': peer_id, 'name': name} if 'initiator' in kwargs: body['initiator'] = kwargs['initiator'] if 'mtu' in kwargs: body['mtu'] = kwargs['mtu'] if 'dpd_action' in kwargs: body['dpd'] = {'action': kwargs['dpd_action']} if 'dpd_interval' in kwargs: if 'dpd' not in body: body['dpd'] = {} body['dpd']['interval'] = kwargs['dpd_interval'] if 'dpd_timeout' in kwargs: if 'dpd' not in body: body['dpd'] = {} body['dpd']['timeout'] = kwargs['dpd_timeout'] return self.network_conn.create_ipsec_site_connection( body={'ipsec_site_connection': body})
python
def create_ipsec_site_connection(self, name, ipsecpolicy, ikepolicy, vpnservice, peer_cidrs, peer_address, peer_id, psk, admin_state_up=True, **kwargs): ''' Creates a new IPsecSiteConnection ''' ipsecpolicy_id = self._find_ipsecpolicy_id(ipsecpolicy) ikepolicy_id = self._find_ikepolicy_id(ikepolicy) vpnservice_id = self._find_vpnservice_id(vpnservice) body = {'psk': psk, 'ipsecpolicy_id': ipsecpolicy_id, 'admin_state_up': admin_state_up, 'peer_cidrs': [peer_cidrs], 'ikepolicy_id': ikepolicy_id, 'vpnservice_id': vpnservice_id, 'peer_address': peer_address, 'peer_id': peer_id, 'name': name} if 'initiator' in kwargs: body['initiator'] = kwargs['initiator'] if 'mtu' in kwargs: body['mtu'] = kwargs['mtu'] if 'dpd_action' in kwargs: body['dpd'] = {'action': kwargs['dpd_action']} if 'dpd_interval' in kwargs: if 'dpd' not in body: body['dpd'] = {} body['dpd']['interval'] = kwargs['dpd_interval'] if 'dpd_timeout' in kwargs: if 'dpd' not in body: body['dpd'] = {} body['dpd']['timeout'] = kwargs['dpd_timeout'] return self.network_conn.create_ipsec_site_connection( body={'ipsec_site_connection': body})
[ "def", "create_ipsec_site_connection", "(", "self", ",", "name", ",", "ipsecpolicy", ",", "ikepolicy", ",", "vpnservice", ",", "peer_cidrs", ",", "peer_address", ",", "peer_id", ",", "psk", ",", "admin_state_up", "=", "True", ",", "*", "*", "kwargs", ")", ":...
Creates a new IPsecSiteConnection
[ "Creates", "a", "new", "IPsecSiteConnection" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L700-L739
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_ipsec_site_connection
def delete_ipsec_site_connection(self, ipsec_site_connection): ''' Deletes the specified IPsecSiteConnection ''' ipsec_site_connection_id = self._find_ipsec_site_connection_id( ipsec_site_connection) ret = self.network_conn.delete_ipsec_site_connection( ipsec_site_connection_id) return ret if ret else True
python
def delete_ipsec_site_connection(self, ipsec_site_connection): ''' Deletes the specified IPsecSiteConnection ''' ipsec_site_connection_id = self._find_ipsec_site_connection_id( ipsec_site_connection) ret = self.network_conn.delete_ipsec_site_connection( ipsec_site_connection_id) return ret if ret else True
[ "def", "delete_ipsec_site_connection", "(", "self", ",", "ipsec_site_connection", ")", ":", "ipsec_site_connection_id", "=", "self", ".", "_find_ipsec_site_connection_id", "(", "ipsec_site_connection", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_ipsec_site_...
Deletes the specified IPsecSiteConnection
[ "Deletes", "the", "specified", "IPsecSiteConnection" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L741-L749
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_ikepolicy
def create_ikepolicy(self, name, **kwargs): ''' Creates a new IKEPolicy ''' body = {'name': name} if 'phase1_negotiation_mode' in kwargs: body['phase1_negotiation_mode'] = kwargs['phase1_negotiation_mode'] if 'auth_algorithm' in kwargs: body['auth_algorithm'] = kwargs['auth_algorithm'] if 'encryption_algorithm' in kwargs: body['encryption_algorithm'] = kwargs['encryption_algorithm'] if 'pfs' in kwargs: body['pfs'] = kwargs['pfs'] if 'ike_version' in kwargs: body['ike_version'] = kwargs['ike_version'] if 'units' in kwargs: body['lifetime'] = {'units': kwargs['units']} if 'value' in kwargs: if 'lifetime' not in body: body['lifetime'] = {} body['lifetime']['value'] = kwargs['value'] return self.network_conn.create_ikepolicy(body={'ikepolicy': body})
python
def create_ikepolicy(self, name, **kwargs): ''' Creates a new IKEPolicy ''' body = {'name': name} if 'phase1_negotiation_mode' in kwargs: body['phase1_negotiation_mode'] = kwargs['phase1_negotiation_mode'] if 'auth_algorithm' in kwargs: body['auth_algorithm'] = kwargs['auth_algorithm'] if 'encryption_algorithm' in kwargs: body['encryption_algorithm'] = kwargs['encryption_algorithm'] if 'pfs' in kwargs: body['pfs'] = kwargs['pfs'] if 'ike_version' in kwargs: body['ike_version'] = kwargs['ike_version'] if 'units' in kwargs: body['lifetime'] = {'units': kwargs['units']} if 'value' in kwargs: if 'lifetime' not in body: body['lifetime'] = {} body['lifetime']['value'] = kwargs['value'] return self.network_conn.create_ikepolicy(body={'ikepolicy': body})
[ "def", "create_ikepolicy", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "body", "=", "{", "'name'", ":", "name", "}", "if", "'phase1_negotiation_mode'", "in", "kwargs", ":", "body", "[", "'phase1_negotiation_mode'", "]", "=", "kwargs", "[",...
Creates a new IKEPolicy
[ "Creates", "a", "new", "IKEPolicy" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L763-L784
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_ikepolicy
def delete_ikepolicy(self, ikepolicy): ''' Deletes the specified IKEPolicy ''' ikepolicy_id = self._find_ikepolicy_id(ikepolicy) ret = self.network_conn.delete_ikepolicy(ikepolicy_id) return ret if ret else True
python
def delete_ikepolicy(self, ikepolicy): ''' Deletes the specified IKEPolicy ''' ikepolicy_id = self._find_ikepolicy_id(ikepolicy) ret = self.network_conn.delete_ikepolicy(ikepolicy_id) return ret if ret else True
[ "def", "delete_ikepolicy", "(", "self", ",", "ikepolicy", ")", ":", "ikepolicy_id", "=", "self", ".", "_find_ikepolicy_id", "(", "ikepolicy", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_ikepolicy", "(", "ikepolicy_id", ")", "return", "ret", "if"...
Deletes the specified IKEPolicy
[ "Deletes", "the", "specified", "IKEPolicy" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L786-L792
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_ipsecpolicy
def create_ipsecpolicy(self, name, **kwargs): ''' Creates a new IPsecPolicy ''' body = {'name': name} if 'transform_protocol' in kwargs: body['transform_protocol'] = kwargs['transform_protocol'] if 'auth_algorithm' in kwargs: body['auth_algorithm'] = kwargs['auth_algorithm'] if 'encapsulation_mode' in kwargs: body['encapsulation_mode'] = kwargs['encapsulation_mode'] if 'encryption_algorithm' in kwargs: body['encryption_algorithm'] = kwargs['encryption_algorithm'] if 'pfs' in kwargs: body['pfs'] = kwargs['pfs'] if 'units' in kwargs: body['lifetime'] = {'units': kwargs['units']} if 'value' in kwargs: if 'lifetime' not in body: body['lifetime'] = {} body['lifetime']['value'] = kwargs['value'] return self.network_conn.create_ipsecpolicy(body={'ipsecpolicy': body})
python
def create_ipsecpolicy(self, name, **kwargs): ''' Creates a new IPsecPolicy ''' body = {'name': name} if 'transform_protocol' in kwargs: body['transform_protocol'] = kwargs['transform_protocol'] if 'auth_algorithm' in kwargs: body['auth_algorithm'] = kwargs['auth_algorithm'] if 'encapsulation_mode' in kwargs: body['encapsulation_mode'] = kwargs['encapsulation_mode'] if 'encryption_algorithm' in kwargs: body['encryption_algorithm'] = kwargs['encryption_algorithm'] if 'pfs' in kwargs: body['pfs'] = kwargs['pfs'] if 'units' in kwargs: body['lifetime'] = {'units': kwargs['units']} if 'value' in kwargs: if 'lifetime' not in body: body['lifetime'] = {} body['lifetime']['value'] = kwargs['value'] return self.network_conn.create_ipsecpolicy(body={'ipsecpolicy': body})
[ "def", "create_ipsecpolicy", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "body", "=", "{", "'name'", ":", "name", "}", "if", "'transform_protocol'", "in", "kwargs", ":", "body", "[", "'transform_protocol'", "]", "=", "kwargs", "[", "'tra...
Creates a new IPsecPolicy
[ "Creates", "a", "new", "IPsecPolicy" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L806-L827
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_ipsecpolicy
def delete_ipsecpolicy(self, ipseecpolicy): ''' Deletes the specified IPsecPolicy ''' ipseecpolicy_id = self._find_ipsecpolicy_id(ipseecpolicy) ret = self.network_conn.delete_ipsecpolicy(ipseecpolicy_id) return ret if ret else True
python
def delete_ipsecpolicy(self, ipseecpolicy): ''' Deletes the specified IPsecPolicy ''' ipseecpolicy_id = self._find_ipsecpolicy_id(ipseecpolicy) ret = self.network_conn.delete_ipsecpolicy(ipseecpolicy_id) return ret if ret else True
[ "def", "delete_ipsecpolicy", "(", "self", ",", "ipseecpolicy", ")", ":", "ipseecpolicy_id", "=", "self", ".", "_find_ipsecpolicy_id", "(", "ipseecpolicy", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_ipsecpolicy", "(", "ipseecpolicy_id", ")", "return...
Deletes the specified IPsecPolicy
[ "Deletes", "the", "specified", "IPsecPolicy" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L829-L835
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.create_firewall_rule
def create_firewall_rule(self, protocol, action, **kwargs): ''' Create a new firlwall rule ''' body = {'protocol': protocol, 'action': action} if 'tenant_id' in kwargs: body['tenant_id'] = kwargs['tenant_id'] if 'name' in kwargs: body['name'] = kwargs['name'] if 'description' in kwargs: body['description'] = kwargs['description'] if 'ip_version' in kwargs: body['ip_version'] = kwargs['ip_version'] if 'source_ip_address' in kwargs: body['source_ip_address'] = kwargs['source_ip_address'] if 'destination_port' in kwargs: body['destination_port'] = kwargs['destination_port'] if 'shared' in kwargs: body['shared'] = kwargs['shared'] if 'enabled' in kwargs: body['enabled'] = kwargs['enabled'] return self.network_conn.create_firewall_rule(body={'firewall_rule': body})
python
def create_firewall_rule(self, protocol, action, **kwargs): ''' Create a new firlwall rule ''' body = {'protocol': protocol, 'action': action} if 'tenant_id' in kwargs: body['tenant_id'] = kwargs['tenant_id'] if 'name' in kwargs: body['name'] = kwargs['name'] if 'description' in kwargs: body['description'] = kwargs['description'] if 'ip_version' in kwargs: body['ip_version'] = kwargs['ip_version'] if 'source_ip_address' in kwargs: body['source_ip_address'] = kwargs['source_ip_address'] if 'destination_port' in kwargs: body['destination_port'] = kwargs['destination_port'] if 'shared' in kwargs: body['shared'] = kwargs['shared'] if 'enabled' in kwargs: body['enabled'] = kwargs['enabled'] return self.network_conn.create_firewall_rule(body={'firewall_rule': body})
[ "def", "create_firewall_rule", "(", "self", ",", "protocol", ",", "action", ",", "*", "*", "kwargs", ")", ":", "body", "=", "{", "'protocol'", ":", "protocol", ",", "'action'", ":", "action", "}", "if", "'tenant_id'", "in", "kwargs", ":", "body", "[", ...
Create a new firlwall rule
[ "Create", "a", "new", "firlwall", "rule" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L849-L870
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.delete_firewall_rule
def delete_firewall_rule(self, firewall_rule): ''' Deletes the specified firewall rule ''' firewall_rule_id = self._find_firewall_rule_id(firewall_rule) ret = self.network_conn.delete_firewall_rule(firewall_rule_id) return ret if ret else True
python
def delete_firewall_rule(self, firewall_rule): ''' Deletes the specified firewall rule ''' firewall_rule_id = self._find_firewall_rule_id(firewall_rule) ret = self.network_conn.delete_firewall_rule(firewall_rule_id) return ret if ret else True
[ "def", "delete_firewall_rule", "(", "self", ",", "firewall_rule", ")", ":", "firewall_rule_id", "=", "self", ".", "_find_firewall_rule_id", "(", "firewall_rule", ")", "ret", "=", "self", ".", "network_conn", ".", "delete_firewall_rule", "(", "firewall_rule_id", ")",...
Deletes the specified firewall rule
[ "Deletes", "the", "specified", "firewall", "rule" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L872-L878
train
saltstack/salt
salt/utils/openstack/neutron.py
SaltNeutron.update_firewall_rule
def update_firewall_rule(self, firewall_rule, protocol=None, action=None, name=None, description=None, ip_version=None, source_ip_address=None, destination_ip_address=None, source_port=None, destination_port=None, shared=None, enabled=None): ''' Update a firewall rule ''' body = {} if protocol: body['protocol'] = protocol if action: body['action'] = action if name: body['name'] = name if description: body['description'] = description if ip_version: body['ip_version'] = ip_version if source_ip_address: body['source_ip_address'] = source_ip_address if destination_ip_address: body['destination_ip_address'] = destination_ip_address if source_port: body['source_port'] = source_port if destination_port: body['destination_port'] = destination_port if shared: body['shared'] = shared if enabled: body['enabled'] = enabled return self.network_conn.update_firewall_rule(firewall_rule, body={'firewall_rule': body})
python
def update_firewall_rule(self, firewall_rule, protocol=None, action=None, name=None, description=None, ip_version=None, source_ip_address=None, destination_ip_address=None, source_port=None, destination_port=None, shared=None, enabled=None): ''' Update a firewall rule ''' body = {} if protocol: body['protocol'] = protocol if action: body['action'] = action if name: body['name'] = name if description: body['description'] = description if ip_version: body['ip_version'] = ip_version if source_ip_address: body['source_ip_address'] = source_ip_address if destination_ip_address: body['destination_ip_address'] = destination_ip_address if source_port: body['source_port'] = source_port if destination_port: body['destination_port'] = destination_port if shared: body['shared'] = shared if enabled: body['enabled'] = enabled return self.network_conn.update_firewall_rule(firewall_rule, body={'firewall_rule': body})
[ "def", "update_firewall_rule", "(", "self", ",", "firewall_rule", ",", "protocol", "=", "None", ",", "action", "=", "None", ",", "name", "=", "None", ",", "description", "=", "None", ",", "ip_version", "=", "None", ",", "source_ip_address", "=", "None", ",...
Update a firewall rule
[ "Update", "a", "firewall", "rule" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L880-L910
train
saltstack/salt
salt/modules/chroot.py
exist
def exist(name): ''' Return True if the chroot environment is present. ''' dev = os.path.join(name, 'dev') proc = os.path.join(name, 'proc') return all(os.path.isdir(i) for i in (name, dev, proc))
python
def exist(name): ''' Return True if the chroot environment is present. ''' dev = os.path.join(name, 'dev') proc = os.path.join(name, 'proc') return all(os.path.isdir(i) for i in (name, dev, proc))
[ "def", "exist", "(", "name", ")", ":", "dev", "=", "os", ".", "path", ".", "join", "(", "name", ",", "'dev'", ")", "proc", "=", "os", ".", "path", ".", "join", "(", "name", ",", "'proc'", ")", "return", "all", "(", "os", ".", "path", ".", "is...
Return True if the chroot environment is present.
[ "Return", "True", "if", "the", "chroot", "environment", "is", "present", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/chroot.py#L53-L59
train
saltstack/salt
salt/modules/chroot.py
create
def create(name): ''' Create a basic chroot environment. Note that this environment is not functional. The caller needs to install the minimal required binaries, including Python if chroot.call is called. name Path to the chroot environment CLI Example: .. code-block:: bash salt myminion chroot.create /chroot ''' if not exist(name): dev = os.path.join(name, 'dev') proc = os.path.join(name, 'proc') try: os.makedirs(dev, mode=0o755) os.makedirs(proc, mode=0o555) except OSError as e: log.error('Error when trying to create chroot directories: %s', e) return False return True
python
def create(name): ''' Create a basic chroot environment. Note that this environment is not functional. The caller needs to install the minimal required binaries, including Python if chroot.call is called. name Path to the chroot environment CLI Example: .. code-block:: bash salt myminion chroot.create /chroot ''' if not exist(name): dev = os.path.join(name, 'dev') proc = os.path.join(name, 'proc') try: os.makedirs(dev, mode=0o755) os.makedirs(proc, mode=0o555) except OSError as e: log.error('Error when trying to create chroot directories: %s', e) return False return True
[ "def", "create", "(", "name", ")", ":", "if", "not", "exist", "(", "name", ")", ":", "dev", "=", "os", ".", "path", ".", "join", "(", "name", ",", "'dev'", ")", "proc", "=", "os", ".", "path", ".", "join", "(", "name", ",", "'proc'", ")", "tr...
Create a basic chroot environment. Note that this environment is not functional. The caller needs to install the minimal required binaries, including Python if chroot.call is called. name Path to the chroot environment CLI Example: .. code-block:: bash salt myminion chroot.create /chroot
[ "Create", "a", "basic", "chroot", "environment", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/chroot.py#L62-L89
train
saltstack/salt
salt/modules/chroot.py
call
def call(name, function, *args, **kwargs): ''' Executes a Salt function inside a chroot environment. The chroot does not need to have Salt installed, but Python is required. name Path to the chroot environment function Salt execution module function CLI Example: .. code-block:: bash salt myminion chroot.call /chroot test.ping ''' if not function: raise CommandExecutionError('Missing function parameter') if not exist(name): raise CommandExecutionError('Chroot environment not found') # Create a temporary directory inside the chroot where we can # untar salt-thin thin_dest_path = tempfile.mkdtemp(dir=name) thin_path = __utils__['thin.gen_thin']( __opts__['cachedir'], extra_mods=__salt__['config.option']('thin_extra_mods', ''), so_mods=__salt__['config.option']('thin_so_mods', '') ) stdout = __salt__['archive.tar']('xzf', thin_path, dest=thin_dest_path) if stdout: __utils__['files.rm_rf'](thin_dest_path) return {'result': False, 'comment': stdout} chroot_path = os.path.join(os.path.sep, os.path.relpath(thin_dest_path, name)) try: safe_kwargs = clean_kwargs(**kwargs) salt_argv = [ 'python{}'.format(sys.version_info[0]), os.path.join(chroot_path, 'salt-call'), '--metadata', '--local', '--log-file', os.path.join(chroot_path, 'log'), '--cachedir', os.path.join(chroot_path, 'cache'), '--out', 'json', '-l', 'quiet', '--', function ] + list(args) + ['{}={}'.format(k, v) for (k, v) in safe_kwargs] ret = __salt__['cmd.run_chroot'](name, [str(x) for x in salt_argv]) if ret['retcode'] != EX_OK: raise CommandExecutionError(ret['stderr']) # Process "real" result in stdout try: data = __utils__['json.find_json'](ret['stdout']) local = data.get('local', data) if isinstance(local, dict) and 'retcode' in local: __context__['retcode'] = local['retcode'] return local.get('return', data) except ValueError: return { 'result': False, 'comment': "Can't parse container command output" } finally: __utils__['files.rm_rf'](thin_dest_path)
python
def call(name, function, *args, **kwargs): ''' Executes a Salt function inside a chroot environment. The chroot does not need to have Salt installed, but Python is required. name Path to the chroot environment function Salt execution module function CLI Example: .. code-block:: bash salt myminion chroot.call /chroot test.ping ''' if not function: raise CommandExecutionError('Missing function parameter') if not exist(name): raise CommandExecutionError('Chroot environment not found') # Create a temporary directory inside the chroot where we can # untar salt-thin thin_dest_path = tempfile.mkdtemp(dir=name) thin_path = __utils__['thin.gen_thin']( __opts__['cachedir'], extra_mods=__salt__['config.option']('thin_extra_mods', ''), so_mods=__salt__['config.option']('thin_so_mods', '') ) stdout = __salt__['archive.tar']('xzf', thin_path, dest=thin_dest_path) if stdout: __utils__['files.rm_rf'](thin_dest_path) return {'result': False, 'comment': stdout} chroot_path = os.path.join(os.path.sep, os.path.relpath(thin_dest_path, name)) try: safe_kwargs = clean_kwargs(**kwargs) salt_argv = [ 'python{}'.format(sys.version_info[0]), os.path.join(chroot_path, 'salt-call'), '--metadata', '--local', '--log-file', os.path.join(chroot_path, 'log'), '--cachedir', os.path.join(chroot_path, 'cache'), '--out', 'json', '-l', 'quiet', '--', function ] + list(args) + ['{}={}'.format(k, v) for (k, v) in safe_kwargs] ret = __salt__['cmd.run_chroot'](name, [str(x) for x in salt_argv]) if ret['retcode'] != EX_OK: raise CommandExecutionError(ret['stderr']) # Process "real" result in stdout try: data = __utils__['json.find_json'](ret['stdout']) local = data.get('local', data) if isinstance(local, dict) and 'retcode' in local: __context__['retcode'] = local['retcode'] return local.get('return', data) except ValueError: return { 'result': False, 'comment': "Can't parse container command output" } finally: __utils__['files.rm_rf'](thin_dest_path)
[ "def", "call", "(", "name", ",", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "function", ":", "raise", "CommandExecutionError", "(", "'Missing function parameter'", ")", "if", "not", "exist", "(", "name", ")", ":", "rais...
Executes a Salt function inside a chroot environment. The chroot does not need to have Salt installed, but Python is required. name Path to the chroot environment function Salt execution module function CLI Example: .. code-block:: bash salt myminion chroot.call /chroot test.ping
[ "Executes", "a", "Salt", "function", "inside", "a", "chroot", "environment", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/chroot.py#L92-L165
train
saltstack/salt
salt/thorium/file.py
save
def save(name, filter=False): ''' Save the register to <salt cachedir>/thorium/saves/<name>, or to an absolute path. If an absolute path is specified, then the directory will be created non-recursively if it doesn't exist. USAGE: .. code-block:: yaml foo: file.save /tmp/foo: file.save ''' ret = {'name': name, 'changes': {}, 'comment': '', 'result': True} if name.startswith('/'): tgt_dir = os.path.dirname(name) fn_ = name else: tgt_dir = os.path.join(__opts__['cachedir'], 'thorium', 'saves') fn_ = os.path.join(tgt_dir, name) if not os.path.isdir(tgt_dir): os.makedirs(tgt_dir) with salt.utils.files.fopen(fn_, 'w+') as fp_: if filter is True: salt.utils.json.dump(salt.utils.data.simple_types_filter(__reg__), fp_) else: salt.utils.json.dump(__reg__, fp_) return ret
python
def save(name, filter=False): ''' Save the register to <salt cachedir>/thorium/saves/<name>, or to an absolute path. If an absolute path is specified, then the directory will be created non-recursively if it doesn't exist. USAGE: .. code-block:: yaml foo: file.save /tmp/foo: file.save ''' ret = {'name': name, 'changes': {}, 'comment': '', 'result': True} if name.startswith('/'): tgt_dir = os.path.dirname(name) fn_ = name else: tgt_dir = os.path.join(__opts__['cachedir'], 'thorium', 'saves') fn_ = os.path.join(tgt_dir, name) if not os.path.isdir(tgt_dir): os.makedirs(tgt_dir) with salt.utils.files.fopen(fn_, 'w+') as fp_: if filter is True: salt.utils.json.dump(salt.utils.data.simple_types_filter(__reg__), fp_) else: salt.utils.json.dump(__reg__, fp_) return ret
[ "def", "save", "(", "name", ",", "filter", "=", "False", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "''", ",", "'result'", ":", "True", "}", "if", "name", ".", "startswith", "(", "'/'...
Save the register to <salt cachedir>/thorium/saves/<name>, or to an absolute path. If an absolute path is specified, then the directory will be created non-recursively if it doesn't exist. USAGE: .. code-block:: yaml foo: file.save /tmp/foo: file.save
[ "Save", "the", "register", "to", "<salt", "cachedir", ">", "/", "thorium", "/", "saves", "/", "<name", ">", "or", "to", "an", "absolute", "path", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/file.py#L51-L86
train
saltstack/salt
salt/fileserver/roots.py
find_file
def find_file(path, saltenv='base', **kwargs): ''' Search the environment for the relative path. ''' if 'env' in kwargs: # "env" is not supported; Use "saltenv". kwargs.pop('env') path = os.path.normpath(path) fnd = {'path': '', 'rel': ''} if os.path.isabs(path): return fnd if saltenv not in __opts__['file_roots']: if '__env__' in __opts__['file_roots']: log.debug("salt environment '%s' maps to __env__ file_roots directory", saltenv) saltenv = '__env__' else: return fnd def _add_file_stat(fnd): ''' Stat the file and, assuming no errors were found, convert the stat result to a list of values and add to the return dict. Converting the stat result to a list, the elements of the list correspond to the following stat_result params: 0 => st_mode=33188 1 => st_ino=10227377 2 => st_dev=65026 3 => st_nlink=1 4 => st_uid=1000 5 => st_gid=1000 6 => st_size=1056233 7 => st_atime=1468284229 8 => st_mtime=1456338235 9 => st_ctime=1456338235 ''' try: fnd['stat'] = list(os.stat(fnd['path'])) except Exception: pass return fnd if 'index' in kwargs: try: root = __opts__['file_roots'][saltenv][int(kwargs['index'])] except IndexError: # An invalid index was passed return fnd except ValueError: # An invalid index option was passed return fnd full = os.path.join(root, path) if os.path.isfile(full) and not salt.fileserver.is_file_ignored(__opts__, full): fnd['path'] = full fnd['rel'] = path return _add_file_stat(fnd) return fnd for root in __opts__['file_roots'][saltenv]: full = os.path.join(root, path) if os.path.isfile(full) and not salt.fileserver.is_file_ignored(__opts__, full): fnd['path'] = full fnd['rel'] = path return _add_file_stat(fnd) return fnd
python
def find_file(path, saltenv='base', **kwargs): ''' Search the environment for the relative path. ''' if 'env' in kwargs: # "env" is not supported; Use "saltenv". kwargs.pop('env') path = os.path.normpath(path) fnd = {'path': '', 'rel': ''} if os.path.isabs(path): return fnd if saltenv not in __opts__['file_roots']: if '__env__' in __opts__['file_roots']: log.debug("salt environment '%s' maps to __env__ file_roots directory", saltenv) saltenv = '__env__' else: return fnd def _add_file_stat(fnd): ''' Stat the file and, assuming no errors were found, convert the stat result to a list of values and add to the return dict. Converting the stat result to a list, the elements of the list correspond to the following stat_result params: 0 => st_mode=33188 1 => st_ino=10227377 2 => st_dev=65026 3 => st_nlink=1 4 => st_uid=1000 5 => st_gid=1000 6 => st_size=1056233 7 => st_atime=1468284229 8 => st_mtime=1456338235 9 => st_ctime=1456338235 ''' try: fnd['stat'] = list(os.stat(fnd['path'])) except Exception: pass return fnd if 'index' in kwargs: try: root = __opts__['file_roots'][saltenv][int(kwargs['index'])] except IndexError: # An invalid index was passed return fnd except ValueError: # An invalid index option was passed return fnd full = os.path.join(root, path) if os.path.isfile(full) and not salt.fileserver.is_file_ignored(__opts__, full): fnd['path'] = full fnd['rel'] = path return _add_file_stat(fnd) return fnd for root in __opts__['file_roots'][saltenv]: full = os.path.join(root, path) if os.path.isfile(full) and not salt.fileserver.is_file_ignored(__opts__, full): fnd['path'] = full fnd['rel'] = path return _add_file_stat(fnd) return fnd
[ "def", "find_file", "(", "path", ",", "saltenv", "=", "'base'", ",", "*", "*", "kwargs", ")", ":", "if", "'env'", "in", "kwargs", ":", "# \"env\" is not supported; Use \"saltenv\".", "kwargs", ".", "pop", "(", "'env'", ")", "path", "=", "os", ".", "path", ...
Search the environment for the relative path.
[ "Search", "the", "environment", "for", "the", "relative", "path", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/roots.py#L40-L106
train
saltstack/salt
salt/fileserver/roots.py
serve_file
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 ret if not fnd['path']: return ret ret['dest'] = fnd['rel'] gzip = load.get('gzip', None) fpath = os.path.normpath(fnd['path']) with salt.utils.files.fopen(fpath, 'rb') as fp_: fp_.seek(load['loc']) data = fp_.read(__opts__['file_buffer_size']) if gzip and data: data = salt.utils.gzip_util.compress(data, gzip) ret['gzip'] = gzip ret['data'] = data return ret
python
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 ret if not fnd['path']: return ret ret['dest'] = fnd['rel'] gzip = load.get('gzip', None) fpath = os.path.normpath(fnd['path']) with salt.utils.files.fopen(fpath, 'rb') as fp_: fp_.seek(load['loc']) data = fp_.read(__opts__['file_buffer_size']) if gzip and data: data = salt.utils.gzip_util.compress(data, gzip) ret['gzip'] = gzip ret['data'] = data return ret
[ "def", "serve_file", "(", "load", ",", "fnd", ")", ":", "if", "'env'", "in", "load", ":", "# \"env\" is not supported; Use \"saltenv\".", "load", ".", "pop", "(", "'env'", ")", "ret", "=", "{", "'data'", ":", "''", ",", "'dest'", ":", "''", "}", "if", ...
Return a chunk from a file based on the data received
[ "Return", "a", "chunk", "from", "a", "file", "based", "on", "the", "data", "received" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/roots.py#L116-L140
train