repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
softlayer/softlayer-python
SoftLayer/managers/metadata.py
MetadataManager.get
def get(self, name, param=None): """Retreive a metadata attribute. :param string name: name of the attribute to retrieve. See `attribs` :param param: Required parameter for some attributes """ if name not in self.attribs: raise exceptions.SoftLayerError('Unknown metadata attribute.') call_details = self.attribs[name] if call_details.get('param_req'): if not param: raise exceptions.SoftLayerError( 'Parameter required to get this attribute.') params = tuple() if param is not None: params = (param,) try: return self.client.call('Resource_Metadata', self.attribs[name]['call'], *params) except exceptions.SoftLayerAPIError as ex: if ex.faultCode == 404: return None raise ex
python
def get(self, name, param=None): """Retreive a metadata attribute. :param string name: name of the attribute to retrieve. See `attribs` :param param: Required parameter for some attributes """ if name not in self.attribs: raise exceptions.SoftLayerError('Unknown metadata attribute.') call_details = self.attribs[name] if call_details.get('param_req'): if not param: raise exceptions.SoftLayerError( 'Parameter required to get this attribute.') params = tuple() if param is not None: params = (param,) try: return self.client.call('Resource_Metadata', self.attribs[name]['call'], *params) except exceptions.SoftLayerAPIError as ex: if ex.faultCode == 404: return None raise ex
[ "def", "get", "(", "self", ",", "name", ",", "param", "=", "None", ")", ":", "if", "name", "not", "in", "self", ".", "attribs", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "'Unknown metadata attribute.'", ")", "call_details", "=", "self", ".", "attribs", "[", "name", "]", "if", "call_details", ".", "get", "(", "'param_req'", ")", ":", "if", "not", "param", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "'Parameter required to get this attribute.'", ")", "params", "=", "tuple", "(", ")", "if", "param", "is", "not", "None", ":", "params", "=", "(", "param", ",", ")", "try", ":", "return", "self", ".", "client", ".", "call", "(", "'Resource_Metadata'", ",", "self", ".", "attribs", "[", "name", "]", "[", "'call'", "]", ",", "*", "params", ")", "except", "exceptions", ".", "SoftLayerAPIError", "as", "ex", ":", "if", "ex", ".", "faultCode", "==", "404", ":", "return", "None", "raise", "ex" ]
Retreive a metadata attribute. :param string name: name of the attribute to retrieve. See `attribs` :param param: Required parameter for some attributes
[ "Retreive", "a", "metadata", "attribute", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/metadata.py#L73-L100
train
234,500
softlayer/softlayer-python
SoftLayer/managers/metadata.py
MetadataManager._get_network
def _get_network(self, kind, router=True, vlans=True, vlan_ids=True): """Wrapper for getting details about networks. :param string kind: network kind. Typically 'public' or 'private' :param boolean router: flag to include router information :param boolean vlans: flag to include vlan information :param boolean vlan_ids: flag to include vlan_ids """ network = {} macs = self.get('%s_mac' % kind) network['mac_addresses'] = macs if len(macs) == 0: return network if router: network['router'] = self.get('router', macs[0]) if vlans: network['vlans'] = self.get('vlans', macs[0]) if vlan_ids: network['vlan_ids'] = self.get('vlan_ids', macs[0]) return network
python
def _get_network(self, kind, router=True, vlans=True, vlan_ids=True): """Wrapper for getting details about networks. :param string kind: network kind. Typically 'public' or 'private' :param boolean router: flag to include router information :param boolean vlans: flag to include vlan information :param boolean vlan_ids: flag to include vlan_ids """ network = {} macs = self.get('%s_mac' % kind) network['mac_addresses'] = macs if len(macs) == 0: return network if router: network['router'] = self.get('router', macs[0]) if vlans: network['vlans'] = self.get('vlans', macs[0]) if vlan_ids: network['vlan_ids'] = self.get('vlan_ids', macs[0]) return network
[ "def", "_get_network", "(", "self", ",", "kind", ",", "router", "=", "True", ",", "vlans", "=", "True", ",", "vlan_ids", "=", "True", ")", ":", "network", "=", "{", "}", "macs", "=", "self", ".", "get", "(", "'%s_mac'", "%", "kind", ")", "network", "[", "'mac_addresses'", "]", "=", "macs", "if", "len", "(", "macs", ")", "==", "0", ":", "return", "network", "if", "router", ":", "network", "[", "'router'", "]", "=", "self", ".", "get", "(", "'router'", ",", "macs", "[", "0", "]", ")", "if", "vlans", ":", "network", "[", "'vlans'", "]", "=", "self", ".", "get", "(", "'vlans'", ",", "macs", "[", "0", "]", ")", "if", "vlan_ids", ":", "network", "[", "'vlan_ids'", "]", "=", "self", ".", "get", "(", "'vlan_ids'", ",", "macs", "[", "0", "]", ")", "return", "network" ]
Wrapper for getting details about networks. :param string kind: network kind. Typically 'public' or 'private' :param boolean router: flag to include router information :param boolean vlans: flag to include vlan information :param boolean vlan_ids: flag to include vlan_ids
[ "Wrapper", "for", "getting", "details", "about", "networks", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/metadata.py#L102-L127
train
234,501
softlayer/softlayer-python
SoftLayer/shell/cmd_env.py
cli
def cli(env): """Print environment variables.""" filtered_vars = dict([(k, v) for k, v in env.vars.items() if not k.startswith('_')]) env.fout(formatting.iter_to_table(filtered_vars))
python
def cli(env): """Print environment variables.""" filtered_vars = dict([(k, v) for k, v in env.vars.items() if not k.startswith('_')]) env.fout(formatting.iter_to_table(filtered_vars))
[ "def", "cli", "(", "env", ")", ":", "filtered_vars", "=", "dict", "(", "[", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "env", ".", "vars", ".", "items", "(", ")", "if", "not", "k", ".", "startswith", "(", "'_'", ")", "]", ")", "env", ".", "fout", "(", "formatting", ".", "iter_to_table", "(", "filtered_vars", ")", ")" ]
Print environment variables.
[ "Print", "environment", "variables", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/shell/cmd_env.py#L12-L17
train
234,502
softlayer/softlayer-python
SoftLayer/CLI/block/snapshot/restore.py
cli
def cli(env, volume_id, snapshot_id): """Restore block volume using a given snapshot""" block_manager = SoftLayer.BlockStorageManager(env.client) success = block_manager.restore_from_snapshot(volume_id, snapshot_id) if success: click.echo('Block volume %s is being restored using snapshot %s' % (volume_id, snapshot_id))
python
def cli(env, volume_id, snapshot_id): """Restore block volume using a given snapshot""" block_manager = SoftLayer.BlockStorageManager(env.client) success = block_manager.restore_from_snapshot(volume_id, snapshot_id) if success: click.echo('Block volume %s is being restored using snapshot %s' % (volume_id, snapshot_id))
[ "def", "cli", "(", "env", ",", "volume_id", ",", "snapshot_id", ")", ":", "block_manager", "=", "SoftLayer", ".", "BlockStorageManager", "(", "env", ".", "client", ")", "success", "=", "block_manager", ".", "restore_from_snapshot", "(", "volume_id", ",", "snapshot_id", ")", "if", "success", ":", "click", ".", "echo", "(", "'Block volume %s is being restored using snapshot %s'", "%", "(", "volume_id", ",", "snapshot_id", ")", ")" ]
Restore block volume using a given snapshot
[ "Restore", "block", "volume", "using", "a", "given", "snapshot" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/block/snapshot/restore.py#L15-L22
train
234,503
softlayer/softlayer-python
SoftLayer/CLI/ssl/add.py
cli
def cli(env, crt, csr, icc, key, notes): """Add and upload SSL certificate details.""" template = { 'intermediateCertificate': '', 'certificateSigningRequest': '', 'notes': notes, } template['certificate'] = open(crt).read() template['privateKey'] = open(key).read() if csr: body = open(csr).read() template['certificateSigningRequest'] = body if icc: body = open(icc).read() template['intermediateCertificate'] = body manager = SoftLayer.SSLManager(env.client) manager.add_certificate(template)
python
def cli(env, crt, csr, icc, key, notes): """Add and upload SSL certificate details.""" template = { 'intermediateCertificate': '', 'certificateSigningRequest': '', 'notes': notes, } template['certificate'] = open(crt).read() template['privateKey'] = open(key).read() if csr: body = open(csr).read() template['certificateSigningRequest'] = body if icc: body = open(icc).read() template['intermediateCertificate'] = body manager = SoftLayer.SSLManager(env.client) manager.add_certificate(template)
[ "def", "cli", "(", "env", ",", "crt", ",", "csr", ",", "icc", ",", "key", ",", "notes", ")", ":", "template", "=", "{", "'intermediateCertificate'", ":", "''", ",", "'certificateSigningRequest'", ":", "''", ",", "'notes'", ":", "notes", ",", "}", "template", "[", "'certificate'", "]", "=", "open", "(", "crt", ")", ".", "read", "(", ")", "template", "[", "'privateKey'", "]", "=", "open", "(", "key", ")", ".", "read", "(", ")", "if", "csr", ":", "body", "=", "open", "(", "csr", ")", ".", "read", "(", ")", "template", "[", "'certificateSigningRequest'", "]", "=", "body", "if", "icc", ":", "body", "=", "open", "(", "icc", ")", ".", "read", "(", ")", "template", "[", "'intermediateCertificate'", "]", "=", "body", "manager", "=", "SoftLayer", ".", "SSLManager", "(", "env", ".", "client", ")", "manager", ".", "add_certificate", "(", "template", ")" ]
Add and upload SSL certificate details.
[ "Add", "and", "upload", "SSL", "certificate", "details", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ssl/add.py#L23-L42
train
234,504
softlayer/softlayer-python
SoftLayer/CLI/image/export.py
cli
def cli(env, identifier, uri, ibm_api_key): """Export an image to object storage. The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage """ image_mgr = SoftLayer.ImageManager(env.client) image_id = helpers.resolve_id(image_mgr.resolve_ids, identifier, 'image') result = image_mgr.export_image_to_uri(image_id, uri, ibm_api_key) if not result: raise exceptions.CLIAbort("Failed to export Image")
python
def cli(env, identifier, uri, ibm_api_key): """Export an image to object storage. The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage """ image_mgr = SoftLayer.ImageManager(env.client) image_id = helpers.resolve_id(image_mgr.resolve_ids, identifier, 'image') result = image_mgr.export_image_to_uri(image_id, uri, ibm_api_key) if not result: raise exceptions.CLIAbort("Failed to export Image")
[ "def", "cli", "(", "env", ",", "identifier", ",", "uri", ",", "ibm_api_key", ")", ":", "image_mgr", "=", "SoftLayer", ".", "ImageManager", "(", "env", ".", "client", ")", "image_id", "=", "helpers", ".", "resolve_id", "(", "image_mgr", ".", "resolve_ids", ",", "identifier", ",", "'image'", ")", "result", "=", "image_mgr", ".", "export_image_to_uri", "(", "image_id", ",", "uri", ",", "ibm_api_key", ")", "if", "not", "result", ":", "raise", "exceptions", ".", "CLIAbort", "(", "\"Failed to export Image\"", ")" ]
Export an image to object storage. The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage
[ "Export", "an", "image", "to", "object", "storage", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/image/export.py#L22-L36
train
234,505
softlayer/softlayer-python
SoftLayer/CLI/virt/__init__.py
MemoryType.convert
def convert(self, value, param, ctx): # pylint: disable=inconsistent-return-statements """Validate memory argument. Returns the memory value in megabytes.""" matches = MEMORY_RE.match(value.lower()) if matches is None: self.fail('%s is not a valid value for memory amount' % value, param, ctx) amount_str, unit = matches.groups() amount = int(amount_str) if unit in [None, 'm', 'mb']: # Assume the user intends gigabytes if they specify a number < 1024 if amount < 1024: return amount * 1024 else: if amount % 1024 != 0: self.fail('%s is not an integer that is divisable by 1024' % value, param, ctx) return amount elif unit in ['g', 'gb']: return amount * 1024
python
def convert(self, value, param, ctx): # pylint: disable=inconsistent-return-statements """Validate memory argument. Returns the memory value in megabytes.""" matches = MEMORY_RE.match(value.lower()) if matches is None: self.fail('%s is not a valid value for memory amount' % value, param, ctx) amount_str, unit = matches.groups() amount = int(amount_str) if unit in [None, 'm', 'mb']: # Assume the user intends gigabytes if they specify a number < 1024 if amount < 1024: return amount * 1024 else: if amount % 1024 != 0: self.fail('%s is not an integer that is divisable by 1024' % value, param, ctx) return amount elif unit in ['g', 'gb']: return amount * 1024
[ "def", "convert", "(", "self", ",", "value", ",", "param", ",", "ctx", ")", ":", "# pylint: disable=inconsistent-return-statements", "matches", "=", "MEMORY_RE", ".", "match", "(", "value", ".", "lower", "(", ")", ")", "if", "matches", "is", "None", ":", "self", ".", "fail", "(", "'%s is not a valid value for memory amount'", "%", "value", ",", "param", ",", "ctx", ")", "amount_str", ",", "unit", "=", "matches", ".", "groups", "(", ")", "amount", "=", "int", "(", "amount_str", ")", "if", "unit", "in", "[", "None", ",", "'m'", ",", "'mb'", "]", ":", "# Assume the user intends gigabytes if they specify a number < 1024", "if", "amount", "<", "1024", ":", "return", "amount", "*", "1024", "else", ":", "if", "amount", "%", "1024", "!=", "0", ":", "self", ".", "fail", "(", "'%s is not an integer that is divisable by 1024'", "%", "value", ",", "param", ",", "ctx", ")", "return", "amount", "elif", "unit", "in", "[", "'g'", ",", "'gb'", "]", ":", "return", "amount", "*", "1024" ]
Validate memory argument. Returns the memory value in megabytes.
[ "Validate", "memory", "argument", ".", "Returns", "the", "memory", "value", "in", "megabytes", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/__init__.py#L15-L31
train
234,506
softlayer/softlayer-python
SoftLayer/CLI/nas/credentials.py
cli
def cli(env, identifier): """List NAS account credentials.""" nw_mgr = SoftLayer.NetworkManager(env.client) result = nw_mgr.get_nas_credentials(identifier) table = formatting.Table(['username', 'password']) table.add_row([result.get('username', 'None'), result.get('password', 'None')]) env.fout(table)
python
def cli(env, identifier): """List NAS account credentials.""" nw_mgr = SoftLayer.NetworkManager(env.client) result = nw_mgr.get_nas_credentials(identifier) table = formatting.Table(['username', 'password']) table.add_row([result.get('username', 'None'), result.get('password', 'None')]) env.fout(table)
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "nw_mgr", "=", "SoftLayer", ".", "NetworkManager", "(", "env", ".", "client", ")", "result", "=", "nw_mgr", ".", "get_nas_credentials", "(", "identifier", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'username'", ",", "'password'", "]", ")", "table", ".", "add_row", "(", "[", "result", ".", "get", "(", "'username'", ",", "'None'", ")", ",", "result", ".", "get", "(", "'password'", ",", "'None'", ")", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List NAS account credentials.
[ "List", "NAS", "account", "credentials", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/nas/credentials.py#L14-L22
train
234,507
softlayer/softlayer-python
SoftLayer/CLI/firewall/detail.py
cli
def cli(env, identifier): """Detail firewall.""" mgr = SoftLayer.FirewallManager(env.client) firewall_type, firewall_id = firewall.parse_id(identifier) if firewall_type == 'vlan': rules = mgr.get_dedicated_fwl_rules(firewall_id) else: rules = mgr.get_standard_fwl_rules(firewall_id) env.fout(get_rules_table(rules))
python
def cli(env, identifier): """Detail firewall.""" mgr = SoftLayer.FirewallManager(env.client) firewall_type, firewall_id = firewall.parse_id(identifier) if firewall_type == 'vlan': rules = mgr.get_dedicated_fwl_rules(firewall_id) else: rules = mgr.get_standard_fwl_rules(firewall_id) env.fout(get_rules_table(rules))
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "mgr", "=", "SoftLayer", ".", "FirewallManager", "(", "env", ".", "client", ")", "firewall_type", ",", "firewall_id", "=", "firewall", ".", "parse_id", "(", "identifier", ")", "if", "firewall_type", "==", "'vlan'", ":", "rules", "=", "mgr", ".", "get_dedicated_fwl_rules", "(", "firewall_id", ")", "else", ":", "rules", "=", "mgr", ".", "get_standard_fwl_rules", "(", "firewall_id", ")", "env", ".", "fout", "(", "get_rules_table", "(", "rules", ")", ")" ]
Detail firewall.
[ "Detail", "firewall", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/firewall/detail.py#L16-L27
train
234,508
softlayer/softlayer-python
SoftLayer/CLI/firewall/detail.py
get_rules_table
def get_rules_table(rules): """Helper to format the rules into a table. :param list rules: A list containing the rules of the firewall :returns: a formatted table of the firewall rules """ table = formatting.Table(['#', 'action', 'protocol', 'src_ip', 'src_mask', 'dest', 'dest_mask']) table.sortby = '#' for rule in rules: table.add_row([ rule['orderValue'], rule['action'], rule['protocol'], rule['sourceIpAddress'], utils.lookup(rule, 'sourceIpSubnetMask'), '%s:%s-%s' % (rule['destinationIpAddress'], rule['destinationPortRangeStart'], rule['destinationPortRangeEnd']), utils.lookup(rule, 'destinationIpSubnetMask')]) return table
python
def get_rules_table(rules): """Helper to format the rules into a table. :param list rules: A list containing the rules of the firewall :returns: a formatted table of the firewall rules """ table = formatting.Table(['#', 'action', 'protocol', 'src_ip', 'src_mask', 'dest', 'dest_mask']) table.sortby = '#' for rule in rules: table.add_row([ rule['orderValue'], rule['action'], rule['protocol'], rule['sourceIpAddress'], utils.lookup(rule, 'sourceIpSubnetMask'), '%s:%s-%s' % (rule['destinationIpAddress'], rule['destinationPortRangeStart'], rule['destinationPortRangeEnd']), utils.lookup(rule, 'destinationIpSubnetMask')]) return table
[ "def", "get_rules_table", "(", "rules", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'#'", ",", "'action'", ",", "'protocol'", ",", "'src_ip'", ",", "'src_mask'", ",", "'dest'", ",", "'dest_mask'", "]", ")", "table", ".", "sortby", "=", "'#'", "for", "rule", "in", "rules", ":", "table", ".", "add_row", "(", "[", "rule", "[", "'orderValue'", "]", ",", "rule", "[", "'action'", "]", ",", "rule", "[", "'protocol'", "]", ",", "rule", "[", "'sourceIpAddress'", "]", ",", "utils", ".", "lookup", "(", "rule", ",", "'sourceIpSubnetMask'", ")", ",", "'%s:%s-%s'", "%", "(", "rule", "[", "'destinationIpAddress'", "]", ",", "rule", "[", "'destinationPortRangeStart'", "]", ",", "rule", "[", "'destinationPortRangeEnd'", "]", ")", ",", "utils", ".", "lookup", "(", "rule", ",", "'destinationIpSubnetMask'", ")", "]", ")", "return", "table" ]
Helper to format the rules into a table. :param list rules: A list containing the rules of the firewall :returns: a formatted table of the firewall rules
[ "Helper", "to", "format", "the", "rules", "into", "a", "table", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/firewall/detail.py#L30-L50
train
234,509
softlayer/softlayer-python
SoftLayer/managers/sshkey.py
SshKeyManager.add_key
def add_key(self, key, label, notes=None): """Adds a new SSH key to the account. :param string key: The SSH key to add :param string label: The label for the key :param string notes: Additional notes for the key :returns: A dictionary of the new key's information. """ order = { 'key': key, 'label': label, 'notes': notes, } return self.sshkey.createObject(order)
python
def add_key(self, key, label, notes=None): """Adds a new SSH key to the account. :param string key: The SSH key to add :param string label: The label for the key :param string notes: Additional notes for the key :returns: A dictionary of the new key's information. """ order = { 'key': key, 'label': label, 'notes': notes, } return self.sshkey.createObject(order)
[ "def", "add_key", "(", "self", ",", "key", ",", "label", ",", "notes", "=", "None", ")", ":", "order", "=", "{", "'key'", ":", "key", ",", "'label'", ":", "label", ",", "'notes'", ":", "notes", ",", "}", "return", "self", ".", "sshkey", ".", "createObject", "(", "order", ")" ]
Adds a new SSH key to the account. :param string key: The SSH key to add :param string label: The label for the key :param string notes: Additional notes for the key :returns: A dictionary of the new key's information.
[ "Adds", "a", "new", "SSH", "key", "to", "the", "account", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/sshkey.py#L26-L40
train
234,510
softlayer/softlayer-python
SoftLayer/managers/sshkey.py
SshKeyManager.edit_key
def edit_key(self, key_id, label=None, notes=None): """Edits information about an SSH key. :param int key_id: The ID of the key to edit :param string label: The new label for the key :param string notes: Notes to set or change on the key :returns: A Boolean indicating success or failure """ data = {} if label: data['label'] = label if notes: data['notes'] = notes return self.sshkey.editObject(data, id=key_id)
python
def edit_key(self, key_id, label=None, notes=None): """Edits information about an SSH key. :param int key_id: The ID of the key to edit :param string label: The new label for the key :param string notes: Notes to set or change on the key :returns: A Boolean indicating success or failure """ data = {} if label: data['label'] = label if notes: data['notes'] = notes return self.sshkey.editObject(data, id=key_id)
[ "def", "edit_key", "(", "self", ",", "key_id", ",", "label", "=", "None", ",", "notes", "=", "None", ")", ":", "data", "=", "{", "}", "if", "label", ":", "data", "[", "'label'", "]", "=", "label", "if", "notes", ":", "data", "[", "'notes'", "]", "=", "notes", "return", "self", ".", "sshkey", ".", "editObject", "(", "data", ",", "id", "=", "key_id", ")" ]
Edits information about an SSH key. :param int key_id: The ID of the key to edit :param string label: The new label for the key :param string notes: Notes to set or change on the key :returns: A Boolean indicating success or failure
[ "Edits", "information", "about", "an", "SSH", "key", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/sshkey.py#L50-L66
train
234,511
softlayer/softlayer-python
SoftLayer/managers/sshkey.py
SshKeyManager.list_keys
def list_keys(self, label=None): """Lists all SSH keys on the account. :param string label: Filter list based on SSH key label :returns: A list of dictionaries with information about each key """ _filter = utils.NestedDict({}) if label: _filter['sshKeys']['label'] = utils.query_filter(label) return self.client['Account'].getSshKeys(filter=_filter.to_dict())
python
def list_keys(self, label=None): """Lists all SSH keys on the account. :param string label: Filter list based on SSH key label :returns: A list of dictionaries with information about each key """ _filter = utils.NestedDict({}) if label: _filter['sshKeys']['label'] = utils.query_filter(label) return self.client['Account'].getSshKeys(filter=_filter.to_dict())
[ "def", "list_keys", "(", "self", ",", "label", "=", "None", ")", ":", "_filter", "=", "utils", ".", "NestedDict", "(", "{", "}", ")", "if", "label", ":", "_filter", "[", "'sshKeys'", "]", "[", "'label'", "]", "=", "utils", ".", "query_filter", "(", "label", ")", "return", "self", ".", "client", "[", "'Account'", "]", ".", "getSshKeys", "(", "filter", "=", "_filter", ".", "to_dict", "(", ")", ")" ]
Lists all SSH keys on the account. :param string label: Filter list based on SSH key label :returns: A list of dictionaries with information about each key
[ "Lists", "all", "SSH", "keys", "on", "the", "account", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/sshkey.py#L76-L86
train
234,512
softlayer/softlayer-python
SoftLayer/managers/sshkey.py
SshKeyManager._get_ids_from_label
def _get_ids_from_label(self, label): """Return sshkey IDs which match the given label.""" keys = self.list_keys() results = [] for key in keys: if key['label'] == label: results.append(key['id']) return results
python
def _get_ids_from_label(self, label): """Return sshkey IDs which match the given label.""" keys = self.list_keys() results = [] for key in keys: if key['label'] == label: results.append(key['id']) return results
[ "def", "_get_ids_from_label", "(", "self", ",", "label", ")", ":", "keys", "=", "self", ".", "list_keys", "(", ")", "results", "=", "[", "]", "for", "key", "in", "keys", ":", "if", "key", "[", "'label'", "]", "==", "label", ":", "results", ".", "append", "(", "key", "[", "'id'", "]", ")", "return", "results" ]
Return sshkey IDs which match the given label.
[ "Return", "sshkey", "IDs", "which", "match", "the", "given", "label", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/sshkey.py#L88-L95
train
234,513
softlayer/softlayer-python
SoftLayer/CLI/ssl/download.py
cli
def cli(env, identifier): """Download SSL certificate and key file.""" manager = SoftLayer.SSLManager(env.client) certificate = manager.get_certificate(identifier) write_cert(certificate['commonName'] + '.crt', certificate['certificate']) write_cert(certificate['commonName'] + '.key', certificate['privateKey']) if 'intermediateCertificate' in certificate: write_cert(certificate['commonName'] + '.icc', certificate['intermediateCertificate']) if 'certificateSigningRequest' in certificate: write_cert(certificate['commonName'] + '.csr', certificate['certificateSigningRequest'])
python
def cli(env, identifier): """Download SSL certificate and key file.""" manager = SoftLayer.SSLManager(env.client) certificate = manager.get_certificate(identifier) write_cert(certificate['commonName'] + '.crt', certificate['certificate']) write_cert(certificate['commonName'] + '.key', certificate['privateKey']) if 'intermediateCertificate' in certificate: write_cert(certificate['commonName'] + '.icc', certificate['intermediateCertificate']) if 'certificateSigningRequest' in certificate: write_cert(certificate['commonName'] + '.csr', certificate['certificateSigningRequest'])
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "manager", "=", "SoftLayer", ".", "SSLManager", "(", "env", ".", "client", ")", "certificate", "=", "manager", ".", "get_certificate", "(", "identifier", ")", "write_cert", "(", "certificate", "[", "'commonName'", "]", "+", "'.crt'", ",", "certificate", "[", "'certificate'", "]", ")", "write_cert", "(", "certificate", "[", "'commonName'", "]", "+", "'.key'", ",", "certificate", "[", "'privateKey'", "]", ")", "if", "'intermediateCertificate'", "in", "certificate", ":", "write_cert", "(", "certificate", "[", "'commonName'", "]", "+", "'.icc'", ",", "certificate", "[", "'intermediateCertificate'", "]", ")", "if", "'certificateSigningRequest'", "in", "certificate", ":", "write_cert", "(", "certificate", "[", "'commonName'", "]", "+", "'.csr'", ",", "certificate", "[", "'certificateSigningRequest'", "]", ")" ]
Download SSL certificate and key file.
[ "Download", "SSL", "certificate", "and", "key", "file", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ssl/download.py#L13-L28
train
234,514
softlayer/softlayer-python
SoftLayer/CLI/virt/capture.py
cli
def cli(env, identifier, name, all, note): """Capture one or all disks from a virtual server to a SoftLayer image.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') capture = vsi.capture(vs_id, name, all, note) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['vs_id', capture['guestId']]) table.add_row(['date', capture['createDate'][:10]]) table.add_row(['time', capture['createDate'][11:19]]) table.add_row(['transaction', formatting.transaction_status(capture)]) table.add_row(['transaction_id', capture['id']]) table.add_row(['all_disks', all]) env.fout(table)
python
def cli(env, identifier, name, all, note): """Capture one or all disks from a virtual server to a SoftLayer image.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') capture = vsi.capture(vs_id, name, all, note) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['vs_id', capture['guestId']]) table.add_row(['date', capture['createDate'][:10]]) table.add_row(['time', capture['createDate'][11:19]]) table.add_row(['transaction', formatting.transaction_status(capture)]) table.add_row(['transaction_id', capture['id']]) table.add_row(['all_disks', all]) env.fout(table)
[ "def", "cli", "(", "env", ",", "identifier", ",", "name", ",", "all", ",", "note", ")", ":", "vsi", "=", "SoftLayer", ".", "VSManager", "(", "env", ".", "client", ")", "vs_id", "=", "helpers", ".", "resolve_id", "(", "vsi", ".", "resolve_ids", ",", "identifier", ",", "'VS'", ")", "capture", "=", "vsi", ".", "capture", "(", "vs_id", ",", "name", ",", "all", ",", "note", ")", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "table", ".", "align", "[", "'name'", "]", "=", "'r'", "table", ".", "align", "[", "'value'", "]", "=", "'l'", "table", ".", "add_row", "(", "[", "'vs_id'", ",", "capture", "[", "'guestId'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'date'", ",", "capture", "[", "'createDate'", "]", "[", ":", "10", "]", "]", ")", "table", ".", "add_row", "(", "[", "'time'", ",", "capture", "[", "'createDate'", "]", "[", "11", ":", "19", "]", "]", ")", "table", ".", "add_row", "(", "[", "'transaction'", ",", "formatting", ".", "transaction_status", "(", "capture", ")", "]", ")", "table", ".", "add_row", "(", "[", "'transaction_id'", ",", "capture", "[", "'id'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'all_disks'", ",", "all", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Capture one or all disks from a virtual server to a SoftLayer image.
[ "Capture", "one", "or", "all", "disks", "from", "a", "virtual", "server", "to", "a", "SoftLayer", "image", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/capture.py#L20-L38
train
234,515
softlayer/softlayer-python
SoftLayer/managers/event_log.py
EventLogManager.get_event_logs
def get_event_logs(self, request_filter=None, log_limit=20, iterator=True): """Returns a list of event logs Example:: event_mgr = SoftLayer.EventLogManager(env.client) request_filter = event_mgr.build_filter(date_min="01/01/2019", date_max="02/01/2019") logs = event_mgr.get_event_logs(request_filter) for log in logs: print("Event Name: {}".format(log['eventName'])) :param dict request_filter: filter dict :param int log_limit: number of results to get in one API call :param bool iterator: False will only make one API call for log_limit results. True will keep making API calls until all logs have been retreived. There may be a lot of these. :returns: List of event logs. If iterator=True, will return a python generator object instead. """ if iterator: # Call iter_call directly as this returns the actual generator return self.client.iter_call('Event_Log', 'getAllObjects', filter=request_filter, limit=log_limit) return self.client.call('Event_Log', 'getAllObjects', filter=request_filter, limit=log_limit)
python
def get_event_logs(self, request_filter=None, log_limit=20, iterator=True): """Returns a list of event logs Example:: event_mgr = SoftLayer.EventLogManager(env.client) request_filter = event_mgr.build_filter(date_min="01/01/2019", date_max="02/01/2019") logs = event_mgr.get_event_logs(request_filter) for log in logs: print("Event Name: {}".format(log['eventName'])) :param dict request_filter: filter dict :param int log_limit: number of results to get in one API call :param bool iterator: False will only make one API call for log_limit results. True will keep making API calls until all logs have been retreived. There may be a lot of these. :returns: List of event logs. If iterator=True, will return a python generator object instead. """ if iterator: # Call iter_call directly as this returns the actual generator return self.client.iter_call('Event_Log', 'getAllObjects', filter=request_filter, limit=log_limit) return self.client.call('Event_Log', 'getAllObjects', filter=request_filter, limit=log_limit)
[ "def", "get_event_logs", "(", "self", ",", "request_filter", "=", "None", ",", "log_limit", "=", "20", ",", "iterator", "=", "True", ")", ":", "if", "iterator", ":", "# Call iter_call directly as this returns the actual generator", "return", "self", ".", "client", ".", "iter_call", "(", "'Event_Log'", ",", "'getAllObjects'", ",", "filter", "=", "request_filter", ",", "limit", "=", "log_limit", ")", "return", "self", ".", "client", ".", "call", "(", "'Event_Log'", ",", "'getAllObjects'", ",", "filter", "=", "request_filter", ",", "limit", "=", "log_limit", ")" ]
Returns a list of event logs Example:: event_mgr = SoftLayer.EventLogManager(env.client) request_filter = event_mgr.build_filter(date_min="01/01/2019", date_max="02/01/2019") logs = event_mgr.get_event_logs(request_filter) for log in logs: print("Event Name: {}".format(log['eventName'])) :param dict request_filter: filter dict :param int log_limit: number of results to get in one API call :param bool iterator: False will only make one API call for log_limit results. True will keep making API calls until all logs have been retreived. There may be a lot of these. :returns: List of event logs. If iterator=True, will return a python generator object instead.
[ "Returns", "a", "list", "of", "event", "logs" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/event_log.py#L23-L44
train
234,516
softlayer/softlayer-python
SoftLayer/managers/event_log.py
EventLogManager.build_filter
def build_filter(date_min=None, date_max=None, obj_event=None, obj_id=None, obj_type=None, utc_offset=None): """Returns a query filter that can be passed into EventLogManager.get_event_logs :param string date_min: Lower bound date in MM/DD/YYYY format :param string date_max: Upper bound date in MM/DD/YYYY format :param string obj_event: The name of the events we want to filter by :param int obj_id: The id of the event we want to filter by :param string obj_type: The type of event we want to filter by :param string utc_offset: The UTC offset we want to use when converting date_min and date_max. (default '+0000') :returns: dict: The generated query filter """ if not any([date_min, date_max, obj_event, obj_id, obj_type]): return {} request_filter = {} if date_min and date_max: request_filter['eventCreateDate'] = utils.event_log_filter_between_date(date_min, date_max, utc_offset) else: if date_min: request_filter['eventCreateDate'] = utils.event_log_filter_greater_than_date(date_min, utc_offset) elif date_max: request_filter['eventCreateDate'] = utils.event_log_filter_less_than_date(date_max, utc_offset) if obj_event: request_filter['eventName'] = {'operation': obj_event} if obj_id: request_filter['objectId'] = {'operation': obj_id} if obj_type: request_filter['objectName'] = {'operation': obj_type} return request_filter
python
def build_filter(date_min=None, date_max=None, obj_event=None, obj_id=None, obj_type=None, utc_offset=None): """Returns a query filter that can be passed into EventLogManager.get_event_logs :param string date_min: Lower bound date in MM/DD/YYYY format :param string date_max: Upper bound date in MM/DD/YYYY format :param string obj_event: The name of the events we want to filter by :param int obj_id: The id of the event we want to filter by :param string obj_type: The type of event we want to filter by :param string utc_offset: The UTC offset we want to use when converting date_min and date_max. (default '+0000') :returns: dict: The generated query filter """ if not any([date_min, date_max, obj_event, obj_id, obj_type]): return {} request_filter = {} if date_min and date_max: request_filter['eventCreateDate'] = utils.event_log_filter_between_date(date_min, date_max, utc_offset) else: if date_min: request_filter['eventCreateDate'] = utils.event_log_filter_greater_than_date(date_min, utc_offset) elif date_max: request_filter['eventCreateDate'] = utils.event_log_filter_less_than_date(date_max, utc_offset) if obj_event: request_filter['eventName'] = {'operation': obj_event} if obj_id: request_filter['objectId'] = {'operation': obj_id} if obj_type: request_filter['objectName'] = {'operation': obj_type} return request_filter
[ "def", "build_filter", "(", "date_min", "=", "None", ",", "date_max", "=", "None", ",", "obj_event", "=", "None", ",", "obj_id", "=", "None", ",", "obj_type", "=", "None", ",", "utc_offset", "=", "None", ")", ":", "if", "not", "any", "(", "[", "date_min", ",", "date_max", ",", "obj_event", ",", "obj_id", ",", "obj_type", "]", ")", ":", "return", "{", "}", "request_filter", "=", "{", "}", "if", "date_min", "and", "date_max", ":", "request_filter", "[", "'eventCreateDate'", "]", "=", "utils", ".", "event_log_filter_between_date", "(", "date_min", ",", "date_max", ",", "utc_offset", ")", "else", ":", "if", "date_min", ":", "request_filter", "[", "'eventCreateDate'", "]", "=", "utils", ".", "event_log_filter_greater_than_date", "(", "date_min", ",", "utc_offset", ")", "elif", "date_max", ":", "request_filter", "[", "'eventCreateDate'", "]", "=", "utils", ".", "event_log_filter_less_than_date", "(", "date_max", ",", "utc_offset", ")", "if", "obj_event", ":", "request_filter", "[", "'eventName'", "]", "=", "{", "'operation'", ":", "obj_event", "}", "if", "obj_id", ":", "request_filter", "[", "'objectId'", "]", "=", "{", "'operation'", ":", "obj_id", "}", "if", "obj_type", ":", "request_filter", "[", "'objectName'", "]", "=", "{", "'operation'", ":", "obj_type", "}", "return", "request_filter" ]
Returns a query filter that can be passed into EventLogManager.get_event_logs :param string date_min: Lower bound date in MM/DD/YYYY format :param string date_max: Upper bound date in MM/DD/YYYY format :param string obj_event: The name of the events we want to filter by :param int obj_id: The id of the event we want to filter by :param string obj_type: The type of event we want to filter by :param string utc_offset: The UTC offset we want to use when converting date_min and date_max. (default '+0000') :returns: dict: The generated query filter
[ "Returns", "a", "query", "filter", "that", "can", "be", "passed", "into", "EventLogManager", ".", "get_event_logs" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/event_log.py#L55-L91
train
234,517
softlayer/softlayer-python
SoftLayer/CLI/dns/record_list.py
cli
def cli(env, zone, data, record, ttl, type): """List all records in a zone.""" manager = SoftLayer.DNSManager(env.client) table = formatting.Table(['id', 'record', 'type', 'ttl', 'data']) table.align['ttl'] = 'l' table.align['record'] = 'r' table.align['data'] = 'l' zone_id = helpers.resolve_id(manager.resolve_ids, zone, name='zone') records = manager.get_records(zone_id, record_type=type, host=record, ttl=ttl, data=data) for the_record in records: table.add_row([ the_record['id'], the_record['host'], the_record['type'].upper(), the_record['ttl'], the_record['data'] ]) env.fout(table)
python
def cli(env, zone, data, record, ttl, type): """List all records in a zone.""" manager = SoftLayer.DNSManager(env.client) table = formatting.Table(['id', 'record', 'type', 'ttl', 'data']) table.align['ttl'] = 'l' table.align['record'] = 'r' table.align['data'] = 'l' zone_id = helpers.resolve_id(manager.resolve_ids, zone, name='zone') records = manager.get_records(zone_id, record_type=type, host=record, ttl=ttl, data=data) for the_record in records: table.add_row([ the_record['id'], the_record['host'], the_record['type'].upper(), the_record['ttl'], the_record['data'] ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "zone", ",", "data", ",", "record", ",", "ttl", ",", "type", ")", ":", "manager", "=", "SoftLayer", ".", "DNSManager", "(", "env", ".", "client", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'id'", ",", "'record'", ",", "'type'", ",", "'ttl'", ",", "'data'", "]", ")", "table", ".", "align", "[", "'ttl'", "]", "=", "'l'", "table", ".", "align", "[", "'record'", "]", "=", "'r'", "table", ".", "align", "[", "'data'", "]", "=", "'l'", "zone_id", "=", "helpers", ".", "resolve_id", "(", "manager", ".", "resolve_ids", ",", "zone", ",", "name", "=", "'zone'", ")", "records", "=", "manager", ".", "get_records", "(", "zone_id", ",", "record_type", "=", "type", ",", "host", "=", "record", ",", "ttl", "=", "ttl", ",", "data", "=", "data", ")", "for", "the_record", "in", "records", ":", "table", ".", "add_row", "(", "[", "the_record", "[", "'id'", "]", ",", "the_record", "[", "'host'", "]", ",", "the_record", "[", "'type'", "]", ".", "upper", "(", ")", ",", "the_record", "[", "'ttl'", "]", ",", "the_record", "[", "'data'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List all records in a zone.
[ "List", "all", "records", "in", "a", "zone", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dns/record_list.py#L22-L49
train
234,518
softlayer/softlayer-python
SoftLayer/CLI/ticket/subjects.py
cli
def cli(env): """List Subject IDs for ticket creation.""" ticket_mgr = SoftLayer.TicketManager(env.client) table = formatting.Table(['id', 'subject']) for subject in ticket_mgr.list_subjects(): table.add_row([subject['id'], subject['name']]) env.fout(table)
python
def cli(env): """List Subject IDs for ticket creation.""" ticket_mgr = SoftLayer.TicketManager(env.client) table = formatting.Table(['id', 'subject']) for subject in ticket_mgr.list_subjects(): table.add_row([subject['id'], subject['name']]) env.fout(table)
[ "def", "cli", "(", "env", ")", ":", "ticket_mgr", "=", "SoftLayer", ".", "TicketManager", "(", "env", ".", "client", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'id'", ",", "'subject'", "]", ")", "for", "subject", "in", "ticket_mgr", ".", "list_subjects", "(", ")", ":", "table", ".", "add_row", "(", "[", "subject", "[", "'id'", "]", ",", "subject", "[", "'name'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List Subject IDs for ticket creation.
[ "List", "Subject", "IDs", "for", "ticket", "creation", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ticket/subjects.py#L13-L21
train
234,519
softlayer/softlayer-python
SoftLayer/CLI/virt/placementgroup/create.py
cli
def cli(env, **args): """Create a placement group.""" manager = PlacementManager(env.client) backend_router_id = helpers.resolve_id(manager.get_backend_router_id_from_hostname, args.get('backend_router'), 'backendRouter') rule_id = helpers.resolve_id(manager.get_rule_id_from_name, args.get('rule'), 'Rule') placement_object = { 'name': args.get('name'), 'backendRouterId': backend_router_id, 'ruleId': rule_id } result = manager.create(placement_object) click.secho("Successfully created placement group: ID: %s, Name: %s" % (result['id'], result['name']), fg='green')
python
def cli(env, **args): """Create a placement group.""" manager = PlacementManager(env.client) backend_router_id = helpers.resolve_id(manager.get_backend_router_id_from_hostname, args.get('backend_router'), 'backendRouter') rule_id = helpers.resolve_id(manager.get_rule_id_from_name, args.get('rule'), 'Rule') placement_object = { 'name': args.get('name'), 'backendRouterId': backend_router_id, 'ruleId': rule_id } result = manager.create(placement_object) click.secho("Successfully created placement group: ID: %s, Name: %s" % (result['id'], result['name']), fg='green')
[ "def", "cli", "(", "env", ",", "*", "*", "args", ")", ":", "manager", "=", "PlacementManager", "(", "env", ".", "client", ")", "backend_router_id", "=", "helpers", ".", "resolve_id", "(", "manager", ".", "get_backend_router_id_from_hostname", ",", "args", ".", "get", "(", "'backend_router'", ")", ",", "'backendRouter'", ")", "rule_id", "=", "helpers", ".", "resolve_id", "(", "manager", ".", "get_rule_id_from_name", ",", "args", ".", "get", "(", "'rule'", ")", ",", "'Rule'", ")", "placement_object", "=", "{", "'name'", ":", "args", ".", "get", "(", "'name'", ")", ",", "'backendRouterId'", ":", "backend_router_id", ",", "'ruleId'", ":", "rule_id", "}", "result", "=", "manager", ".", "create", "(", "placement_object", ")", "click", ".", "secho", "(", "\"Successfully created placement group: ID: %s, Name: %s\"", "%", "(", "result", "[", "'id'", "]", ",", "result", "[", "'name'", "]", ")", ",", "fg", "=", "'green'", ")" ]
Create a placement group.
[ "Create", "a", "placement", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/placementgroup/create.py#L17-L31
train
234,520
softlayer/softlayer-python
SoftLayer/CLI/user/detail.py
cli
def cli(env, identifier, keys, permissions, hardware, virtual, logins, events): """User details.""" mgr = SoftLayer.UserManager(env.client) user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username') object_mask = "userStatus[name], parent[id, username], apiAuthenticationKeys[authenticationKey], "\ "unsuccessfulLogins, successfulLogins" user = mgr.get_user(user_id, object_mask) env.fout(basic_info(user, keys)) if permissions: perms = mgr.get_user_permissions(user_id) env.fout(print_permissions(perms)) if hardware: mask = "id, hardware, dedicatedHosts" access = mgr.get_user(user_id, mask) env.fout(print_dedicated_access(access.get('dedicatedHosts', []))) env.fout(print_access(access.get('hardware', []), 'Hardware')) if virtual: mask = "id, virtualGuests" access = mgr.get_user(user_id, mask) env.fout(print_access(access.get('virtualGuests', []), 'Virtual Guests')) if logins: login_log = mgr.get_logins(user_id) env.fout(print_logins(login_log)) if events: event_log = mgr.get_events(user_id) env.fout(print_events(event_log))
python
def cli(env, identifier, keys, permissions, hardware, virtual, logins, events): """User details.""" mgr = SoftLayer.UserManager(env.client) user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username') object_mask = "userStatus[name], parent[id, username], apiAuthenticationKeys[authenticationKey], "\ "unsuccessfulLogins, successfulLogins" user = mgr.get_user(user_id, object_mask) env.fout(basic_info(user, keys)) if permissions: perms = mgr.get_user_permissions(user_id) env.fout(print_permissions(perms)) if hardware: mask = "id, hardware, dedicatedHosts" access = mgr.get_user(user_id, mask) env.fout(print_dedicated_access(access.get('dedicatedHosts', []))) env.fout(print_access(access.get('hardware', []), 'Hardware')) if virtual: mask = "id, virtualGuests" access = mgr.get_user(user_id, mask) env.fout(print_access(access.get('virtualGuests', []), 'Virtual Guests')) if logins: login_log = mgr.get_logins(user_id) env.fout(print_logins(login_log)) if events: event_log = mgr.get_events(user_id) env.fout(print_events(event_log))
[ "def", "cli", "(", "env", ",", "identifier", ",", "keys", ",", "permissions", ",", "hardware", ",", "virtual", ",", "logins", ",", "events", ")", ":", "mgr", "=", "SoftLayer", ".", "UserManager", "(", "env", ".", "client", ")", "user_id", "=", "helpers", ".", "resolve_id", "(", "mgr", ".", "resolve_ids", ",", "identifier", ",", "'username'", ")", "object_mask", "=", "\"userStatus[name], parent[id, username], apiAuthenticationKeys[authenticationKey], \"", "\"unsuccessfulLogins, successfulLogins\"", "user", "=", "mgr", ".", "get_user", "(", "user_id", ",", "object_mask", ")", "env", ".", "fout", "(", "basic_info", "(", "user", ",", "keys", ")", ")", "if", "permissions", ":", "perms", "=", "mgr", ".", "get_user_permissions", "(", "user_id", ")", "env", ".", "fout", "(", "print_permissions", "(", "perms", ")", ")", "if", "hardware", ":", "mask", "=", "\"id, hardware, dedicatedHosts\"", "access", "=", "mgr", ".", "get_user", "(", "user_id", ",", "mask", ")", "env", ".", "fout", "(", "print_dedicated_access", "(", "access", ".", "get", "(", "'dedicatedHosts'", ",", "[", "]", ")", ")", ")", "env", ".", "fout", "(", "print_access", "(", "access", ".", "get", "(", "'hardware'", ",", "[", "]", ")", ",", "'Hardware'", ")", ")", "if", "virtual", ":", "mask", "=", "\"id, virtualGuests\"", "access", "=", "mgr", ".", "get_user", "(", "user_id", ",", "mask", ")", "env", ".", "fout", "(", "print_access", "(", "access", ".", "get", "(", "'virtualGuests'", ",", "[", "]", ")", ",", "'Virtual Guests'", ")", ")", "if", "logins", ":", "login_log", "=", "mgr", ".", "get_logins", "(", "user_id", ")", "env", ".", "fout", "(", "print_logins", "(", "login_log", ")", ")", "if", "events", ":", "event_log", "=", "mgr", ".", "get_events", "(", "user_id", ")", "env", ".", "fout", "(", "print_events", "(", "event_log", ")", ")" ]
User details.
[ "User", "details", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/detail.py#L28-L56
train
234,521
softlayer/softlayer-python
SoftLayer/CLI/user/detail.py
basic_info
def basic_info(user, keys): """Prints a table of basic user information""" table = formatting.KeyValueTable(['Title', 'Basic Information']) table.align['Title'] = 'r' table.align['Basic Information'] = 'l' table.add_row(['Id', user.get('id', '-')]) table.add_row(['Username', user.get('username', '-')]) if keys: for key in user.get('apiAuthenticationKeys'): table.add_row(['APIKEY', key.get('authenticationKey')]) table.add_row(['Name', "%s %s" % (user.get('firstName', '-'), user.get('lastName', '-'))]) table.add_row(['Email', user.get('email')]) table.add_row(['OpenID', user.get('openIdConnectUserName')]) address = "%s %s %s %s %s %s" % ( user.get('address1'), user.get('address2'), user.get('city'), user.get('state'), user.get('country'), user.get('postalCode')) table.add_row(['Address', address]) table.add_row(['Company', user.get('companyName')]) table.add_row(['Created', user.get('createDate')]) table.add_row(['Phone Number', user.get('officePhone')]) if user.get('parentId', False): table.add_row(['Parent User', utils.lookup(user, 'parent', 'username')]) table.add_row(['Status', utils.lookup(user, 'userStatus', 'name')]) table.add_row(['PPTP VPN', user.get('pptpVpnAllowedFlag', 'No')]) table.add_row(['SSL VPN', user.get('sslVpnAllowedFlag', 'No')]) for login in user.get('unsuccessfulLogins', {}): login_string = "%s From: %s" % (login.get('createDate'), login.get('ipAddress')) table.add_row(['Last Failed Login', login_string]) break for login in user.get('successfulLogins', {}): login_string = "%s From: %s" % (login.get('createDate'), login.get('ipAddress')) table.add_row(['Last Login', login_string]) break return table
python
def basic_info(user, keys): """Prints a table of basic user information""" table = formatting.KeyValueTable(['Title', 'Basic Information']) table.align['Title'] = 'r' table.align['Basic Information'] = 'l' table.add_row(['Id', user.get('id', '-')]) table.add_row(['Username', user.get('username', '-')]) if keys: for key in user.get('apiAuthenticationKeys'): table.add_row(['APIKEY', key.get('authenticationKey')]) table.add_row(['Name', "%s %s" % (user.get('firstName', '-'), user.get('lastName', '-'))]) table.add_row(['Email', user.get('email')]) table.add_row(['OpenID', user.get('openIdConnectUserName')]) address = "%s %s %s %s %s %s" % ( user.get('address1'), user.get('address2'), user.get('city'), user.get('state'), user.get('country'), user.get('postalCode')) table.add_row(['Address', address]) table.add_row(['Company', user.get('companyName')]) table.add_row(['Created', user.get('createDate')]) table.add_row(['Phone Number', user.get('officePhone')]) if user.get('parentId', False): table.add_row(['Parent User', utils.lookup(user, 'parent', 'username')]) table.add_row(['Status', utils.lookup(user, 'userStatus', 'name')]) table.add_row(['PPTP VPN', user.get('pptpVpnAllowedFlag', 'No')]) table.add_row(['SSL VPN', user.get('sslVpnAllowedFlag', 'No')]) for login in user.get('unsuccessfulLogins', {}): login_string = "%s From: %s" % (login.get('createDate'), login.get('ipAddress')) table.add_row(['Last Failed Login', login_string]) break for login in user.get('successfulLogins', {}): login_string = "%s From: %s" % (login.get('createDate'), login.get('ipAddress')) table.add_row(['Last Login', login_string]) break return table
[ "def", "basic_info", "(", "user", ",", "keys", ")", ":", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'Title'", ",", "'Basic Information'", "]", ")", "table", ".", "align", "[", "'Title'", "]", "=", "'r'", "table", ".", "align", "[", "'Basic Information'", "]", "=", "'l'", "table", ".", "add_row", "(", "[", "'Id'", ",", "user", ".", "get", "(", "'id'", ",", "'-'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'Username'", ",", "user", ".", "get", "(", "'username'", ",", "'-'", ")", "]", ")", "if", "keys", ":", "for", "key", "in", "user", ".", "get", "(", "'apiAuthenticationKeys'", ")", ":", "table", ".", "add_row", "(", "[", "'APIKEY'", ",", "key", ".", "get", "(", "'authenticationKey'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'Name'", ",", "\"%s %s\"", "%", "(", "user", ".", "get", "(", "'firstName'", ",", "'-'", ")", ",", "user", ".", "get", "(", "'lastName'", ",", "'-'", ")", ")", "]", ")", "table", ".", "add_row", "(", "[", "'Email'", ",", "user", ".", "get", "(", "'email'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'OpenID'", ",", "user", ".", "get", "(", "'openIdConnectUserName'", ")", "]", ")", "address", "=", "\"%s %s %s %s %s %s\"", "%", "(", "user", ".", "get", "(", "'address1'", ")", ",", "user", ".", "get", "(", "'address2'", ")", ",", "user", ".", "get", "(", "'city'", ")", ",", "user", ".", "get", "(", "'state'", ")", ",", "user", ".", "get", "(", "'country'", ")", ",", "user", ".", "get", "(", "'postalCode'", ")", ")", "table", ".", "add_row", "(", "[", "'Address'", ",", "address", "]", ")", "table", ".", "add_row", "(", "[", "'Company'", ",", "user", ".", "get", "(", "'companyName'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'Created'", ",", "user", ".", "get", "(", "'createDate'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'Phone Number'", ",", "user", ".", "get", "(", "'officePhone'", ")", "]", ")", "if", "user", ".", "get", "(", "'parentId'", ",", "False", ")", ":", "table", ".", "add_row", "(", "[", "'Parent User'", ",", "utils", ".", "lookup", "(", "user", ",", "'parent'", ",", "'username'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'Status'", ",", "utils", ".", "lookup", "(", "user", ",", "'userStatus'", ",", "'name'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'PPTP VPN'", ",", "user", ".", "get", "(", "'pptpVpnAllowedFlag'", ",", "'No'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'SSL VPN'", ",", "user", ".", "get", "(", "'sslVpnAllowedFlag'", ",", "'No'", ")", "]", ")", "for", "login", "in", "user", ".", "get", "(", "'unsuccessfulLogins'", ",", "{", "}", ")", ":", "login_string", "=", "\"%s From: %s\"", "%", "(", "login", ".", "get", "(", "'createDate'", ")", ",", "login", ".", "get", "(", "'ipAddress'", ")", ")", "table", ".", "add_row", "(", "[", "'Last Failed Login'", ",", "login_string", "]", ")", "break", "for", "login", "in", "user", ".", "get", "(", "'successfulLogins'", ",", "{", "}", ")", ":", "login_string", "=", "\"%s From: %s\"", "%", "(", "login", ".", "get", "(", "'createDate'", ")", ",", "login", ".", "get", "(", "'ipAddress'", ")", ")", "table", ".", "add_row", "(", "[", "'Last Login'", ",", "login_string", "]", ")", "break", "return", "table" ]
Prints a table of basic user information
[ "Prints", "a", "table", "of", "basic", "user", "information" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/detail.py#L59-L95
train
234,522
softlayer/softlayer-python
SoftLayer/CLI/user/detail.py
print_permissions
def print_permissions(permissions): """Prints out a users permissions""" table = formatting.Table(['keyName', 'Description']) for perm in permissions: table.add_row([perm['keyName'], perm['name']]) return table
python
def print_permissions(permissions): """Prints out a users permissions""" table = formatting.Table(['keyName', 'Description']) for perm in permissions: table.add_row([perm['keyName'], perm['name']]) return table
[ "def", "print_permissions", "(", "permissions", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'keyName'", ",", "'Description'", "]", ")", "for", "perm", "in", "permissions", ":", "table", ".", "add_row", "(", "[", "perm", "[", "'keyName'", "]", ",", "perm", "[", "'name'", "]", "]", ")", "return", "table" ]
Prints out a users permissions
[ "Prints", "out", "a", "users", "permissions" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/detail.py#L98-L104
train
234,523
softlayer/softlayer-python
SoftLayer/CLI/user/detail.py
print_access
def print_access(access, title): """Prints out the hardware or virtual guests a user can access""" columns = ['id', 'hostname', 'Primary Public IP', 'Primary Private IP', 'Created'] table = formatting.Table(columns, title) for host in access: host_id = host.get('id') host_fqdn = host.get('fullyQualifiedDomainName', '-') host_primary = host.get('primaryIpAddress') host_private = host.get('primaryBackendIpAddress') host_created = host.get('provisionDate') table.add_row([host_id, host_fqdn, host_primary, host_private, host_created]) return table
python
def print_access(access, title): """Prints out the hardware or virtual guests a user can access""" columns = ['id', 'hostname', 'Primary Public IP', 'Primary Private IP', 'Created'] table = formatting.Table(columns, title) for host in access: host_id = host.get('id') host_fqdn = host.get('fullyQualifiedDomainName', '-') host_primary = host.get('primaryIpAddress') host_private = host.get('primaryBackendIpAddress') host_created = host.get('provisionDate') table.add_row([host_id, host_fqdn, host_primary, host_private, host_created]) return table
[ "def", "print_access", "(", "access", ",", "title", ")", ":", "columns", "=", "[", "'id'", ",", "'hostname'", ",", "'Primary Public IP'", ",", "'Primary Private IP'", ",", "'Created'", "]", "table", "=", "formatting", ".", "Table", "(", "columns", ",", "title", ")", "for", "host", "in", "access", ":", "host_id", "=", "host", ".", "get", "(", "'id'", ")", "host_fqdn", "=", "host", ".", "get", "(", "'fullyQualifiedDomainName'", ",", "'-'", ")", "host_primary", "=", "host", ".", "get", "(", "'primaryIpAddress'", ")", "host_private", "=", "host", ".", "get", "(", "'primaryBackendIpAddress'", ")", "host_created", "=", "host", ".", "get", "(", "'provisionDate'", ")", "table", ".", "add_row", "(", "[", "host_id", ",", "host_fqdn", ",", "host_primary", ",", "host_private", ",", "host_created", "]", ")", "return", "table" ]
Prints out the hardware or virtual guests a user can access
[ "Prints", "out", "the", "hardware", "or", "virtual", "guests", "a", "user", "can", "access" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/detail.py#L107-L120
train
234,524
softlayer/softlayer-python
SoftLayer/CLI/user/detail.py
print_dedicated_access
def print_dedicated_access(access): """Prints out the dedicated hosts a user can access""" table = formatting.Table(['id', 'Name', 'Cpus', 'Memory', 'Disk', 'Created'], 'Dedicated Access') for host in access: host_id = host.get('id') host_fqdn = host.get('name') host_cpu = host.get('cpuCount') host_mem = host.get('memoryCapacity') host_disk = host.get('diskCapacity') host_created = host.get('createDate') table.add_row([host_id, host_fqdn, host_cpu, host_mem, host_disk, host_created]) return table
python
def print_dedicated_access(access): """Prints out the dedicated hosts a user can access""" table = formatting.Table(['id', 'Name', 'Cpus', 'Memory', 'Disk', 'Created'], 'Dedicated Access') for host in access: host_id = host.get('id') host_fqdn = host.get('name') host_cpu = host.get('cpuCount') host_mem = host.get('memoryCapacity') host_disk = host.get('diskCapacity') host_created = host.get('createDate') table.add_row([host_id, host_fqdn, host_cpu, host_mem, host_disk, host_created]) return table
[ "def", "print_dedicated_access", "(", "access", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'id'", ",", "'Name'", ",", "'Cpus'", ",", "'Memory'", ",", "'Disk'", ",", "'Created'", "]", ",", "'Dedicated Access'", ")", "for", "host", "in", "access", ":", "host_id", "=", "host", ".", "get", "(", "'id'", ")", "host_fqdn", "=", "host", ".", "get", "(", "'name'", ")", "host_cpu", "=", "host", ".", "get", "(", "'cpuCount'", ")", "host_mem", "=", "host", ".", "get", "(", "'memoryCapacity'", ")", "host_disk", "=", "host", ".", "get", "(", "'diskCapacity'", ")", "host_created", "=", "host", ".", "get", "(", "'createDate'", ")", "table", ".", "add_row", "(", "[", "host_id", ",", "host_fqdn", ",", "host_cpu", ",", "host_mem", ",", "host_disk", ",", "host_created", "]", ")", "return", "table" ]
Prints out the dedicated hosts a user can access
[ "Prints", "out", "the", "dedicated", "hosts", "a", "user", "can", "access" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/detail.py#L123-L135
train
234,525
softlayer/softlayer-python
SoftLayer/CLI/user/detail.py
print_logins
def print_logins(logins): """Prints out the login history for a user""" table = formatting.Table(['Date', 'IP Address', 'Successufl Login?']) for login in logins: table.add_row([login.get('createDate'), login.get('ipAddress'), login.get('successFlag')]) return table
python
def print_logins(logins): """Prints out the login history for a user""" table = formatting.Table(['Date', 'IP Address', 'Successufl Login?']) for login in logins: table.add_row([login.get('createDate'), login.get('ipAddress'), login.get('successFlag')]) return table
[ "def", "print_logins", "(", "logins", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'Date'", ",", "'IP Address'", ",", "'Successufl Login?'", "]", ")", "for", "login", "in", "logins", ":", "table", ".", "add_row", "(", "[", "login", ".", "get", "(", "'createDate'", ")", ",", "login", ".", "get", "(", "'ipAddress'", ")", ",", "login", ".", "get", "(", "'successFlag'", ")", "]", ")", "return", "table" ]
Prints out the login history for a user
[ "Prints", "out", "the", "login", "history", "for", "a", "user" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/detail.py#L138-L143
train
234,526
softlayer/softlayer-python
SoftLayer/CLI/user/detail.py
print_events
def print_events(events): """Prints out the event log for a user""" columns = ['Date', 'Type', 'IP Address', 'label', 'username'] table = formatting.Table(columns) for event in events: table.add_row([event.get('eventCreateDate'), event.get('eventName'), event.get('ipAddress'), event.get('label'), event.get('username')]) return table
python
def print_events(events): """Prints out the event log for a user""" columns = ['Date', 'Type', 'IP Address', 'label', 'username'] table = formatting.Table(columns) for event in events: table.add_row([event.get('eventCreateDate'), event.get('eventName'), event.get('ipAddress'), event.get('label'), event.get('username')]) return table
[ "def", "print_events", "(", "events", ")", ":", "columns", "=", "[", "'Date'", ",", "'Type'", ",", "'IP Address'", ",", "'label'", ",", "'username'", "]", "table", "=", "formatting", ".", "Table", "(", "columns", ")", "for", "event", "in", "events", ":", "table", ".", "add_row", "(", "[", "event", ".", "get", "(", "'eventCreateDate'", ")", ",", "event", ".", "get", "(", "'eventName'", ")", ",", "event", ".", "get", "(", "'ipAddress'", ")", ",", "event", ".", "get", "(", "'label'", ")", ",", "event", ".", "get", "(", "'username'", ")", "]", ")", "return", "table" ]
Prints out the event log for a user
[ "Prints", "out", "the", "event", "log", "for", "a", "user" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/detail.py#L146-L153
train
234,527
softlayer/softlayer-python
SoftLayer/CLI/user/delete.py
cli
def cli(env, identifier): """Sets a user's status to CANCEL_PENDING, which will immediately disable the account, and will eventually be fully removed from the account by an automated internal process. Example: slcli user delete userId """ mgr = SoftLayer.UserManager(env.client) user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username') user_template = {'userStatusId': 1021} result = mgr.edit_user(user_id, user_template) if result: click.secho("%s deleted successfully" % identifier, fg='green') else: click.secho("Failed to delete %s" % identifier, fg='red')
python
def cli(env, identifier): """Sets a user's status to CANCEL_PENDING, which will immediately disable the account, and will eventually be fully removed from the account by an automated internal process. Example: slcli user delete userId """ mgr = SoftLayer.UserManager(env.client) user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username') user_template = {'userStatusId': 1021} result = mgr.edit_user(user_id, user_template) if result: click.secho("%s deleted successfully" % identifier, fg='green') else: click.secho("Failed to delete %s" % identifier, fg='red')
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "mgr", "=", "SoftLayer", ".", "UserManager", "(", "env", ".", "client", ")", "user_id", "=", "helpers", ".", "resolve_id", "(", "mgr", ".", "resolve_ids", ",", "identifier", ",", "'username'", ")", "user_template", "=", "{", "'userStatusId'", ":", "1021", "}", "result", "=", "mgr", ".", "edit_user", "(", "user_id", ",", "user_template", ")", "if", "result", ":", "click", ".", "secho", "(", "\"%s deleted successfully\"", "%", "identifier", ",", "fg", "=", "'green'", ")", "else", ":", "click", ".", "secho", "(", "\"Failed to delete %s\"", "%", "identifier", ",", "fg", "=", "'red'", ")" ]
Sets a user's status to CANCEL_PENDING, which will immediately disable the account, and will eventually be fully removed from the account by an automated internal process. Example: slcli user delete userId
[ "Sets", "a", "user", "s", "status", "to", "CANCEL_PENDING", "which", "will", "immediately", "disable", "the", "account" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/delete.py#L14-L32
train
234,528
softlayer/softlayer-python
SoftLayer/CLI/ssl/edit.py
cli
def cli(env, identifier, crt, csr, icc, key, notes): """Edit SSL certificate.""" template = {'id': identifier} if crt: template['certificate'] = open(crt).read() if key: template['privateKey'] = open(key).read() if csr: template['certificateSigningRequest'] = open(csr).read() if icc: template['intermediateCertificate'] = open(icc).read() if notes: template['notes'] = notes manager = SoftLayer.SSLManager(env.client) manager.edit_certificate(template)
python
def cli(env, identifier, crt, csr, icc, key, notes): """Edit SSL certificate.""" template = {'id': identifier} if crt: template['certificate'] = open(crt).read() if key: template['privateKey'] = open(key).read() if csr: template['certificateSigningRequest'] = open(csr).read() if icc: template['intermediateCertificate'] = open(icc).read() if notes: template['notes'] = notes manager = SoftLayer.SSLManager(env.client) manager.edit_certificate(template)
[ "def", "cli", "(", "env", ",", "identifier", ",", "crt", ",", "csr", ",", "icc", ",", "key", ",", "notes", ")", ":", "template", "=", "{", "'id'", ":", "identifier", "}", "if", "crt", ":", "template", "[", "'certificate'", "]", "=", "open", "(", "crt", ")", ".", "read", "(", ")", "if", "key", ":", "template", "[", "'privateKey'", "]", "=", "open", "(", "key", ")", ".", "read", "(", ")", "if", "csr", ":", "template", "[", "'certificateSigningRequest'", "]", "=", "open", "(", "csr", ")", ".", "read", "(", ")", "if", "icc", ":", "template", "[", "'intermediateCertificate'", "]", "=", "open", "(", "icc", ")", ".", "read", "(", ")", "if", "notes", ":", "template", "[", "'notes'", "]", "=", "notes", "manager", "=", "SoftLayer", ".", "SSLManager", "(", "env", ".", "client", ")", "manager", ".", "edit_certificate", "(", "template", ")" ]
Edit SSL certificate.
[ "Edit", "SSL", "certificate", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ssl/edit.py#L24-L39
train
234,529
softlayer/softlayer-python
SoftLayer/CLI/cdn/origin_add.py
cli
def cli(env, account_id, content_url, type, cname): """Create an origin pull mapping.""" manager = SoftLayer.CDNManager(env.client) manager.add_origin(account_id, type, content_url, cname)
python
def cli(env, account_id, content_url, type, cname): """Create an origin pull mapping.""" manager = SoftLayer.CDNManager(env.client) manager.add_origin(account_id, type, content_url, cname)
[ "def", "cli", "(", "env", ",", "account_id", ",", "content_url", ",", "type", ",", "cname", ")", ":", "manager", "=", "SoftLayer", ".", "CDNManager", "(", "env", ".", "client", ")", "manager", ".", "add_origin", "(", "account_id", ",", "type", ",", "content_url", ",", "cname", ")" ]
Create an origin pull mapping.
[ "Create", "an", "origin", "pull", "mapping", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/cdn/origin_add.py#L22-L26
train
234,530
softlayer/softlayer-python
SoftLayer/CLI/template.py
export_to_template
def export_to_template(filename, args, exclude=None): """Exports given options to the given filename in INI format. :param filename: Filename to save options to :param dict args: Arguments to export :param list exclude (optional): Exclusion list for options that should not be exported """ exclude = exclude or [] exclude.append('config') exclude.append('really') exclude.append('format') exclude.append('debug') with open(filename, "w") as template_file: for k, val in args.items(): if val and k not in exclude: if isinstance(val, tuple): val = ','.join(val) if isinstance(val, list): val = ','.join(val) template_file.write('%s=%s\n' % (k, val))
python
def export_to_template(filename, args, exclude=None): """Exports given options to the given filename in INI format. :param filename: Filename to save options to :param dict args: Arguments to export :param list exclude (optional): Exclusion list for options that should not be exported """ exclude = exclude or [] exclude.append('config') exclude.append('really') exclude.append('format') exclude.append('debug') with open(filename, "w") as template_file: for k, val in args.items(): if val and k not in exclude: if isinstance(val, tuple): val = ','.join(val) if isinstance(val, list): val = ','.join(val) template_file.write('%s=%s\n' % (k, val))
[ "def", "export_to_template", "(", "filename", ",", "args", ",", "exclude", "=", "None", ")", ":", "exclude", "=", "exclude", "or", "[", "]", "exclude", ".", "append", "(", "'config'", ")", "exclude", ".", "append", "(", "'really'", ")", "exclude", ".", "append", "(", "'format'", ")", "exclude", ".", "append", "(", "'debug'", ")", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "template_file", ":", "for", "k", ",", "val", "in", "args", ".", "items", "(", ")", ":", "if", "val", "and", "k", "not", "in", "exclude", ":", "if", "isinstance", "(", "val", ",", "tuple", ")", ":", "val", "=", "','", ".", "join", "(", "val", ")", "if", "isinstance", "(", "val", ",", "list", ")", ":", "val", "=", "','", ".", "join", "(", "val", ")", "template_file", ".", "write", "(", "'%s=%s\\n'", "%", "(", "k", ",", "val", ")", ")" ]
Exports given options to the given filename in INI format. :param filename: Filename to save options to :param dict args: Arguments to export :param list exclude (optional): Exclusion list for options that should not be exported
[ "Exports", "given", "options", "to", "the", "given", "filename", "in", "INI", "format", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/template.py#L47-L68
train
234,531
softlayer/softlayer-python
SoftLayer/managers/vs_placement.py
PlacementManager.list
def list(self, mask=None): """List existing placement groups Calls SoftLayer_Account::getPlacementGroups """ if mask is None: mask = "mask[id, name, createDate, rule, guestCount, backendRouter[id, hostname]]" groups = self.client.call('Account', 'getPlacementGroups', mask=mask, iter=True) return groups
python
def list(self, mask=None): """List existing placement groups Calls SoftLayer_Account::getPlacementGroups """ if mask is None: mask = "mask[id, name, createDate, rule, guestCount, backendRouter[id, hostname]]" groups = self.client.call('Account', 'getPlacementGroups', mask=mask, iter=True) return groups
[ "def", "list", "(", "self", ",", "mask", "=", "None", ")", ":", "if", "mask", "is", "None", ":", "mask", "=", "\"mask[id, name, createDate, rule, guestCount, backendRouter[id, hostname]]\"", "groups", "=", "self", ".", "client", ".", "call", "(", "'Account'", ",", "'getPlacementGroups'", ",", "mask", "=", "mask", ",", "iter", "=", "True", ")", "return", "groups" ]
List existing placement groups Calls SoftLayer_Account::getPlacementGroups
[ "List", "existing", "placement", "groups" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_placement.py#L40-L48
train
234,532
softlayer/softlayer-python
SoftLayer/managers/vs_placement.py
PlacementManager.get_object
def get_object(self, group_id, mask=None): """Returns a PlacementGroup Object https://softlayer.github.io/reference/services/SoftLayer_Virtual_PlacementGroup/getObject """ if mask is None: mask = "mask[id, name, createDate, rule, backendRouter[id, hostname]," \ "guests[activeTransaction[id,transactionStatus[name,friendlyName]]]]" return self.client.call('SoftLayer_Virtual_PlacementGroup', 'getObject', id=group_id, mask=mask)
python
def get_object(self, group_id, mask=None): """Returns a PlacementGroup Object https://softlayer.github.io/reference/services/SoftLayer_Virtual_PlacementGroup/getObject """ if mask is None: mask = "mask[id, name, createDate, rule, backendRouter[id, hostname]," \ "guests[activeTransaction[id,transactionStatus[name,friendlyName]]]]" return self.client.call('SoftLayer_Virtual_PlacementGroup', 'getObject', id=group_id, mask=mask)
[ "def", "get_object", "(", "self", ",", "group_id", ",", "mask", "=", "None", ")", ":", "if", "mask", "is", "None", ":", "mask", "=", "\"mask[id, name, createDate, rule, backendRouter[id, hostname],\"", "\"guests[activeTransaction[id,transactionStatus[name,friendlyName]]]]\"", "return", "self", ".", "client", ".", "call", "(", "'SoftLayer_Virtual_PlacementGroup'", ",", "'getObject'", ",", "id", "=", "group_id", ",", "mask", "=", "mask", ")" ]
Returns a PlacementGroup Object https://softlayer.github.io/reference/services/SoftLayer_Virtual_PlacementGroup/getObject
[ "Returns", "a", "PlacementGroup", "Object" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_placement.py#L72-L80
train
234,533
softlayer/softlayer-python
SoftLayer/managers/vs_placement.py
PlacementManager.get_rule_id_from_name
def get_rule_id_from_name(self, name): """Finds the rule that matches name. SoftLayer_Virtual_PlacementGroup_Rule.getAllObjects doesn't support objectFilters. """ results = self.client.call('SoftLayer_Virtual_PlacementGroup_Rule', 'getAllObjects') return [result['id'] for result in results if result['keyName'] == name.upper()]
python
def get_rule_id_from_name(self, name): """Finds the rule that matches name. SoftLayer_Virtual_PlacementGroup_Rule.getAllObjects doesn't support objectFilters. """ results = self.client.call('SoftLayer_Virtual_PlacementGroup_Rule', 'getAllObjects') return [result['id'] for result in results if result['keyName'] == name.upper()]
[ "def", "get_rule_id_from_name", "(", "self", ",", "name", ")", ":", "results", "=", "self", ".", "client", ".", "call", "(", "'SoftLayer_Virtual_PlacementGroup_Rule'", ",", "'getAllObjects'", ")", "return", "[", "result", "[", "'id'", "]", "for", "result", "in", "results", "if", "result", "[", "'keyName'", "]", "==", "name", ".", "upper", "(", ")", "]" ]
Finds the rule that matches name. SoftLayer_Virtual_PlacementGroup_Rule.getAllObjects doesn't support objectFilters.
[ "Finds", "the", "rule", "that", "matches", "name", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_placement.py#L94-L100
train
234,534
softlayer/softlayer-python
SoftLayer/managers/vs_placement.py
PlacementManager.get_backend_router_id_from_hostname
def get_backend_router_id_from_hostname(self, hostname): """Finds the backend router Id that matches the hostname given No way to use an objectFilter to find a backendRouter, so we have to search the hard way. """ results = self.client.call('SoftLayer_Network_Pod', 'getAllObjects') return [result['backendRouterId'] for result in results if result['backendRouterName'] == hostname.lower()]
python
def get_backend_router_id_from_hostname(self, hostname): """Finds the backend router Id that matches the hostname given No way to use an objectFilter to find a backendRouter, so we have to search the hard way. """ results = self.client.call('SoftLayer_Network_Pod', 'getAllObjects') return [result['backendRouterId'] for result in results if result['backendRouterName'] == hostname.lower()]
[ "def", "get_backend_router_id_from_hostname", "(", "self", ",", "hostname", ")", ":", "results", "=", "self", ".", "client", ".", "call", "(", "'SoftLayer_Network_Pod'", ",", "'getAllObjects'", ")", "return", "[", "result", "[", "'backendRouterId'", "]", "for", "result", "in", "results", "if", "result", "[", "'backendRouterName'", "]", "==", "hostname", ".", "lower", "(", ")", "]" ]
Finds the backend router Id that matches the hostname given No way to use an objectFilter to find a backendRouter, so we have to search the hard way.
[ "Finds", "the", "backend", "router", "Id", "that", "matches", "the", "hostname", "given" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_placement.py#L102-L108
train
234,535
softlayer/softlayer-python
SoftLayer/managers/vs_placement.py
PlacementManager._get_id_from_name
def _get_id_from_name(self, name): """List placement group ids which match the given name.""" _filter = { 'placementGroups': { 'name': {'operation': name} } } mask = "mask[id, name]" results = self.client.call('Account', 'getPlacementGroups', filter=_filter, mask=mask) return [result['id'] for result in results]
python
def _get_id_from_name(self, name): """List placement group ids which match the given name.""" _filter = { 'placementGroups': { 'name': {'operation': name} } } mask = "mask[id, name]" results = self.client.call('Account', 'getPlacementGroups', filter=_filter, mask=mask) return [result['id'] for result in results]
[ "def", "_get_id_from_name", "(", "self", ",", "name", ")", ":", "_filter", "=", "{", "'placementGroups'", ":", "{", "'name'", ":", "{", "'operation'", ":", "name", "}", "}", "}", "mask", "=", "\"mask[id, name]\"", "results", "=", "self", ".", "client", ".", "call", "(", "'Account'", ",", "'getPlacementGroups'", ",", "filter", "=", "_filter", ",", "mask", "=", "mask", ")", "return", "[", "result", "[", "'id'", "]", "for", "result", "in", "results", "]" ]
List placement group ids which match the given name.
[ "List", "placement", "group", "ids", "which", "match", "the", "given", "name", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_placement.py#L110-L119
train
234,536
softlayer/softlayer-python
SoftLayer/CLI/virt/capacity/create_options.py
cli
def cli(env): """List options for creating Reserved Capacity""" manager = CapacityManager(env.client) items = manager.get_create_options() items.sort(key=lambda term: int(term['capacity'])) table = formatting.Table(["KeyName", "Description", "Term", "Default Hourly Price Per Instance"], title="Reserved Capacity Options") table.align["Hourly Price"] = "l" table.align["Description"] = "l" table.align["KeyName"] = "l" for item in items: table.add_row([ item['keyName'], item['description'], item['capacity'], get_price(item) ]) env.fout(table) regions = manager.get_available_routers() location_table = formatting.Table(['Location', 'POD', 'BackendRouterId'], 'Orderable Locations') for region in regions: for location in region['locations']: for pod in location['location']['pods']: location_table.add_row([region['keyname'], pod['backendRouterName'], pod['backendRouterId']]) env.fout(location_table)
python
def cli(env): """List options for creating Reserved Capacity""" manager = CapacityManager(env.client) items = manager.get_create_options() items.sort(key=lambda term: int(term['capacity'])) table = formatting.Table(["KeyName", "Description", "Term", "Default Hourly Price Per Instance"], title="Reserved Capacity Options") table.align["Hourly Price"] = "l" table.align["Description"] = "l" table.align["KeyName"] = "l" for item in items: table.add_row([ item['keyName'], item['description'], item['capacity'], get_price(item) ]) env.fout(table) regions = manager.get_available_routers() location_table = formatting.Table(['Location', 'POD', 'BackendRouterId'], 'Orderable Locations') for region in regions: for location in region['locations']: for pod in location['location']['pods']: location_table.add_row([region['keyname'], pod['backendRouterName'], pod['backendRouterId']]) env.fout(location_table)
[ "def", "cli", "(", "env", ")", ":", "manager", "=", "CapacityManager", "(", "env", ".", "client", ")", "items", "=", "manager", ".", "get_create_options", "(", ")", "items", ".", "sort", "(", "key", "=", "lambda", "term", ":", "int", "(", "term", "[", "'capacity'", "]", ")", ")", "table", "=", "formatting", ".", "Table", "(", "[", "\"KeyName\"", ",", "\"Description\"", ",", "\"Term\"", ",", "\"Default Hourly Price Per Instance\"", "]", ",", "title", "=", "\"Reserved Capacity Options\"", ")", "table", ".", "align", "[", "\"Hourly Price\"", "]", "=", "\"l\"", "table", ".", "align", "[", "\"Description\"", "]", "=", "\"l\"", "table", ".", "align", "[", "\"KeyName\"", "]", "=", "\"l\"", "for", "item", "in", "items", ":", "table", ".", "add_row", "(", "[", "item", "[", "'keyName'", "]", ",", "item", "[", "'description'", "]", ",", "item", "[", "'capacity'", "]", ",", "get_price", "(", "item", ")", "]", ")", "env", ".", "fout", "(", "table", ")", "regions", "=", "manager", ".", "get_available_routers", "(", ")", "location_table", "=", "formatting", ".", "Table", "(", "[", "'Location'", ",", "'POD'", ",", "'BackendRouterId'", "]", ",", "'Orderable Locations'", ")", "for", "region", "in", "regions", ":", "for", "location", "in", "region", "[", "'locations'", "]", ":", "for", "pod", "in", "location", "[", "'location'", "]", "[", "'pods'", "]", ":", "location_table", ".", "add_row", "(", "[", "region", "[", "'keyname'", "]", ",", "pod", "[", "'backendRouterName'", "]", ",", "pod", "[", "'backendRouterId'", "]", "]", ")", "env", ".", "fout", "(", "location_table", ")" ]
List options for creating Reserved Capacity
[ "List", "options", "for", "creating", "Reserved", "Capacity" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/capacity/create_options.py#L13-L36
train
234,537
softlayer/softlayer-python
SoftLayer/CLI/virt/capacity/create_options.py
get_price
def get_price(item): """Finds the price with the default locationGroupId""" the_price = "No Default Pricing" for price in item.get('prices', []): if not price.get('locationGroupId'): the_price = "%0.4f" % float(price['hourlyRecurringFee']) return the_price
python
def get_price(item): """Finds the price with the default locationGroupId""" the_price = "No Default Pricing" for price in item.get('prices', []): if not price.get('locationGroupId'): the_price = "%0.4f" % float(price['hourlyRecurringFee']) return the_price
[ "def", "get_price", "(", "item", ")", ":", "the_price", "=", "\"No Default Pricing\"", "for", "price", "in", "item", ".", "get", "(", "'prices'", ",", "[", "]", ")", ":", "if", "not", "price", ".", "get", "(", "'locationGroupId'", ")", ":", "the_price", "=", "\"%0.4f\"", "%", "float", "(", "price", "[", "'hourlyRecurringFee'", "]", ")", "return", "the_price" ]
Finds the price with the default locationGroupId
[ "Finds", "the", "price", "with", "the", "default", "locationGroupId" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/capacity/create_options.py#L39-L45
train
234,538
softlayer/softlayer-python
SoftLayer/CLI/order/package_list.py
cli
def cli(env, keyword, package_type): """List packages that can be ordered via the placeOrder API. :: # List out all packages for ordering slcli order package-list # List out all packages with "server" in the name slcli order package-list --keyword server # Select only specifict package types slcli order package-list --package_type BARE_METAL_CPU """ manager = ordering.OrderingManager(env.client) table = formatting.Table(COLUMNS) _filter = {'type': {'keyName': {'operation': '!= BLUEMIX_SERVICE'}}} if keyword: _filter['name'] = {'operation': '*= %s' % keyword} if package_type: _filter['type'] = {'keyName': {'operation': package_type}} packages = manager.list_packages(filter=_filter) for package in packages: table.add_row([ package['id'], package['name'], package['keyName'], package['type']['keyName'] ]) env.fout(table)
python
def cli(env, keyword, package_type): """List packages that can be ordered via the placeOrder API. :: # List out all packages for ordering slcli order package-list # List out all packages with "server" in the name slcli order package-list --keyword server # Select only specifict package types slcli order package-list --package_type BARE_METAL_CPU """ manager = ordering.OrderingManager(env.client) table = formatting.Table(COLUMNS) _filter = {'type': {'keyName': {'operation': '!= BLUEMIX_SERVICE'}}} if keyword: _filter['name'] = {'operation': '*= %s' % keyword} if package_type: _filter['type'] = {'keyName': {'operation': package_type}} packages = manager.list_packages(filter=_filter) for package in packages: table.add_row([ package['id'], package['name'], package['keyName'], package['type']['keyName'] ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "keyword", ",", "package_type", ")", ":", "manager", "=", "ordering", ".", "OrderingManager", "(", "env", ".", "client", ")", "table", "=", "formatting", ".", "Table", "(", "COLUMNS", ")", "_filter", "=", "{", "'type'", ":", "{", "'keyName'", ":", "{", "'operation'", ":", "'!= BLUEMIX_SERVICE'", "}", "}", "}", "if", "keyword", ":", "_filter", "[", "'name'", "]", "=", "{", "'operation'", ":", "'*= %s'", "%", "keyword", "}", "if", "package_type", ":", "_filter", "[", "'type'", "]", "=", "{", "'keyName'", ":", "{", "'operation'", ":", "package_type", "}", "}", "packages", "=", "manager", ".", "list_packages", "(", "filter", "=", "_filter", ")", "for", "package", "in", "packages", ":", "table", ".", "add_row", "(", "[", "package", "[", "'id'", "]", ",", "package", "[", "'name'", "]", ",", "package", "[", "'keyName'", "]", ",", "package", "[", "'type'", "]", "[", "'keyName'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List packages that can be ordered via the placeOrder API. :: # List out all packages for ordering slcli order package-list # List out all packages with "server" in the name slcli order package-list --keyword server # Select only specifict package types slcli order package-list --package_type BARE_METAL_CPU
[ "List", "packages", "that", "can", "be", "ordered", "via", "the", "placeOrder", "API", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/package_list.py#L20-L53
train
234,539
softlayer/softlayer-python
SoftLayer/CLI/loadbal/list.py
cli
def cli(env): """List active load balancers.""" mgr = SoftLayer.LoadBalancerManager(env.client) load_balancers = mgr.get_local_lbs() table = formatting.Table(['ID', 'VIP Address', 'Location', 'SSL Offload', 'Connections/second', 'Type']) table.align['Connections/second'] = 'r' for load_balancer in load_balancers: ssl_support = 'Not Supported' if load_balancer['sslEnabledFlag']: if load_balancer['sslActiveFlag']: ssl_support = 'On' else: ssl_support = 'Off' lb_type = 'Standard' if load_balancer['dedicatedFlag']: lb_type = 'Dedicated' elif load_balancer['highAvailabilityFlag']: lb_type = 'HA' table.add_row([ 'local:%s' % load_balancer['id'], load_balancer['ipAddress']['ipAddress'], load_balancer['loadBalancerHardware'][0]['datacenter']['name'], ssl_support, load_balancer['connectionLimit'], lb_type ]) env.fout(table)
python
def cli(env): """List active load balancers.""" mgr = SoftLayer.LoadBalancerManager(env.client) load_balancers = mgr.get_local_lbs() table = formatting.Table(['ID', 'VIP Address', 'Location', 'SSL Offload', 'Connections/second', 'Type']) table.align['Connections/second'] = 'r' for load_balancer in load_balancers: ssl_support = 'Not Supported' if load_balancer['sslEnabledFlag']: if load_balancer['sslActiveFlag']: ssl_support = 'On' else: ssl_support = 'Off' lb_type = 'Standard' if load_balancer['dedicatedFlag']: lb_type = 'Dedicated' elif load_balancer['highAvailabilityFlag']: lb_type = 'HA' table.add_row([ 'local:%s' % load_balancer['id'], load_balancer['ipAddress']['ipAddress'], load_balancer['loadBalancerHardware'][0]['datacenter']['name'], ssl_support, load_balancer['connectionLimit'], lb_type ]) env.fout(table)
[ "def", "cli", "(", "env", ")", ":", "mgr", "=", "SoftLayer", ".", "LoadBalancerManager", "(", "env", ".", "client", ")", "load_balancers", "=", "mgr", ".", "get_local_lbs", "(", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'ID'", ",", "'VIP Address'", ",", "'Location'", ",", "'SSL Offload'", ",", "'Connections/second'", ",", "'Type'", "]", ")", "table", ".", "align", "[", "'Connections/second'", "]", "=", "'r'", "for", "load_balancer", "in", "load_balancers", ":", "ssl_support", "=", "'Not Supported'", "if", "load_balancer", "[", "'sslEnabledFlag'", "]", ":", "if", "load_balancer", "[", "'sslActiveFlag'", "]", ":", "ssl_support", "=", "'On'", "else", ":", "ssl_support", "=", "'Off'", "lb_type", "=", "'Standard'", "if", "load_balancer", "[", "'dedicatedFlag'", "]", ":", "lb_type", "=", "'Dedicated'", "elif", "load_balancer", "[", "'highAvailabilityFlag'", "]", ":", "lb_type", "=", "'HA'", "table", ".", "add_row", "(", "[", "'local:%s'", "%", "load_balancer", "[", "'id'", "]", ",", "load_balancer", "[", "'ipAddress'", "]", "[", "'ipAddress'", "]", ",", "load_balancer", "[", "'loadBalancerHardware'", "]", "[", "0", "]", "[", "'datacenter'", "]", "[", "'name'", "]", ",", "ssl_support", ",", "load_balancer", "[", "'connectionLimit'", "]", ",", "lb_type", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List active load balancers.
[ "List", "active", "load", "balancers", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/list.py#L13-L49
train
234,540
softlayer/softlayer-python
SoftLayer/CLI/hardware/credentials.py
cli
def cli(env, identifier): """List server credentials.""" manager = SoftLayer.HardwareManager(env.client) hardware_id = helpers.resolve_id(manager.resolve_ids, identifier, 'hardware') instance = manager.get_hardware(hardware_id) table = formatting.Table(['username', 'password']) for item in instance['softwareComponents']: if 'passwords' not in item: raise exceptions.SoftLayerError("No passwords found in softwareComponents") for credentials in item['passwords']: table.add_row([credentials.get('username', 'None'), credentials.get('password', 'None')]) env.fout(table)
python
def cli(env, identifier): """List server credentials.""" manager = SoftLayer.HardwareManager(env.client) hardware_id = helpers.resolve_id(manager.resolve_ids, identifier, 'hardware') instance = manager.get_hardware(hardware_id) table = formatting.Table(['username', 'password']) for item in instance['softwareComponents']: if 'passwords' not in item: raise exceptions.SoftLayerError("No passwords found in softwareComponents") for credentials in item['passwords']: table.add_row([credentials.get('username', 'None'), credentials.get('password', 'None')]) env.fout(table)
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "manager", "=", "SoftLayer", ".", "HardwareManager", "(", "env", ".", "client", ")", "hardware_id", "=", "helpers", ".", "resolve_id", "(", "manager", ".", "resolve_ids", ",", "identifier", ",", "'hardware'", ")", "instance", "=", "manager", ".", "get_hardware", "(", "hardware_id", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'username'", ",", "'password'", "]", ")", "for", "item", "in", "instance", "[", "'softwareComponents'", "]", ":", "if", "'passwords'", "not", "in", "item", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"No passwords found in softwareComponents\"", ")", "for", "credentials", "in", "item", "[", "'passwords'", "]", ":", "table", ".", "add_row", "(", "[", "credentials", ".", "get", "(", "'username'", ",", "'None'", ")", ",", "credentials", ".", "get", "(", "'password'", ",", "'None'", ")", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List server credentials.
[ "List", "server", "credentials", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/hardware/credentials.py#L16-L31
train
234,541
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
populate_host_templates
def populate_host_templates(host_templates, hardware_ids=None, virtual_guest_ids=None, ip_address_ids=None, subnet_ids=None): """Populate the given host_templates array with the IDs provided :param host_templates: The array to which host templates will be added :param hardware_ids: A List of SoftLayer_Hardware ids :param virtual_guest_ids: A List of SoftLayer_Virtual_Guest ids :param ip_address_ids: A List of SoftLayer_Network_Subnet_IpAddress ids :param subnet_ids: A List of SoftLayer_Network_Subnet ids """ if hardware_ids is not None: for hardware_id in hardware_ids: host_templates.append({ 'objectType': 'SoftLayer_Hardware', 'id': hardware_id }) if virtual_guest_ids is not None: for virtual_guest_id in virtual_guest_ids: host_templates.append({ 'objectType': 'SoftLayer_Virtual_Guest', 'id': virtual_guest_id }) if ip_address_ids is not None: for ip_address_id in ip_address_ids: host_templates.append({ 'objectType': 'SoftLayer_Network_Subnet_IpAddress', 'id': ip_address_id }) if subnet_ids is not None: for subnet_id in subnet_ids: host_templates.append({ 'objectType': 'SoftLayer_Network_Subnet', 'id': subnet_id })
python
def populate_host_templates(host_templates, hardware_ids=None, virtual_guest_ids=None, ip_address_ids=None, subnet_ids=None): """Populate the given host_templates array with the IDs provided :param host_templates: The array to which host templates will be added :param hardware_ids: A List of SoftLayer_Hardware ids :param virtual_guest_ids: A List of SoftLayer_Virtual_Guest ids :param ip_address_ids: A List of SoftLayer_Network_Subnet_IpAddress ids :param subnet_ids: A List of SoftLayer_Network_Subnet ids """ if hardware_ids is not None: for hardware_id in hardware_ids: host_templates.append({ 'objectType': 'SoftLayer_Hardware', 'id': hardware_id }) if virtual_guest_ids is not None: for virtual_guest_id in virtual_guest_ids: host_templates.append({ 'objectType': 'SoftLayer_Virtual_Guest', 'id': virtual_guest_id }) if ip_address_ids is not None: for ip_address_id in ip_address_ids: host_templates.append({ 'objectType': 'SoftLayer_Network_Subnet_IpAddress', 'id': ip_address_id }) if subnet_ids is not None: for subnet_id in subnet_ids: host_templates.append({ 'objectType': 'SoftLayer_Network_Subnet', 'id': subnet_id })
[ "def", "populate_host_templates", "(", "host_templates", ",", "hardware_ids", "=", "None", ",", "virtual_guest_ids", "=", "None", ",", "ip_address_ids", "=", "None", ",", "subnet_ids", "=", "None", ")", ":", "if", "hardware_ids", "is", "not", "None", ":", "for", "hardware_id", "in", "hardware_ids", ":", "host_templates", ".", "append", "(", "{", "'objectType'", ":", "'SoftLayer_Hardware'", ",", "'id'", ":", "hardware_id", "}", ")", "if", "virtual_guest_ids", "is", "not", "None", ":", "for", "virtual_guest_id", "in", "virtual_guest_ids", ":", "host_templates", ".", "append", "(", "{", "'objectType'", ":", "'SoftLayer_Virtual_Guest'", ",", "'id'", ":", "virtual_guest_id", "}", ")", "if", "ip_address_ids", "is", "not", "None", ":", "for", "ip_address_id", "in", "ip_address_ids", ":", "host_templates", ".", "append", "(", "{", "'objectType'", ":", "'SoftLayer_Network_Subnet_IpAddress'", ",", "'id'", ":", "ip_address_id", "}", ")", "if", "subnet_ids", "is", "not", "None", ":", "for", "subnet_id", "in", "subnet_ids", ":", "host_templates", ".", "append", "(", "{", "'objectType'", ":", "'SoftLayer_Network_Subnet'", ",", "'id'", ":", "subnet_id", "}", ")" ]
Populate the given host_templates array with the IDs provided :param host_templates: The array to which host templates will be added :param hardware_ids: A List of SoftLayer_Hardware ids :param virtual_guest_ids: A List of SoftLayer_Virtual_Guest ids :param ip_address_ids: A List of SoftLayer_Network_Subnet_IpAddress ids :param subnet_ids: A List of SoftLayer_Network_Subnet ids
[ "Populate", "the", "given", "host_templates", "array", "with", "the", "IDs", "provided" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L22-L61
train
234,542
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
get_package
def get_package(manager, category_code): """Returns a product package based on type of storage. :param manager: The storage manager which calls this function. :param category_code: Category code of product package. :return: Returns a packaged based on type of storage. """ _filter = utils.NestedDict({}) _filter['categories']['categoryCode'] = ( utils.query_filter(category_code)) _filter['statusCode'] = (utils.query_filter('ACTIVE')) packages = manager.client.call( 'Product_Package', 'getAllObjects', filter=_filter.to_dict(), mask='id,name,items[prices[categories],attributes]' ) if len(packages) == 0: raise ValueError('No packages were found for %s' % category_code) if len(packages) > 1: raise ValueError('More than one package was found for %s' % category_code) return packages[0]
python
def get_package(manager, category_code): """Returns a product package based on type of storage. :param manager: The storage manager which calls this function. :param category_code: Category code of product package. :return: Returns a packaged based on type of storage. """ _filter = utils.NestedDict({}) _filter['categories']['categoryCode'] = ( utils.query_filter(category_code)) _filter['statusCode'] = (utils.query_filter('ACTIVE')) packages = manager.client.call( 'Product_Package', 'getAllObjects', filter=_filter.to_dict(), mask='id,name,items[prices[categories],attributes]' ) if len(packages) == 0: raise ValueError('No packages were found for %s' % category_code) if len(packages) > 1: raise ValueError('More than one package was found for %s' % category_code) return packages[0]
[ "def", "get_package", "(", "manager", ",", "category_code", ")", ":", "_filter", "=", "utils", ".", "NestedDict", "(", "{", "}", ")", "_filter", "[", "'categories'", "]", "[", "'categoryCode'", "]", "=", "(", "utils", ".", "query_filter", "(", "category_code", ")", ")", "_filter", "[", "'statusCode'", "]", "=", "(", "utils", ".", "query_filter", "(", "'ACTIVE'", ")", ")", "packages", "=", "manager", ".", "client", ".", "call", "(", "'Product_Package'", ",", "'getAllObjects'", ",", "filter", "=", "_filter", ".", "to_dict", "(", ")", ",", "mask", "=", "'id,name,items[prices[categories],attributes]'", ")", "if", "len", "(", "packages", ")", "==", "0", ":", "raise", "ValueError", "(", "'No packages were found for %s'", "%", "category_code", ")", "if", "len", "(", "packages", ")", ">", "1", ":", "raise", "ValueError", "(", "'More than one package was found for %s'", "%", "category_code", ")", "return", "packages", "[", "0", "]" ]
Returns a product package based on type of storage. :param manager: The storage manager which calls this function. :param category_code: Category code of product package. :return: Returns a packaged based on type of storage.
[ "Returns", "a", "product", "package", "based", "on", "type", "of", "storage", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L64-L88
train
234,543
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
get_location_id
def get_location_id(manager, location): """Returns location id :param manager: The storage manager which calls this function. :param location: Datacenter short name :return: Returns location id """ loc_svc = manager.client['Location_Datacenter'] datacenters = loc_svc.getDatacenters(mask='mask[longName,id,name]') for datacenter in datacenters: if datacenter['name'] == location: location = datacenter['id'] return location raise ValueError('Invalid datacenter name specified.')
python
def get_location_id(manager, location): """Returns location id :param manager: The storage manager which calls this function. :param location: Datacenter short name :return: Returns location id """ loc_svc = manager.client['Location_Datacenter'] datacenters = loc_svc.getDatacenters(mask='mask[longName,id,name]') for datacenter in datacenters: if datacenter['name'] == location: location = datacenter['id'] return location raise ValueError('Invalid datacenter name specified.')
[ "def", "get_location_id", "(", "manager", ",", "location", ")", ":", "loc_svc", "=", "manager", ".", "client", "[", "'Location_Datacenter'", "]", "datacenters", "=", "loc_svc", ".", "getDatacenters", "(", "mask", "=", "'mask[longName,id,name]'", ")", "for", "datacenter", "in", "datacenters", ":", "if", "datacenter", "[", "'name'", "]", "==", "location", ":", "location", "=", "datacenter", "[", "'id'", "]", "return", "location", "raise", "ValueError", "(", "'Invalid datacenter name specified.'", ")" ]
Returns location id :param manager: The storage manager which calls this function. :param location: Datacenter short name :return: Returns location id
[ "Returns", "location", "id" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L91-L104
train
234,544
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_price_by_category
def find_price_by_category(package, price_category): """Find the price in the given package that has the specified category :param package: The AsAService, Enterprise, or Performance product package :param price_category: The price category code to search for :return: Returns the price for the given category, or an error if not found """ for item in package['items']: price_id = _find_price_id(item['prices'], price_category) if price_id: return price_id raise ValueError("Could not find price with the category, %s" % price_category)
python
def find_price_by_category(package, price_category): """Find the price in the given package that has the specified category :param package: The AsAService, Enterprise, or Performance product package :param price_category: The price category code to search for :return: Returns the price for the given category, or an error if not found """ for item in package['items']: price_id = _find_price_id(item['prices'], price_category) if price_id: return price_id raise ValueError("Could not find price with the category, %s" % price_category)
[ "def", "find_price_by_category", "(", "package", ",", "price_category", ")", ":", "for", "item", "in", "package", "[", "'items'", "]", ":", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "price_category", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price with the category, %s\"", "%", "price_category", ")" ]
Find the price in the given package that has the specified category :param package: The AsAService, Enterprise, or Performance product package :param price_category: The price category code to search for :return: Returns the price for the given category, or an error if not found
[ "Find", "the", "price", "in", "the", "given", "package", "that", "has", "the", "specified", "category" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L107-L119
train
234,545
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_ent_space_price
def find_ent_space_price(package, category, size, tier_level): """Find the space price for the given category, size, and tier :param package: The Enterprise (Endurance) product package :param category: The category of space (endurance, replication, snapshot) :param size: The size for which a price is desired :param tier_level: The endurance tier for which a price is desired :return: Returns the matching price, or an error if not found """ if category == 'snapshot': category_code = 'storage_snapshot_space' elif category == 'replication': category_code = 'performance_storage_replication' else: # category == 'endurance' category_code = 'performance_storage_space' level = ENDURANCE_TIERS.get(tier_level) for item in package['items']: if int(item['capacity']) != size: continue price_id = _find_price_id(item['prices'], category_code, 'STORAGE_TIER_LEVEL', level) if price_id: return price_id raise ValueError("Could not find price for %s storage space" % category)
python
def find_ent_space_price(package, category, size, tier_level): """Find the space price for the given category, size, and tier :param package: The Enterprise (Endurance) product package :param category: The category of space (endurance, replication, snapshot) :param size: The size for which a price is desired :param tier_level: The endurance tier for which a price is desired :return: Returns the matching price, or an error if not found """ if category == 'snapshot': category_code = 'storage_snapshot_space' elif category == 'replication': category_code = 'performance_storage_replication' else: # category == 'endurance' category_code = 'performance_storage_space' level = ENDURANCE_TIERS.get(tier_level) for item in package['items']: if int(item['capacity']) != size: continue price_id = _find_price_id(item['prices'], category_code, 'STORAGE_TIER_LEVEL', level) if price_id: return price_id raise ValueError("Could not find price for %s storage space" % category)
[ "def", "find_ent_space_price", "(", "package", ",", "category", ",", "size", ",", "tier_level", ")", ":", "if", "category", "==", "'snapshot'", ":", "category_code", "=", "'storage_snapshot_space'", "elif", "category", "==", "'replication'", ":", "category_code", "=", "'performance_storage_replication'", "else", ":", "# category == 'endurance'", "category_code", "=", "'performance_storage_space'", "level", "=", "ENDURANCE_TIERS", ".", "get", "(", "tier_level", ")", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "int", "(", "item", "[", "'capacity'", "]", ")", "!=", "size", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "category_code", ",", "'STORAGE_TIER_LEVEL'", ",", "level", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for %s storage space\"", "%", "category", ")" ]
Find the space price for the given category, size, and tier :param package: The Enterprise (Endurance) product package :param category: The category of space (endurance, replication, snapshot) :param size: The size for which a price is desired :param tier_level: The endurance tier for which a price is desired :return: Returns the matching price, or an error if not found
[ "Find", "the", "space", "price", "for", "the", "given", "category", "size", "and", "tier" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L122-L147
train
234,546
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_ent_endurance_tier_price
def find_ent_endurance_tier_price(package, tier_level): """Find the price in the given package with the specified tier level :param package: The Enterprise (Endurance) product package :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the given tier, or an error if not found """ for item in package['items']: for attribute in item.get('attributes', []): if int(attribute['value']) == ENDURANCE_TIERS.get(tier_level): break else: continue price_id = _find_price_id(item['prices'], 'storage_tier_level') if price_id: return price_id raise ValueError("Could not find price for endurance tier level")
python
def find_ent_endurance_tier_price(package, tier_level): """Find the price in the given package with the specified tier level :param package: The Enterprise (Endurance) product package :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the given tier, or an error if not found """ for item in package['items']: for attribute in item.get('attributes', []): if int(attribute['value']) == ENDURANCE_TIERS.get(tier_level): break else: continue price_id = _find_price_id(item['prices'], 'storage_tier_level') if price_id: return price_id raise ValueError("Could not find price for endurance tier level")
[ "def", "find_ent_endurance_tier_price", "(", "package", ",", "tier_level", ")", ":", "for", "item", "in", "package", "[", "'items'", "]", ":", "for", "attribute", "in", "item", ".", "get", "(", "'attributes'", ",", "[", "]", ")", ":", "if", "int", "(", "attribute", "[", "'value'", "]", ")", "==", "ENDURANCE_TIERS", ".", "get", "(", "tier_level", ")", ":", "break", "else", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'storage_tier_level'", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for endurance tier level\"", ")" ]
Find the price in the given package with the specified tier level :param package: The Enterprise (Endurance) product package :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the given tier, or an error if not found
[ "Find", "the", "price", "in", "the", "given", "package", "with", "the", "specified", "tier", "level" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L150-L168
train
234,547
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_perf_space_price
def find_perf_space_price(package, size): """Find the price in the given package with the specified size :param package: The Performance product package :param size: The storage space size for which a price is desired :return: Returns the price for the given size, or an error if not found """ for item in package['items']: if int(item['capacity']) != size: continue price_id = _find_price_id(item['prices'], 'performance_storage_space') if price_id: return price_id raise ValueError("Could not find performance space price for this volume")
python
def find_perf_space_price(package, size): """Find the price in the given package with the specified size :param package: The Performance product package :param size: The storage space size for which a price is desired :return: Returns the price for the given size, or an error if not found """ for item in package['items']: if int(item['capacity']) != size: continue price_id = _find_price_id(item['prices'], 'performance_storage_space') if price_id: return price_id raise ValueError("Could not find performance space price for this volume")
[ "def", "find_perf_space_price", "(", "package", ",", "size", ")", ":", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "int", "(", "item", "[", "'capacity'", "]", ")", "!=", "size", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'performance_storage_space'", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find performance space price for this volume\"", ")" ]
Find the price in the given package with the specified size :param package: The Performance product package :param size: The storage space size for which a price is desired :return: Returns the price for the given size, or an error if not found
[ "Find", "the", "price", "in", "the", "given", "package", "with", "the", "specified", "size" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L194-L209
train
234,548
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_perf_iops_price
def find_perf_iops_price(package, size, iops): """Find the price in the given package with the specified size and iops :param package: The Performance product package :param size: The size of storage space for which an IOPS price is desired :param iops: The number of IOPS for which a price is desired :return: Returns the price for the size and IOPS, or an error if not found """ for item in package['items']: if int(item['capacity']) != int(iops): continue price_id = _find_price_id(item['prices'], 'performance_storage_iops', 'STORAGE_SPACE', size) if price_id: return price_id raise ValueError("Could not find price for iops for the given volume")
python
def find_perf_iops_price(package, size, iops): """Find the price in the given package with the specified size and iops :param package: The Performance product package :param size: The size of storage space for which an IOPS price is desired :param iops: The number of IOPS for which a price is desired :return: Returns the price for the size and IOPS, or an error if not found """ for item in package['items']: if int(item['capacity']) != int(iops): continue price_id = _find_price_id(item['prices'], 'performance_storage_iops', 'STORAGE_SPACE', size) if price_id: return price_id raise ValueError("Could not find price for iops for the given volume")
[ "def", "find_perf_iops_price", "(", "package", ",", "size", ",", "iops", ")", ":", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "int", "(", "item", "[", "'capacity'", "]", ")", "!=", "int", "(", "iops", ")", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'performance_storage_iops'", ",", "'STORAGE_SPACE'", ",", "size", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for iops for the given volume\"", ")" ]
Find the price in the given package with the specified size and iops :param package: The Performance product package :param size: The size of storage space for which an IOPS price is desired :param iops: The number of IOPS for which a price is desired :return: Returns the price for the size and IOPS, or an error if not found
[ "Find", "the", "price", "in", "the", "given", "package", "with", "the", "specified", "size", "and", "iops" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L212-L228
train
234,549
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_saas_endurance_space_price
def find_saas_endurance_space_price(package, size, tier_level): """Find the SaaS endurance storage space price for the size and tier :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the size and tier, or an error if not found """ if tier_level != 0.25: tier_level = int(tier_level) key_name = 'STORAGE_SPACE_FOR_{0}_IOPS_PER_GB'.format(tier_level) key_name = key_name.replace(".", "_") for item in package['items']: if key_name not in item['keyName']: continue if 'capacityMinimum' not in item or 'capacityMaximum' not in item: continue capacity_minimum = int(item['capacityMinimum']) capacity_maximum = int(item['capacityMaximum']) if size < capacity_minimum or size > capacity_maximum: continue price_id = _find_price_id(item['prices'], 'performance_storage_space') if price_id: return price_id raise ValueError("Could not find price for endurance storage space")
python
def find_saas_endurance_space_price(package, size, tier_level): """Find the SaaS endurance storage space price for the size and tier :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the size and tier, or an error if not found """ if tier_level != 0.25: tier_level = int(tier_level) key_name = 'STORAGE_SPACE_FOR_{0}_IOPS_PER_GB'.format(tier_level) key_name = key_name.replace(".", "_") for item in package['items']: if key_name not in item['keyName']: continue if 'capacityMinimum' not in item or 'capacityMaximum' not in item: continue capacity_minimum = int(item['capacityMinimum']) capacity_maximum = int(item['capacityMaximum']) if size < capacity_minimum or size > capacity_maximum: continue price_id = _find_price_id(item['prices'], 'performance_storage_space') if price_id: return price_id raise ValueError("Could not find price for endurance storage space")
[ "def", "find_saas_endurance_space_price", "(", "package", ",", "size", ",", "tier_level", ")", ":", "if", "tier_level", "!=", "0.25", ":", "tier_level", "=", "int", "(", "tier_level", ")", "key_name", "=", "'STORAGE_SPACE_FOR_{0}_IOPS_PER_GB'", ".", "format", "(", "tier_level", ")", "key_name", "=", "key_name", ".", "replace", "(", "\".\"", ",", "\"_\"", ")", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "key_name", "not", "in", "item", "[", "'keyName'", "]", ":", "continue", "if", "'capacityMinimum'", "not", "in", "item", "or", "'capacityMaximum'", "not", "in", "item", ":", "continue", "capacity_minimum", "=", "int", "(", "item", "[", "'capacityMinimum'", "]", ")", "capacity_maximum", "=", "int", "(", "item", "[", "'capacityMaximum'", "]", ")", "if", "size", "<", "capacity_minimum", "or", "size", ">", "capacity_maximum", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'performance_storage_space'", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for endurance storage space\"", ")" ]
Find the SaaS endurance storage space price for the size and tier :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the size and tier, or an error if not found
[ "Find", "the", "SaaS", "endurance", "storage", "space", "price", "for", "the", "size", "and", "tier" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L231-L259
train
234,550
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_saas_endurance_tier_price
def find_saas_endurance_tier_price(package, tier_level): """Find the SaaS storage tier level price for the specified tier level :param package: The Storage As A Service product package :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the given tier, or an error if not found """ target_capacity = ENDURANCE_TIERS.get(tier_level) for item in package['items']: if 'itemCategory' not in item\ or 'categoryCode' not in item['itemCategory']\ or item['itemCategory']['categoryCode']\ != 'storage_tier_level': continue if int(item['capacity']) != target_capacity: continue price_id = _find_price_id(item['prices'], 'storage_tier_level') if price_id: return price_id raise ValueError("Could not find price for endurance tier level")
python
def find_saas_endurance_tier_price(package, tier_level): """Find the SaaS storage tier level price for the specified tier level :param package: The Storage As A Service product package :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the given tier, or an error if not found """ target_capacity = ENDURANCE_TIERS.get(tier_level) for item in package['items']: if 'itemCategory' not in item\ or 'categoryCode' not in item['itemCategory']\ or item['itemCategory']['categoryCode']\ != 'storage_tier_level': continue if int(item['capacity']) != target_capacity: continue price_id = _find_price_id(item['prices'], 'storage_tier_level') if price_id: return price_id raise ValueError("Could not find price for endurance tier level")
[ "def", "find_saas_endurance_tier_price", "(", "package", ",", "tier_level", ")", ":", "target_capacity", "=", "ENDURANCE_TIERS", ".", "get", "(", "tier_level", ")", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "'itemCategory'", "not", "in", "item", "or", "'categoryCode'", "not", "in", "item", "[", "'itemCategory'", "]", "or", "item", "[", "'itemCategory'", "]", "[", "'categoryCode'", "]", "!=", "'storage_tier_level'", ":", "continue", "if", "int", "(", "item", "[", "'capacity'", "]", ")", "!=", "target_capacity", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'storage_tier_level'", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for endurance tier level\"", ")" ]
Find the SaaS storage tier level price for the specified tier level :param package: The Storage As A Service product package :param tier_level: The endurance tier for which a price is desired :return: Returns the price for the given tier, or an error if not found
[ "Find", "the", "SaaS", "storage", "tier", "level", "price", "for", "the", "specified", "tier", "level" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L262-L284
train
234,551
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_saas_perform_space_price
def find_saas_perform_space_price(package, size): """Find the SaaS performance storage space price for the given size :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :return: Returns the price for the size and tier, or an error if not found """ for item in package['items']: if 'itemCategory' not in item\ or 'categoryCode' not in item['itemCategory']\ or item['itemCategory']['categoryCode']\ != 'performance_storage_space': continue if 'capacityMinimum' not in item or 'capacityMaximum' not in item: continue capacity_minimum = int(item['capacityMinimum']) capacity_maximum = int(item['capacityMaximum']) if size < capacity_minimum or size > capacity_maximum: continue key_name = '{0}_{1}_GBS'.format(capacity_minimum, capacity_maximum) if item['keyName'] != key_name: continue price_id = _find_price_id(item['prices'], 'performance_storage_space') if price_id: return price_id raise ValueError("Could not find price for performance storage space")
python
def find_saas_perform_space_price(package, size): """Find the SaaS performance storage space price for the given size :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :return: Returns the price for the size and tier, or an error if not found """ for item in package['items']: if 'itemCategory' not in item\ or 'categoryCode' not in item['itemCategory']\ or item['itemCategory']['categoryCode']\ != 'performance_storage_space': continue if 'capacityMinimum' not in item or 'capacityMaximum' not in item: continue capacity_minimum = int(item['capacityMinimum']) capacity_maximum = int(item['capacityMaximum']) if size < capacity_minimum or size > capacity_maximum: continue key_name = '{0}_{1}_GBS'.format(capacity_minimum, capacity_maximum) if item['keyName'] != key_name: continue price_id = _find_price_id(item['prices'], 'performance_storage_space') if price_id: return price_id raise ValueError("Could not find price for performance storage space")
[ "def", "find_saas_perform_space_price", "(", "package", ",", "size", ")", ":", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "'itemCategory'", "not", "in", "item", "or", "'categoryCode'", "not", "in", "item", "[", "'itemCategory'", "]", "or", "item", "[", "'itemCategory'", "]", "[", "'categoryCode'", "]", "!=", "'performance_storage_space'", ":", "continue", "if", "'capacityMinimum'", "not", "in", "item", "or", "'capacityMaximum'", "not", "in", "item", ":", "continue", "capacity_minimum", "=", "int", "(", "item", "[", "'capacityMinimum'", "]", ")", "capacity_maximum", "=", "int", "(", "item", "[", "'capacityMaximum'", "]", ")", "if", "size", "<", "capacity_minimum", "or", "size", ">", "capacity_maximum", ":", "continue", "key_name", "=", "'{0}_{1}_GBS'", ".", "format", "(", "capacity_minimum", ",", "capacity_maximum", ")", "if", "item", "[", "'keyName'", "]", "!=", "key_name", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'performance_storage_space'", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for performance storage space\"", ")" ]
Find the SaaS performance storage space price for the given size :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :return: Returns the price for the size and tier, or an error if not found
[ "Find", "the", "SaaS", "performance", "storage", "space", "price", "for", "the", "given", "size" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L287-L316
train
234,552
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_saas_perform_iops_price
def find_saas_perform_iops_price(package, size, iops): """Find the SaaS IOPS price for the specified size and iops :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :param iops: The number of IOPS for which a price is desired :return: Returns the price for the size and IOPS, or an error if not found """ for item in package['items']: if 'itemCategory' not in item\ or 'categoryCode' not in item['itemCategory']\ or item['itemCategory']['categoryCode']\ != 'performance_storage_iops': continue if 'capacityMinimum' not in item or 'capacityMaximum' not in item: continue capacity_minimum = int(item['capacityMinimum']) capacity_maximum = int(item['capacityMaximum']) if iops < capacity_minimum or iops > capacity_maximum: continue price_id = _find_price_id(item['prices'], 'performance_storage_iops', 'STORAGE_SPACE', size) if price_id: return price_id raise ValueError("Could not find price for iops for the given volume")
python
def find_saas_perform_iops_price(package, size, iops): """Find the SaaS IOPS price for the specified size and iops :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :param iops: The number of IOPS for which a price is desired :return: Returns the price for the size and IOPS, or an error if not found """ for item in package['items']: if 'itemCategory' not in item\ or 'categoryCode' not in item['itemCategory']\ or item['itemCategory']['categoryCode']\ != 'performance_storage_iops': continue if 'capacityMinimum' not in item or 'capacityMaximum' not in item: continue capacity_minimum = int(item['capacityMinimum']) capacity_maximum = int(item['capacityMaximum']) if iops < capacity_minimum or iops > capacity_maximum: continue price_id = _find_price_id(item['prices'], 'performance_storage_iops', 'STORAGE_SPACE', size) if price_id: return price_id raise ValueError("Could not find price for iops for the given volume")
[ "def", "find_saas_perform_iops_price", "(", "package", ",", "size", ",", "iops", ")", ":", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "'itemCategory'", "not", "in", "item", "or", "'categoryCode'", "not", "in", "item", "[", "'itemCategory'", "]", "or", "item", "[", "'itemCategory'", "]", "[", "'categoryCode'", "]", "!=", "'performance_storage_iops'", ":", "continue", "if", "'capacityMinimum'", "not", "in", "item", "or", "'capacityMaximum'", "not", "in", "item", ":", "continue", "capacity_minimum", "=", "int", "(", "item", "[", "'capacityMinimum'", "]", ")", "capacity_maximum", "=", "int", "(", "item", "[", "'capacityMaximum'", "]", ")", "if", "iops", "<", "capacity_minimum", "or", "iops", ">", "capacity_maximum", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'performance_storage_iops'", ",", "'STORAGE_SPACE'", ",", "size", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for iops for the given volume\"", ")" ]
Find the SaaS IOPS price for the specified size and iops :param package: The Storage As A Service product package :param size: The volume size for which a price is desired :param iops: The number of IOPS for which a price is desired :return: Returns the price for the size and IOPS, or an error if not found
[ "Find", "the", "SaaS", "IOPS", "price", "for", "the", "specified", "size", "and", "iops" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L319-L346
train
234,553
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_saas_snapshot_space_price
def find_saas_snapshot_space_price(package, size, tier=None, iops=None): """Find the price in the SaaS package for the desired snapshot space size :param package: The product package of the endurance storage type :param size: The snapshot space size for which a price is desired :param tier: The tier of the volume for which space is being ordered :param iops: The IOPS of the volume for which space is being ordered :return: Returns the price for the given size, or an error if not found """ if tier is not None: target_value = ENDURANCE_TIERS.get(tier) target_restriction_type = 'STORAGE_TIER_LEVEL' else: target_value = iops target_restriction_type = 'IOPS' for item in package['items']: if int(item['capacity']) != size: continue price_id = _find_price_id(item['prices'], 'storage_snapshot_space', target_restriction_type, target_value) if price_id: return price_id raise ValueError("Could not find price for snapshot space")
python
def find_saas_snapshot_space_price(package, size, tier=None, iops=None): """Find the price in the SaaS package for the desired snapshot space size :param package: The product package of the endurance storage type :param size: The snapshot space size for which a price is desired :param tier: The tier of the volume for which space is being ordered :param iops: The IOPS of the volume for which space is being ordered :return: Returns the price for the given size, or an error if not found """ if tier is not None: target_value = ENDURANCE_TIERS.get(tier) target_restriction_type = 'STORAGE_TIER_LEVEL' else: target_value = iops target_restriction_type = 'IOPS' for item in package['items']: if int(item['capacity']) != size: continue price_id = _find_price_id(item['prices'], 'storage_snapshot_space', target_restriction_type, target_value) if price_id: return price_id raise ValueError("Could not find price for snapshot space")
[ "def", "find_saas_snapshot_space_price", "(", "package", ",", "size", ",", "tier", "=", "None", ",", "iops", "=", "None", ")", ":", "if", "tier", "is", "not", "None", ":", "target_value", "=", "ENDURANCE_TIERS", ".", "get", "(", "tier", ")", "target_restriction_type", "=", "'STORAGE_TIER_LEVEL'", "else", ":", "target_value", "=", "iops", "target_restriction_type", "=", "'IOPS'", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "int", "(", "item", "[", "'capacity'", "]", ")", "!=", "size", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'storage_snapshot_space'", ",", "target_restriction_type", ",", "target_value", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for snapshot space\"", ")" ]
Find the price in the SaaS package for the desired snapshot space size :param package: The product package of the endurance storage type :param size: The snapshot space size for which a price is desired :param tier: The tier of the volume for which space is being ordered :param iops: The IOPS of the volume for which space is being ordered :return: Returns the price for the given size, or an error if not found
[ "Find", "the", "price", "in", "the", "SaaS", "package", "for", "the", "desired", "snapshot", "space", "size" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L349-L373
train
234,554
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_saas_replication_price
def find_saas_replication_price(package, tier=None, iops=None): """Find the price in the given package for the desired replicant volume :param package: The product package of the endurance storage type :param tier: The tier of the primary storage volume :param iops: The IOPS of the primary storage volume :return: Returns the replication price, or an error if not found """ if tier is not None: target_value = ENDURANCE_TIERS.get(tier) target_item_keyname = 'REPLICATION_FOR_TIERBASED_PERFORMANCE' target_restriction_type = 'STORAGE_TIER_LEVEL' else: target_value = iops target_item_keyname = 'REPLICATION_FOR_IOPSBASED_PERFORMANCE' target_restriction_type = 'IOPS' for item in package['items']: if item['keyName'] != target_item_keyname: continue price_id = _find_price_id( item['prices'], 'performance_storage_replication', target_restriction_type, target_value ) if price_id: return price_id raise ValueError("Could not find price for replicant volume")
python
def find_saas_replication_price(package, tier=None, iops=None): """Find the price in the given package for the desired replicant volume :param package: The product package of the endurance storage type :param tier: The tier of the primary storage volume :param iops: The IOPS of the primary storage volume :return: Returns the replication price, or an error if not found """ if tier is not None: target_value = ENDURANCE_TIERS.get(tier) target_item_keyname = 'REPLICATION_FOR_TIERBASED_PERFORMANCE' target_restriction_type = 'STORAGE_TIER_LEVEL' else: target_value = iops target_item_keyname = 'REPLICATION_FOR_IOPSBASED_PERFORMANCE' target_restriction_type = 'IOPS' for item in package['items']: if item['keyName'] != target_item_keyname: continue price_id = _find_price_id( item['prices'], 'performance_storage_replication', target_restriction_type, target_value ) if price_id: return price_id raise ValueError("Could not find price for replicant volume")
[ "def", "find_saas_replication_price", "(", "package", ",", "tier", "=", "None", ",", "iops", "=", "None", ")", ":", "if", "tier", "is", "not", "None", ":", "target_value", "=", "ENDURANCE_TIERS", ".", "get", "(", "tier", ")", "target_item_keyname", "=", "'REPLICATION_FOR_TIERBASED_PERFORMANCE'", "target_restriction_type", "=", "'STORAGE_TIER_LEVEL'", "else", ":", "target_value", "=", "iops", "target_item_keyname", "=", "'REPLICATION_FOR_IOPSBASED_PERFORMANCE'", "target_restriction_type", "=", "'IOPS'", "for", "item", "in", "package", "[", "'items'", "]", ":", "if", "item", "[", "'keyName'", "]", "!=", "target_item_keyname", ":", "continue", "price_id", "=", "_find_price_id", "(", "item", "[", "'prices'", "]", ",", "'performance_storage_replication'", ",", "target_restriction_type", ",", "target_value", ")", "if", "price_id", ":", "return", "price_id", "raise", "ValueError", "(", "\"Could not find price for replicant volume\"", ")" ]
Find the price in the given package for the desired replicant volume :param package: The product package of the endurance storage type :param tier: The tier of the primary storage volume :param iops: The IOPS of the primary storage volume :return: Returns the replication price, or an error if not found
[ "Find", "the", "price", "in", "the", "given", "package", "for", "the", "desired", "replicant", "volume" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L376-L406
train
234,555
softlayer/softlayer-python
SoftLayer/managers/storage_utils.py
find_snapshot_schedule_id
def find_snapshot_schedule_id(volume, snapshot_schedule_keyname): """Find the snapshot schedule ID for the given volume and keyname :param volume: The volume for which the snapshot ID is desired :param snapshot_schedule_keyname: The keyname of the snapshot schedule :return: Returns an int value indicating the volume's snapshot schedule ID """ for schedule in volume['schedules']: if 'type' in schedule and 'keyname' in schedule['type']: if schedule['type']['keyname'] == snapshot_schedule_keyname: return schedule['id'] raise ValueError("The given snapshot schedule ID was not found for " "the given storage volume")
python
def find_snapshot_schedule_id(volume, snapshot_schedule_keyname): """Find the snapshot schedule ID for the given volume and keyname :param volume: The volume for which the snapshot ID is desired :param snapshot_schedule_keyname: The keyname of the snapshot schedule :return: Returns an int value indicating the volume's snapshot schedule ID """ for schedule in volume['schedules']: if 'type' in schedule and 'keyname' in schedule['type']: if schedule['type']['keyname'] == snapshot_schedule_keyname: return schedule['id'] raise ValueError("The given snapshot schedule ID was not found for " "the given storage volume")
[ "def", "find_snapshot_schedule_id", "(", "volume", ",", "snapshot_schedule_keyname", ")", ":", "for", "schedule", "in", "volume", "[", "'schedules'", "]", ":", "if", "'type'", "in", "schedule", "and", "'keyname'", "in", "schedule", "[", "'type'", "]", ":", "if", "schedule", "[", "'type'", "]", "[", "'keyname'", "]", "==", "snapshot_schedule_keyname", ":", "return", "schedule", "[", "'id'", "]", "raise", "ValueError", "(", "\"The given snapshot schedule ID was not found for \"", "\"the given storage volume\"", ")" ]
Find the snapshot schedule ID for the given volume and keyname :param volume: The volume for which the snapshot ID is desired :param snapshot_schedule_keyname: The keyname of the snapshot schedule :return: Returns an int value indicating the volume's snapshot schedule ID
[ "Find", "the", "snapshot", "schedule", "ID", "for", "the", "given", "volume", "and", "keyname" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L409-L422
train
234,556
softlayer/softlayer-python
SoftLayer/CLI/file/snapshot/cancel.py
cli
def cli(env, volume_id, reason, immediate): """Cancel existing snapshot space for a given volume.""" file_storage_manager = SoftLayer.FileStorageManager(env.client) if not (env.skip_confirmations or formatting.no_going_back(volume_id)): raise exceptions.CLIAbort('Aborted') cancelled = file_storage_manager.cancel_snapshot_space( volume_id, reason, immediate) if cancelled: if immediate: click.echo('File volume with id %s has been marked' ' for immediate snapshot cancellation' % volume_id) else: click.echo('File volume with id %s has been marked' ' for snapshot cancellation' % volume_id) else: click.echo('Unable to cancel snapshot space for file volume %s' % volume_id)
python
def cli(env, volume_id, reason, immediate): """Cancel existing snapshot space for a given volume.""" file_storage_manager = SoftLayer.FileStorageManager(env.client) if not (env.skip_confirmations or formatting.no_going_back(volume_id)): raise exceptions.CLIAbort('Aborted') cancelled = file_storage_manager.cancel_snapshot_space( volume_id, reason, immediate) if cancelled: if immediate: click.echo('File volume with id %s has been marked' ' for immediate snapshot cancellation' % volume_id) else: click.echo('File volume with id %s has been marked' ' for snapshot cancellation' % volume_id) else: click.echo('Unable to cancel snapshot space for file volume %s' % volume_id)
[ "def", "cli", "(", "env", ",", "volume_id", ",", "reason", ",", "immediate", ")", ":", "file_storage_manager", "=", "SoftLayer", ".", "FileStorageManager", "(", "env", ".", "client", ")", "if", "not", "(", "env", ".", "skip_confirmations", "or", "formatting", ".", "no_going_back", "(", "volume_id", ")", ")", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Aborted'", ")", "cancelled", "=", "file_storage_manager", ".", "cancel_snapshot_space", "(", "volume_id", ",", "reason", ",", "immediate", ")", "if", "cancelled", ":", "if", "immediate", ":", "click", ".", "echo", "(", "'File volume with id %s has been marked'", "' for immediate snapshot cancellation'", "%", "volume_id", ")", "else", ":", "click", ".", "echo", "(", "'File volume with id %s has been marked'", "' for snapshot cancellation'", "%", "volume_id", ")", "else", ":", "click", ".", "echo", "(", "'Unable to cancel snapshot space for file volume %s'", "%", "volume_id", ")" ]
Cancel existing snapshot space for a given volume.
[ "Cancel", "existing", "snapshot", "space", "for", "a", "given", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/snapshot/cancel.py#L20-L40
train
234,557
softlayer/softlayer-python
SoftLayer/CLI/securitygroup/event_log.py
get_by_request_id
def get_by_request_id(env, request_id): """Search for event logs by request id""" mgr = SoftLayer.NetworkManager(env.client) logs = mgr.get_event_logs_by_request_id(request_id) table = formatting.Table(COLUMNS) table.align['metadata'] = "l" for log in logs: metadata = json.dumps(json.loads(log['metaData']), indent=4, sort_keys=True) table.add_row([log['eventName'], log['label'], log['eventCreateDate'], metadata]) env.fout(table)
python
def get_by_request_id(env, request_id): """Search for event logs by request id""" mgr = SoftLayer.NetworkManager(env.client) logs = mgr.get_event_logs_by_request_id(request_id) table = formatting.Table(COLUMNS) table.align['metadata'] = "l" for log in logs: metadata = json.dumps(json.loads(log['metaData']), indent=4, sort_keys=True) table.add_row([log['eventName'], log['label'], log['eventCreateDate'], metadata]) env.fout(table)
[ "def", "get_by_request_id", "(", "env", ",", "request_id", ")", ":", "mgr", "=", "SoftLayer", ".", "NetworkManager", "(", "env", ".", "client", ")", "logs", "=", "mgr", ".", "get_event_logs_by_request_id", "(", "request_id", ")", "table", "=", "formatting", ".", "Table", "(", "COLUMNS", ")", "table", ".", "align", "[", "'metadata'", "]", "=", "\"l\"", "for", "log", "in", "logs", ":", "metadata", "=", "json", ".", "dumps", "(", "json", ".", "loads", "(", "log", "[", "'metaData'", "]", ")", ",", "indent", "=", "4", ",", "sort_keys", "=", "True", ")", "table", ".", "add_row", "(", "[", "log", "[", "'eventName'", "]", ",", "log", "[", "'label'", "]", ",", "log", "[", "'eventCreateDate'", "]", ",", "metadata", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Search for event logs by request id
[ "Search", "for", "event", "logs", "by", "request", "id" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/securitygroup/event_log.py#L18-L32
train
234,558
softlayer/softlayer-python
SoftLayer/CLI/ticket/create.py
cli
def cli(env, title, subject_id, body, hardware_identifier, virtual_identifier, priority): """Create a support ticket.""" ticket_mgr = SoftLayer.TicketManager(env.client) if body is None: body = click.edit('\n\n' + ticket.TEMPLATE_MSG) created_ticket = ticket_mgr.create_ticket( title=title, body=body, subject=subject_id, priority=priority) if hardware_identifier: hardware_mgr = SoftLayer.HardwareManager(env.client) hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids, hardware_identifier, 'hardware') ticket_mgr.attach_hardware(created_ticket['id'], hardware_id) if virtual_identifier: vs_mgr = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vs_mgr.resolve_ids, virtual_identifier, 'VS') ticket_mgr.attach_virtual_server(created_ticket['id'], vs_id) env.fout(ticket.get_ticket_results(ticket_mgr, created_ticket['id']))
python
def cli(env, title, subject_id, body, hardware_identifier, virtual_identifier, priority): """Create a support ticket.""" ticket_mgr = SoftLayer.TicketManager(env.client) if body is None: body = click.edit('\n\n' + ticket.TEMPLATE_MSG) created_ticket = ticket_mgr.create_ticket( title=title, body=body, subject=subject_id, priority=priority) if hardware_identifier: hardware_mgr = SoftLayer.HardwareManager(env.client) hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids, hardware_identifier, 'hardware') ticket_mgr.attach_hardware(created_ticket['id'], hardware_id) if virtual_identifier: vs_mgr = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vs_mgr.resolve_ids, virtual_identifier, 'VS') ticket_mgr.attach_virtual_server(created_ticket['id'], vs_id) env.fout(ticket.get_ticket_results(ticket_mgr, created_ticket['id']))
[ "def", "cli", "(", "env", ",", "title", ",", "subject_id", ",", "body", ",", "hardware_identifier", ",", "virtual_identifier", ",", "priority", ")", ":", "ticket_mgr", "=", "SoftLayer", ".", "TicketManager", "(", "env", ".", "client", ")", "if", "body", "is", "None", ":", "body", "=", "click", ".", "edit", "(", "'\\n\\n'", "+", "ticket", ".", "TEMPLATE_MSG", ")", "created_ticket", "=", "ticket_mgr", ".", "create_ticket", "(", "title", "=", "title", ",", "body", "=", "body", ",", "subject", "=", "subject_id", ",", "priority", "=", "priority", ")", "if", "hardware_identifier", ":", "hardware_mgr", "=", "SoftLayer", ".", "HardwareManager", "(", "env", ".", "client", ")", "hardware_id", "=", "helpers", ".", "resolve_id", "(", "hardware_mgr", ".", "resolve_ids", ",", "hardware_identifier", ",", "'hardware'", ")", "ticket_mgr", ".", "attach_hardware", "(", "created_ticket", "[", "'id'", "]", ",", "hardware_id", ")", "if", "virtual_identifier", ":", "vs_mgr", "=", "SoftLayer", ".", "VSManager", "(", "env", ".", "client", ")", "vs_id", "=", "helpers", ".", "resolve_id", "(", "vs_mgr", ".", "resolve_ids", ",", "virtual_identifier", ",", "'VS'", ")", "ticket_mgr", ".", "attach_virtual_server", "(", "created_ticket", "[", "'id'", "]", ",", "vs_id", ")", "env", ".", "fout", "(", "ticket", ".", "get_ticket_results", "(", "ticket_mgr", ",", "created_ticket", "[", "'id'", "]", ")", ")" ]
Create a support ticket.
[ "Create", "a", "support", "ticket", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ticket/create.py#L26-L48
train
234,559
softlayer/softlayer-python
SoftLayer/CLI/file/replication/failback.py
cli
def cli(env, volume_id, replicant_id): """Failback a file volume from the given replicant volume.""" file_storage_manager = SoftLayer.FileStorageManager(env.client) success = file_storage_manager.failback_from_replicant( volume_id, replicant_id ) if success: click.echo("Failback from replicant is now in progress.") else: click.echo("Failback operation could not be initiated.")
python
def cli(env, volume_id, replicant_id): """Failback a file volume from the given replicant volume.""" file_storage_manager = SoftLayer.FileStorageManager(env.client) success = file_storage_manager.failback_from_replicant( volume_id, replicant_id ) if success: click.echo("Failback from replicant is now in progress.") else: click.echo("Failback operation could not be initiated.")
[ "def", "cli", "(", "env", ",", "volume_id", ",", "replicant_id", ")", ":", "file_storage_manager", "=", "SoftLayer", ".", "FileStorageManager", "(", "env", ".", "client", ")", "success", "=", "file_storage_manager", ".", "failback_from_replicant", "(", "volume_id", ",", "replicant_id", ")", "if", "success", ":", "click", ".", "echo", "(", "\"Failback from replicant is now in progress.\"", ")", "else", ":", "click", ".", "echo", "(", "\"Failback operation could not be initiated.\"", ")" ]
Failback a file volume from the given replicant volume.
[ "Failback", "a", "file", "volume", "from", "the", "given", "replicant", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/replication/failback.py#L14-L26
train
234,560
softlayer/softlayer-python
SoftLayer/CLI/file/snapshot/restore.py
cli
def cli(env, volume_id, snapshot_id): """Restore file volume using a given snapshot""" file_manager = SoftLayer.FileStorageManager(env.client) success = file_manager.restore_from_snapshot(volume_id, snapshot_id) if success: click.echo('File volume %s is being restored using snapshot %s' % (volume_id, snapshot_id))
python
def cli(env, volume_id, snapshot_id): """Restore file volume using a given snapshot""" file_manager = SoftLayer.FileStorageManager(env.client) success = file_manager.restore_from_snapshot(volume_id, snapshot_id) if success: click.echo('File volume %s is being restored using snapshot %s' % (volume_id, snapshot_id))
[ "def", "cli", "(", "env", ",", "volume_id", ",", "snapshot_id", ")", ":", "file_manager", "=", "SoftLayer", ".", "FileStorageManager", "(", "env", ".", "client", ")", "success", "=", "file_manager", ".", "restore_from_snapshot", "(", "volume_id", ",", "snapshot_id", ")", "if", "success", ":", "click", ".", "echo", "(", "'File volume %s is being restored using snapshot %s'", "%", "(", "volume_id", ",", "snapshot_id", ")", ")" ]
Restore file volume using a given snapshot
[ "Restore", "file", "volume", "using", "a", "given", "snapshot" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/snapshot/restore.py#L15-L22
train
234,561
softlayer/softlayer-python
SoftLayer/CLI/config/show.py
cli
def cli(env): """Show current configuration.""" settings = config.get_settings_from_client(env.client) env.fout(config.config_table(settings))
python
def cli(env): """Show current configuration.""" settings = config.get_settings_from_client(env.client) env.fout(config.config_table(settings))
[ "def", "cli", "(", "env", ")", ":", "settings", "=", "config", ".", "get_settings_from_client", "(", "env", ".", "client", ")", "env", ".", "fout", "(", "config", ".", "config_table", "(", "settings", ")", ")" ]
Show current configuration.
[ "Show", "current", "configuration", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/config/show.py#L12-L16
train
234,562
softlayer/softlayer-python
SoftLayer/CLI/file/order.py
cli
def cli(env, storage_type, size, iops, tier, location, snapshot_size, service_offering, billing): """Order a file storage volume. Valid size and iops options can be found here: https://console.bluemix.net/docs/infrastructure/FileStorage/index.html#provisioning """ file_manager = SoftLayer.FileStorageManager(env.client) storage_type = storage_type.lower() hourly_billing_flag = False if billing.lower() == "hourly": hourly_billing_flag = True if service_offering != 'storage_as_a_service': click.secho('{} is a legacy storage offering'.format(service_offering), fg='red') if hourly_billing_flag: raise exceptions.CLIAbort( 'Hourly billing is only available for the storage_as_a_service service offering' ) if storage_type == 'performance': if iops is None: raise exceptions.CLIAbort('Option --iops required with Performance') if service_offering == 'performance' and snapshot_size is not None: raise exceptions.CLIAbort( '--snapshot-size is not available for performance service offerings. ' 'Use --service-offering storage_as_a_service' ) try: order = file_manager.order_file_volume( storage_type=storage_type, location=location, size=size, iops=iops, snapshot_size=snapshot_size, service_offering=service_offering, hourly_billing_flag=hourly_billing_flag ) except ValueError as ex: raise exceptions.ArgumentError(str(ex)) if storage_type == 'endurance': if tier is None: raise exceptions.CLIAbort( 'Option --tier required with Endurance in IOPS/GB [0.25,2,4,10]' ) try: order = file_manager.order_file_volume( storage_type=storage_type, location=location, size=size, tier_level=float(tier), snapshot_size=snapshot_size, service_offering=service_offering, hourly_billing_flag=hourly_billing_flag ) except ValueError as ex: raise exceptions.ArgumentError(str(ex)) if 'placedOrder' in order.keys(): click.echo("Order #{0} placed successfully!".format( order['placedOrder']['id'])) for item in order['placedOrder']['items']: click.echo(" > %s" % item['description']) else: click.echo("Order could not be placed! Please verify your options and try again.")
python
def cli(env, storage_type, size, iops, tier, location, snapshot_size, service_offering, billing): """Order a file storage volume. Valid size and iops options can be found here: https://console.bluemix.net/docs/infrastructure/FileStorage/index.html#provisioning """ file_manager = SoftLayer.FileStorageManager(env.client) storage_type = storage_type.lower() hourly_billing_flag = False if billing.lower() == "hourly": hourly_billing_flag = True if service_offering != 'storage_as_a_service': click.secho('{} is a legacy storage offering'.format(service_offering), fg='red') if hourly_billing_flag: raise exceptions.CLIAbort( 'Hourly billing is only available for the storage_as_a_service service offering' ) if storage_type == 'performance': if iops is None: raise exceptions.CLIAbort('Option --iops required with Performance') if service_offering == 'performance' and snapshot_size is not None: raise exceptions.CLIAbort( '--snapshot-size is not available for performance service offerings. ' 'Use --service-offering storage_as_a_service' ) try: order = file_manager.order_file_volume( storage_type=storage_type, location=location, size=size, iops=iops, snapshot_size=snapshot_size, service_offering=service_offering, hourly_billing_flag=hourly_billing_flag ) except ValueError as ex: raise exceptions.ArgumentError(str(ex)) if storage_type == 'endurance': if tier is None: raise exceptions.CLIAbort( 'Option --tier required with Endurance in IOPS/GB [0.25,2,4,10]' ) try: order = file_manager.order_file_volume( storage_type=storage_type, location=location, size=size, tier_level=float(tier), snapshot_size=snapshot_size, service_offering=service_offering, hourly_billing_flag=hourly_billing_flag ) except ValueError as ex: raise exceptions.ArgumentError(str(ex)) if 'placedOrder' in order.keys(): click.echo("Order #{0} placed successfully!".format( order['placedOrder']['id'])) for item in order['placedOrder']['items']: click.echo(" > %s" % item['description']) else: click.echo("Order could not be placed! Please verify your options and try again.")
[ "def", "cli", "(", "env", ",", "storage_type", ",", "size", ",", "iops", ",", "tier", ",", "location", ",", "snapshot_size", ",", "service_offering", ",", "billing", ")", ":", "file_manager", "=", "SoftLayer", ".", "FileStorageManager", "(", "env", ".", "client", ")", "storage_type", "=", "storage_type", ".", "lower", "(", ")", "hourly_billing_flag", "=", "False", "if", "billing", ".", "lower", "(", ")", "==", "\"hourly\"", ":", "hourly_billing_flag", "=", "True", "if", "service_offering", "!=", "'storage_as_a_service'", ":", "click", ".", "secho", "(", "'{} is a legacy storage offering'", ".", "format", "(", "service_offering", ")", ",", "fg", "=", "'red'", ")", "if", "hourly_billing_flag", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Hourly billing is only available for the storage_as_a_service service offering'", ")", "if", "storage_type", "==", "'performance'", ":", "if", "iops", "is", "None", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Option --iops required with Performance'", ")", "if", "service_offering", "==", "'performance'", "and", "snapshot_size", "is", "not", "None", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'--snapshot-size is not available for performance service offerings. '", "'Use --service-offering storage_as_a_service'", ")", "try", ":", "order", "=", "file_manager", ".", "order_file_volume", "(", "storage_type", "=", "storage_type", ",", "location", "=", "location", ",", "size", "=", "size", ",", "iops", "=", "iops", ",", "snapshot_size", "=", "snapshot_size", ",", "service_offering", "=", "service_offering", ",", "hourly_billing_flag", "=", "hourly_billing_flag", ")", "except", "ValueError", "as", "ex", ":", "raise", "exceptions", ".", "ArgumentError", "(", "str", "(", "ex", ")", ")", "if", "storage_type", "==", "'endurance'", ":", "if", "tier", "is", "None", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Option --tier required with Endurance in IOPS/GB [0.25,2,4,10]'", ")", "try", ":", "order", "=", "file_manager", ".", "order_file_volume", "(", "storage_type", "=", "storage_type", ",", "location", "=", "location", ",", "size", "=", "size", ",", "tier_level", "=", "float", "(", "tier", ")", ",", "snapshot_size", "=", "snapshot_size", ",", "service_offering", "=", "service_offering", ",", "hourly_billing_flag", "=", "hourly_billing_flag", ")", "except", "ValueError", "as", "ex", ":", "raise", "exceptions", ".", "ArgumentError", "(", "str", "(", "ex", ")", ")", "if", "'placedOrder'", "in", "order", ".", "keys", "(", ")", ":", "click", ".", "echo", "(", "\"Order #{0} placed successfully!\"", ".", "format", "(", "order", "[", "'placedOrder'", "]", "[", "'id'", "]", ")", ")", "for", "item", "in", "order", "[", "'placedOrder'", "]", "[", "'items'", "]", ":", "click", ".", "echo", "(", "\" > %s\"", "%", "item", "[", "'description'", "]", ")", "else", ":", "click", ".", "echo", "(", "\"Order could not be placed! Please verify your options and try again.\"", ")" ]
Order a file storage volume. Valid size and iops options can be found here: https://console.bluemix.net/docs/infrastructure/FileStorage/index.html#provisioning
[ "Order", "a", "file", "storage", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/order.py#L50-L119
train
234,563
softlayer/softlayer-python
SoftLayer/CLI/virt/capacity/create_guest.py
cli
def cli(env, **args): """Allows for creating a virtual guest in a reserved capacity.""" create_args = _parse_create_args(env.client, args) create_args['primary_disk'] = args.get('primary_disk') manager = CapacityManager(env.client) capacity_id = args.get('capacity_id') test = args.get('test') result = manager.create_guest(capacity_id, test, create_args) env.fout(_build_receipt(result, test))
python
def cli(env, **args): """Allows for creating a virtual guest in a reserved capacity.""" create_args = _parse_create_args(env.client, args) create_args['primary_disk'] = args.get('primary_disk') manager = CapacityManager(env.client) capacity_id = args.get('capacity_id') test = args.get('test') result = manager.create_guest(capacity_id, test, create_args) env.fout(_build_receipt(result, test))
[ "def", "cli", "(", "env", ",", "*", "*", "args", ")", ":", "create_args", "=", "_parse_create_args", "(", "env", ".", "client", ",", "args", ")", "create_args", "[", "'primary_disk'", "]", "=", "args", ".", "get", "(", "'primary_disk'", ")", "manager", "=", "CapacityManager", "(", "env", ".", "client", ")", "capacity_id", "=", "args", ".", "get", "(", "'capacity_id'", ")", "test", "=", "args", ".", "get", "(", "'test'", ")", "result", "=", "manager", ".", "create_guest", "(", "capacity_id", ",", "test", ",", "create_args", ")", "env", ".", "fout", "(", "_build_receipt", "(", "result", ",", "test", ")", ")" ]
Allows for creating a virtual guest in a reserved capacity.
[ "Allows", "for", "creating", "a", "virtual", "guest", "in", "a", "reserved", "capacity", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/capacity/create_guest.py#L36-L47
train
234,564
softlayer/softlayer-python
SoftLayer/CLI/sshkey/print.py
cli
def cli(env, identifier, out_file): """Prints out an SSH key to the screen.""" mgr = SoftLayer.SshKeyManager(env.client) key_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'SshKey') key = mgr.get_key(key_id) if out_file: with open(path.expanduser(out_file), 'w') as pub_file: pub_file.write(key['key']) table = formatting.KeyValueTable(['name', 'value']) table.add_row(['id', key['id']]) table.add_row(['label', key.get('label')]) table.add_row(['notes', key.get('notes', '-')]) env.fout(table)
python
def cli(env, identifier, out_file): """Prints out an SSH key to the screen.""" mgr = SoftLayer.SshKeyManager(env.client) key_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'SshKey') key = mgr.get_key(key_id) if out_file: with open(path.expanduser(out_file), 'w') as pub_file: pub_file.write(key['key']) table = formatting.KeyValueTable(['name', 'value']) table.add_row(['id', key['id']]) table.add_row(['label', key.get('label')]) table.add_row(['notes', key.get('notes', '-')]) env.fout(table)
[ "def", "cli", "(", "env", ",", "identifier", ",", "out_file", ")", ":", "mgr", "=", "SoftLayer", ".", "SshKeyManager", "(", "env", ".", "client", ")", "key_id", "=", "helpers", ".", "resolve_id", "(", "mgr", ".", "resolve_ids", ",", "identifier", ",", "'SshKey'", ")", "key", "=", "mgr", ".", "get_key", "(", "key_id", ")", "if", "out_file", ":", "with", "open", "(", "path", ".", "expanduser", "(", "out_file", ")", ",", "'w'", ")", "as", "pub_file", ":", "pub_file", ".", "write", "(", "key", "[", "'key'", "]", ")", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "table", ".", "add_row", "(", "[", "'id'", ",", "key", "[", "'id'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'label'", ",", "key", ".", "get", "(", "'label'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'notes'", ",", "key", ".", "get", "(", "'notes'", ",", "'-'", ")", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Prints out an SSH key to the screen.
[ "Prints", "out", "an", "SSH", "key", "to", "the", "screen", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/sshkey/print.py#L19-L36
train
234,565
softlayer/softlayer-python
SoftLayer/managers/object_storage.py
ObjectStorageManager.list_endpoints
def list_endpoints(self): """Lists the known object storage endpoints.""" _filter = { 'hubNetworkStorage': {'vendorName': {'operation': 'Swift'}}, } endpoints = [] network_storage = self.client.call('Account', 'getHubNetworkStorage', mask=ENDPOINT_MASK, limit=1, filter=_filter) if network_storage: for node in network_storage['storageNodes']: endpoints.append({ 'datacenter': node['datacenter'], 'public': node['frontendIpAddress'], 'private': node['backendIpAddress'], }) return endpoints
python
def list_endpoints(self): """Lists the known object storage endpoints.""" _filter = { 'hubNetworkStorage': {'vendorName': {'operation': 'Swift'}}, } endpoints = [] network_storage = self.client.call('Account', 'getHubNetworkStorage', mask=ENDPOINT_MASK, limit=1, filter=_filter) if network_storage: for node in network_storage['storageNodes']: endpoints.append({ 'datacenter': node['datacenter'], 'public': node['frontendIpAddress'], 'private': node['backendIpAddress'], }) return endpoints
[ "def", "list_endpoints", "(", "self", ")", ":", "_filter", "=", "{", "'hubNetworkStorage'", ":", "{", "'vendorName'", ":", "{", "'operation'", ":", "'Swift'", "}", "}", ",", "}", "endpoints", "=", "[", "]", "network_storage", "=", "self", ".", "client", ".", "call", "(", "'Account'", ",", "'getHubNetworkStorage'", ",", "mask", "=", "ENDPOINT_MASK", ",", "limit", "=", "1", ",", "filter", "=", "_filter", ")", "if", "network_storage", ":", "for", "node", "in", "network_storage", "[", "'storageNodes'", "]", ":", "endpoints", ".", "append", "(", "{", "'datacenter'", ":", "node", "[", "'datacenter'", "]", ",", "'public'", ":", "node", "[", "'frontendIpAddress'", "]", ",", "'private'", ":", "node", "[", "'backendIpAddress'", "]", ",", "}", ")", "return", "endpoints" ]
Lists the known object storage endpoints.
[ "Lists", "the", "known", "object", "storage", "endpoints", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/object_storage.py#L35-L54
train
234,566
softlayer/softlayer-python
SoftLayer/managers/object_storage.py
ObjectStorageManager.delete_credential
def delete_credential(self, identifier, credential_id=None): """Delete the object storage credential. :param int id: The object storage account identifier. :param int credential_id: The credential id to be deleted. """ credential = { 'id': credential_id } return self.client.call('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'credentialDelete', credential, id=identifier)
python
def delete_credential(self, identifier, credential_id=None): """Delete the object storage credential. :param int id: The object storage account identifier. :param int credential_id: The credential id to be deleted. """ credential = { 'id': credential_id } return self.client.call('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'credentialDelete', credential, id=identifier)
[ "def", "delete_credential", "(", "self", ",", "identifier", ",", "credential_id", "=", "None", ")", ":", "credential", "=", "{", "'id'", ":", "credential_id", "}", "return", "self", ".", "client", ".", "call", "(", "'SoftLayer_Network_Storage_Hub_Cleversafe_Account'", ",", "'credentialDelete'", ",", "credential", ",", "id", "=", "identifier", ")" ]
Delete the object storage credential. :param int id: The object storage account identifier. :param int credential_id: The credential id to be deleted.
[ "Delete", "the", "object", "storage", "credential", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/object_storage.py#L66-L78
train
234,567
softlayer/softlayer-python
SoftLayer/CLI/hardware/list.py
cli
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, tag, columns, limit): """List hardware servers.""" manager = SoftLayer.HardwareManager(env.client) servers = manager.list_hardware(hostname=hostname, domain=domain, cpus=cpu, memory=memory, datacenter=datacenter, nic_speed=network, tags=tag, mask="mask(SoftLayer_Hardware_Server)[%s]" % columns.mask(), limit=limit) table = formatting.Table(columns.columns) table.sortby = sortby for server in servers: table.add_row([value or formatting.blank() for value in columns.row(server)]) env.fout(table)
python
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, tag, columns, limit): """List hardware servers.""" manager = SoftLayer.HardwareManager(env.client) servers = manager.list_hardware(hostname=hostname, domain=domain, cpus=cpu, memory=memory, datacenter=datacenter, nic_speed=network, tags=tag, mask="mask(SoftLayer_Hardware_Server)[%s]" % columns.mask(), limit=limit) table = formatting.Table(columns.columns) table.sortby = sortby for server in servers: table.add_row([value or formatting.blank() for value in columns.row(server)]) env.fout(table)
[ "def", "cli", "(", "env", ",", "sortby", ",", "cpu", ",", "domain", ",", "datacenter", ",", "hostname", ",", "memory", ",", "network", ",", "tag", ",", "columns", ",", "limit", ")", ":", "manager", "=", "SoftLayer", ".", "HardwareManager", "(", "env", ".", "client", ")", "servers", "=", "manager", ".", "list_hardware", "(", "hostname", "=", "hostname", ",", "domain", "=", "domain", ",", "cpus", "=", "cpu", ",", "memory", "=", "memory", ",", "datacenter", "=", "datacenter", ",", "nic_speed", "=", "network", ",", "tags", "=", "tag", ",", "mask", "=", "\"mask(SoftLayer_Hardware_Server)[%s]\"", "%", "columns", ".", "mask", "(", ")", ",", "limit", "=", "limit", ")", "table", "=", "formatting", ".", "Table", "(", "columns", ".", "columns", ")", "table", ".", "sortby", "=", "sortby", "for", "server", "in", "servers", ":", "table", ".", "add_row", "(", "[", "value", "or", "formatting", ".", "blank", "(", ")", "for", "value", "in", "columns", ".", "row", "(", "server", ")", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List hardware servers.
[ "List", "hardware", "servers", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/hardware/list.py#L62-L83
train
234,568
softlayer/softlayer-python
SoftLayer/CLI/user/edit_details.py
cli
def cli(env, user, template): """Edit a Users details JSON strings should be enclosed in '' and each item should be enclosed in "" :Example: slcli user edit-details testUser -t '{"firstName": "Test", "lastName": "Testerson"}' """ mgr = SoftLayer.UserManager(env.client) user_id = helpers.resolve_id(mgr.resolve_ids, user, 'username') user_template = {} if template is not None: try: template_object = json.loads(template) for key in template_object: user_template[key] = template_object[key] except ValueError as ex: raise exceptions.ArgumentError("Unable to parse --template. %s" % ex) result = mgr.edit_user(user_id, user_template) if result: click.secho("%s updated successfully" % (user), fg='green') else: click.secho("Failed to update %s" % (user), fg='red')
python
def cli(env, user, template): """Edit a Users details JSON strings should be enclosed in '' and each item should be enclosed in "" :Example: slcli user edit-details testUser -t '{"firstName": "Test", "lastName": "Testerson"}' """ mgr = SoftLayer.UserManager(env.client) user_id = helpers.resolve_id(mgr.resolve_ids, user, 'username') user_template = {} if template is not None: try: template_object = json.loads(template) for key in template_object: user_template[key] = template_object[key] except ValueError as ex: raise exceptions.ArgumentError("Unable to parse --template. %s" % ex) result = mgr.edit_user(user_id, user_template) if result: click.secho("%s updated successfully" % (user), fg='green') else: click.secho("Failed to update %s" % (user), fg='red')
[ "def", "cli", "(", "env", ",", "user", ",", "template", ")", ":", "mgr", "=", "SoftLayer", ".", "UserManager", "(", "env", ".", "client", ")", "user_id", "=", "helpers", ".", "resolve_id", "(", "mgr", ".", "resolve_ids", ",", "user", ",", "'username'", ")", "user_template", "=", "{", "}", "if", "template", "is", "not", "None", ":", "try", ":", "template_object", "=", "json", ".", "loads", "(", "template", ")", "for", "key", "in", "template_object", ":", "user_template", "[", "key", "]", "=", "template_object", "[", "key", "]", "except", "ValueError", "as", "ex", ":", "raise", "exceptions", ".", "ArgumentError", "(", "\"Unable to parse --template. %s\"", "%", "ex", ")", "result", "=", "mgr", ".", "edit_user", "(", "user_id", ",", "user_template", ")", "if", "result", ":", "click", ".", "secho", "(", "\"%s updated successfully\"", "%", "(", "user", ")", ",", "fg", "=", "'green'", ")", "else", ":", "click", ".", "secho", "(", "\"Failed to update %s\"", "%", "(", "user", ")", ",", "fg", "=", "'red'", ")" ]
Edit a Users details JSON strings should be enclosed in '' and each item should be enclosed in "" :Example: slcli user edit-details testUser -t '{"firstName": "Test", "lastName": "Testerson"}'
[ "Edit", "a", "Users", "details" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/edit_details.py#L20-L43
train
234,569
softlayer/softlayer-python
SoftLayer/CLI/subnet/lookup.py
cli
def cli(env, ip_address): """Find an IP address and display its subnet and device info.""" mgr = SoftLayer.NetworkManager(env.client) addr_info = mgr.ip_lookup(ip_address) if not addr_info: raise exceptions.CLIAbort('Not found') table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', addr_info['id']]) table.add_row(['ip', addr_info['ipAddress']]) subnet_table = formatting.KeyValueTable(['name', 'value']) subnet_table.align['name'] = 'r' subnet_table.align['value'] = 'l' subnet_table.add_row(['id', addr_info['subnet']['id']]) subnet_table.add_row(['identifier', '%s/%s' % (addr_info['subnet']['networkIdentifier'], str(addr_info['subnet']['cidr']))]) subnet_table.add_row(['netmask', addr_info['subnet']['netmask']]) if addr_info['subnet'].get('gateway'): subnet_table.add_row(['gateway', addr_info['subnet']['gateway']]) subnet_table.add_row(['type', addr_info['subnet'].get('subnetType')]) table.add_row(['subnet', subnet_table]) if addr_info.get('virtualGuest') or addr_info.get('hardware'): device_table = formatting.KeyValueTable(['name', 'value']) device_table.align['name'] = 'r' device_table.align['value'] = 'l' if addr_info.get('virtualGuest'): device = addr_info['virtualGuest'] device_type = 'vs' else: device = addr_info['hardware'] device_type = 'server' device_table.add_row(['id', device['id']]) device_table.add_row(['name', device['fullyQualifiedDomainName']]) device_table.add_row(['type', device_type]) table.add_row(['device', device_table]) env.fout(table)
python
def cli(env, ip_address): """Find an IP address and display its subnet and device info.""" mgr = SoftLayer.NetworkManager(env.client) addr_info = mgr.ip_lookup(ip_address) if not addr_info: raise exceptions.CLIAbort('Not found') table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', addr_info['id']]) table.add_row(['ip', addr_info['ipAddress']]) subnet_table = formatting.KeyValueTable(['name', 'value']) subnet_table.align['name'] = 'r' subnet_table.align['value'] = 'l' subnet_table.add_row(['id', addr_info['subnet']['id']]) subnet_table.add_row(['identifier', '%s/%s' % (addr_info['subnet']['networkIdentifier'], str(addr_info['subnet']['cidr']))]) subnet_table.add_row(['netmask', addr_info['subnet']['netmask']]) if addr_info['subnet'].get('gateway'): subnet_table.add_row(['gateway', addr_info['subnet']['gateway']]) subnet_table.add_row(['type', addr_info['subnet'].get('subnetType')]) table.add_row(['subnet', subnet_table]) if addr_info.get('virtualGuest') or addr_info.get('hardware'): device_table = formatting.KeyValueTable(['name', 'value']) device_table.align['name'] = 'r' device_table.align['value'] = 'l' if addr_info.get('virtualGuest'): device = addr_info['virtualGuest'] device_type = 'vs' else: device = addr_info['hardware'] device_type = 'server' device_table.add_row(['id', device['id']]) device_table.add_row(['name', device['fullyQualifiedDomainName']]) device_table.add_row(['type', device_type]) table.add_row(['device', device_table]) env.fout(table)
[ "def", "cli", "(", "env", ",", "ip_address", ")", ":", "mgr", "=", "SoftLayer", ".", "NetworkManager", "(", "env", ".", "client", ")", "addr_info", "=", "mgr", ".", "ip_lookup", "(", "ip_address", ")", "if", "not", "addr_info", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Not found'", ")", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "table", ".", "align", "[", "'name'", "]", "=", "'r'", "table", ".", "align", "[", "'value'", "]", "=", "'l'", "table", ".", "add_row", "(", "[", "'id'", ",", "addr_info", "[", "'id'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'ip'", ",", "addr_info", "[", "'ipAddress'", "]", "]", ")", "subnet_table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "subnet_table", ".", "align", "[", "'name'", "]", "=", "'r'", "subnet_table", ".", "align", "[", "'value'", "]", "=", "'l'", "subnet_table", ".", "add_row", "(", "[", "'id'", ",", "addr_info", "[", "'subnet'", "]", "[", "'id'", "]", "]", ")", "subnet_table", ".", "add_row", "(", "[", "'identifier'", ",", "'%s/%s'", "%", "(", "addr_info", "[", "'subnet'", "]", "[", "'networkIdentifier'", "]", ",", "str", "(", "addr_info", "[", "'subnet'", "]", "[", "'cidr'", "]", ")", ")", "]", ")", "subnet_table", ".", "add_row", "(", "[", "'netmask'", ",", "addr_info", "[", "'subnet'", "]", "[", "'netmask'", "]", "]", ")", "if", "addr_info", "[", "'subnet'", "]", ".", "get", "(", "'gateway'", ")", ":", "subnet_table", ".", "add_row", "(", "[", "'gateway'", ",", "addr_info", "[", "'subnet'", "]", "[", "'gateway'", "]", "]", ")", "subnet_table", ".", "add_row", "(", "[", "'type'", ",", "addr_info", "[", "'subnet'", "]", ".", "get", "(", "'subnetType'", ")", "]", ")", "table", ".", "add_row", "(", "[", "'subnet'", ",", "subnet_table", "]", ")", "if", "addr_info", ".", "get", "(", "'virtualGuest'", ")", "or", "addr_info", ".", "get", "(", "'hardware'", ")", ":", "device_table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "device_table", ".", "align", "[", "'name'", "]", "=", "'r'", "device_table", ".", "align", "[", "'value'", "]", "=", "'l'", "if", "addr_info", ".", "get", "(", "'virtualGuest'", ")", ":", "device", "=", "addr_info", "[", "'virtualGuest'", "]", "device_type", "=", "'vs'", "else", ":", "device", "=", "addr_info", "[", "'hardware'", "]", "device_type", "=", "'server'", "device_table", ".", "add_row", "(", "[", "'id'", ",", "device", "[", "'id'", "]", "]", ")", "device_table", ".", "add_row", "(", "[", "'name'", ",", "device", "[", "'fullyQualifiedDomainName'", "]", "]", ")", "device_table", ".", "add_row", "(", "[", "'type'", ",", "device_type", "]", ")", "table", ".", "add_row", "(", "[", "'device'", ",", "device_table", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Find an IP address and display its subnet and device info.
[ "Find", "an", "IP", "address", "and", "display", "its", "subnet", "and", "device", "info", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/subnet/lookup.py#L15-L60
train
234,570
softlayer/softlayer-python
SoftLayer/CLI/image/import.py
cli
def cli(env, name, note, os_code, uri, ibm_api_key, root_key_crn, wrapped_dek, cloud_init, byol, is_encrypted): """Import an image. The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage """ image_mgr = SoftLayer.ImageManager(env.client) result = image_mgr.import_image_from_uri( name=name, note=note, os_code=os_code, uri=uri, ibm_api_key=ibm_api_key, root_key_crn=root_key_crn, wrapped_dek=wrapped_dek, cloud_init=cloud_init, byol=byol, is_encrypted=is_encrypted ) if not result: raise exceptions.CLIAbort("Failed to import Image") table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['name', result['name']]) table.add_row(['id', result['id']]) table.add_row(['created', result['createDate']]) table.add_row(['guid', result['globalIdentifier']]) env.fout(table)
python
def cli(env, name, note, os_code, uri, ibm_api_key, root_key_crn, wrapped_dek, cloud_init, byol, is_encrypted): """Import an image. The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage """ image_mgr = SoftLayer.ImageManager(env.client) result = image_mgr.import_image_from_uri( name=name, note=note, os_code=os_code, uri=uri, ibm_api_key=ibm_api_key, root_key_crn=root_key_crn, wrapped_dek=wrapped_dek, cloud_init=cloud_init, byol=byol, is_encrypted=is_encrypted ) if not result: raise exceptions.CLIAbort("Failed to import Image") table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['name', result['name']]) table.add_row(['id', result['id']]) table.add_row(['created', result['createDate']]) table.add_row(['guid', result['globalIdentifier']]) env.fout(table)
[ "def", "cli", "(", "env", ",", "name", ",", "note", ",", "os_code", ",", "uri", ",", "ibm_api_key", ",", "root_key_crn", ",", "wrapped_dek", ",", "cloud_init", ",", "byol", ",", "is_encrypted", ")", ":", "image_mgr", "=", "SoftLayer", ".", "ImageManager", "(", "env", ".", "client", ")", "result", "=", "image_mgr", ".", "import_image_from_uri", "(", "name", "=", "name", ",", "note", "=", "note", ",", "os_code", "=", "os_code", ",", "uri", "=", "uri", ",", "ibm_api_key", "=", "ibm_api_key", ",", "root_key_crn", "=", "root_key_crn", ",", "wrapped_dek", "=", "wrapped_dek", ",", "cloud_init", "=", "cloud_init", ",", "byol", "=", "byol", ",", "is_encrypted", "=", "is_encrypted", ")", "if", "not", "result", ":", "raise", "exceptions", ".", "CLIAbort", "(", "\"Failed to import Image\"", ")", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "table", ".", "align", "[", "'name'", "]", "=", "'r'", "table", ".", "align", "[", "'value'", "]", "=", "'l'", "table", ".", "add_row", "(", "[", "'name'", ",", "result", "[", "'name'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'id'", ",", "result", "[", "'id'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'created'", ",", "result", "[", "'createDate'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'guid'", ",", "result", "[", "'globalIdentifier'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Import an image. The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage
[ "Import", "an", "image", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/image/import.py#L46-L80
train
234,571
softlayer/softlayer-python
SoftLayer/CLI/vpn/ipsec/update.py
cli
def cli(env, context_id, friendly_name, remote_peer, preshared_key, phase1_auth, phase1_crypto, phase1_dh, phase1_key_ttl, phase2_auth, phase2_crypto, phase2_dh, phase2_forward_secrecy, phase2_key_ttl): """Update tunnel context properties. Updates are made atomically, so either all are accepted or none are. Key life values must be in the range 120-172800. Phase 2 perfect forward secrecy must be in the range 0-1. A separate configuration request should be made to realize changes on network devices. """ manager = SoftLayer.IPSECManager(env.client) succeeded = manager.update_tunnel_context( context_id, friendly_name=friendly_name, remote_peer=remote_peer, preshared_key=preshared_key, phase1_auth=phase1_auth, phase1_crypto=phase1_crypto, phase1_dh=phase1_dh, phase1_key_ttl=phase1_key_ttl, phase2_auth=phase2_auth, phase2_crypto=phase2_crypto, phase2_dh=phase2_dh, phase2_forward_secrecy=phase2_forward_secrecy, phase2_key_ttl=phase2_key_ttl ) if succeeded: env.out('Updated context #{}'.format(context_id)) else: raise CLIHalt('Failed to update context #{}'.format(context_id))
python
def cli(env, context_id, friendly_name, remote_peer, preshared_key, phase1_auth, phase1_crypto, phase1_dh, phase1_key_ttl, phase2_auth, phase2_crypto, phase2_dh, phase2_forward_secrecy, phase2_key_ttl): """Update tunnel context properties. Updates are made atomically, so either all are accepted or none are. Key life values must be in the range 120-172800. Phase 2 perfect forward secrecy must be in the range 0-1. A separate configuration request should be made to realize changes on network devices. """ manager = SoftLayer.IPSECManager(env.client) succeeded = manager.update_tunnel_context( context_id, friendly_name=friendly_name, remote_peer=remote_peer, preshared_key=preshared_key, phase1_auth=phase1_auth, phase1_crypto=phase1_crypto, phase1_dh=phase1_dh, phase1_key_ttl=phase1_key_ttl, phase2_auth=phase2_auth, phase2_crypto=phase2_crypto, phase2_dh=phase2_dh, phase2_forward_secrecy=phase2_forward_secrecy, phase2_key_ttl=phase2_key_ttl ) if succeeded: env.out('Updated context #{}'.format(context_id)) else: raise CLIHalt('Failed to update context #{}'.format(context_id))
[ "def", "cli", "(", "env", ",", "context_id", ",", "friendly_name", ",", "remote_peer", ",", "preshared_key", ",", "phase1_auth", ",", "phase1_crypto", ",", "phase1_dh", ",", "phase1_key_ttl", ",", "phase2_auth", ",", "phase2_crypto", ",", "phase2_dh", ",", "phase2_forward_secrecy", ",", "phase2_key_ttl", ")", ":", "manager", "=", "SoftLayer", ".", "IPSECManager", "(", "env", ".", "client", ")", "succeeded", "=", "manager", ".", "update_tunnel_context", "(", "context_id", ",", "friendly_name", "=", "friendly_name", ",", "remote_peer", "=", "remote_peer", ",", "preshared_key", "=", "preshared_key", ",", "phase1_auth", "=", "phase1_auth", ",", "phase1_crypto", "=", "phase1_crypto", ",", "phase1_dh", "=", "phase1_dh", ",", "phase1_key_ttl", "=", "phase1_key_ttl", ",", "phase2_auth", "=", "phase2_auth", ",", "phase2_crypto", "=", "phase2_crypto", ",", "phase2_dh", "=", "phase2_dh", ",", "phase2_forward_secrecy", "=", "phase2_forward_secrecy", ",", "phase2_key_ttl", "=", "phase2_key_ttl", ")", "if", "succeeded", ":", "env", ".", "out", "(", "'Updated context #{}'", ".", "format", "(", "context_id", ")", ")", "else", ":", "raise", "CLIHalt", "(", "'Failed to update context #{}'", ".", "format", "(", "context_id", ")", ")" ]
Update tunnel context properties. Updates are made atomically, so either all are accepted or none are. Key life values must be in the range 120-172800. Phase 2 perfect forward secrecy must be in the range 0-1. A separate configuration request should be made to realize changes on network devices.
[ "Update", "tunnel", "context", "properties", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/vpn/ipsec/update.py#L68-L101
train
234,572
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.add_internal_subnet
def add_internal_subnet(self, context_id, subnet_id): """Add an internal subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the internal subnet. :return bool: True if internal subnet addition was successful. """ return self.context.addPrivateSubnetToNetworkTunnel(subnet_id, id=context_id)
python
def add_internal_subnet(self, context_id, subnet_id): """Add an internal subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the internal subnet. :return bool: True if internal subnet addition was successful. """ return self.context.addPrivateSubnetToNetworkTunnel(subnet_id, id=context_id)
[ "def", "add_internal_subnet", "(", "self", ",", "context_id", ",", "subnet_id", ")", ":", "return", "self", ".", "context", ".", "addPrivateSubnetToNetworkTunnel", "(", "subnet_id", ",", "id", "=", "context_id", ")" ]
Add an internal subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the internal subnet. :return bool: True if internal subnet addition was successful.
[ "Add", "an", "internal", "subnet", "to", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L31-L39
train
234,573
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.add_remote_subnet
def add_remote_subnet(self, context_id, subnet_id): """Adds a remote subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the remote subnet. :return bool: True if remote subnet addition was successful. """ return self.context.addCustomerSubnetToNetworkTunnel(subnet_id, id=context_id)
python
def add_remote_subnet(self, context_id, subnet_id): """Adds a remote subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the remote subnet. :return bool: True if remote subnet addition was successful. """ return self.context.addCustomerSubnetToNetworkTunnel(subnet_id, id=context_id)
[ "def", "add_remote_subnet", "(", "self", ",", "context_id", ",", "subnet_id", ")", ":", "return", "self", ".", "context", ".", "addCustomerSubnetToNetworkTunnel", "(", "subnet_id", ",", "id", "=", "context_id", ")" ]
Adds a remote subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the remote subnet. :return bool: True if remote subnet addition was successful.
[ "Adds", "a", "remote", "subnet", "to", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L41-L49
train
234,574
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.add_service_subnet
def add_service_subnet(self, context_id, subnet_id): """Adds a service subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the service subnet. :return bool: True if service subnet addition was successful. """ return self.context.addServiceSubnetToNetworkTunnel(subnet_id, id=context_id)
python
def add_service_subnet(self, context_id, subnet_id): """Adds a service subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the service subnet. :return bool: True if service subnet addition was successful. """ return self.context.addServiceSubnetToNetworkTunnel(subnet_id, id=context_id)
[ "def", "add_service_subnet", "(", "self", ",", "context_id", ",", "subnet_id", ")", ":", "return", "self", ".", "context", ".", "addServiceSubnetToNetworkTunnel", "(", "subnet_id", ",", "id", "=", "context_id", ")" ]
Adds a service subnet to a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the service subnet. :return bool: True if service subnet addition was successful.
[ "Adds", "a", "service", "subnet", "to", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L51-L59
train
234,575
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.create_remote_subnet
def create_remote_subnet(self, account_id, identifier, cidr): """Creates a remote subnet on the given account. :param string account_id: The account identifier. :param string identifier: The network identifier of the remote subnet. :param string cidr: The CIDR value of the remote subnet. :return dict: Mapping of properties for the new remote subnet. """ return self.remote_subnet.createObject({ 'accountId': account_id, 'cidr': cidr, 'networkIdentifier': identifier })
python
def create_remote_subnet(self, account_id, identifier, cidr): """Creates a remote subnet on the given account. :param string account_id: The account identifier. :param string identifier: The network identifier of the remote subnet. :param string cidr: The CIDR value of the remote subnet. :return dict: Mapping of properties for the new remote subnet. """ return self.remote_subnet.createObject({ 'accountId': account_id, 'cidr': cidr, 'networkIdentifier': identifier })
[ "def", "create_remote_subnet", "(", "self", ",", "account_id", ",", "identifier", ",", "cidr", ")", ":", "return", "self", ".", "remote_subnet", ".", "createObject", "(", "{", "'accountId'", ":", "account_id", ",", "'cidr'", ":", "cidr", ",", "'networkIdentifier'", ":", "identifier", "}", ")" ]
Creates a remote subnet on the given account. :param string account_id: The account identifier. :param string identifier: The network identifier of the remote subnet. :param string cidr: The CIDR value of the remote subnet. :return dict: Mapping of properties for the new remote subnet.
[ "Creates", "a", "remote", "subnet", "on", "the", "given", "account", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L69-L81
train
234,576
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.get_tunnel_context
def get_tunnel_context(self, context_id, **kwargs): """Retrieves the network tunnel context instance. :param int context_id: The id-value representing the context instance. :return dict: Mapping of properties for the tunnel context. :raise SoftLayerAPIError: If a context cannot be found. """ _filter = utils.NestedDict(kwargs.get('filter') or {}) _filter['networkTunnelContexts']['id'] = utils.query_filter(context_id) kwargs['filter'] = _filter.to_dict() contexts = self.account.getNetworkTunnelContexts(**kwargs) if len(contexts) == 0: raise SoftLayerAPIError('SoftLayer_Exception_ObjectNotFound', 'Unable to find object with id of \'{}\'' .format(context_id)) return contexts[0]
python
def get_tunnel_context(self, context_id, **kwargs): """Retrieves the network tunnel context instance. :param int context_id: The id-value representing the context instance. :return dict: Mapping of properties for the tunnel context. :raise SoftLayerAPIError: If a context cannot be found. """ _filter = utils.NestedDict(kwargs.get('filter') or {}) _filter['networkTunnelContexts']['id'] = utils.query_filter(context_id) kwargs['filter'] = _filter.to_dict() contexts = self.account.getNetworkTunnelContexts(**kwargs) if len(contexts) == 0: raise SoftLayerAPIError('SoftLayer_Exception_ObjectNotFound', 'Unable to find object with id of \'{}\'' .format(context_id)) return contexts[0]
[ "def", "get_tunnel_context", "(", "self", ",", "context_id", ",", "*", "*", "kwargs", ")", ":", "_filter", "=", "utils", ".", "NestedDict", "(", "kwargs", ".", "get", "(", "'filter'", ")", "or", "{", "}", ")", "_filter", "[", "'networkTunnelContexts'", "]", "[", "'id'", "]", "=", "utils", ".", "query_filter", "(", "context_id", ")", "kwargs", "[", "'filter'", "]", "=", "_filter", ".", "to_dict", "(", ")", "contexts", "=", "self", ".", "account", ".", "getNetworkTunnelContexts", "(", "*", "*", "kwargs", ")", "if", "len", "(", "contexts", ")", "==", "0", ":", "raise", "SoftLayerAPIError", "(", "'SoftLayer_Exception_ObjectNotFound'", ",", "'Unable to find object with id of \\'{}\\''", ".", "format", "(", "context_id", ")", ")", "return", "contexts", "[", "0", "]" ]
Retrieves the network tunnel context instance. :param int context_id: The id-value representing the context instance. :return dict: Mapping of properties for the tunnel context. :raise SoftLayerAPIError: If a context cannot be found.
[ "Retrieves", "the", "network", "tunnel", "context", "instance", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L108-L124
train
234,577
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.get_translation
def get_translation(self, context_id, translation_id): """Retrieves a translation entry for the given id values. :param int context_id: The id-value representing the context instance. :param int translation_id: The id-value representing the translation instance. :return dict: Mapping of properties for the translation entry. :raise SoftLayerAPIError: If a translation cannot be found. """ translation = next((x for x in self.get_translations(context_id) if x['id'] == translation_id), None) if translation is None: raise SoftLayerAPIError('SoftLayer_Exception_ObjectNotFound', 'Unable to find object with id of \'{}\'' .format(translation_id)) return translation
python
def get_translation(self, context_id, translation_id): """Retrieves a translation entry for the given id values. :param int context_id: The id-value representing the context instance. :param int translation_id: The id-value representing the translation instance. :return dict: Mapping of properties for the translation entry. :raise SoftLayerAPIError: If a translation cannot be found. """ translation = next((x for x in self.get_translations(context_id) if x['id'] == translation_id), None) if translation is None: raise SoftLayerAPIError('SoftLayer_Exception_ObjectNotFound', 'Unable to find object with id of \'{}\'' .format(translation_id)) return translation
[ "def", "get_translation", "(", "self", ",", "context_id", ",", "translation_id", ")", ":", "translation", "=", "next", "(", "(", "x", "for", "x", "in", "self", ".", "get_translations", "(", "context_id", ")", "if", "x", "[", "'id'", "]", "==", "translation_id", ")", ",", "None", ")", "if", "translation", "is", "None", ":", "raise", "SoftLayerAPIError", "(", "'SoftLayer_Exception_ObjectNotFound'", ",", "'Unable to find object with id of \\'{}\\''", ".", "format", "(", "translation_id", ")", ")", "return", "translation" ]
Retrieves a translation entry for the given id values. :param int context_id: The id-value representing the context instance. :param int translation_id: The id-value representing the translation instance. :return dict: Mapping of properties for the translation entry. :raise SoftLayerAPIError: If a translation cannot be found.
[ "Retrieves", "a", "translation", "entry", "for", "the", "given", "id", "values", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L126-L141
train
234,578
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.get_translations
def get_translations(self, context_id): """Retrieves all translation entries for a tunnel context. :param int context_id: The id-value representing the context instance. :return list(dict): Translations associated with the given context """ _mask = ('[mask[addressTranslations[customerIpAddressRecord,' 'internalIpAddressRecord]]]') context = self.get_tunnel_context(context_id, mask=_mask) # Pull the internal and remote IP addresses into the translation for translation in context.get('addressTranslations', []): remote_ip = translation.get('customerIpAddressRecord', {}) internal_ip = translation.get('internalIpAddressRecord', {}) translation['customerIpAddress'] = remote_ip.get('ipAddress', '') translation['internalIpAddress'] = internal_ip.get('ipAddress', '') translation.pop('customerIpAddressRecord', None) translation.pop('internalIpAddressRecord', None) return context['addressTranslations']
python
def get_translations(self, context_id): """Retrieves all translation entries for a tunnel context. :param int context_id: The id-value representing the context instance. :return list(dict): Translations associated with the given context """ _mask = ('[mask[addressTranslations[customerIpAddressRecord,' 'internalIpAddressRecord]]]') context = self.get_tunnel_context(context_id, mask=_mask) # Pull the internal and remote IP addresses into the translation for translation in context.get('addressTranslations', []): remote_ip = translation.get('customerIpAddressRecord', {}) internal_ip = translation.get('internalIpAddressRecord', {}) translation['customerIpAddress'] = remote_ip.get('ipAddress', '') translation['internalIpAddress'] = internal_ip.get('ipAddress', '') translation.pop('customerIpAddressRecord', None) translation.pop('internalIpAddressRecord', None) return context['addressTranslations']
[ "def", "get_translations", "(", "self", ",", "context_id", ")", ":", "_mask", "=", "(", "'[mask[addressTranslations[customerIpAddressRecord,'", "'internalIpAddressRecord]]]'", ")", "context", "=", "self", ".", "get_tunnel_context", "(", "context_id", ",", "mask", "=", "_mask", ")", "# Pull the internal and remote IP addresses into the translation", "for", "translation", "in", "context", ".", "get", "(", "'addressTranslations'", ",", "[", "]", ")", ":", "remote_ip", "=", "translation", ".", "get", "(", "'customerIpAddressRecord'", ",", "{", "}", ")", "internal_ip", "=", "translation", ".", "get", "(", "'internalIpAddressRecord'", ",", "{", "}", ")", "translation", "[", "'customerIpAddress'", "]", "=", "remote_ip", ".", "get", "(", "'ipAddress'", ",", "''", ")", "translation", "[", "'internalIpAddress'", "]", "=", "internal_ip", ".", "get", "(", "'ipAddress'", ",", "''", ")", "translation", ".", "pop", "(", "'customerIpAddressRecord'", ",", "None", ")", "translation", ".", "pop", "(", "'internalIpAddressRecord'", ",", "None", ")", "return", "context", "[", "'addressTranslations'", "]" ]
Retrieves all translation entries for a tunnel context. :param int context_id: The id-value representing the context instance. :return list(dict): Translations associated with the given context
[ "Retrieves", "all", "translation", "entries", "for", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L143-L160
train
234,579
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.remove_internal_subnet
def remove_internal_subnet(self, context_id, subnet_id): """Remove an internal subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the internal subnet. :return bool: True if internal subnet removal was successful. """ return self.context.removePrivateSubnetFromNetworkTunnel(subnet_id, id=context_id)
python
def remove_internal_subnet(self, context_id, subnet_id): """Remove an internal subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the internal subnet. :return bool: True if internal subnet removal was successful. """ return self.context.removePrivateSubnetFromNetworkTunnel(subnet_id, id=context_id)
[ "def", "remove_internal_subnet", "(", "self", ",", "context_id", ",", "subnet_id", ")", ":", "return", "self", ".", "context", ".", "removePrivateSubnetFromNetworkTunnel", "(", "subnet_id", ",", "id", "=", "context_id", ")" ]
Remove an internal subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the internal subnet. :return bool: True if internal subnet removal was successful.
[ "Remove", "an", "internal", "subnet", "from", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L169-L177
train
234,580
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.remove_remote_subnet
def remove_remote_subnet(self, context_id, subnet_id): """Removes a remote subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the remote subnet. :return bool: True if remote subnet removal was successful. """ return self.context.removeCustomerSubnetFromNetworkTunnel(subnet_id, id=context_id)
python
def remove_remote_subnet(self, context_id, subnet_id): """Removes a remote subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the remote subnet. :return bool: True if remote subnet removal was successful. """ return self.context.removeCustomerSubnetFromNetworkTunnel(subnet_id, id=context_id)
[ "def", "remove_remote_subnet", "(", "self", ",", "context_id", ",", "subnet_id", ")", ":", "return", "self", ".", "context", ".", "removeCustomerSubnetFromNetworkTunnel", "(", "subnet_id", ",", "id", "=", "context_id", ")" ]
Removes a remote subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the remote subnet. :return bool: True if remote subnet removal was successful.
[ "Removes", "a", "remote", "subnet", "from", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L179-L187
train
234,581
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.remove_service_subnet
def remove_service_subnet(self, context_id, subnet_id): """Removes a service subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the service subnet. :return bool: True if service subnet removal was successful. """ return self.context.removeServiceSubnetFromNetworkTunnel(subnet_id, id=context_id)
python
def remove_service_subnet(self, context_id, subnet_id): """Removes a service subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the service subnet. :return bool: True if service subnet removal was successful. """ return self.context.removeServiceSubnetFromNetworkTunnel(subnet_id, id=context_id)
[ "def", "remove_service_subnet", "(", "self", ",", "context_id", ",", "subnet_id", ")", ":", "return", "self", ".", "context", ".", "removeServiceSubnetFromNetworkTunnel", "(", "subnet_id", ",", "id", "=", "context_id", ")" ]
Removes a service subnet from a tunnel context. :param int context_id: The id-value representing the context instance. :param int subnet_id: The id-value representing the service subnet. :return bool: True if service subnet removal was successful.
[ "Removes", "a", "service", "subnet", "from", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L189-L197
train
234,582
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.remove_translation
def remove_translation(self, context_id, translation_id): """Removes a translation entry from a tunnel context. :param int context_id: The id-value representing the context instance. :param int translation_id: The id-value representing the translation. :return bool: True if translation entry removal was successful. """ return self.context.deleteAddressTranslation(translation_id, id=context_id)
python
def remove_translation(self, context_id, translation_id): """Removes a translation entry from a tunnel context. :param int context_id: The id-value representing the context instance. :param int translation_id: The id-value representing the translation. :return bool: True if translation entry removal was successful. """ return self.context.deleteAddressTranslation(translation_id, id=context_id)
[ "def", "remove_translation", "(", "self", ",", "context_id", ",", "translation_id", ")", ":", "return", "self", ".", "context", ".", "deleteAddressTranslation", "(", "translation_id", ",", "id", "=", "context_id", ")" ]
Removes a translation entry from a tunnel context. :param int context_id: The id-value representing the context instance. :param int translation_id: The id-value representing the translation. :return bool: True if translation entry removal was successful.
[ "Removes", "a", "translation", "entry", "from", "a", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L199-L207
train
234,583
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.update_translation
def update_translation(self, context_id, translation_id, static_ip=None, remote_ip=None, notes=None): """Updates an address translation entry using the given values. :param int context_id: The id-value representing the context instance. :param dict template: A key-value mapping of translation properties. :param string static_ip: The static IP address value to update. :param string remote_ip: The remote IP address value to update. :param string notes: The notes value to update. :return bool: True if the update was successful. """ translation = self.get_translation(context_id, translation_id) if static_ip is not None: translation['internalIpAddress'] = static_ip translation.pop('internalIpAddressId', None) if remote_ip is not None: translation['customerIpAddress'] = remote_ip translation.pop('customerIpAddressId', None) if notes is not None: translation['notes'] = notes self.context.editAddressTranslation(translation, id=context_id) return True
python
def update_translation(self, context_id, translation_id, static_ip=None, remote_ip=None, notes=None): """Updates an address translation entry using the given values. :param int context_id: The id-value representing the context instance. :param dict template: A key-value mapping of translation properties. :param string static_ip: The static IP address value to update. :param string remote_ip: The remote IP address value to update. :param string notes: The notes value to update. :return bool: True if the update was successful. """ translation = self.get_translation(context_id, translation_id) if static_ip is not None: translation['internalIpAddress'] = static_ip translation.pop('internalIpAddressId', None) if remote_ip is not None: translation['customerIpAddress'] = remote_ip translation.pop('customerIpAddressId', None) if notes is not None: translation['notes'] = notes self.context.editAddressTranslation(translation, id=context_id) return True
[ "def", "update_translation", "(", "self", ",", "context_id", ",", "translation_id", ",", "static_ip", "=", "None", ",", "remote_ip", "=", "None", ",", "notes", "=", "None", ")", ":", "translation", "=", "self", ".", "get_translation", "(", "context_id", ",", "translation_id", ")", "if", "static_ip", "is", "not", "None", ":", "translation", "[", "'internalIpAddress'", "]", "=", "static_ip", "translation", ".", "pop", "(", "'internalIpAddressId'", ",", "None", ")", "if", "remote_ip", "is", "not", "None", ":", "translation", "[", "'customerIpAddress'", "]", "=", "remote_ip", "translation", ".", "pop", "(", "'customerIpAddressId'", ",", "None", ")", "if", "notes", "is", "not", "None", ":", "translation", "[", "'notes'", "]", "=", "notes", "self", ".", "context", ".", "editAddressTranslation", "(", "translation", ",", "id", "=", "context_id", ")", "return", "True" ]
Updates an address translation entry using the given values. :param int context_id: The id-value representing the context instance. :param dict template: A key-value mapping of translation properties. :param string static_ip: The static IP address value to update. :param string remote_ip: The remote IP address value to update. :param string notes: The notes value to update. :return bool: True if the update was successful.
[ "Updates", "an", "address", "translation", "entry", "using", "the", "given", "values", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L209-L231
train
234,584
softlayer/softlayer-python
SoftLayer/managers/ipsec.py
IPSECManager.update_tunnel_context
def update_tunnel_context(self, context_id, friendly_name=None, remote_peer=None, preshared_key=None, phase1_auth=None, phase1_crypto=None, phase1_dh=None, phase1_key_ttl=None, phase2_auth=None, phase2_crypto=None, phase2_dh=None, phase2_forward_secrecy=None, phase2_key_ttl=None): """Updates a tunnel context using the given values. :param string context_id: The id-value representing the context. :param string friendly_name: The friendly name value to update. :param string remote_peer: The remote peer IP address value to update. :param string preshared_key: The preshared key value to update. :param string phase1_auth: The phase 1 authentication value to update. :param string phase1_crypto: The phase 1 encryption value to update. :param string phase1_dh: The phase 1 diffie hellman group value to update. :param string phase1_key_ttl: The phase 1 key life value to update. :param string phase2_auth: The phase 2 authentication value to update. :param string phase2_crypto: The phase 2 encryption value to update. :param string phase2_df: The phase 2 diffie hellman group value to update. :param string phase2_forward_secriecy: The phase 2 perfect forward secrecy value to update. :param string phase2_key_ttl: The phase 2 key life value to update. :return bool: True if the update was successful. """ context = self.get_tunnel_context(context_id) if friendly_name is not None: context['friendlyName'] = friendly_name if remote_peer is not None: context['customerPeerIpAddress'] = remote_peer if preshared_key is not None: context['presharedKey'] = preshared_key if phase1_auth is not None: context['phaseOneAuthentication'] = phase1_auth if phase1_crypto is not None: context['phaseOneEncryption'] = phase1_crypto if phase1_dh is not None: context['phaseOneDiffieHellmanGroup'] = phase1_dh if phase1_key_ttl is not None: context['phaseOneKeylife'] = phase1_key_ttl if phase2_auth is not None: context['phaseTwoAuthentication'] = phase2_auth if phase2_crypto is not None: context['phaseTwoEncryption'] = phase2_crypto if phase2_dh is not None: context['phaseTwoDiffieHellmanGroup'] = phase2_dh if phase2_forward_secrecy is not None: context['phaseTwoPerfectForwardSecrecy'] = phase2_forward_secrecy if phase2_key_ttl is not None: context['phaseTwoKeylife'] = phase2_key_ttl return self.context.editObject(context, id=context_id)
python
def update_tunnel_context(self, context_id, friendly_name=None, remote_peer=None, preshared_key=None, phase1_auth=None, phase1_crypto=None, phase1_dh=None, phase1_key_ttl=None, phase2_auth=None, phase2_crypto=None, phase2_dh=None, phase2_forward_secrecy=None, phase2_key_ttl=None): """Updates a tunnel context using the given values. :param string context_id: The id-value representing the context. :param string friendly_name: The friendly name value to update. :param string remote_peer: The remote peer IP address value to update. :param string preshared_key: The preshared key value to update. :param string phase1_auth: The phase 1 authentication value to update. :param string phase1_crypto: The phase 1 encryption value to update. :param string phase1_dh: The phase 1 diffie hellman group value to update. :param string phase1_key_ttl: The phase 1 key life value to update. :param string phase2_auth: The phase 2 authentication value to update. :param string phase2_crypto: The phase 2 encryption value to update. :param string phase2_df: The phase 2 diffie hellman group value to update. :param string phase2_forward_secriecy: The phase 2 perfect forward secrecy value to update. :param string phase2_key_ttl: The phase 2 key life value to update. :return bool: True if the update was successful. """ context = self.get_tunnel_context(context_id) if friendly_name is not None: context['friendlyName'] = friendly_name if remote_peer is not None: context['customerPeerIpAddress'] = remote_peer if preshared_key is not None: context['presharedKey'] = preshared_key if phase1_auth is not None: context['phaseOneAuthentication'] = phase1_auth if phase1_crypto is not None: context['phaseOneEncryption'] = phase1_crypto if phase1_dh is not None: context['phaseOneDiffieHellmanGroup'] = phase1_dh if phase1_key_ttl is not None: context['phaseOneKeylife'] = phase1_key_ttl if phase2_auth is not None: context['phaseTwoAuthentication'] = phase2_auth if phase2_crypto is not None: context['phaseTwoEncryption'] = phase2_crypto if phase2_dh is not None: context['phaseTwoDiffieHellmanGroup'] = phase2_dh if phase2_forward_secrecy is not None: context['phaseTwoPerfectForwardSecrecy'] = phase2_forward_secrecy if phase2_key_ttl is not None: context['phaseTwoKeylife'] = phase2_key_ttl return self.context.editObject(context, id=context_id)
[ "def", "update_tunnel_context", "(", "self", ",", "context_id", ",", "friendly_name", "=", "None", ",", "remote_peer", "=", "None", ",", "preshared_key", "=", "None", ",", "phase1_auth", "=", "None", ",", "phase1_crypto", "=", "None", ",", "phase1_dh", "=", "None", ",", "phase1_key_ttl", "=", "None", ",", "phase2_auth", "=", "None", ",", "phase2_crypto", "=", "None", ",", "phase2_dh", "=", "None", ",", "phase2_forward_secrecy", "=", "None", ",", "phase2_key_ttl", "=", "None", ")", ":", "context", "=", "self", ".", "get_tunnel_context", "(", "context_id", ")", "if", "friendly_name", "is", "not", "None", ":", "context", "[", "'friendlyName'", "]", "=", "friendly_name", "if", "remote_peer", "is", "not", "None", ":", "context", "[", "'customerPeerIpAddress'", "]", "=", "remote_peer", "if", "preshared_key", "is", "not", "None", ":", "context", "[", "'presharedKey'", "]", "=", "preshared_key", "if", "phase1_auth", "is", "not", "None", ":", "context", "[", "'phaseOneAuthentication'", "]", "=", "phase1_auth", "if", "phase1_crypto", "is", "not", "None", ":", "context", "[", "'phaseOneEncryption'", "]", "=", "phase1_crypto", "if", "phase1_dh", "is", "not", "None", ":", "context", "[", "'phaseOneDiffieHellmanGroup'", "]", "=", "phase1_dh", "if", "phase1_key_ttl", "is", "not", "None", ":", "context", "[", "'phaseOneKeylife'", "]", "=", "phase1_key_ttl", "if", "phase2_auth", "is", "not", "None", ":", "context", "[", "'phaseTwoAuthentication'", "]", "=", "phase2_auth", "if", "phase2_crypto", "is", "not", "None", ":", "context", "[", "'phaseTwoEncryption'", "]", "=", "phase2_crypto", "if", "phase2_dh", "is", "not", "None", ":", "context", "[", "'phaseTwoDiffieHellmanGroup'", "]", "=", "phase2_dh", "if", "phase2_forward_secrecy", "is", "not", "None", ":", "context", "[", "'phaseTwoPerfectForwardSecrecy'", "]", "=", "phase2_forward_secrecy", "if", "phase2_key_ttl", "is", "not", "None", ":", "context", "[", "'phaseTwoKeylife'", "]", "=", "phase2_key_ttl", "return", "self", ".", "context", ".", "editObject", "(", "context", ",", "id", "=", "context_id", ")" ]
Updates a tunnel context using the given values. :param string context_id: The id-value representing the context. :param string friendly_name: The friendly name value to update. :param string remote_peer: The remote peer IP address value to update. :param string preshared_key: The preshared key value to update. :param string phase1_auth: The phase 1 authentication value to update. :param string phase1_crypto: The phase 1 encryption value to update. :param string phase1_dh: The phase 1 diffie hellman group value to update. :param string phase1_key_ttl: The phase 1 key life value to update. :param string phase2_auth: The phase 2 authentication value to update. :param string phase2_crypto: The phase 2 encryption value to update. :param string phase2_df: The phase 2 diffie hellman group value to update. :param string phase2_forward_secriecy: The phase 2 perfect forward secrecy value to update. :param string phase2_key_ttl: The phase 2 key life value to update. :return bool: True if the update was successful.
[ "Updates", "a", "tunnel", "context", "using", "the", "given", "values", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L233-L286
train
234,585
softlayer/softlayer-python
SoftLayer/CLI/object_storage/credential/create.py
cli
def cli(env, identifier): """Create credentials for an IBM Cloud Object Storage Account""" mgr = SoftLayer.ObjectStorageManager(env.client) credential = mgr.create_credential(identifier) table = formatting.Table(['id', 'password', 'username', 'type_name']) table.sortby = 'id' table.add_row([ credential['id'], credential['password'], credential['username'], credential['type']['name'] ]) env.fout(table)
python
def cli(env, identifier): """Create credentials for an IBM Cloud Object Storage Account""" mgr = SoftLayer.ObjectStorageManager(env.client) credential = mgr.create_credential(identifier) table = formatting.Table(['id', 'password', 'username', 'type_name']) table.sortby = 'id' table.add_row([ credential['id'], credential['password'], credential['username'], credential['type']['name'] ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "mgr", "=", "SoftLayer", ".", "ObjectStorageManager", "(", "env", ".", "client", ")", "credential", "=", "mgr", ".", "create_credential", "(", "identifier", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'id'", ",", "'password'", ",", "'username'", ",", "'type_name'", "]", ")", "table", ".", "sortby", "=", "'id'", "table", ".", "add_row", "(", "[", "credential", "[", "'id'", "]", ",", "credential", "[", "'password'", "]", ",", "credential", "[", "'username'", "]", ",", "credential", "[", "'type'", "]", "[", "'name'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Create credentials for an IBM Cloud Object Storage Account
[ "Create", "credentials", "for", "an", "IBM", "Cloud", "Object", "Storage", "Account" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/object_storage/credential/create.py#L14-L28
train
234,586
softlayer/softlayer-python
SoftLayer/CLI/image/list.py
cli
def cli(env, name, public): """List images.""" image_mgr = SoftLayer.ImageManager(env.client) images = [] if public in [False, None]: for image in image_mgr.list_private_images(name=name, mask=image_mod.MASK): images.append(image) if public in [True, None]: for image in image_mgr.list_public_images(name=name, mask=image_mod.MASK): images.append(image) table = formatting.Table(['id', 'name', 'type', 'visibility', 'account']) images = [image for image in images if image['parentId'] == ''] for image in images: visibility = (image_mod.PUBLIC_TYPE if image['publicFlag'] else image_mod.PRIVATE_TYPE) table.add_row([ image.get('id', formatting.blank()), formatting.FormattedItem(image['name'], click.wrap_text(image['name'], width=50)), formatting.FormattedItem( utils.lookup(image, 'imageType', 'keyName'), utils.lookup(image, 'imageType', 'name')), visibility, image.get('accountId', formatting.blank()), ]) env.fout(table)
python
def cli(env, name, public): """List images.""" image_mgr = SoftLayer.ImageManager(env.client) images = [] if public in [False, None]: for image in image_mgr.list_private_images(name=name, mask=image_mod.MASK): images.append(image) if public in [True, None]: for image in image_mgr.list_public_images(name=name, mask=image_mod.MASK): images.append(image) table = formatting.Table(['id', 'name', 'type', 'visibility', 'account']) images = [image for image in images if image['parentId'] == ''] for image in images: visibility = (image_mod.PUBLIC_TYPE if image['publicFlag'] else image_mod.PRIVATE_TYPE) table.add_row([ image.get('id', formatting.blank()), formatting.FormattedItem(image['name'], click.wrap_text(image['name'], width=50)), formatting.FormattedItem( utils.lookup(image, 'imageType', 'keyName'), utils.lookup(image, 'imageType', 'name')), visibility, image.get('accountId', formatting.blank()), ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "name", ",", "public", ")", ":", "image_mgr", "=", "SoftLayer", ".", "ImageManager", "(", "env", ".", "client", ")", "images", "=", "[", "]", "if", "public", "in", "[", "False", ",", "None", "]", ":", "for", "image", "in", "image_mgr", ".", "list_private_images", "(", "name", "=", "name", ",", "mask", "=", "image_mod", ".", "MASK", ")", ":", "images", ".", "append", "(", "image", ")", "if", "public", "in", "[", "True", ",", "None", "]", ":", "for", "image", "in", "image_mgr", ".", "list_public_images", "(", "name", "=", "name", ",", "mask", "=", "image_mod", ".", "MASK", ")", ":", "images", ".", "append", "(", "image", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'id'", ",", "'name'", ",", "'type'", ",", "'visibility'", ",", "'account'", "]", ")", "images", "=", "[", "image", "for", "image", "in", "images", "if", "image", "[", "'parentId'", "]", "==", "''", "]", "for", "image", "in", "images", ":", "visibility", "=", "(", "image_mod", ".", "PUBLIC_TYPE", "if", "image", "[", "'publicFlag'", "]", "else", "image_mod", ".", "PRIVATE_TYPE", ")", "table", ".", "add_row", "(", "[", "image", ".", "get", "(", "'id'", ",", "formatting", ".", "blank", "(", ")", ")", ",", "formatting", ".", "FormattedItem", "(", "image", "[", "'name'", "]", ",", "click", ".", "wrap_text", "(", "image", "[", "'name'", "]", ",", "width", "=", "50", ")", ")", ",", "formatting", ".", "FormattedItem", "(", "utils", ".", "lookup", "(", "image", ",", "'imageType'", ",", "'keyName'", ")", ",", "utils", ".", "lookup", "(", "image", ",", "'imageType'", ",", "'name'", ")", ")", ",", "visibility", ",", "image", ".", "get", "(", "'accountId'", ",", "formatting", ".", "blank", "(", ")", ")", ",", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List images.
[ "List", "images", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/image/list.py#L20-L58
train
234,587
softlayer/softlayer-python
SoftLayer/CLI/vpn/ipsec/subnet/add.py
cli
def cli(env, context_id, subnet_id, subnet_type, network_identifier): """Add a subnet to an IPSEC tunnel context. A subnet id may be specified to link to the existing tunnel context. Otherwise, a network identifier in CIDR notation should be specified, indicating that a subnet resource should first be created before associating it with the tunnel context. Note that this is only supported for remote subnets, which are also deleted upon failure to attach to a context. A separate configuration request should be made to realize changes on network devices. """ create_remote = False if subnet_id is None: if network_identifier is None: raise ArgumentError('Either a network identifier or subnet id ' 'must be provided.') if subnet_type != 'remote': raise ArgumentError('Unable to create {} subnets' .format(subnet_type)) create_remote = True manager = SoftLayer.IPSECManager(env.client) context = manager.get_tunnel_context(context_id) if create_remote: subnet = manager.create_remote_subnet(context['accountId'], identifier=network_identifier[0], cidr=network_identifier[1]) subnet_id = subnet['id'] env.out('Created subnet {}/{} #{}' .format(network_identifier[0], network_identifier[1], subnet_id)) succeeded = False if subnet_type == 'internal': succeeded = manager.add_internal_subnet(context_id, subnet_id) elif subnet_type == 'remote': succeeded = manager.add_remote_subnet(context_id, subnet_id) elif subnet_type == 'service': succeeded = manager.add_service_subnet(context_id, subnet_id) if succeeded: env.out('Added {} subnet #{}'.format(subnet_type, subnet_id)) else: raise CLIHalt('Failed to add {} subnet #{}' .format(subnet_type, subnet_id))
python
def cli(env, context_id, subnet_id, subnet_type, network_identifier): """Add a subnet to an IPSEC tunnel context. A subnet id may be specified to link to the existing tunnel context. Otherwise, a network identifier in CIDR notation should be specified, indicating that a subnet resource should first be created before associating it with the tunnel context. Note that this is only supported for remote subnets, which are also deleted upon failure to attach to a context. A separate configuration request should be made to realize changes on network devices. """ create_remote = False if subnet_id is None: if network_identifier is None: raise ArgumentError('Either a network identifier or subnet id ' 'must be provided.') if subnet_type != 'remote': raise ArgumentError('Unable to create {} subnets' .format(subnet_type)) create_remote = True manager = SoftLayer.IPSECManager(env.client) context = manager.get_tunnel_context(context_id) if create_remote: subnet = manager.create_remote_subnet(context['accountId'], identifier=network_identifier[0], cidr=network_identifier[1]) subnet_id = subnet['id'] env.out('Created subnet {}/{} #{}' .format(network_identifier[0], network_identifier[1], subnet_id)) succeeded = False if subnet_type == 'internal': succeeded = manager.add_internal_subnet(context_id, subnet_id) elif subnet_type == 'remote': succeeded = manager.add_remote_subnet(context_id, subnet_id) elif subnet_type == 'service': succeeded = manager.add_service_subnet(context_id, subnet_id) if succeeded: env.out('Added {} subnet #{}'.format(subnet_type, subnet_id)) else: raise CLIHalt('Failed to add {} subnet #{}' .format(subnet_type, subnet_id))
[ "def", "cli", "(", "env", ",", "context_id", ",", "subnet_id", ",", "subnet_type", ",", "network_identifier", ")", ":", "create_remote", "=", "False", "if", "subnet_id", "is", "None", ":", "if", "network_identifier", "is", "None", ":", "raise", "ArgumentError", "(", "'Either a network identifier or subnet id '", "'must be provided.'", ")", "if", "subnet_type", "!=", "'remote'", ":", "raise", "ArgumentError", "(", "'Unable to create {} subnets'", ".", "format", "(", "subnet_type", ")", ")", "create_remote", "=", "True", "manager", "=", "SoftLayer", ".", "IPSECManager", "(", "env", ".", "client", ")", "context", "=", "manager", ".", "get_tunnel_context", "(", "context_id", ")", "if", "create_remote", ":", "subnet", "=", "manager", ".", "create_remote_subnet", "(", "context", "[", "'accountId'", "]", ",", "identifier", "=", "network_identifier", "[", "0", "]", ",", "cidr", "=", "network_identifier", "[", "1", "]", ")", "subnet_id", "=", "subnet", "[", "'id'", "]", "env", ".", "out", "(", "'Created subnet {}/{} #{}'", ".", "format", "(", "network_identifier", "[", "0", "]", ",", "network_identifier", "[", "1", "]", ",", "subnet_id", ")", ")", "succeeded", "=", "False", "if", "subnet_type", "==", "'internal'", ":", "succeeded", "=", "manager", ".", "add_internal_subnet", "(", "context_id", ",", "subnet_id", ")", "elif", "subnet_type", "==", "'remote'", ":", "succeeded", "=", "manager", ".", "add_remote_subnet", "(", "context_id", ",", "subnet_id", ")", "elif", "subnet_type", "==", "'service'", ":", "succeeded", "=", "manager", ".", "add_service_subnet", "(", "context_id", ",", "subnet_id", ")", "if", "succeeded", ":", "env", ".", "out", "(", "'Added {} subnet #{}'", ".", "format", "(", "subnet_type", ",", "subnet_id", ")", ")", "else", ":", "raise", "CLIHalt", "(", "'Failed to add {} subnet #{}'", ".", "format", "(", "subnet_type", ",", "subnet_id", ")", ")" ]
Add a subnet to an IPSEC tunnel context. A subnet id may be specified to link to the existing tunnel context. Otherwise, a network identifier in CIDR notation should be specified, indicating that a subnet resource should first be created before associating it with the tunnel context. Note that this is only supported for remote subnets, which are also deleted upon failure to attach to a context. A separate configuration request should be made to realize changes on network devices.
[ "Add", "a", "subnet", "to", "an", "IPSEC", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/vpn/ipsec/subnet/add.py#L33-L81
train
234,588
softlayer/softlayer-python
SoftLayer/CLI/virt/placementgroup/list.py
cli
def cli(env): """List placement groups.""" manager = PlacementManager(env.client) result = manager.list() table = formatting.Table( ["Id", "Name", "Backend Router", "Rule", "Guests", "Created"], title="Placement Groups" ) for group in result: table.add_row([ group['id'], group['name'], group['backendRouter']['hostname'], group['rule']['name'], group['guestCount'], group['createDate'] ]) env.fout(table)
python
def cli(env): """List placement groups.""" manager = PlacementManager(env.client) result = manager.list() table = formatting.Table( ["Id", "Name", "Backend Router", "Rule", "Guests", "Created"], title="Placement Groups" ) for group in result: table.add_row([ group['id'], group['name'], group['backendRouter']['hostname'], group['rule']['name'], group['guestCount'], group['createDate'] ]) env.fout(table)
[ "def", "cli", "(", "env", ")", ":", "manager", "=", "PlacementManager", "(", "env", ".", "client", ")", "result", "=", "manager", ".", "list", "(", ")", "table", "=", "formatting", ".", "Table", "(", "[", "\"Id\"", ",", "\"Name\"", ",", "\"Backend Router\"", ",", "\"Rule\"", ",", "\"Guests\"", ",", "\"Created\"", "]", ",", "title", "=", "\"Placement Groups\"", ")", "for", "group", "in", "result", ":", "table", ".", "add_row", "(", "[", "group", "[", "'id'", "]", ",", "group", "[", "'name'", "]", ",", "group", "[", "'backendRouter'", "]", "[", "'hostname'", "]", ",", "group", "[", "'rule'", "]", "[", "'name'", "]", ",", "group", "[", "'guestCount'", "]", ",", "group", "[", "'createDate'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List placement groups.
[ "List", "placement", "groups", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/placementgroup/list.py#L12-L30
train
234,589
softlayer/softlayer-python
SoftLayer/CLI/account/events.py
cli
def cli(env, ack_all): """Summary and acknowledgement of upcoming and ongoing maintenance events""" manager = AccountManager(env.client) events = manager.get_upcoming_events() if ack_all: for event in events: result = manager.ack_event(event['id']) event['acknowledgedFlag'] = result env.fout(event_table(events))
python
def cli(env, ack_all): """Summary and acknowledgement of upcoming and ongoing maintenance events""" manager = AccountManager(env.client) events = manager.get_upcoming_events() if ack_all: for event in events: result = manager.ack_event(event['id']) event['acknowledgedFlag'] = result env.fout(event_table(events))
[ "def", "cli", "(", "env", ",", "ack_all", ")", ":", "manager", "=", "AccountManager", "(", "env", ".", "client", ")", "events", "=", "manager", ".", "get_upcoming_events", "(", ")", "if", "ack_all", ":", "for", "event", "in", "events", ":", "result", "=", "manager", ".", "ack_event", "(", "event", "[", "'id'", "]", ")", "event", "[", "'acknowledgedFlag'", "]", "=", "result", "env", ".", "fout", "(", "event_table", "(", "events", ")", ")" ]
Summary and acknowledgement of upcoming and ongoing maintenance events
[ "Summary", "and", "acknowledgement", "of", "upcoming", "and", "ongoing", "maintenance", "events" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/account/events.py#L15-L25
train
234,590
softlayer/softlayer-python
SoftLayer/CLI/account/events.py
event_table
def event_table(events): """Formats a table for events""" table = formatting.Table([ "Id", "Start Date", "End Date", "Subject", "Status", "Acknowledged", "Updates", "Impacted Resources" ], title="Upcoming Events") table.align['Subject'] = 'l' table.align['Impacted Resources'] = 'l' for event in events: table.add_row([ event.get('id'), utils.clean_time(event.get('startDate')), utils.clean_time(event.get('endDate')), # Some subjects can have \r\n for some reason. utils.clean_splitlines(event.get('subject')), utils.lookup(event, 'statusCode', 'name'), event.get('acknowledgedFlag'), event.get('updateCount'), event.get('impactedResourceCount') ]) return table
python
def event_table(events): """Formats a table for events""" table = formatting.Table([ "Id", "Start Date", "End Date", "Subject", "Status", "Acknowledged", "Updates", "Impacted Resources" ], title="Upcoming Events") table.align['Subject'] = 'l' table.align['Impacted Resources'] = 'l' for event in events: table.add_row([ event.get('id'), utils.clean_time(event.get('startDate')), utils.clean_time(event.get('endDate')), # Some subjects can have \r\n for some reason. utils.clean_splitlines(event.get('subject')), utils.lookup(event, 'statusCode', 'name'), event.get('acknowledgedFlag'), event.get('updateCount'), event.get('impactedResourceCount') ]) return table
[ "def", "event_table", "(", "events", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "\"Id\"", ",", "\"Start Date\"", ",", "\"End Date\"", ",", "\"Subject\"", ",", "\"Status\"", ",", "\"Acknowledged\"", ",", "\"Updates\"", ",", "\"Impacted Resources\"", "]", ",", "title", "=", "\"Upcoming Events\"", ")", "table", ".", "align", "[", "'Subject'", "]", "=", "'l'", "table", ".", "align", "[", "'Impacted Resources'", "]", "=", "'l'", "for", "event", "in", "events", ":", "table", ".", "add_row", "(", "[", "event", ".", "get", "(", "'id'", ")", ",", "utils", ".", "clean_time", "(", "event", ".", "get", "(", "'startDate'", ")", ")", ",", "utils", ".", "clean_time", "(", "event", ".", "get", "(", "'endDate'", ")", ")", ",", "# Some subjects can have \\r\\n for some reason.", "utils", ".", "clean_splitlines", "(", "event", ".", "get", "(", "'subject'", ")", ")", ",", "utils", ".", "lookup", "(", "event", ",", "'statusCode'", ",", "'name'", ")", ",", "event", ".", "get", "(", "'acknowledgedFlag'", ")", ",", "event", ".", "get", "(", "'updateCount'", ")", ",", "event", ".", "get", "(", "'impactedResourceCount'", ")", "]", ")", "return", "table" ]
Formats a table for events
[ "Formats", "a", "table", "for", "events" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/account/events.py#L28-L54
train
234,591
softlayer/softlayer-python
SoftLayer/CLI/block/access/password.py
cli
def cli(env, access_id, password): """Changes a password for a volume's access. access id is the allowed_host_id from slcli block access-list """ block_manager = SoftLayer.BlockStorageManager(env.client) result = block_manager.set_credential_password(access_id=access_id, password=password) if result: click.echo('Password updated for %s' % access_id) else: click.echo('FAILED updating password for %s' % access_id)
python
def cli(env, access_id, password): """Changes a password for a volume's access. access id is the allowed_host_id from slcli block access-list """ block_manager = SoftLayer.BlockStorageManager(env.client) result = block_manager.set_credential_password(access_id=access_id, password=password) if result: click.echo('Password updated for %s' % access_id) else: click.echo('FAILED updating password for %s' % access_id)
[ "def", "cli", "(", "env", ",", "access_id", ",", "password", ")", ":", "block_manager", "=", "SoftLayer", ".", "BlockStorageManager", "(", "env", ".", "client", ")", "result", "=", "block_manager", ".", "set_credential_password", "(", "access_id", "=", "access_id", ",", "password", "=", "password", ")", "if", "result", ":", "click", ".", "echo", "(", "'Password updated for %s'", "%", "access_id", ")", "else", ":", "click", ".", "echo", "(", "'FAILED updating password for %s'", "%", "access_id", ")" ]
Changes a password for a volume's access. access id is the allowed_host_id from slcli block access-list
[ "Changes", "a", "password", "for", "a", "volume", "s", "access", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/block/access/password.py#L14-L27
train
234,592
softlayer/softlayer-python
SoftLayer/CLI/cdn/detail.py
cli
def cli(env, account_id): """Detail a CDN Account.""" manager = SoftLayer.CDNManager(env.client) account = manager.get_account(account_id) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', account['id']]) table.add_row(['account_name', account['cdnAccountName']]) table.add_row(['type', account['cdnSolutionName']]) table.add_row(['status', account['status']['name']]) table.add_row(['created', account['createDate']]) table.add_row(['notes', account.get('cdnAccountNote', formatting.blank())]) env.fout(table)
python
def cli(env, account_id): """Detail a CDN Account.""" manager = SoftLayer.CDNManager(env.client) account = manager.get_account(account_id) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', account['id']]) table.add_row(['account_name', account['cdnAccountName']]) table.add_row(['type', account['cdnSolutionName']]) table.add_row(['status', account['status']['name']]) table.add_row(['created', account['createDate']]) table.add_row(['notes', account.get('cdnAccountNote', formatting.blank())]) env.fout(table)
[ "def", "cli", "(", "env", ",", "account_id", ")", ":", "manager", "=", "SoftLayer", ".", "CDNManager", "(", "env", ".", "client", ")", "account", "=", "manager", ".", "get_account", "(", "account_id", ")", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "table", ".", "align", "[", "'name'", "]", "=", "'r'", "table", ".", "align", "[", "'value'", "]", "=", "'l'", "table", ".", "add_row", "(", "[", "'id'", ",", "account", "[", "'id'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'account_name'", ",", "account", "[", "'cdnAccountName'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'type'", ",", "account", "[", "'cdnSolutionName'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'status'", ",", "account", "[", "'status'", "]", "[", "'name'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'created'", ",", "account", "[", "'createDate'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'notes'", ",", "account", ".", "get", "(", "'cdnAccountNote'", ",", "formatting", ".", "blank", "(", ")", ")", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Detail a CDN Account.
[ "Detail", "a", "CDN", "Account", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/cdn/detail.py#L14-L32
train
234,593
softlayer/softlayer-python
SoftLayer/utils.py
lookup
def lookup(dic, key, *keys): """A generic dictionary access helper. This helps simplify code that uses heavily nested dictionaries. It will return None if any of the keys in *keys do not exist. :: >>> lookup({'this': {'is': 'nested'}}, 'this', 'is') nested >>> lookup({}, 'this', 'is') None """ if keys: return lookup(dic.get(key, {}), keys[0], *keys[1:]) return dic.get(key)
python
def lookup(dic, key, *keys): """A generic dictionary access helper. This helps simplify code that uses heavily nested dictionaries. It will return None if any of the keys in *keys do not exist. :: >>> lookup({'this': {'is': 'nested'}}, 'this', 'is') nested >>> lookup({}, 'this', 'is') None """ if keys: return lookup(dic.get(key, {}), keys[0], *keys[1:]) return dic.get(key)
[ "def", "lookup", "(", "dic", ",", "key", ",", "*", "keys", ")", ":", "if", "keys", ":", "return", "lookup", "(", "dic", ".", "get", "(", "key", ",", "{", "}", ")", ",", "keys", "[", "0", "]", ",", "*", "keys", "[", "1", ":", "]", ")", "return", "dic", ".", "get", "(", "key", ")" ]
A generic dictionary access helper. This helps simplify code that uses heavily nested dictionaries. It will return None if any of the keys in *keys do not exist. :: >>> lookup({'this': {'is': 'nested'}}, 'this', 'is') nested >>> lookup({}, 'this', 'is') None
[ "A", "generic", "dictionary", "access", "helper", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/utils.py#L24-L41
train
234,594
softlayer/softlayer-python
SoftLayer/utils.py
query_filter
def query_filter(query): """Translate a query-style string to a 'filter'. Query can be the following formats: Case Insensitive 'value' OR '*= value' Contains 'value*' OR '^= value' Begins with value '*value' OR '$= value' Ends with value '*value*' OR '_= value' Contains value Case Sensitive '~ value' Contains '!~ value' Does not contain '> value' Greater than value '< value' Less than value '>= value' Greater than or equal to value '<= value' Less than or equal to value :param string query: query string """ try: return {'operation': int(query)} except ValueError: pass if isinstance(query, string_types): query = query.strip() for operation in KNOWN_OPERATIONS: if query.startswith(operation): query = "%s %s" % (operation, query[len(operation):].strip()) return {'operation': query} if query.startswith('*') and query.endswith('*'): query = "*= %s" % query.strip('*') elif query.startswith('*'): query = "$= %s" % query.strip('*') elif query.endswith('*'): query = "^= %s" % query.strip('*') else: query = "_= %s" % query return {'operation': query}
python
def query_filter(query): """Translate a query-style string to a 'filter'. Query can be the following formats: Case Insensitive 'value' OR '*= value' Contains 'value*' OR '^= value' Begins with value '*value' OR '$= value' Ends with value '*value*' OR '_= value' Contains value Case Sensitive '~ value' Contains '!~ value' Does not contain '> value' Greater than value '< value' Less than value '>= value' Greater than or equal to value '<= value' Less than or equal to value :param string query: query string """ try: return {'operation': int(query)} except ValueError: pass if isinstance(query, string_types): query = query.strip() for operation in KNOWN_OPERATIONS: if query.startswith(operation): query = "%s %s" % (operation, query[len(operation):].strip()) return {'operation': query} if query.startswith('*') and query.endswith('*'): query = "*= %s" % query.strip('*') elif query.startswith('*'): query = "$= %s" % query.strip('*') elif query.endswith('*'): query = "^= %s" % query.strip('*') else: query = "_= %s" % query return {'operation': query}
[ "def", "query_filter", "(", "query", ")", ":", "try", ":", "return", "{", "'operation'", ":", "int", "(", "query", ")", "}", "except", "ValueError", ":", "pass", "if", "isinstance", "(", "query", ",", "string_types", ")", ":", "query", "=", "query", ".", "strip", "(", ")", "for", "operation", "in", "KNOWN_OPERATIONS", ":", "if", "query", ".", "startswith", "(", "operation", ")", ":", "query", "=", "\"%s %s\"", "%", "(", "operation", ",", "query", "[", "len", "(", "operation", ")", ":", "]", ".", "strip", "(", ")", ")", "return", "{", "'operation'", ":", "query", "}", "if", "query", ".", "startswith", "(", "'*'", ")", "and", "query", ".", "endswith", "(", "'*'", ")", ":", "query", "=", "\"*= %s\"", "%", "query", ".", "strip", "(", "'*'", ")", "elif", "query", ".", "startswith", "(", "'*'", ")", ":", "query", "=", "\"$= %s\"", "%", "query", ".", "strip", "(", "'*'", ")", "elif", "query", ".", "endswith", "(", "'*'", ")", ":", "query", "=", "\"^= %s\"", "%", "query", ".", "strip", "(", "'*'", ")", "else", ":", "query", "=", "\"_= %s\"", "%", "query", "return", "{", "'operation'", ":", "query", "}" ]
Translate a query-style string to a 'filter'. Query can be the following formats: Case Insensitive 'value' OR '*= value' Contains 'value*' OR '^= value' Begins with value '*value' OR '$= value' Ends with value '*value*' OR '_= value' Contains value Case Sensitive '~ value' Contains '!~ value' Does not contain '> value' Greater than value '< value' Less than value '>= value' Greater than or equal to value '<= value' Less than or equal to value :param string query: query string
[ "Translate", "a", "query", "-", "style", "string", "to", "a", "filter", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/utils.py#L66-L108
train
234,595
softlayer/softlayer-python
SoftLayer/utils.py
query_filter_date
def query_filter_date(start, end): """Query filters given start and end date. :param start:YY-MM-DD :param end: YY-MM-DD """ sdate = datetime.datetime.strptime(start, "%Y-%m-%d") edate = datetime.datetime.strptime(end, "%Y-%m-%d") startdate = "%s/%s/%s" % (sdate.month, sdate.day, sdate.year) enddate = "%s/%s/%s" % (edate.month, edate.day, edate.year) return { 'operation': 'betweenDate', 'options': [ {'name': 'startDate', 'value': [startdate + ' 0:0:0']}, {'name': 'endDate', 'value': [enddate + ' 0:0:0']} ] }
python
def query_filter_date(start, end): """Query filters given start and end date. :param start:YY-MM-DD :param end: YY-MM-DD """ sdate = datetime.datetime.strptime(start, "%Y-%m-%d") edate = datetime.datetime.strptime(end, "%Y-%m-%d") startdate = "%s/%s/%s" % (sdate.month, sdate.day, sdate.year) enddate = "%s/%s/%s" % (edate.month, edate.day, edate.year) return { 'operation': 'betweenDate', 'options': [ {'name': 'startDate', 'value': [startdate + ' 0:0:0']}, {'name': 'endDate', 'value': [enddate + ' 0:0:0']} ] }
[ "def", "query_filter_date", "(", "start", ",", "end", ")", ":", "sdate", "=", "datetime", ".", "datetime", ".", "strptime", "(", "start", ",", "\"%Y-%m-%d\"", ")", "edate", "=", "datetime", ".", "datetime", ".", "strptime", "(", "end", ",", "\"%Y-%m-%d\"", ")", "startdate", "=", "\"%s/%s/%s\"", "%", "(", "sdate", ".", "month", ",", "sdate", ".", "day", ",", "sdate", ".", "year", ")", "enddate", "=", "\"%s/%s/%s\"", "%", "(", "edate", ".", "month", ",", "edate", ".", "day", ",", "edate", ".", "year", ")", "return", "{", "'operation'", ":", "'betweenDate'", ",", "'options'", ":", "[", "{", "'name'", ":", "'startDate'", ",", "'value'", ":", "[", "startdate", "+", "' 0:0:0'", "]", "}", ",", "{", "'name'", ":", "'endDate'", ",", "'value'", ":", "[", "enddate", "+", "' 0:0:0'", "]", "}", "]", "}" ]
Query filters given start and end date. :param start:YY-MM-DD :param end: YY-MM-DD
[ "Query", "filters", "given", "start", "and", "end", "date", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/utils.py#L111-L127
train
234,596
softlayer/softlayer-python
SoftLayer/utils.py
format_event_log_date
def format_event_log_date(date_string, utc): """Gets a date in the format that the SoftLayer_EventLog object likes. :param string date_string: date in mm/dd/yyyy format :param string utc: utc offset. Defaults to '+0000' """ user_date_format = "%m/%d/%Y" user_date = datetime.datetime.strptime(date_string, user_date_format) dirty_time = user_date.isoformat() if utc is None: utc = "+0000" iso_time_zone = utc[:3] + ':' + utc[3:] cleaned_time = "{}.000000{}".format(dirty_time, iso_time_zone) return cleaned_time
python
def format_event_log_date(date_string, utc): """Gets a date in the format that the SoftLayer_EventLog object likes. :param string date_string: date in mm/dd/yyyy format :param string utc: utc offset. Defaults to '+0000' """ user_date_format = "%m/%d/%Y" user_date = datetime.datetime.strptime(date_string, user_date_format) dirty_time = user_date.isoformat() if utc is None: utc = "+0000" iso_time_zone = utc[:3] + ':' + utc[3:] cleaned_time = "{}.000000{}".format(dirty_time, iso_time_zone) return cleaned_time
[ "def", "format_event_log_date", "(", "date_string", ",", "utc", ")", ":", "user_date_format", "=", "\"%m/%d/%Y\"", "user_date", "=", "datetime", ".", "datetime", ".", "strptime", "(", "date_string", ",", "user_date_format", ")", "dirty_time", "=", "user_date", ".", "isoformat", "(", ")", "if", "utc", "is", "None", ":", "utc", "=", "\"+0000\"", "iso_time_zone", "=", "utc", "[", ":", "3", "]", "+", "':'", "+", "utc", "[", "3", ":", "]", "cleaned_time", "=", "\"{}.000000{}\"", ".", "format", "(", "dirty_time", ",", "iso_time_zone", ")", "return", "cleaned_time" ]
Gets a date in the format that the SoftLayer_EventLog object likes. :param string date_string: date in mm/dd/yyyy format :param string utc: utc offset. Defaults to '+0000'
[ "Gets", "a", "date", "in", "the", "format", "that", "the", "SoftLayer_EventLog", "object", "likes", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/utils.py#L130-L147
train
234,597
softlayer/softlayer-python
SoftLayer/utils.py
event_log_filter_between_date
def event_log_filter_between_date(start, end, utc): """betweenDate Query filter that SoftLayer_EventLog likes :param string start: lower bound date in mm/dd/yyyy format :param string end: upper bound date in mm/dd/yyyy format :param string utc: utc offset. Defaults to '+0000' """ return { 'operation': 'betweenDate', 'options': [ {'name': 'startDate', 'value': [format_event_log_date(start, utc)]}, {'name': 'endDate', 'value': [format_event_log_date(end, utc)]} ] }
python
def event_log_filter_between_date(start, end, utc): """betweenDate Query filter that SoftLayer_EventLog likes :param string start: lower bound date in mm/dd/yyyy format :param string end: upper bound date in mm/dd/yyyy format :param string utc: utc offset. Defaults to '+0000' """ return { 'operation': 'betweenDate', 'options': [ {'name': 'startDate', 'value': [format_event_log_date(start, utc)]}, {'name': 'endDate', 'value': [format_event_log_date(end, utc)]} ] }
[ "def", "event_log_filter_between_date", "(", "start", ",", "end", ",", "utc", ")", ":", "return", "{", "'operation'", ":", "'betweenDate'", ",", "'options'", ":", "[", "{", "'name'", ":", "'startDate'", ",", "'value'", ":", "[", "format_event_log_date", "(", "start", ",", "utc", ")", "]", "}", ",", "{", "'name'", ":", "'endDate'", ",", "'value'", ":", "[", "format_event_log_date", "(", "end", ",", "utc", ")", "]", "}", "]", "}" ]
betweenDate Query filter that SoftLayer_EventLog likes :param string start: lower bound date in mm/dd/yyyy format :param string end: upper bound date in mm/dd/yyyy format :param string utc: utc offset. Defaults to '+0000'
[ "betweenDate", "Query", "filter", "that", "SoftLayer_EventLog", "likes" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/utils.py#L150-L163
train
234,598
softlayer/softlayer-python
SoftLayer/utils.py
resolve_ids
def resolve_ids(identifier, resolvers): """Resolves IDs given a list of functions. :param string identifier: identifier string :param list resolvers: a list of functions :returns list: """ # Before doing anything, let's see if this is an integer try: return [int(identifier)] except ValueError: pass # It was worth a shot # This looks like a globalIdentifier (UUID) if len(identifier) == 36 and UUID_RE.match(identifier): return [identifier] for resolver in resolvers: ids = resolver(identifier) if ids: return ids return []
python
def resolve_ids(identifier, resolvers): """Resolves IDs given a list of functions. :param string identifier: identifier string :param list resolvers: a list of functions :returns list: """ # Before doing anything, let's see if this is an integer try: return [int(identifier)] except ValueError: pass # It was worth a shot # This looks like a globalIdentifier (UUID) if len(identifier) == 36 and UUID_RE.match(identifier): return [identifier] for resolver in resolvers: ids = resolver(identifier) if ids: return ids return []
[ "def", "resolve_ids", "(", "identifier", ",", "resolvers", ")", ":", "# Before doing anything, let's see if this is an integer", "try", ":", "return", "[", "int", "(", "identifier", ")", "]", "except", "ValueError", ":", "pass", "# It was worth a shot", "# This looks like a globalIdentifier (UUID)", "if", "len", "(", "identifier", ")", "==", "36", "and", "UUID_RE", ".", "match", "(", "identifier", ")", ":", "return", "[", "identifier", "]", "for", "resolver", "in", "resolvers", ":", "ids", "=", "resolver", "(", "identifier", ")", "if", "ids", ":", "return", "ids", "return", "[", "]" ]
Resolves IDs given a list of functions. :param string identifier: identifier string :param list resolvers: a list of functions :returns list:
[ "Resolves", "IDs", "given", "a", "list", "of", "functions", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/utils.py#L215-L238
train
234,599