id
int32
0
252k
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
sequence
docstring
stringlengths
3
17.3k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
87
242
1,500
softlayer/softlayer-python
SoftLayer/CLI/virt/placementgroup/create_options.py
cli
def cli(env): """List options for creating a placement group.""" manager = PlacementManager(env.client) routers = manager.get_routers() env.fout(get_router_table(routers)) rules = manager.get_all_rules() env.fout(get_rule_table(rules))
python
def cli(env): """List options for creating a placement group.""" manager = PlacementManager(env.client) routers = manager.get_routers() env.fout(get_router_table(routers)) rules = manager.get_all_rules() env.fout(get_rule_table(rules))
[ "def", "cli", "(", "env", ")", ":", "manager", "=", "PlacementManager", "(", "env", ".", "client", ")", "routers", "=", "manager", ".", "get_routers", "(", ")", "env", ".", "fout", "(", "get_router_table", "(", "routers", ")", ")", "rules", "=", "manager", ".", "get_all_rules", "(", ")", "env", ".", "fout", "(", "get_rule_table", "(", "rules", ")", ")" ]
List options for creating a placement group.
[ "List", "options", "for", "creating", "a", "placement", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/placementgroup/create_options.py#L13-L21
1,501
softlayer/softlayer-python
SoftLayer/CLI/virt/placementgroup/create_options.py
get_router_table
def get_router_table(routers): """Formats output from _get_routers and returns a table. """ table = formatting.Table(['Datacenter', 'Hostname', 'Backend Router Id'], "Available Routers") for router in routers: datacenter = router['topLevelLocation']['longName'] table.add_row([datacenter, router['hostname'], router['id']]) return table
python
def get_router_table(routers): """Formats output from _get_routers and returns a table. """ table = formatting.Table(['Datacenter', 'Hostname', 'Backend Router Id'], "Available Routers") for router in routers: datacenter = router['topLevelLocation']['longName'] table.add_row([datacenter, router['hostname'], router['id']]) return table
[ "def", "get_router_table", "(", "routers", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'Datacenter'", ",", "'Hostname'", ",", "'Backend Router Id'", "]", ",", "\"Available Routers\"", ")", "for", "router", "in", "routers", ":", "datacenter", "=", "router", "[", "'topLevelLocation'", "]", "[", "'longName'", "]", "table", ".", "add_row", "(", "[", "datacenter", ",", "router", "[", "'hostname'", "]", ",", "router", "[", "'id'", "]", "]", ")", "return", "table" ]
Formats output from _get_routers and returns a table.
[ "Formats", "output", "from", "_get_routers", "and", "returns", "a", "table", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/placementgroup/create_options.py#L24-L30
1,502
softlayer/softlayer-python
SoftLayer/CLI/virt/placementgroup/create_options.py
get_rule_table
def get_rule_table(rules): """Formats output from get_all_rules and returns a table. """ table = formatting.Table(['Id', 'KeyName'], "Rules") for rule in rules: table.add_row([rule['id'], rule['keyName']]) return table
python
def get_rule_table(rules): """Formats output from get_all_rules and returns a table. """ table = formatting.Table(['Id', 'KeyName'], "Rules") for rule in rules: table.add_row([rule['id'], rule['keyName']]) return table
[ "def", "get_rule_table", "(", "rules", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'Id'", ",", "'KeyName'", "]", ",", "\"Rules\"", ")", "for", "rule", "in", "rules", ":", "table", ".", "add_row", "(", "[", "rule", "[", "'id'", "]", ",", "rule", "[", "'keyName'", "]", "]", ")", "return", "table" ]
Formats output from get_all_rules and returns a table.
[ "Formats", "output", "from", "get_all_rules", "and", "returns", "a", "table", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/placementgroup/create_options.py#L33-L38
1,503
softlayer/softlayer-python
SoftLayer/CLI/virt/detail.py
_cli_helper_dedicated_host
def _cli_helper_dedicated_host(env, result, table): """Get details on dedicated host for a virtual server.""" dedicated_host_id = utils.lookup(result, 'dedicatedHost', 'id') if dedicated_host_id: table.add_row(['dedicated_host_id', dedicated_host_id]) # Try to find name of dedicated host try: dedicated_host = env.client.call('Virtual_DedicatedHost', 'getObject', id=dedicated_host_id) except SoftLayer.SoftLayerAPIError: LOGGER.error('Unable to get dedicated host id %s', dedicated_host_id) dedicated_host = {} table.add_row(['dedicated_host', dedicated_host.get('name') or formatting.blank()])
python
def _cli_helper_dedicated_host(env, result, table): """Get details on dedicated host for a virtual server.""" dedicated_host_id = utils.lookup(result, 'dedicatedHost', 'id') if dedicated_host_id: table.add_row(['dedicated_host_id', dedicated_host_id]) # Try to find name of dedicated host try: dedicated_host = env.client.call('Virtual_DedicatedHost', 'getObject', id=dedicated_host_id) except SoftLayer.SoftLayerAPIError: LOGGER.error('Unable to get dedicated host id %s', dedicated_host_id) dedicated_host = {} table.add_row(['dedicated_host', dedicated_host.get('name') or formatting.blank()])
[ "def", "_cli_helper_dedicated_host", "(", "env", ",", "result", ",", "table", ")", ":", "dedicated_host_id", "=", "utils", ".", "lookup", "(", "result", ",", "'dedicatedHost'", ",", "'id'", ")", "if", "dedicated_host_id", ":", "table", ".", "add_row", "(", "[", "'dedicated_host_id'", ",", "dedicated_host_id", "]", ")", "# Try to find name of dedicated host", "try", ":", "dedicated_host", "=", "env", ".", "client", ".", "call", "(", "'Virtual_DedicatedHost'", ",", "'getObject'", ",", "id", "=", "dedicated_host_id", ")", "except", "SoftLayer", ".", "SoftLayerAPIError", ":", "LOGGER", ".", "error", "(", "'Unable to get dedicated host id %s'", ",", "dedicated_host_id", ")", "dedicated_host", "=", "{", "}", "table", ".", "add_row", "(", "[", "'dedicated_host'", ",", "dedicated_host", ".", "get", "(", "'name'", ")", "or", "formatting", ".", "blank", "(", ")", "]", ")" ]
Get details on dedicated host for a virtual server.
[ "Get", "details", "on", "dedicated", "host", "for", "a", "virtual", "server", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/detail.py#L148-L162
1,504
softlayer/softlayer-python
SoftLayer/CLI/virt/ready.py
cli
def cli(env, identifier, wait): """Check if a virtual server is ready.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') ready = vsi.wait_for_ready(vs_id, wait) if ready: env.fout("READY") else: raise exceptions.CLIAbort("Instance %s not ready" % vs_id)
python
def cli(env, identifier, wait): """Check if a virtual server is ready.""" vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS') ready = vsi.wait_for_ready(vs_id, wait) if ready: env.fout("READY") else: raise exceptions.CLIAbort("Instance %s not ready" % vs_id)
[ "def", "cli", "(", "env", ",", "identifier", ",", "wait", ")", ":", "vsi", "=", "SoftLayer", ".", "VSManager", "(", "env", ".", "client", ")", "vs_id", "=", "helpers", ".", "resolve_id", "(", "vsi", ".", "resolve_ids", ",", "identifier", ",", "'VS'", ")", "ready", "=", "vsi", ".", "wait_for_ready", "(", "vs_id", ",", "wait", ")", "if", "ready", ":", "env", ".", "fout", "(", "\"READY\"", ")", "else", ":", "raise", "exceptions", ".", "CLIAbort", "(", "\"Instance %s not ready\"", "%", "vs_id", ")" ]
Check if a virtual server is ready.
[ "Check", "if", "a", "virtual", "server", "is", "ready", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/ready.py#L16-L25
1,505
softlayer/softlayer-python
SoftLayer/CLI/block/replication/failover.py
cli
def cli(env, volume_id, replicant_id, immediate): """Failover a block volume to the given replicant volume.""" block_storage_manager = SoftLayer.BlockStorageManager(env.client) success = block_storage_manager.failover_to_replicant( volume_id, replicant_id, immediate ) if success: click.echo("Failover to replicant is now in progress.") else: click.echo("Failover operation could not be initiated.")
python
def cli(env, volume_id, replicant_id, immediate): """Failover a block volume to the given replicant volume.""" block_storage_manager = SoftLayer.BlockStorageManager(env.client) success = block_storage_manager.failover_to_replicant( volume_id, replicant_id, immediate ) if success: click.echo("Failover to replicant is now in progress.") else: click.echo("Failover operation could not be initiated.")
[ "def", "cli", "(", "env", ",", "volume_id", ",", "replicant_id", ",", "immediate", ")", ":", "block_storage_manager", "=", "SoftLayer", ".", "BlockStorageManager", "(", "env", ".", "client", ")", "success", "=", "block_storage_manager", ".", "failover_to_replicant", "(", "volume_id", ",", "replicant_id", ",", "immediate", ")", "if", "success", ":", "click", ".", "echo", "(", "\"Failover to replicant is now in progress.\"", ")", "else", ":", "click", ".", "echo", "(", "\"Failover operation could not be initiated.\"", ")" ]
Failover a block volume to the given replicant volume.
[ "Failover", "a", "block", "volume", "to", "the", "given", "replicant", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/block/replication/failover.py#L17-L30
1,506
softlayer/softlayer-python
SoftLayer/CLI/dedicatedhost/cancel.py
cli
def cli(env, identifier): """Cancel a dedicated host server immediately""" mgr = SoftLayer.DedicatedHostManager(env.client) host_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'dedicated host') if not (env.skip_confirmations or formatting.no_going_back(host_id)): raise exceptions.CLIAbort('Aborted') mgr.cancel_host(host_id) click.secho('Dedicated Host %s was cancelled' % host_id, fg='green')
python
def cli(env, identifier): """Cancel a dedicated host server immediately""" mgr = SoftLayer.DedicatedHostManager(env.client) host_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'dedicated host') if not (env.skip_confirmations or formatting.no_going_back(host_id)): raise exceptions.CLIAbort('Aborted') mgr.cancel_host(host_id) click.secho('Dedicated Host %s was cancelled' % host_id, fg='green')
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "mgr", "=", "SoftLayer", ".", "DedicatedHostManager", "(", "env", ".", "client", ")", "host_id", "=", "helpers", ".", "resolve_id", "(", "mgr", ".", "resolve_ids", ",", "identifier", ",", "'dedicated host'", ")", "if", "not", "(", "env", ".", "skip_confirmations", "or", "formatting", ".", "no_going_back", "(", "host_id", ")", ")", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Aborted'", ")", "mgr", ".", "cancel_host", "(", "host_id", ")", "click", ".", "secho", "(", "'Dedicated Host %s was cancelled'", "%", "host_id", ",", "fg", "=", "'green'", ")" ]
Cancel a dedicated host server immediately
[ "Cancel", "a", "dedicated", "host", "server", "immediately" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dedicatedhost/cancel.py#L16-L28
1,507
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager.get_image
def get_image(self, image_id, **kwargs): """Get details about an image. :param int image: The ID of the image. :param dict \\*\\*kwargs: response-level options (mask, limit, etc.) """ if 'mask' not in kwargs: kwargs['mask'] = IMAGE_MASK return self.vgbdtg.getObject(id=image_id, **kwargs)
python
def get_image(self, image_id, **kwargs): """Get details about an image. :param int image: The ID of the image. :param dict \\*\\*kwargs: response-level options (mask, limit, etc.) """ if 'mask' not in kwargs: kwargs['mask'] = IMAGE_MASK return self.vgbdtg.getObject(id=image_id, **kwargs)
[ "def", "get_image", "(", "self", ",", "image_id", ",", "*", "*", "kwargs", ")", ":", "if", "'mask'", "not", "in", "kwargs", ":", "kwargs", "[", "'mask'", "]", "=", "IMAGE_MASK", "return", "self", ".", "vgbdtg", ".", "getObject", "(", "id", "=", "image_id", ",", "*", "*", "kwargs", ")" ]
Get details about an image. :param int image: The ID of the image. :param dict \\*\\*kwargs: response-level options (mask, limit, etc.)
[ "Get", "details", "about", "an", "image", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L30-L39
1,508
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager.list_private_images
def list_private_images(self, guid=None, name=None, **kwargs): """List all private images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.) """ if 'mask' not in kwargs: kwargs['mask'] = IMAGE_MASK _filter = utils.NestedDict(kwargs.get('filter') or {}) if name: _filter['privateBlockDeviceTemplateGroups']['name'] = ( utils.query_filter(name)) if guid: _filter['privateBlockDeviceTemplateGroups']['globalIdentifier'] = ( utils.query_filter(guid)) kwargs['filter'] = _filter.to_dict() account = self.client['Account'] return account.getPrivateBlockDeviceTemplateGroups(**kwargs)
python
def list_private_images(self, guid=None, name=None, **kwargs): """List all private images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.) """ if 'mask' not in kwargs: kwargs['mask'] = IMAGE_MASK _filter = utils.NestedDict(kwargs.get('filter') or {}) if name: _filter['privateBlockDeviceTemplateGroups']['name'] = ( utils.query_filter(name)) if guid: _filter['privateBlockDeviceTemplateGroups']['globalIdentifier'] = ( utils.query_filter(guid)) kwargs['filter'] = _filter.to_dict() account = self.client['Account'] return account.getPrivateBlockDeviceTemplateGroups(**kwargs)
[ "def", "list_private_images", "(", "self", ",", "guid", "=", "None", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'mask'", "not", "in", "kwargs", ":", "kwargs", "[", "'mask'", "]", "=", "IMAGE_MASK", "_filter", "=", "utils", ".", "NestedDict", "(", "kwargs", ".", "get", "(", "'filter'", ")", "or", "{", "}", ")", "if", "name", ":", "_filter", "[", "'privateBlockDeviceTemplateGroups'", "]", "[", "'name'", "]", "=", "(", "utils", ".", "query_filter", "(", "name", ")", ")", "if", "guid", ":", "_filter", "[", "'privateBlockDeviceTemplateGroups'", "]", "[", "'globalIdentifier'", "]", "=", "(", "utils", ".", "query_filter", "(", "guid", ")", ")", "kwargs", "[", "'filter'", "]", "=", "_filter", ".", "to_dict", "(", ")", "account", "=", "self", ".", "client", "[", "'Account'", "]", "return", "account", ".", "getPrivateBlockDeviceTemplateGroups", "(", "*", "*", "kwargs", ")" ]
List all private images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.)
[ "List", "all", "private", "images", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L48-L70
1,509
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager.list_public_images
def list_public_images(self, guid=None, name=None, **kwargs): """List all public images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.) """ if 'mask' not in kwargs: kwargs['mask'] = IMAGE_MASK _filter = utils.NestedDict(kwargs.get('filter') or {}) if name: _filter['name'] = utils.query_filter(name) if guid: _filter['globalIdentifier'] = utils.query_filter(guid) kwargs['filter'] = _filter.to_dict() return self.vgbdtg.getPublicImages(**kwargs)
python
def list_public_images(self, guid=None, name=None, **kwargs): """List all public images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.) """ if 'mask' not in kwargs: kwargs['mask'] = IMAGE_MASK _filter = utils.NestedDict(kwargs.get('filter') or {}) if name: _filter['name'] = utils.query_filter(name) if guid: _filter['globalIdentifier'] = utils.query_filter(guid) kwargs['filter'] = _filter.to_dict() return self.vgbdtg.getPublicImages(**kwargs)
[ "def", "list_public_images", "(", "self", ",", "guid", "=", "None", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'mask'", "not", "in", "kwargs", ":", "kwargs", "[", "'mask'", "]", "=", "IMAGE_MASK", "_filter", "=", "utils", ".", "NestedDict", "(", "kwargs", ".", "get", "(", "'filter'", ")", "or", "{", "}", ")", "if", "name", ":", "_filter", "[", "'name'", "]", "=", "utils", ".", "query_filter", "(", "name", ")", "if", "guid", ":", "_filter", "[", "'globalIdentifier'", "]", "=", "utils", ".", "query_filter", "(", "guid", ")", "kwargs", "[", "'filter'", "]", "=", "_filter", ".", "to_dict", "(", ")", "return", "self", ".", "vgbdtg", ".", "getPublicImages", "(", "*", "*", "kwargs", ")" ]
List all public images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.)
[ "List", "all", "public", "images", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L72-L91
1,510
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager._get_ids_from_name_public
def _get_ids_from_name_public(self, name): """Get public images which match the given name.""" results = self.list_public_images(name=name) return [result['id'] for result in results]
python
def _get_ids_from_name_public(self, name): """Get public images which match the given name.""" results = self.list_public_images(name=name) return [result['id'] for result in results]
[ "def", "_get_ids_from_name_public", "(", "self", ",", "name", ")", ":", "results", "=", "self", ".", "list_public_images", "(", "name", "=", "name", ")", "return", "[", "result", "[", "'id'", "]", "for", "result", "in", "results", "]" ]
Get public images which match the given name.
[ "Get", "public", "images", "which", "match", "the", "given", "name", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L93-L96
1,511
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager._get_ids_from_name_private
def _get_ids_from_name_private(self, name): """Get private images which match the given name.""" results = self.list_private_images(name=name) return [result['id'] for result in results]
python
def _get_ids_from_name_private(self, name): """Get private images which match the given name.""" results = self.list_private_images(name=name) return [result['id'] for result in results]
[ "def", "_get_ids_from_name_private", "(", "self", ",", "name", ")", ":", "results", "=", "self", ".", "list_private_images", "(", "name", "=", "name", ")", "return", "[", "result", "[", "'id'", "]", "for", "result", "in", "results", "]" ]
Get private images which match the given name.
[ "Get", "private", "images", "which", "match", "the", "given", "name", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L98-L101
1,512
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager.edit
def edit(self, image_id, name=None, note=None, tag=None): """Edit image related details. :param int image_id: The ID of the image :param string name: Name of the Image. :param string note: Note of the image. :param string tag: Tags of the image to be updated to. """ obj = {} if name: obj['name'] = name if note: obj['note'] = note if obj: self.vgbdtg.editObject(obj, id=image_id) if tag: self.vgbdtg.setTags(str(tag), id=image_id) return bool(name or note or tag)
python
def edit(self, image_id, name=None, note=None, tag=None): """Edit image related details. :param int image_id: The ID of the image :param string name: Name of the Image. :param string note: Note of the image. :param string tag: Tags of the image to be updated to. """ obj = {} if name: obj['name'] = name if note: obj['note'] = note if obj: self.vgbdtg.editObject(obj, id=image_id) if tag: self.vgbdtg.setTags(str(tag), id=image_id) return bool(name or note or tag)
[ "def", "edit", "(", "self", ",", "image_id", ",", "name", "=", "None", ",", "note", "=", "None", ",", "tag", "=", "None", ")", ":", "obj", "=", "{", "}", "if", "name", ":", "obj", "[", "'name'", "]", "=", "name", "if", "note", ":", "obj", "[", "'note'", "]", "=", "note", "if", "obj", ":", "self", ".", "vgbdtg", ".", "editObject", "(", "obj", ",", "id", "=", "image_id", ")", "if", "tag", ":", "self", ".", "vgbdtg", ".", "setTags", "(", "str", "(", "tag", ")", ",", "id", "=", "image_id", ")", "return", "bool", "(", "name", "or", "note", "or", "tag", ")" ]
Edit image related details. :param int image_id: The ID of the image :param string name: Name of the Image. :param string note: Note of the image. :param string tag: Tags of the image to be updated to.
[ "Edit", "image", "related", "details", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L103-L121
1,513
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager.import_image_from_uri
def import_image_from_uri(self, name, uri, os_code=None, note=None, ibm_api_key=None, root_key_crn=None, wrapped_dek=None, cloud_init=False, byol=False, is_encrypted=False): """Import a new image from object storage. :param string name: Name of the new image :param string uri: The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or (.vhd/.iso/.raw file) of the format: cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage :param string os_code: The reference code of the operating system :param string note: Note to add to the image :param string ibm_api_key: Ibm Api Key needed to communicate with ICOS and your KMS :param string root_key_crn: CRN of the root key in your KMS. Go to your KMS (Key Protect or Hyper Protect) provider to get the CRN for your root key. An example CRN: crn:v1:bluemix:public:hs-crypto:us-south:acctID:serviceID:key:keyID' Used only when is_encrypted is True. :param string wrapped_dek: Wrapped Data Encryption Key provided by your KMS. Used only when is_encrypted is True. :param boolean cloud_init: Specifies if image is cloud-init :param boolean byol: Specifies if image is bring your own license :param boolean is_encrypted: Specifies if image is encrypted """ if 'cos://' in uri: return self.vgbdtg.createFromIcos({ 'name': name, 'note': note, 'operatingSystemReferenceCode': os_code, 'uri': uri, 'ibmApiKey': ibm_api_key, 'crkCrn': root_key_crn, 'wrappedDek': wrapped_dek, 'cloudInit': cloud_init, 'byol': byol, 'isEncrypted': is_encrypted }) else: return self.vgbdtg.createFromExternalSource({ 'name': name, 'note': note, 'operatingSystemReferenceCode': os_code, 'uri': uri, })
python
def import_image_from_uri(self, name, uri, os_code=None, note=None, ibm_api_key=None, root_key_crn=None, wrapped_dek=None, cloud_init=False, byol=False, is_encrypted=False): """Import a new image from object storage. :param string name: Name of the new image :param string uri: The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or (.vhd/.iso/.raw file) of the format: cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage :param string os_code: The reference code of the operating system :param string note: Note to add to the image :param string ibm_api_key: Ibm Api Key needed to communicate with ICOS and your KMS :param string root_key_crn: CRN of the root key in your KMS. Go to your KMS (Key Protect or Hyper Protect) provider to get the CRN for your root key. An example CRN: crn:v1:bluemix:public:hs-crypto:us-south:acctID:serviceID:key:keyID' Used only when is_encrypted is True. :param string wrapped_dek: Wrapped Data Encryption Key provided by your KMS. Used only when is_encrypted is True. :param boolean cloud_init: Specifies if image is cloud-init :param boolean byol: Specifies if image is bring your own license :param boolean is_encrypted: Specifies if image is encrypted """ if 'cos://' in uri: return self.vgbdtg.createFromIcos({ 'name': name, 'note': note, 'operatingSystemReferenceCode': os_code, 'uri': uri, 'ibmApiKey': ibm_api_key, 'crkCrn': root_key_crn, 'wrappedDek': wrapped_dek, 'cloudInit': cloud_init, 'byol': byol, 'isEncrypted': is_encrypted }) else: return self.vgbdtg.createFromExternalSource({ 'name': name, 'note': note, 'operatingSystemReferenceCode': os_code, 'uri': uri, })
[ "def", "import_image_from_uri", "(", "self", ",", "name", ",", "uri", ",", "os_code", "=", "None", ",", "note", "=", "None", ",", "ibm_api_key", "=", "None", ",", "root_key_crn", "=", "None", ",", "wrapped_dek", "=", "None", ",", "cloud_init", "=", "False", ",", "byol", "=", "False", ",", "is_encrypted", "=", "False", ")", ":", "if", "'cos://'", "in", "uri", ":", "return", "self", ".", "vgbdtg", ".", "createFromIcos", "(", "{", "'name'", ":", "name", ",", "'note'", ":", "note", ",", "'operatingSystemReferenceCode'", ":", "os_code", ",", "'uri'", ":", "uri", ",", "'ibmApiKey'", ":", "ibm_api_key", ",", "'crkCrn'", ":", "root_key_crn", ",", "'wrappedDek'", ":", "wrapped_dek", ",", "'cloudInit'", ":", "cloud_init", ",", "'byol'", ":", "byol", ",", "'isEncrypted'", ":", "is_encrypted", "}", ")", "else", ":", "return", "self", ".", "vgbdtg", ".", "createFromExternalSource", "(", "{", "'name'", ":", "name", ",", "'note'", ":", "note", ",", "'operatingSystemReferenceCode'", ":", "os_code", ",", "'uri'", ":", "uri", ",", "}", ")" ]
Import a new image from object storage. :param string name: Name of the new image :param string uri: The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or (.vhd/.iso/.raw file) of the format: cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage :param string os_code: The reference code of the operating system :param string note: Note to add to the image :param string ibm_api_key: Ibm Api Key needed to communicate with ICOS and your KMS :param string root_key_crn: CRN of the root key in your KMS. Go to your KMS (Key Protect or Hyper Protect) provider to get the CRN for your root key. An example CRN: crn:v1:bluemix:public:hs-crypto:us-south:acctID:serviceID:key:keyID' Used only when is_encrypted is True. :param string wrapped_dek: Wrapped Data Encryption Key provided by your KMS. Used only when is_encrypted is True. :param boolean cloud_init: Specifies if image is cloud-init :param boolean byol: Specifies if image is bring your own license :param boolean is_encrypted: Specifies if image is encrypted
[ "Import", "a", "new", "image", "from", "object", "storage", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L123-L170
1,514
softlayer/softlayer-python
SoftLayer/managers/image.py
ImageManager.export_image_to_uri
def export_image_to_uri(self, image_id, uri, ibm_api_key=None): """Export image into the given object storage :param int image_id: The ID of the image :param string uri: The URI for object storage of the format swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage :param string ibm_api_key: Ibm Api Key needed to communicate with IBM Cloud Object Storage """ if 'cos://' in uri: return self.vgbdtg.copyToIcos({ 'uri': uri, 'ibmApiKey': ibm_api_key }, id=image_id) else: return self.vgbdtg.copyToExternalSource({'uri': uri}, id=image_id)
python
def export_image_to_uri(self, image_id, uri, ibm_api_key=None): """Export image into the given object storage :param int image_id: The ID of the image :param string uri: The URI for object storage of the format swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage :param string ibm_api_key: Ibm Api Key needed to communicate with IBM Cloud Object Storage """ if 'cos://' in uri: return self.vgbdtg.copyToIcos({ 'uri': uri, 'ibmApiKey': ibm_api_key }, id=image_id) else: return self.vgbdtg.copyToExternalSource({'uri': uri}, id=image_id)
[ "def", "export_image_to_uri", "(", "self", ",", "image_id", ",", "uri", ",", "ibm_api_key", "=", "None", ")", ":", "if", "'cos://'", "in", "uri", ":", "return", "self", ".", "vgbdtg", ".", "copyToIcos", "(", "{", "'uri'", ":", "uri", ",", "'ibmApiKey'", ":", "ibm_api_key", "}", ",", "id", "=", "image_id", ")", "else", ":", "return", "self", ".", "vgbdtg", ".", "copyToExternalSource", "(", "{", "'uri'", ":", "uri", "}", ",", "id", "=", "image_id", ")" ]
Export image into the given object storage :param int image_id: The ID of the image :param string uri: The URI for object storage of the format swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage :param string ibm_api_key: Ibm Api Key needed to communicate with IBM Cloud Object Storage
[ "Export", "image", "into", "the", "given", "object", "storage" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L172-L189
1,515
softlayer/softlayer-python
SoftLayer/CLI/object_storage/credential/delete.py
cli
def cli(env, identifier, credential_id): """Delete the credential of an Object Storage Account.""" mgr = SoftLayer.ObjectStorageManager(env.client) credential = mgr.delete_credential(identifier, credential_id=credential_id) env.fout(credential)
python
def cli(env, identifier, credential_id): """Delete the credential of an Object Storage Account.""" mgr = SoftLayer.ObjectStorageManager(env.client) credential = mgr.delete_credential(identifier, credential_id=credential_id) env.fout(credential)
[ "def", "cli", "(", "env", ",", "identifier", ",", "credential_id", ")", ":", "mgr", "=", "SoftLayer", ".", "ObjectStorageManager", "(", "env", ".", "client", ")", "credential", "=", "mgr", ".", "delete_credential", "(", "identifier", ",", "credential_id", "=", "credential_id", ")", "env", ".", "fout", "(", "credential", ")" ]
Delete the credential of an Object Storage Account.
[ "Delete", "the", "credential", "of", "an", "Object", "Storage", "Account", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/object_storage/credential/delete.py#L15-L21
1,516
softlayer/softlayer-python
SoftLayer/managers/vs_capacity.py
CapacityManager.list
def list(self): """List Reserved Capacities""" mask = """mask[availableInstanceCount, occupiedInstanceCount, instances[id, billingItem[description, hourlyRecurringFee]], instanceCount, backendRouter[datacenter]]""" results = self.client.call('Account', 'getReservedCapacityGroups', mask=mask) return results
python
def list(self): """List Reserved Capacities""" mask = """mask[availableInstanceCount, occupiedInstanceCount, instances[id, billingItem[description, hourlyRecurringFee]], instanceCount, backendRouter[datacenter]]""" results = self.client.call('Account', 'getReservedCapacityGroups', mask=mask) return results
[ "def", "list", "(", "self", ")", ":", "mask", "=", "\"\"\"mask[availableInstanceCount, occupiedInstanceCount,\ninstances[id, billingItem[description, hourlyRecurringFee]], instanceCount, backendRouter[datacenter]]\"\"\"", "results", "=", "self", ".", "client", ".", "call", "(", "'Account'", ",", "'getReservedCapacityGroups'", ",", "mask", "=", "mask", ")", "return", "results" ]
List Reserved Capacities
[ "List", "Reserved", "Capacities" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_capacity.py#L46-L51
1,517
softlayer/softlayer-python
SoftLayer/managers/vs_capacity.py
CapacityManager.get_object
def get_object(self, identifier, mask=None): """Get a Reserved Capacity Group :param int identifier: Id of the SoftLayer_Virtual_ReservedCapacityGroup :param string mask: override default object Mask """ if mask is None: mask = "mask[instances[billingItem[item[keyName],category], guest], backendRouter[datacenter]]" result = self.client.call(self.rcg_service, 'getObject', id=identifier, mask=mask) return result
python
def get_object(self, identifier, mask=None): """Get a Reserved Capacity Group :param int identifier: Id of the SoftLayer_Virtual_ReservedCapacityGroup :param string mask: override default object Mask """ if mask is None: mask = "mask[instances[billingItem[item[keyName],category], guest], backendRouter[datacenter]]" result = self.client.call(self.rcg_service, 'getObject', id=identifier, mask=mask) return result
[ "def", "get_object", "(", "self", ",", "identifier", ",", "mask", "=", "None", ")", ":", "if", "mask", "is", "None", ":", "mask", "=", "\"mask[instances[billingItem[item[keyName],category], guest], backendRouter[datacenter]]\"", "result", "=", "self", ".", "client", ".", "call", "(", "self", ".", "rcg_service", ",", "'getObject'", ",", "id", "=", "identifier", ",", "mask", "=", "mask", ")", "return", "result" ]
Get a Reserved Capacity Group :param int identifier: Id of the SoftLayer_Virtual_ReservedCapacityGroup :param string mask: override default object Mask
[ "Get", "a", "Reserved", "Capacity", "Group" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_capacity.py#L53-L62
1,518
softlayer/softlayer-python
SoftLayer/managers/vs_capacity.py
CapacityManager.get_create_options
def get_create_options(self): """List available reserved capacity plans""" mask = "mask[attributes,prices[pricingLocationGroup]]" results = self.ordering_manager.list_items(self.capacity_package, mask=mask) return results
python
def get_create_options(self): """List available reserved capacity plans""" mask = "mask[attributes,prices[pricingLocationGroup]]" results = self.ordering_manager.list_items(self.capacity_package, mask=mask) return results
[ "def", "get_create_options", "(", "self", ")", ":", "mask", "=", "\"mask[attributes,prices[pricingLocationGroup]]\"", "results", "=", "self", ".", "ordering_manager", ".", "list_items", "(", "self", ".", "capacity_package", ",", "mask", "=", "mask", ")", "return", "results" ]
List available reserved capacity plans
[ "List", "available", "reserved", "capacity", "plans" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_capacity.py#L64-L68
1,519
softlayer/softlayer-python
SoftLayer/managers/vs_capacity.py
CapacityManager.get_available_routers
def get_available_routers(self, dc=None): """Pulls down all backendRouterIds that are available :param string dc: A specific location to get routers for, like 'dal13'. :returns list: A list of locations where RESERVED_CAPACITY can be ordered. """ mask = "mask[locations]" # Step 1, get the package id package = self.ordering_manager.get_package_by_key(self.capacity_package, mask="id") # Step 2, get the regions this package is orderable in regions = self.client.call('Product_Package', 'getRegions', id=package['id'], mask=mask, iter=True) _filter = None routers = {} if dc is not None: _filter = {'datacenterName': {'operation': dc}} # Step 3, for each location in each region, get the pod details, which contains the router id pods = self.client.call('Network_Pod', 'getAllObjects', filter=_filter, iter=True) for region in regions: routers[region['keyname']] = [] for location in region['locations']: location['location']['pods'] = list() for pod in pods: if pod['datacenterName'] == location['location']['name']: location['location']['pods'].append(pod) # Step 4, return the data. return regions
python
def get_available_routers(self, dc=None): """Pulls down all backendRouterIds that are available :param string dc: A specific location to get routers for, like 'dal13'. :returns list: A list of locations where RESERVED_CAPACITY can be ordered. """ mask = "mask[locations]" # Step 1, get the package id package = self.ordering_manager.get_package_by_key(self.capacity_package, mask="id") # Step 2, get the regions this package is orderable in regions = self.client.call('Product_Package', 'getRegions', id=package['id'], mask=mask, iter=True) _filter = None routers = {} if dc is not None: _filter = {'datacenterName': {'operation': dc}} # Step 3, for each location in each region, get the pod details, which contains the router id pods = self.client.call('Network_Pod', 'getAllObjects', filter=_filter, iter=True) for region in regions: routers[region['keyname']] = [] for location in region['locations']: location['location']['pods'] = list() for pod in pods: if pod['datacenterName'] == location['location']['name']: location['location']['pods'].append(pod) # Step 4, return the data. return regions
[ "def", "get_available_routers", "(", "self", ",", "dc", "=", "None", ")", ":", "mask", "=", "\"mask[locations]\"", "# Step 1, get the package id", "package", "=", "self", ".", "ordering_manager", ".", "get_package_by_key", "(", "self", ".", "capacity_package", ",", "mask", "=", "\"id\"", ")", "# Step 2, get the regions this package is orderable in", "regions", "=", "self", ".", "client", ".", "call", "(", "'Product_Package'", ",", "'getRegions'", ",", "id", "=", "package", "[", "'id'", "]", ",", "mask", "=", "mask", ",", "iter", "=", "True", ")", "_filter", "=", "None", "routers", "=", "{", "}", "if", "dc", "is", "not", "None", ":", "_filter", "=", "{", "'datacenterName'", ":", "{", "'operation'", ":", "dc", "}", "}", "# Step 3, for each location in each region, get the pod details, which contains the router id", "pods", "=", "self", ".", "client", ".", "call", "(", "'Network_Pod'", ",", "'getAllObjects'", ",", "filter", "=", "_filter", ",", "iter", "=", "True", ")", "for", "region", "in", "regions", ":", "routers", "[", "region", "[", "'keyname'", "]", "]", "=", "[", "]", "for", "location", "in", "region", "[", "'locations'", "]", ":", "location", "[", "'location'", "]", "[", "'pods'", "]", "=", "list", "(", ")", "for", "pod", "in", "pods", ":", "if", "pod", "[", "'datacenterName'", "]", "==", "location", "[", "'location'", "]", "[", "'name'", "]", ":", "location", "[", "'location'", "]", "[", "'pods'", "]", ".", "append", "(", "pod", ")", "# Step 4, return the data.", "return", "regions" ]
Pulls down all backendRouterIds that are available :param string dc: A specific location to get routers for, like 'dal13'. :returns list: A list of locations where RESERVED_CAPACITY can be ordered.
[ "Pulls", "down", "all", "backendRouterIds", "that", "are", "available" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_capacity.py#L70-L98
1,520
softlayer/softlayer-python
SoftLayer/managers/vs_capacity.py
CapacityManager.create
def create(self, name, backend_router_id, flavor, instances, test=False): """Orders a Virtual_ReservedCapacityGroup :param string name: Name for the new reserved capacity :param int backend_router_id: This selects the pod. See create_options for a list :param string flavor: Capacity KeyName, see create_options for a list :param int instances: Number of guest this capacity can support :param bool test: If True, don't actually order, just test. """ # Since orderManger needs a DC id, just send in 0, the API will ignore it args = (self.capacity_package, 0, [flavor]) extras = {"backendRouterId": backend_router_id, "name": name} kwargs = { 'extras': extras, 'quantity': instances, 'complex_type': 'SoftLayer_Container_Product_Order_Virtual_ReservedCapacity', 'hourly': True } if test: receipt = self.ordering_manager.verify_order(*args, **kwargs) else: receipt = self.ordering_manager.place_order(*args, **kwargs) return receipt
python
def create(self, name, backend_router_id, flavor, instances, test=False): """Orders a Virtual_ReservedCapacityGroup :param string name: Name for the new reserved capacity :param int backend_router_id: This selects the pod. See create_options for a list :param string flavor: Capacity KeyName, see create_options for a list :param int instances: Number of guest this capacity can support :param bool test: If True, don't actually order, just test. """ # Since orderManger needs a DC id, just send in 0, the API will ignore it args = (self.capacity_package, 0, [flavor]) extras = {"backendRouterId": backend_router_id, "name": name} kwargs = { 'extras': extras, 'quantity': instances, 'complex_type': 'SoftLayer_Container_Product_Order_Virtual_ReservedCapacity', 'hourly': True } if test: receipt = self.ordering_manager.verify_order(*args, **kwargs) else: receipt = self.ordering_manager.place_order(*args, **kwargs) return receipt
[ "def", "create", "(", "self", ",", "name", ",", "backend_router_id", ",", "flavor", ",", "instances", ",", "test", "=", "False", ")", ":", "# Since orderManger needs a DC id, just send in 0, the API will ignore it", "args", "=", "(", "self", ".", "capacity_package", ",", "0", ",", "[", "flavor", "]", ")", "extras", "=", "{", "\"backendRouterId\"", ":", "backend_router_id", ",", "\"name\"", ":", "name", "}", "kwargs", "=", "{", "'extras'", ":", "extras", ",", "'quantity'", ":", "instances", ",", "'complex_type'", ":", "'SoftLayer_Container_Product_Order_Virtual_ReservedCapacity'", ",", "'hourly'", ":", "True", "}", "if", "test", ":", "receipt", "=", "self", ".", "ordering_manager", ".", "verify_order", "(", "*", "args", ",", "*", "*", "kwargs", ")", "else", ":", "receipt", "=", "self", ".", "ordering_manager", ".", "place_order", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "receipt" ]
Orders a Virtual_ReservedCapacityGroup :param string name: Name for the new reserved capacity :param int backend_router_id: This selects the pod. See create_options for a list :param string flavor: Capacity KeyName, see create_options for a list :param int instances: Number of guest this capacity can support :param bool test: If True, don't actually order, just test.
[ "Orders", "a", "Virtual_ReservedCapacityGroup" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_capacity.py#L100-L123
1,521
softlayer/softlayer-python
SoftLayer/managers/vs_capacity.py
CapacityManager.create_guest
def create_guest(self, capacity_id, test, guest_object): """Turns an empty Reserve Capacity into a real Virtual Guest :param int capacity_id: ID of the RESERVED_CAPACITY_GROUP to create this guest into :param bool test: True will use verifyOrder, False will use placeOrder :param dictionary guest_object: Below is the minimum info you need to send in guest_object = { 'domain': 'test.com', 'hostname': 'A1538172419', 'os_code': 'UBUNTU_LATEST_64', 'primary_disk': '25', } """ vs_manager = VSManager(self.client) mask = "mask[instances[id, billingItem[id, item[id,keyName]]], backendRouter[id, datacenter[name]]]" capacity = self.get_object(capacity_id, mask=mask) try: capacity_flavor = capacity['instances'][0]['billingItem']['item']['keyName'] flavor = _flavor_string(capacity_flavor, guest_object['primary_disk']) except KeyError: raise SoftLayer.SoftLayerError("Unable to find capacity Flavor.") guest_object['flavor'] = flavor guest_object['datacenter'] = capacity['backendRouter']['datacenter']['name'] # Reserved capacity only supports SAN as of 20181008 guest_object['local_disk'] = False template = vs_manager.verify_create_instance(**guest_object) template['reservedCapacityId'] = capacity_id if guest_object.get('ipv6'): ipv6_price = self.ordering_manager.get_price_id_list('PUBLIC_CLOUD_SERVER', ['1_IPV6_ADDRESS']) template['prices'].append({'id': ipv6_price[0]}) if test: result = self.client.call('Product_Order', 'verifyOrder', template) else: result = self.client.call('Product_Order', 'placeOrder', template) return result
python
def create_guest(self, capacity_id, test, guest_object): """Turns an empty Reserve Capacity into a real Virtual Guest :param int capacity_id: ID of the RESERVED_CAPACITY_GROUP to create this guest into :param bool test: True will use verifyOrder, False will use placeOrder :param dictionary guest_object: Below is the minimum info you need to send in guest_object = { 'domain': 'test.com', 'hostname': 'A1538172419', 'os_code': 'UBUNTU_LATEST_64', 'primary_disk': '25', } """ vs_manager = VSManager(self.client) mask = "mask[instances[id, billingItem[id, item[id,keyName]]], backendRouter[id, datacenter[name]]]" capacity = self.get_object(capacity_id, mask=mask) try: capacity_flavor = capacity['instances'][0]['billingItem']['item']['keyName'] flavor = _flavor_string(capacity_flavor, guest_object['primary_disk']) except KeyError: raise SoftLayer.SoftLayerError("Unable to find capacity Flavor.") guest_object['flavor'] = flavor guest_object['datacenter'] = capacity['backendRouter']['datacenter']['name'] # Reserved capacity only supports SAN as of 20181008 guest_object['local_disk'] = False template = vs_manager.verify_create_instance(**guest_object) template['reservedCapacityId'] = capacity_id if guest_object.get('ipv6'): ipv6_price = self.ordering_manager.get_price_id_list('PUBLIC_CLOUD_SERVER', ['1_IPV6_ADDRESS']) template['prices'].append({'id': ipv6_price[0]}) if test: result = self.client.call('Product_Order', 'verifyOrder', template) else: result = self.client.call('Product_Order', 'placeOrder', template) return result
[ "def", "create_guest", "(", "self", ",", "capacity_id", ",", "test", ",", "guest_object", ")", ":", "vs_manager", "=", "VSManager", "(", "self", ".", "client", ")", "mask", "=", "\"mask[instances[id, billingItem[id, item[id,keyName]]], backendRouter[id, datacenter[name]]]\"", "capacity", "=", "self", ".", "get_object", "(", "capacity_id", ",", "mask", "=", "mask", ")", "try", ":", "capacity_flavor", "=", "capacity", "[", "'instances'", "]", "[", "0", "]", "[", "'billingItem'", "]", "[", "'item'", "]", "[", "'keyName'", "]", "flavor", "=", "_flavor_string", "(", "capacity_flavor", ",", "guest_object", "[", "'primary_disk'", "]", ")", "except", "KeyError", ":", "raise", "SoftLayer", ".", "SoftLayerError", "(", "\"Unable to find capacity Flavor.\"", ")", "guest_object", "[", "'flavor'", "]", "=", "flavor", "guest_object", "[", "'datacenter'", "]", "=", "capacity", "[", "'backendRouter'", "]", "[", "'datacenter'", "]", "[", "'name'", "]", "# Reserved capacity only supports SAN as of 20181008", "guest_object", "[", "'local_disk'", "]", "=", "False", "template", "=", "vs_manager", ".", "verify_create_instance", "(", "*", "*", "guest_object", ")", "template", "[", "'reservedCapacityId'", "]", "=", "capacity_id", "if", "guest_object", ".", "get", "(", "'ipv6'", ")", ":", "ipv6_price", "=", "self", ".", "ordering_manager", ".", "get_price_id_list", "(", "'PUBLIC_CLOUD_SERVER'", ",", "[", "'1_IPV6_ADDRESS'", "]", ")", "template", "[", "'prices'", "]", ".", "append", "(", "{", "'id'", ":", "ipv6_price", "[", "0", "]", "}", ")", "if", "test", ":", "result", "=", "self", ".", "client", ".", "call", "(", "'Product_Order'", ",", "'verifyOrder'", ",", "template", ")", "else", ":", "result", "=", "self", ".", "client", ".", "call", "(", "'Product_Order'", ",", "'placeOrder'", ",", "template", ")", "return", "result" ]
Turns an empty Reserve Capacity into a real Virtual Guest :param int capacity_id: ID of the RESERVED_CAPACITY_GROUP to create this guest into :param bool test: True will use verifyOrder, False will use placeOrder :param dictionary guest_object: Below is the minimum info you need to send in guest_object = { 'domain': 'test.com', 'hostname': 'A1538172419', 'os_code': 'UBUNTU_LATEST_64', 'primary_disk': '25', }
[ "Turns", "an", "empty", "Reserve", "Capacity", "into", "a", "real", "Virtual", "Guest" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_capacity.py#L125-L165
1,522
softlayer/softlayer-python
SoftLayer/CLI/virt/capacity/list.py
cli
def cli(env): """List Reserved Capacity groups.""" manager = CapacityManager(env.client) result = manager.list() table = formatting.Table( ["ID", "Name", "Capacity", "Flavor", "Location", "Created"], title="Reserved Capacity" ) for r_c in result: occupied_string = "#" * int(r_c.get('occupiedInstanceCount', 0)) available_string = "-" * int(r_c.get('availableInstanceCount', 0)) try: flavor = r_c['instances'][0]['billingItem']['description'] # cost = float(r_c['instances'][0]['billingItem']['hourlyRecurringFee']) except KeyError: flavor = "Unknown Billing Item" location = r_c['backendRouter']['hostname'] capacity = "%s%s" % (occupied_string, available_string) table.add_row([r_c['id'], r_c['name'], capacity, flavor, location, r_c['createDate']]) env.fout(table)
python
def cli(env): """List Reserved Capacity groups.""" manager = CapacityManager(env.client) result = manager.list() table = formatting.Table( ["ID", "Name", "Capacity", "Flavor", "Location", "Created"], title="Reserved Capacity" ) for r_c in result: occupied_string = "#" * int(r_c.get('occupiedInstanceCount', 0)) available_string = "-" * int(r_c.get('availableInstanceCount', 0)) try: flavor = r_c['instances'][0]['billingItem']['description'] # cost = float(r_c['instances'][0]['billingItem']['hourlyRecurringFee']) except KeyError: flavor = "Unknown Billing Item" location = r_c['backendRouter']['hostname'] capacity = "%s%s" % (occupied_string, available_string) table.add_row([r_c['id'], r_c['name'], capacity, flavor, location, r_c['createDate']]) env.fout(table)
[ "def", "cli", "(", "env", ")", ":", "manager", "=", "CapacityManager", "(", "env", ".", "client", ")", "result", "=", "manager", ".", "list", "(", ")", "table", "=", "formatting", ".", "Table", "(", "[", "\"ID\"", ",", "\"Name\"", ",", "\"Capacity\"", ",", "\"Flavor\"", ",", "\"Location\"", ",", "\"Created\"", "]", ",", "title", "=", "\"Reserved Capacity\"", ")", "for", "r_c", "in", "result", ":", "occupied_string", "=", "\"#\"", "*", "int", "(", "r_c", ".", "get", "(", "'occupiedInstanceCount'", ",", "0", ")", ")", "available_string", "=", "\"-\"", "*", "int", "(", "r_c", ".", "get", "(", "'availableInstanceCount'", ",", "0", ")", ")", "try", ":", "flavor", "=", "r_c", "[", "'instances'", "]", "[", "0", "]", "[", "'billingItem'", "]", "[", "'description'", "]", "# cost = float(r_c['instances'][0]['billingItem']['hourlyRecurringFee'])", "except", "KeyError", ":", "flavor", "=", "\"Unknown Billing Item\"", "location", "=", "r_c", "[", "'backendRouter'", "]", "[", "'hostname'", "]", "capacity", "=", "\"%s%s\"", "%", "(", "occupied_string", ",", "available_string", ")", "table", ".", "add_row", "(", "[", "r_c", "[", "'id'", "]", ",", "r_c", "[", "'name'", "]", ",", "capacity", ",", "flavor", ",", "location", ",", "r_c", "[", "'createDate'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List Reserved Capacity groups.
[ "List", "Reserved", "Capacity", "groups", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/capacity/list.py#L12-L32
1,523
softlayer/softlayer-python
SoftLayer/CLI/order/place_quote.py
cli
def cli(env, package_keyname, location, preset, name, send_email, complex_type, extras, order_items): """Place a quote. This CLI command is used for creating a quote of the specified package in the given location (denoted by a datacenter's long name). Orders made via the CLI can then be converted to be made programmatically by calling SoftLayer.OrderingManager.place_quote() with the same keynames. Packages for ordering can be retrieved from `slcli order package-list` Presets for ordering can be retrieved from `slcli order preset-list` (not all packages have presets) Items can be retrieved from `slcli order item-list`. In order to find required items for the order, use `slcli order category-list`, and then provide the --category option for each category code in `slcli order item-list`. Example:: # Place quote a VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk, # Ubuntu 16.04, and 1 Gbps public & private uplink in dal13 slcli order place-quote --name "foobar" --send-email CLOUD_SERVER DALLAS13 \\ GUEST_CORES_4 \\ RAM_16_GB \\ REBOOT_REMOTE_CONSOLE \\ 1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS \\ BANDWIDTH_0_GB_2 \\ 1_IP_ADDRESS \\ GUEST_DISK_100_GB_SAN \\ OS_UBUNTU_16_04_LTS_XENIAL_XERUS_MINIMAL_64_BIT_FOR_VSI \\ MONITORING_HOST_PING \\ NOTIFICATION_EMAIL_AND_TICKET \\ AUTOMATED_NOTIFICATION \\ UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \\ NESSUS_VULNERABILITY_ASSESSMENT_REPORTING \\ --extras '{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com"}]}' \\ --complex-type SoftLayer_Container_Product_Order_Virtual_Guest """ manager = ordering.OrderingManager(env.client) if extras: try: extras = json.loads(extras) except ValueError as err: raise exceptions.CLIAbort("There was an error when parsing the --extras value: {}".format(err)) args = (package_keyname, location, order_items) kwargs = {'preset_keyname': preset, 'extras': extras, 'quantity': 1, 'quote_name': name, 'send_email': send_email, 'complex_type': complex_type} order = manager.place_quote(*args, **kwargs) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', order['quote']['id']]) table.add_row(['name', order['quote']['name']]) table.add_row(['created', order['orderDate']]) table.add_row(['expires', order['quote']['expirationDate']]) table.add_row(['status', order['quote']['status']]) env.fout(table)
python
def cli(env, package_keyname, location, preset, name, send_email, complex_type, extras, order_items): """Place a quote. This CLI command is used for creating a quote of the specified package in the given location (denoted by a datacenter's long name). Orders made via the CLI can then be converted to be made programmatically by calling SoftLayer.OrderingManager.place_quote() with the same keynames. Packages for ordering can be retrieved from `slcli order package-list` Presets for ordering can be retrieved from `slcli order preset-list` (not all packages have presets) Items can be retrieved from `slcli order item-list`. In order to find required items for the order, use `slcli order category-list`, and then provide the --category option for each category code in `slcli order item-list`. Example:: # Place quote a VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk, # Ubuntu 16.04, and 1 Gbps public & private uplink in dal13 slcli order place-quote --name "foobar" --send-email CLOUD_SERVER DALLAS13 \\ GUEST_CORES_4 \\ RAM_16_GB \\ REBOOT_REMOTE_CONSOLE \\ 1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS \\ BANDWIDTH_0_GB_2 \\ 1_IP_ADDRESS \\ GUEST_DISK_100_GB_SAN \\ OS_UBUNTU_16_04_LTS_XENIAL_XERUS_MINIMAL_64_BIT_FOR_VSI \\ MONITORING_HOST_PING \\ NOTIFICATION_EMAIL_AND_TICKET \\ AUTOMATED_NOTIFICATION \\ UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \\ NESSUS_VULNERABILITY_ASSESSMENT_REPORTING \\ --extras '{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com"}]}' \\ --complex-type SoftLayer_Container_Product_Order_Virtual_Guest """ manager = ordering.OrderingManager(env.client) if extras: try: extras = json.loads(extras) except ValueError as err: raise exceptions.CLIAbort("There was an error when parsing the --extras value: {}".format(err)) args = (package_keyname, location, order_items) kwargs = {'preset_keyname': preset, 'extras': extras, 'quantity': 1, 'quote_name': name, 'send_email': send_email, 'complex_type': complex_type} order = manager.place_quote(*args, **kwargs) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', order['quote']['id']]) table.add_row(['name', order['quote']['name']]) table.add_row(['created', order['orderDate']]) table.add_row(['expires', order['quote']['expirationDate']]) table.add_row(['status', order['quote']['status']]) env.fout(table)
[ "def", "cli", "(", "env", ",", "package_keyname", ",", "location", ",", "preset", ",", "name", ",", "send_email", ",", "complex_type", ",", "extras", ",", "order_items", ")", ":", "manager", "=", "ordering", ".", "OrderingManager", "(", "env", ".", "client", ")", "if", "extras", ":", "try", ":", "extras", "=", "json", ".", "loads", "(", "extras", ")", "except", "ValueError", "as", "err", ":", "raise", "exceptions", ".", "CLIAbort", "(", "\"There was an error when parsing the --extras value: {}\"", ".", "format", "(", "err", ")", ")", "args", "=", "(", "package_keyname", ",", "location", ",", "order_items", ")", "kwargs", "=", "{", "'preset_keyname'", ":", "preset", ",", "'extras'", ":", "extras", ",", "'quantity'", ":", "1", ",", "'quote_name'", ":", "name", ",", "'send_email'", ":", "send_email", ",", "'complex_type'", ":", "complex_type", "}", "order", "=", "manager", ".", "place_quote", "(", "*", "args", ",", "*", "*", "kwargs", ")", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "table", ".", "align", "[", "'name'", "]", "=", "'r'", "table", ".", "align", "[", "'value'", "]", "=", "'l'", "table", ".", "add_row", "(", "[", "'id'", ",", "order", "[", "'quote'", "]", "[", "'id'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'name'", ",", "order", "[", "'quote'", "]", "[", "'name'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'created'", ",", "order", "[", "'orderDate'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'expires'", ",", "order", "[", "'quote'", "]", "[", "'expirationDate'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'status'", ",", "order", "[", "'quote'", "]", "[", "'status'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Place a quote. This CLI command is used for creating a quote of the specified package in the given location (denoted by a datacenter's long name). Orders made via the CLI can then be converted to be made programmatically by calling SoftLayer.OrderingManager.place_quote() with the same keynames. Packages for ordering can be retrieved from `slcli order package-list` Presets for ordering can be retrieved from `slcli order preset-list` (not all packages have presets) Items can be retrieved from `slcli order item-list`. In order to find required items for the order, use `slcli order category-list`, and then provide the --category option for each category code in `slcli order item-list`. Example:: # Place quote a VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk, # Ubuntu 16.04, and 1 Gbps public & private uplink in dal13 slcli order place-quote --name "foobar" --send-email CLOUD_SERVER DALLAS13 \\ GUEST_CORES_4 \\ RAM_16_GB \\ REBOOT_REMOTE_CONSOLE \\ 1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS \\ BANDWIDTH_0_GB_2 \\ 1_IP_ADDRESS \\ GUEST_DISK_100_GB_SAN \\ OS_UBUNTU_16_04_LTS_XENIAL_XERUS_MINIMAL_64_BIT_FOR_VSI \\ MONITORING_HOST_PING \\ NOTIFICATION_EMAIL_AND_TICKET \\ AUTOMATED_NOTIFICATION \\ UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \\ NESSUS_VULNERABILITY_ASSESSMENT_REPORTING \\ --extras '{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com"}]}' \\ --complex-type SoftLayer_Container_Product_Order_Virtual_Guest
[ "Place", "a", "quote", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/place_quote.py#L30-L96
1,524
softlayer/softlayer-python
SoftLayer/CLI/order/quote_list.py
cli
def cli(env): """List all active quotes on an account""" table = formatting.Table([ 'Id', 'Name', 'Created', 'Expiration', 'Status', 'Package Name', 'Package Id' ]) table.align['Name'] = 'l' table.align['Package Name'] = 'r' table.align['Package Id'] = 'l' manager = ordering.OrderingManager(env.client) items = manager.get_quotes() for item in items: package = item['order']['items'][0]['package'] table.add_row([ item.get('id'), item.get('name'), clean_time(item.get('createDate')), clean_time(item.get('modifyDate')), item.get('status'), package.get('keyName'), package.get('id') ]) env.fout(table)
python
def cli(env): """List all active quotes on an account""" table = formatting.Table([ 'Id', 'Name', 'Created', 'Expiration', 'Status', 'Package Name', 'Package Id' ]) table.align['Name'] = 'l' table.align['Package Name'] = 'r' table.align['Package Id'] = 'l' manager = ordering.OrderingManager(env.client) items = manager.get_quotes() for item in items: package = item['order']['items'][0]['package'] table.add_row([ item.get('id'), item.get('name'), clean_time(item.get('createDate')), clean_time(item.get('modifyDate')), item.get('status'), package.get('keyName'), package.get('id') ]) env.fout(table)
[ "def", "cli", "(", "env", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'Id'", ",", "'Name'", ",", "'Created'", ",", "'Expiration'", ",", "'Status'", ",", "'Package Name'", ",", "'Package Id'", "]", ")", "table", ".", "align", "[", "'Name'", "]", "=", "'l'", "table", ".", "align", "[", "'Package Name'", "]", "=", "'r'", "table", ".", "align", "[", "'Package Id'", "]", "=", "'l'", "manager", "=", "ordering", ".", "OrderingManager", "(", "env", ".", "client", ")", "items", "=", "manager", ".", "get_quotes", "(", ")", "for", "item", "in", "items", ":", "package", "=", "item", "[", "'order'", "]", "[", "'items'", "]", "[", "0", "]", "[", "'package'", "]", "table", ".", "add_row", "(", "[", "item", ".", "get", "(", "'id'", ")", ",", "item", ".", "get", "(", "'name'", ")", ",", "clean_time", "(", "item", ".", "get", "(", "'createDate'", ")", ")", ",", "clean_time", "(", "item", ".", "get", "(", "'modifyDate'", ")", ")", ",", "item", ".", "get", "(", "'status'", ")", ",", "package", ".", "get", "(", "'keyName'", ")", ",", "package", ".", "get", "(", "'id'", ")", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List all active quotes on an account
[ "List", "all", "active", "quotes", "on", "an", "account" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/quote_list.py#L13-L36
1,525
softlayer/softlayer-python
SoftLayer/CLI/image/delete.py
cli
def cli(env, identifier): """Delete an image.""" image_mgr = SoftLayer.ImageManager(env.client) image_id = helpers.resolve_id(image_mgr.resolve_ids, identifier, 'image') image_mgr.delete_image(image_id)
python
def cli(env, identifier): """Delete an image.""" image_mgr = SoftLayer.ImageManager(env.client) image_id = helpers.resolve_id(image_mgr.resolve_ids, identifier, 'image') image_mgr.delete_image(image_id)
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "image_mgr", "=", "SoftLayer", ".", "ImageManager", "(", "env", ".", "client", ")", "image_id", "=", "helpers", ".", "resolve_id", "(", "image_mgr", ".", "resolve_ids", ",", "identifier", ",", "'image'", ")", "image_mgr", ".", "delete_image", "(", "image_id", ")" ]
Delete an image.
[ "Delete", "an", "image", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/image/delete.py#L14-L20
1,526
softlayer/softlayer-python
SoftLayer/CLI/loadbal/service_add.py
cli
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address): """Adds a new load balancer service.""" mgr = SoftLayer.LoadBalancerManager(env.client) loadbal_id, group_id = loadbal.parse_id(identifier) # check if the IP is valid ip_address_id = None if ip_address: ip_service = env.client['Network_Subnet_IpAddress'] ip_record = ip_service.getByIpAddress(ip_address) if len(ip_record) > 0: ip_address_id = ip_record['id'] mgr.add_service(loadbal_id, group_id, ip_address_id=ip_address_id, enabled=enabled, port=port, weight=weight, hc_type=healthcheck_type) env.fout('Load balancer service is being added!')
python
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address): """Adds a new load balancer service.""" mgr = SoftLayer.LoadBalancerManager(env.client) loadbal_id, group_id = loadbal.parse_id(identifier) # check if the IP is valid ip_address_id = None if ip_address: ip_service = env.client['Network_Subnet_IpAddress'] ip_record = ip_service.getByIpAddress(ip_address) if len(ip_record) > 0: ip_address_id = ip_record['id'] mgr.add_service(loadbal_id, group_id, ip_address_id=ip_address_id, enabled=enabled, port=port, weight=weight, hc_type=healthcheck_type) env.fout('Load balancer service is being added!')
[ "def", "cli", "(", "env", ",", "identifier", ",", "enabled", ",", "port", ",", "weight", ",", "healthcheck_type", ",", "ip_address", ")", ":", "mgr", "=", "SoftLayer", ".", "LoadBalancerManager", "(", "env", ".", "client", ")", "loadbal_id", ",", "group_id", "=", "loadbal", ".", "parse_id", "(", "identifier", ")", "# check if the IP is valid", "ip_address_id", "=", "None", "if", "ip_address", ":", "ip_service", "=", "env", ".", "client", "[", "'Network_Subnet_IpAddress'", "]", "ip_record", "=", "ip_service", ".", "getByIpAddress", "(", "ip_address", ")", "if", "len", "(", "ip_record", ")", ">", "0", ":", "ip_address_id", "=", "ip_record", "[", "'id'", "]", "mgr", ".", "add_service", "(", "loadbal_id", ",", "group_id", ",", "ip_address_id", "=", "ip_address_id", ",", "enabled", "=", "enabled", ",", "port", "=", "port", ",", "weight", "=", "weight", ",", "hc_type", "=", "healthcheck_type", ")", "env", ".", "fout", "(", "'Load balancer service is being added!'", ")" ]
Adds a new load balancer service.
[ "Adds", "a", "new", "load", "balancer", "service", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/service_add.py#L31-L53
1,527
softlayer/softlayer-python
SoftLayer/shell/core.py
cli
def cli(ctx, env): """Enters a shell for slcli.""" # Set up the environment env = copy.deepcopy(env) env.load_modules_from_python(routes.ALL_ROUTES) env.aliases.update(routes.ALL_ALIASES) env.vars['global_args'] = ctx.parent.params env.vars['is_shell'] = True env.vars['last_exit_code'] = 0 # Set up prompt_toolkit settings app_path = click.get_app_dir('softlayer_shell') if not os.path.exists(app_path): os.makedirs(app_path) complete = completer.ShellCompleter(core.cli) while True: try: line = p_shortcuts.prompt( completer=complete, complete_while_typing=True, auto_suggest=p_auto_suggest.AutoSuggestFromHistory(), ) # Parse arguments try: args = shlex.split(line) except ValueError as ex: print("Invalid Command: %s" % ex) continue if not args: continue # Run Command try: # Reset client so that the client gets refreshed env.client = None core.main(args=list(get_env_args(env)) + args, obj=env, prog_name="", reraise_exceptions=True) except SystemExit as ex: env.vars['last_exit_code'] = ex.code except EOFError: return except ShellExit: return except Exception as ex: env.vars['last_exit_code'] = 1 traceback.print_exc(file=sys.stderr) except KeyboardInterrupt: env.vars['last_exit_code'] = 130
python
def cli(ctx, env): """Enters a shell for slcli.""" # Set up the environment env = copy.deepcopy(env) env.load_modules_from_python(routes.ALL_ROUTES) env.aliases.update(routes.ALL_ALIASES) env.vars['global_args'] = ctx.parent.params env.vars['is_shell'] = True env.vars['last_exit_code'] = 0 # Set up prompt_toolkit settings app_path = click.get_app_dir('softlayer_shell') if not os.path.exists(app_path): os.makedirs(app_path) complete = completer.ShellCompleter(core.cli) while True: try: line = p_shortcuts.prompt( completer=complete, complete_while_typing=True, auto_suggest=p_auto_suggest.AutoSuggestFromHistory(), ) # Parse arguments try: args = shlex.split(line) except ValueError as ex: print("Invalid Command: %s" % ex) continue if not args: continue # Run Command try: # Reset client so that the client gets refreshed env.client = None core.main(args=list(get_env_args(env)) + args, obj=env, prog_name="", reraise_exceptions=True) except SystemExit as ex: env.vars['last_exit_code'] = ex.code except EOFError: return except ShellExit: return except Exception as ex: env.vars['last_exit_code'] = 1 traceback.print_exc(file=sys.stderr) except KeyboardInterrupt: env.vars['last_exit_code'] = 130
[ "def", "cli", "(", "ctx", ",", "env", ")", ":", "# Set up the environment", "env", "=", "copy", ".", "deepcopy", "(", "env", ")", "env", ".", "load_modules_from_python", "(", "routes", ".", "ALL_ROUTES", ")", "env", ".", "aliases", ".", "update", "(", "routes", ".", "ALL_ALIASES", ")", "env", ".", "vars", "[", "'global_args'", "]", "=", "ctx", ".", "parent", ".", "params", "env", ".", "vars", "[", "'is_shell'", "]", "=", "True", "env", ".", "vars", "[", "'last_exit_code'", "]", "=", "0", "# Set up prompt_toolkit settings", "app_path", "=", "click", ".", "get_app_dir", "(", "'softlayer_shell'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "app_path", ")", ":", "os", ".", "makedirs", "(", "app_path", ")", "complete", "=", "completer", ".", "ShellCompleter", "(", "core", ".", "cli", ")", "while", "True", ":", "try", ":", "line", "=", "p_shortcuts", ".", "prompt", "(", "completer", "=", "complete", ",", "complete_while_typing", "=", "True", ",", "auto_suggest", "=", "p_auto_suggest", ".", "AutoSuggestFromHistory", "(", ")", ",", ")", "# Parse arguments", "try", ":", "args", "=", "shlex", ".", "split", "(", "line", ")", "except", "ValueError", "as", "ex", ":", "print", "(", "\"Invalid Command: %s\"", "%", "ex", ")", "continue", "if", "not", "args", ":", "continue", "# Run Command", "try", ":", "# Reset client so that the client gets refreshed", "env", ".", "client", "=", "None", "core", ".", "main", "(", "args", "=", "list", "(", "get_env_args", "(", "env", ")", ")", "+", "args", ",", "obj", "=", "env", ",", "prog_name", "=", "\"\"", ",", "reraise_exceptions", "=", "True", ")", "except", "SystemExit", "as", "ex", ":", "env", ".", "vars", "[", "'last_exit_code'", "]", "=", "ex", ".", "code", "except", "EOFError", ":", "return", "except", "ShellExit", ":", "return", "except", "Exception", "as", "ex", ":", "env", ".", "vars", "[", "'last_exit_code'", "]", "=", "1", "traceback", ".", "print_exc", "(", "file", "=", "sys", ".", "stderr", ")", "except", "KeyboardInterrupt", ":", "env", ".", "vars", "[", "'last_exit_code'", "]", "=", "130" ]
Enters a shell for slcli.
[ "Enters", "a", "shell", "for", "slcli", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/shell/core.py#L34-L88
1,528
softlayer/softlayer-python
SoftLayer/shell/core.py
get_env_args
def get_env_args(env): """Yield options to inject into the slcli command from the environment.""" for arg, val in env.vars.get('global_args', {}).items(): if val is True: yield '--%s' % arg elif isinstance(val, int): for _ in range(val): yield '--%s' % arg elif val is None: continue else: yield '--%s=%s' % (arg, val)
python
def get_env_args(env): """Yield options to inject into the slcli command from the environment.""" for arg, val in env.vars.get('global_args', {}).items(): if val is True: yield '--%s' % arg elif isinstance(val, int): for _ in range(val): yield '--%s' % arg elif val is None: continue else: yield '--%s=%s' % (arg, val)
[ "def", "get_env_args", "(", "env", ")", ":", "for", "arg", ",", "val", "in", "env", ".", "vars", ".", "get", "(", "'global_args'", ",", "{", "}", ")", ".", "items", "(", ")", ":", "if", "val", "is", "True", ":", "yield", "'--%s'", "%", "arg", "elif", "isinstance", "(", "val", ",", "int", ")", ":", "for", "_", "in", "range", "(", "val", ")", ":", "yield", "'--%s'", "%", "arg", "elif", "val", "is", "None", ":", "continue", "else", ":", "yield", "'--%s=%s'", "%", "(", "arg", ",", "val", ")" ]
Yield options to inject into the slcli command from the environment.
[ "Yield", "options", "to", "inject", "into", "the", "slcli", "command", "from", "the", "environment", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/shell/core.py#L91-L102
1,529
softlayer/softlayer-python
SoftLayer/CLI/virt/placementgroup/delete.py
cli
def cli(env, identifier, purge): """Delete a placement group. Placement Group MUST be empty before you can delete it. IDENTIFIER can be either the Name or Id of the placement group you want to view """ manager = PlacementManager(env.client) group_id = helpers.resolve_id(manager.resolve_ids, identifier, 'placement_group') if purge: placement_group = manager.get_object(group_id) guest_list = ', '.join([guest['fullyQualifiedDomainName'] for guest in placement_group['guests']]) if len(placement_group['guests']) < 1: raise exceptions.CLIAbort('No virtual servers were found in placement group %s' % identifier) click.secho("You are about to delete the following guests!\n%s" % guest_list, fg='red') if not (env.skip_confirmations or formatting.confirm("This action will cancel all guests! Continue?")): raise exceptions.CLIAbort('Aborting virtual server order.') vm_manager = VSManager(env.client) for guest in placement_group['guests']: click.secho("Deleting %s..." % guest['fullyQualifiedDomainName']) vm_manager.cancel_instance(guest['id']) return click.secho("You are about to delete the following placement group! %s" % identifier, fg='red') if not (env.skip_confirmations or formatting.confirm("This action will cancel the placement group! Continue?")): raise exceptions.CLIAbort('Aborting virtual server order.') cancel_result = manager.delete(group_id) if cancel_result: click.secho("Placement Group %s has been canceld." % identifier, fg='green')
python
def cli(env, identifier, purge): """Delete a placement group. Placement Group MUST be empty before you can delete it. IDENTIFIER can be either the Name or Id of the placement group you want to view """ manager = PlacementManager(env.client) group_id = helpers.resolve_id(manager.resolve_ids, identifier, 'placement_group') if purge: placement_group = manager.get_object(group_id) guest_list = ', '.join([guest['fullyQualifiedDomainName'] for guest in placement_group['guests']]) if len(placement_group['guests']) < 1: raise exceptions.CLIAbort('No virtual servers were found in placement group %s' % identifier) click.secho("You are about to delete the following guests!\n%s" % guest_list, fg='red') if not (env.skip_confirmations or formatting.confirm("This action will cancel all guests! Continue?")): raise exceptions.CLIAbort('Aborting virtual server order.') vm_manager = VSManager(env.client) for guest in placement_group['guests']: click.secho("Deleting %s..." % guest['fullyQualifiedDomainName']) vm_manager.cancel_instance(guest['id']) return click.secho("You are about to delete the following placement group! %s" % identifier, fg='red') if not (env.skip_confirmations or formatting.confirm("This action will cancel the placement group! Continue?")): raise exceptions.CLIAbort('Aborting virtual server order.') cancel_result = manager.delete(group_id) if cancel_result: click.secho("Placement Group %s has been canceld." % identifier, fg='green')
[ "def", "cli", "(", "env", ",", "identifier", ",", "purge", ")", ":", "manager", "=", "PlacementManager", "(", "env", ".", "client", ")", "group_id", "=", "helpers", ".", "resolve_id", "(", "manager", ".", "resolve_ids", ",", "identifier", ",", "'placement_group'", ")", "if", "purge", ":", "placement_group", "=", "manager", ".", "get_object", "(", "group_id", ")", "guest_list", "=", "', '", ".", "join", "(", "[", "guest", "[", "'fullyQualifiedDomainName'", "]", "for", "guest", "in", "placement_group", "[", "'guests'", "]", "]", ")", "if", "len", "(", "placement_group", "[", "'guests'", "]", ")", "<", "1", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'No virtual servers were found in placement group %s'", "%", "identifier", ")", "click", ".", "secho", "(", "\"You are about to delete the following guests!\\n%s\"", "%", "guest_list", ",", "fg", "=", "'red'", ")", "if", "not", "(", "env", ".", "skip_confirmations", "or", "formatting", ".", "confirm", "(", "\"This action will cancel all guests! Continue?\"", ")", ")", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Aborting virtual server order.'", ")", "vm_manager", "=", "VSManager", "(", "env", ".", "client", ")", "for", "guest", "in", "placement_group", "[", "'guests'", "]", ":", "click", ".", "secho", "(", "\"Deleting %s...\"", "%", "guest", "[", "'fullyQualifiedDomainName'", "]", ")", "vm_manager", ".", "cancel_instance", "(", "guest", "[", "'id'", "]", ")", "return", "click", ".", "secho", "(", "\"You are about to delete the following placement group! %s\"", "%", "identifier", ",", "fg", "=", "'red'", ")", "if", "not", "(", "env", ".", "skip_confirmations", "or", "formatting", ".", "confirm", "(", "\"This action will cancel the placement group! Continue?\"", ")", ")", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Aborting virtual server order.'", ")", "cancel_result", "=", "manager", ".", "delete", "(", "group_id", ")", "if", "cancel_result", ":", "click", ".", "secho", "(", "\"Placement Group %s has been canceld.\"", "%", "identifier", ",", "fg", "=", "'green'", ")" ]
Delete a placement group. Placement Group MUST be empty before you can delete it. IDENTIFIER can be either the Name or Id of the placement group you want to view
[ "Delete", "a", "placement", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/placementgroup/delete.py#L19-L49
1,530
softlayer/softlayer-python
SoftLayer/CLI/vpn/ipsec/translation/update.py
cli
def cli(env, context_id, translation_id, static_ip, remote_ip, note): """Update an address translation for an IPSEC tunnel context. A separate configuration request should be made to realize changes on network devices. """ manager = SoftLayer.IPSECManager(env.client) succeeded = manager.update_translation(context_id, translation_id, static_ip=static_ip, remote_ip=remote_ip, notes=note) if succeeded: env.out('Updated translation #{}'.format(translation_id)) else: raise CLIHalt('Failed to update translation #{}'.format(translation_id))
python
def cli(env, context_id, translation_id, static_ip, remote_ip, note): """Update an address translation for an IPSEC tunnel context. A separate configuration request should be made to realize changes on network devices. """ manager = SoftLayer.IPSECManager(env.client) succeeded = manager.update_translation(context_id, translation_id, static_ip=static_ip, remote_ip=remote_ip, notes=note) if succeeded: env.out('Updated translation #{}'.format(translation_id)) else: raise CLIHalt('Failed to update translation #{}'.format(translation_id))
[ "def", "cli", "(", "env", ",", "context_id", ",", "translation_id", ",", "static_ip", ",", "remote_ip", ",", "note", ")", ":", "manager", "=", "SoftLayer", ".", "IPSECManager", "(", "env", ".", "client", ")", "succeeded", "=", "manager", ".", "update_translation", "(", "context_id", ",", "translation_id", ",", "static_ip", "=", "static_ip", ",", "remote_ip", "=", "remote_ip", ",", "notes", "=", "note", ")", "if", "succeeded", ":", "env", ".", "out", "(", "'Updated translation #{}'", ".", "format", "(", "translation_id", ")", ")", "else", ":", "raise", "CLIHalt", "(", "'Failed to update translation #{}'", ".", "format", "(", "translation_id", ")", ")" ]
Update an address translation for an IPSEC tunnel context. A separate configuration request should be made to realize changes on network devices.
[ "Update", "an", "address", "translation", "for", "an", "IPSEC", "tunnel", "context", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/vpn/ipsec/translation/update.py#L31-L46
1,531
softlayer/softlayer-python
SoftLayer/shell/cmd_help.py
cli
def cli(ctx, env): """Print shell help text.""" env.out("Welcome to the SoftLayer shell.") env.out("") formatter = formatting.HelpFormatter() commands = [] shell_commands = [] for name in cli_core.cli.list_commands(ctx): command = cli_core.cli.get_command(ctx, name) if command.short_help is None: command.short_help = command.help details = (name, command.short_help) if name in dict(routes.ALL_ROUTES): shell_commands.append(details) else: commands.append(details) with formatter.section('Shell Commands'): formatter.write_dl(shell_commands) with formatter.section('Commands'): formatter.write_dl(commands) for line in formatter.buffer: env.out(line, newline=False)
python
def cli(ctx, env): """Print shell help text.""" env.out("Welcome to the SoftLayer shell.") env.out("") formatter = formatting.HelpFormatter() commands = [] shell_commands = [] for name in cli_core.cli.list_commands(ctx): command = cli_core.cli.get_command(ctx, name) if command.short_help is None: command.short_help = command.help details = (name, command.short_help) if name in dict(routes.ALL_ROUTES): shell_commands.append(details) else: commands.append(details) with formatter.section('Shell Commands'): formatter.write_dl(shell_commands) with formatter.section('Commands'): formatter.write_dl(commands) for line in formatter.buffer: env.out(line, newline=False)
[ "def", "cli", "(", "ctx", ",", "env", ")", ":", "env", ".", "out", "(", "\"Welcome to the SoftLayer shell.\"", ")", "env", ".", "out", "(", "\"\"", ")", "formatter", "=", "formatting", ".", "HelpFormatter", "(", ")", "commands", "=", "[", "]", "shell_commands", "=", "[", "]", "for", "name", "in", "cli_core", ".", "cli", ".", "list_commands", "(", "ctx", ")", ":", "command", "=", "cli_core", ".", "cli", ".", "get_command", "(", "ctx", ",", "name", ")", "if", "command", ".", "short_help", "is", "None", ":", "command", ".", "short_help", "=", "command", ".", "help", "details", "=", "(", "name", ",", "command", ".", "short_help", ")", "if", "name", "in", "dict", "(", "routes", ".", "ALL_ROUTES", ")", ":", "shell_commands", ".", "append", "(", "details", ")", "else", ":", "commands", ".", "append", "(", "details", ")", "with", "formatter", ".", "section", "(", "'Shell Commands'", ")", ":", "formatter", ".", "write_dl", "(", "shell_commands", ")", "with", "formatter", ".", "section", "(", "'Commands'", ")", ":", "formatter", ".", "write_dl", "(", "commands", ")", "for", "line", "in", "formatter", ".", "buffer", ":", "env", ".", "out", "(", "line", ",", "newline", "=", "False", ")" ]
Print shell help text.
[ "Print", "shell", "help", "text", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/shell/cmd_help.py#L15-L40
1,532
softlayer/softlayer-python
SoftLayer/CLI/hardware/reload.py
cli
def cli(env, identifier, postinstall, key): """Reload operating system on a server.""" hardware = SoftLayer.HardwareManager(env.client) hardware_id = helpers.resolve_id(hardware.resolve_ids, identifier, 'hardware') key_list = [] if key: for single_key in key: resolver = SoftLayer.SshKeyManager(env.client).resolve_ids key_id = helpers.resolve_id(resolver, single_key, 'SshKey') key_list.append(key_id) if not (env.skip_confirmations or formatting.no_going_back(hardware_id)): raise exceptions.CLIAbort('Aborted') hardware.reload(hardware_id, postinstall, key_list)
python
def cli(env, identifier, postinstall, key): """Reload operating system on a server.""" hardware = SoftLayer.HardwareManager(env.client) hardware_id = helpers.resolve_id(hardware.resolve_ids, identifier, 'hardware') key_list = [] if key: for single_key in key: resolver = SoftLayer.SshKeyManager(env.client).resolve_ids key_id = helpers.resolve_id(resolver, single_key, 'SshKey') key_list.append(key_id) if not (env.skip_confirmations or formatting.no_going_back(hardware_id)): raise exceptions.CLIAbort('Aborted') hardware.reload(hardware_id, postinstall, key_list)
[ "def", "cli", "(", "env", ",", "identifier", ",", "postinstall", ",", "key", ")", ":", "hardware", "=", "SoftLayer", ".", "HardwareManager", "(", "env", ".", "client", ")", "hardware_id", "=", "helpers", ".", "resolve_id", "(", "hardware", ".", "resolve_ids", ",", "identifier", ",", "'hardware'", ")", "key_list", "=", "[", "]", "if", "key", ":", "for", "single_key", "in", "key", ":", "resolver", "=", "SoftLayer", ".", "SshKeyManager", "(", "env", ".", "client", ")", ".", "resolve_ids", "key_id", "=", "helpers", ".", "resolve_id", "(", "resolver", ",", "single_key", ",", "'SshKey'", ")", "key_list", ".", "append", "(", "key_id", ")", "if", "not", "(", "env", ".", "skip_confirmations", "or", "formatting", ".", "no_going_back", "(", "hardware_id", ")", ")", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Aborted'", ")", "hardware", ".", "reload", "(", "hardware_id", ",", "postinstall", ",", "key_list", ")" ]
Reload operating system on a server.
[ "Reload", "operating", "system", "on", "a", "server", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/hardware/reload.py#L20-L36
1,533
softlayer/softlayer-python
SoftLayer/CLI/loadbal/service_edit.py
cli
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address): """Edit the properties of a service group.""" mgr = SoftLayer.LoadBalancerManager(env.client) loadbal_id, service_id = loadbal.parse_id(identifier) # check if any input is provided if ((not any([ip_address, weight, port, healthcheck_type])) and enabled is None): raise exceptions.CLIAbort( 'At least one property is required to be changed!') # check if the IP is valid ip_address_id = None if ip_address: ip_service = env.client['Network_Subnet_IpAddress'] ip_record = ip_service.getByIpAddress(ip_address) ip_address_id = ip_record['id'] mgr.edit_service(loadbal_id, service_id, ip_address_id=ip_address_id, enabled=enabled, port=port, weight=weight, hc_type=healthcheck_type) env.fout('Load balancer service %s is being modified!' % identifier)
python
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address): """Edit the properties of a service group.""" mgr = SoftLayer.LoadBalancerManager(env.client) loadbal_id, service_id = loadbal.parse_id(identifier) # check if any input is provided if ((not any([ip_address, weight, port, healthcheck_type])) and enabled is None): raise exceptions.CLIAbort( 'At least one property is required to be changed!') # check if the IP is valid ip_address_id = None if ip_address: ip_service = env.client['Network_Subnet_IpAddress'] ip_record = ip_service.getByIpAddress(ip_address) ip_address_id = ip_record['id'] mgr.edit_service(loadbal_id, service_id, ip_address_id=ip_address_id, enabled=enabled, port=port, weight=weight, hc_type=healthcheck_type) env.fout('Load balancer service %s is being modified!' % identifier)
[ "def", "cli", "(", "env", ",", "identifier", ",", "enabled", ",", "port", ",", "weight", ",", "healthcheck_type", ",", "ip_address", ")", ":", "mgr", "=", "SoftLayer", ".", "LoadBalancerManager", "(", "env", ".", "client", ")", "loadbal_id", ",", "service_id", "=", "loadbal", ".", "parse_id", "(", "identifier", ")", "# check if any input is provided", "if", "(", "(", "not", "any", "(", "[", "ip_address", ",", "weight", ",", "port", ",", "healthcheck_type", "]", ")", ")", "and", "enabled", "is", "None", ")", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'At least one property is required to be changed!'", ")", "# check if the IP is valid", "ip_address_id", "=", "None", "if", "ip_address", ":", "ip_service", "=", "env", ".", "client", "[", "'Network_Subnet_IpAddress'", "]", "ip_record", "=", "ip_service", ".", "getByIpAddress", "(", "ip_address", ")", "ip_address_id", "=", "ip_record", "[", "'id'", "]", "mgr", ".", "edit_service", "(", "loadbal_id", ",", "service_id", ",", "ip_address_id", "=", "ip_address_id", ",", "enabled", "=", "enabled", ",", "port", "=", "port", ",", "weight", "=", "weight", ",", "hc_type", "=", "healthcheck_type", ")", "env", ".", "fout", "(", "'Load balancer service %s is being modified!'", "%", "identifier", ")" ]
Edit the properties of a service group.
[ "Edit", "the", "properties", "of", "a", "service", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/service_edit.py#L25-L52
1,534
softlayer/softlayer-python
SoftLayer/CLI/subnet/list.py
cli
def cli(env, sortby, datacenter, identifier, subnet_type, network_space, ipv4, ipv6): """List subnets.""" mgr = SoftLayer.NetworkManager(env.client) table = formatting.Table([ 'id', 'identifier', 'type', 'network_space', 'datacenter', 'vlan_id', 'IPs', 'hardware', 'vs', ]) table.sortby = sortby version = 0 if ipv4: version = 4 elif ipv6: version = 6 subnets = mgr.list_subnets( datacenter=datacenter, version=version, identifier=identifier, subnet_type=subnet_type, network_space=network_space, ) for subnet in subnets: table.add_row([ subnet['id'], '%s/%s' % (subnet['networkIdentifier'], str(subnet['cidr'])), subnet.get('subnetType', formatting.blank()), utils.lookup(subnet, 'networkVlan', 'networkSpace') or formatting.blank(), utils.lookup(subnet, 'datacenter', 'name',) or formatting.blank(), subnet['networkVlanId'], subnet['ipAddressCount'], len(subnet['hardware']), len(subnet['virtualGuests']), ]) env.fout(table)
python
def cli(env, sortby, datacenter, identifier, subnet_type, network_space, ipv4, ipv6): """List subnets.""" mgr = SoftLayer.NetworkManager(env.client) table = formatting.Table([ 'id', 'identifier', 'type', 'network_space', 'datacenter', 'vlan_id', 'IPs', 'hardware', 'vs', ]) table.sortby = sortby version = 0 if ipv4: version = 4 elif ipv6: version = 6 subnets = mgr.list_subnets( datacenter=datacenter, version=version, identifier=identifier, subnet_type=subnet_type, network_space=network_space, ) for subnet in subnets: table.add_row([ subnet['id'], '%s/%s' % (subnet['networkIdentifier'], str(subnet['cidr'])), subnet.get('subnetType', formatting.blank()), utils.lookup(subnet, 'networkVlan', 'networkSpace') or formatting.blank(), utils.lookup(subnet, 'datacenter', 'name',) or formatting.blank(), subnet['networkVlanId'], subnet['ipAddressCount'], len(subnet['hardware']), len(subnet['virtualGuests']), ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "sortby", ",", "datacenter", ",", "identifier", ",", "subnet_type", ",", "network_space", ",", "ipv4", ",", "ipv6", ")", ":", "mgr", "=", "SoftLayer", ".", "NetworkManager", "(", "env", ".", "client", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'id'", ",", "'identifier'", ",", "'type'", ",", "'network_space'", ",", "'datacenter'", ",", "'vlan_id'", ",", "'IPs'", ",", "'hardware'", ",", "'vs'", ",", "]", ")", "table", ".", "sortby", "=", "sortby", "version", "=", "0", "if", "ipv4", ":", "version", "=", "4", "elif", "ipv6", ":", "version", "=", "6", "subnets", "=", "mgr", ".", "list_subnets", "(", "datacenter", "=", "datacenter", ",", "version", "=", "version", ",", "identifier", "=", "identifier", ",", "subnet_type", "=", "subnet_type", ",", "network_space", "=", "network_space", ",", ")", "for", "subnet", "in", "subnets", ":", "table", ".", "add_row", "(", "[", "subnet", "[", "'id'", "]", ",", "'%s/%s'", "%", "(", "subnet", "[", "'networkIdentifier'", "]", ",", "str", "(", "subnet", "[", "'cidr'", "]", ")", ")", ",", "subnet", ".", "get", "(", "'subnetType'", ",", "formatting", ".", "blank", "(", ")", ")", ",", "utils", ".", "lookup", "(", "subnet", ",", "'networkVlan'", ",", "'networkSpace'", ")", "or", "formatting", ".", "blank", "(", ")", ",", "utils", ".", "lookup", "(", "subnet", ",", "'datacenter'", ",", "'name'", ",", ")", "or", "formatting", ".", "blank", "(", ")", ",", "subnet", "[", "'networkVlanId'", "]", ",", "subnet", "[", "'ipAddressCount'", "]", ",", "len", "(", "subnet", "[", "'hardware'", "]", ")", ",", "len", "(", "subnet", "[", "'virtualGuests'", "]", ")", ",", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List subnets.
[ "List", "subnets", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/subnet/list.py#L32-L72
1,535
softlayer/softlayer-python
SoftLayer/CLI/firewall/add.py
cli
def cli(env, target, firewall_type, high_availability): """Create new firewall. TARGET: Id of the server the firewall will protect """ mgr = SoftLayer.FirewallManager(env.client) if not env.skip_confirmations: if firewall_type == 'vlan': pkg = mgr.get_dedicated_package(ha_enabled=high_availability) elif firewall_type == 'vs': pkg = mgr.get_standard_package(target, is_virt=True) elif firewall_type == 'server': pkg = mgr.get_standard_package(target, is_virt=False) if not pkg: exceptions.CLIAbort( "Unable to add firewall - Is network public enabled?") env.out("******************") env.out("Product: %s" % pkg[0]['description']) env.out("Price: $%s monthly" % pkg[0]['prices'][0]['recurringFee']) env.out("******************") if not formatting.confirm("This action will incur charges on your " "account. Continue?"): raise exceptions.CLIAbort('Aborted.') if firewall_type == 'vlan': mgr.add_vlan_firewall(target, ha_enabled=high_availability) elif firewall_type == 'vs': mgr.add_standard_firewall(target, is_virt=True) elif firewall_type == 'server': mgr.add_standard_firewall(target, is_virt=False) env.fout("Firewall is being created!")
python
def cli(env, target, firewall_type, high_availability): """Create new firewall. TARGET: Id of the server the firewall will protect """ mgr = SoftLayer.FirewallManager(env.client) if not env.skip_confirmations: if firewall_type == 'vlan': pkg = mgr.get_dedicated_package(ha_enabled=high_availability) elif firewall_type == 'vs': pkg = mgr.get_standard_package(target, is_virt=True) elif firewall_type == 'server': pkg = mgr.get_standard_package(target, is_virt=False) if not pkg: exceptions.CLIAbort( "Unable to add firewall - Is network public enabled?") env.out("******************") env.out("Product: %s" % pkg[0]['description']) env.out("Price: $%s monthly" % pkg[0]['prices'][0]['recurringFee']) env.out("******************") if not formatting.confirm("This action will incur charges on your " "account. Continue?"): raise exceptions.CLIAbort('Aborted.') if firewall_type == 'vlan': mgr.add_vlan_firewall(target, ha_enabled=high_availability) elif firewall_type == 'vs': mgr.add_standard_firewall(target, is_virt=True) elif firewall_type == 'server': mgr.add_standard_firewall(target, is_virt=False) env.fout("Firewall is being created!")
[ "def", "cli", "(", "env", ",", "target", ",", "firewall_type", ",", "high_availability", ")", ":", "mgr", "=", "SoftLayer", ".", "FirewallManager", "(", "env", ".", "client", ")", "if", "not", "env", ".", "skip_confirmations", ":", "if", "firewall_type", "==", "'vlan'", ":", "pkg", "=", "mgr", ".", "get_dedicated_package", "(", "ha_enabled", "=", "high_availability", ")", "elif", "firewall_type", "==", "'vs'", ":", "pkg", "=", "mgr", ".", "get_standard_package", "(", "target", ",", "is_virt", "=", "True", ")", "elif", "firewall_type", "==", "'server'", ":", "pkg", "=", "mgr", ".", "get_standard_package", "(", "target", ",", "is_virt", "=", "False", ")", "if", "not", "pkg", ":", "exceptions", ".", "CLIAbort", "(", "\"Unable to add firewall - Is network public enabled?\"", ")", "env", ".", "out", "(", "\"******************\"", ")", "env", ".", "out", "(", "\"Product: %s\"", "%", "pkg", "[", "0", "]", "[", "'description'", "]", ")", "env", ".", "out", "(", "\"Price: $%s monthly\"", "%", "pkg", "[", "0", "]", "[", "'prices'", "]", "[", "0", "]", "[", "'recurringFee'", "]", ")", "env", ".", "out", "(", "\"******************\"", ")", "if", "not", "formatting", ".", "confirm", "(", "\"This action will incur charges on your \"", "\"account. Continue?\"", ")", ":", "raise", "exceptions", ".", "CLIAbort", "(", "'Aborted.'", ")", "if", "firewall_type", "==", "'vlan'", ":", "mgr", ".", "add_vlan_firewall", "(", "target", ",", "ha_enabled", "=", "high_availability", ")", "elif", "firewall_type", "==", "'vs'", ":", "mgr", ".", "add_standard_firewall", "(", "target", ",", "is_virt", "=", "True", ")", "elif", "firewall_type", "==", "'server'", ":", "mgr", ".", "add_standard_firewall", "(", "target", ",", "is_virt", "=", "False", ")", "env", ".", "fout", "(", "\"Firewall is being created!\"", ")" ]
Create new firewall. TARGET: Id of the server the firewall will protect
[ "Create", "new", "firewall", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/firewall/add.py#L22-L58
1,536
softlayer/softlayer-python
SoftLayer/CLI/cdn/purge.py
cli
def cli(env, account_id, content_url): """Purge cached files from all edge nodes. Examples: slcli cdn purge 97794 http://example.com/cdn/file.txt slcli cdn purge 97794 http://example.com/cdn/file.txt https://dal01.example.softlayer.net/image.png """ manager = SoftLayer.CDNManager(env.client) content_list = manager.purge_content(account_id, content_url) table = formatting.Table(['url', 'status']) for content in content_list: table.add_row([ content['url'], content['statusCode'] ]) env.fout(table)
python
def cli(env, account_id, content_url): """Purge cached files from all edge nodes. Examples: slcli cdn purge 97794 http://example.com/cdn/file.txt slcli cdn purge 97794 http://example.com/cdn/file.txt https://dal01.example.softlayer.net/image.png """ manager = SoftLayer.CDNManager(env.client) content_list = manager.purge_content(account_id, content_url) table = formatting.Table(['url', 'status']) for content in content_list: table.add_row([ content['url'], content['statusCode'] ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "account_id", ",", "content_url", ")", ":", "manager", "=", "SoftLayer", ".", "CDNManager", "(", "env", ".", "client", ")", "content_list", "=", "manager", ".", "purge_content", "(", "account_id", ",", "content_url", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'url'", ",", "'status'", "]", ")", "for", "content", "in", "content_list", ":", "table", ".", "add_row", "(", "[", "content", "[", "'url'", "]", ",", "content", "[", "'statusCode'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Purge cached files from all edge nodes. Examples: slcli cdn purge 97794 http://example.com/cdn/file.txt slcli cdn purge 97794 http://example.com/cdn/file.txt https://dal01.example.softlayer.net/image.png
[ "Purge", "cached", "files", "from", "all", "edge", "nodes", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/cdn/purge.py#L15-L34
1,537
softlayer/softlayer-python
SoftLayer/CLI/order/package_locations.py
cli
def cli(env, package_keyname): """List Datacenters a package can be ordered in. Use the location Key Name to place orders """ manager = ordering.OrderingManager(env.client) table = formatting.Table(COLUMNS) locations = manager.package_locations(package_keyname) for region in locations: for datacenter in region['locations']: table.add_row([ datacenter['location']['id'], datacenter['location']['name'], region['description'], region['keyname'] ]) env.fout(table)
python
def cli(env, package_keyname): """List Datacenters a package can be ordered in. Use the location Key Name to place orders """ manager = ordering.OrderingManager(env.client) table = formatting.Table(COLUMNS) locations = manager.package_locations(package_keyname) for region in locations: for datacenter in region['locations']: table.add_row([ datacenter['location']['id'], datacenter['location']['name'], region['description'], region['keyname'] ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "package_keyname", ")", ":", "manager", "=", "ordering", ".", "OrderingManager", "(", "env", ".", "client", ")", "table", "=", "formatting", ".", "Table", "(", "COLUMNS", ")", "locations", "=", "manager", ".", "package_locations", "(", "package_keyname", ")", "for", "region", "in", "locations", ":", "for", "datacenter", "in", "region", "[", "'locations'", "]", ":", "table", ".", "add_row", "(", "[", "datacenter", "[", "'location'", "]", "[", "'id'", "]", ",", "datacenter", "[", "'location'", "]", "[", "'name'", "]", ",", "region", "[", "'description'", "]", ",", "region", "[", "'keyname'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
List Datacenters a package can be ordered in. Use the location Key Name to place orders
[ "List", "Datacenters", "a", "package", "can", "be", "ordered", "in", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/package_locations.py#L15-L32
1,538
softlayer/softlayer-python
SoftLayer/CLI/rwhois/edit.py
cli
def cli(env, abuse, address1, address2, city, company, country, firstname, lastname, postal, public, state): """Edit the RWhois data on the account.""" mgr = SoftLayer.NetworkManager(env.client) update = { 'abuse_email': abuse, 'address1': address1, 'address2': address2, 'company_name': company, 'city': city, 'country': country, 'first_name': firstname, 'last_name': lastname, 'postal_code': postal, 'state': state, 'private_residence': public, } if public is True: update['private_residence'] = False elif public is False: update['private_residence'] = True check = [x for x in update.values() if x is not None] if not check: raise exceptions.CLIAbort( "You must specify at least one field to update.") mgr.edit_rwhois(**update)
python
def cli(env, abuse, address1, address2, city, company, country, firstname, lastname, postal, public, state): """Edit the RWhois data on the account.""" mgr = SoftLayer.NetworkManager(env.client) update = { 'abuse_email': abuse, 'address1': address1, 'address2': address2, 'company_name': company, 'city': city, 'country': country, 'first_name': firstname, 'last_name': lastname, 'postal_code': postal, 'state': state, 'private_residence': public, } if public is True: update['private_residence'] = False elif public is False: update['private_residence'] = True check = [x for x in update.values() if x is not None] if not check: raise exceptions.CLIAbort( "You must specify at least one field to update.") mgr.edit_rwhois(**update)
[ "def", "cli", "(", "env", ",", "abuse", ",", "address1", ",", "address2", ",", "city", ",", "company", ",", "country", ",", "firstname", ",", "lastname", ",", "postal", ",", "public", ",", "state", ")", ":", "mgr", "=", "SoftLayer", ".", "NetworkManager", "(", "env", ".", "client", ")", "update", "=", "{", "'abuse_email'", ":", "abuse", ",", "'address1'", ":", "address1", ",", "'address2'", ":", "address2", ",", "'company_name'", ":", "company", ",", "'city'", ":", "city", ",", "'country'", ":", "country", ",", "'first_name'", ":", "firstname", ",", "'last_name'", ":", "lastname", ",", "'postal_code'", ":", "postal", ",", "'state'", ":", "state", ",", "'private_residence'", ":", "public", ",", "}", "if", "public", "is", "True", ":", "update", "[", "'private_residence'", "]", "=", "False", "elif", "public", "is", "False", ":", "update", "[", "'private_residence'", "]", "=", "True", "check", "=", "[", "x", "for", "x", "in", "update", ".", "values", "(", ")", "if", "x", "is", "not", "None", "]", "if", "not", "check", ":", "raise", "exceptions", ".", "CLIAbort", "(", "\"You must specify at least one field to update.\"", ")", "mgr", ".", "edit_rwhois", "(", "*", "*", "update", ")" ]
Edit the RWhois data on the account.
[ "Edit", "the", "RWhois", "data", "on", "the", "account", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/rwhois/edit.py#L26-L55
1,539
softlayer/softlayer-python
SoftLayer/CLI/order/quote.py
cli
def cli(env, quote, **args): """View and Order a quote \f :note: The hostname and domain are split out from the fully qualified domain name. If you want to order multiple servers, you need to specify each FQDN. Postinstall, userdata, and sshkeys are applied to all servers in an order. :: slcli order quote 12345 --fqdn testing.tester.com \\ --complex-type SoftLayer_Container_Product_Order_Virtual_Guest -k sshKeyNameLabel\\ -i https://domain.com/runthis.sh --userdata DataGoesHere """ table = formatting.Table([ 'Id', 'Name', 'Created', 'Expiration', 'Status' ]) create_args = _parse_create_args(env.client, args) manager = ordering.OrderingManager(env.client) quote_details = manager.get_quote_details(quote) package = quote_details['order']['items'][0]['package'] create_args['packageId'] = package['id'] if args.get('verify'): result = manager.verify_quote(quote, create_args) verify_table = formatting.Table(['keyName', 'description', 'cost']) verify_table.align['keyName'] = 'l' verify_table.align['description'] = 'l' for price in result['prices']: cost_key = 'hourlyRecurringFee' if result['useHourlyPricing'] is True else 'recurringFee' verify_table.add_row([ price['item']['keyName'], price['item']['description'], price[cost_key] if cost_key in price else formatting.blank() ]) env.fout(verify_table) else: result = manager.order_quote(quote, create_args) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', result['orderId']]) table.add_row(['created', result['orderDate']]) table.add_row(['status', result['placedOrder']['status']]) env.fout(table)
python
def cli(env, quote, **args): """View and Order a quote \f :note: The hostname and domain are split out from the fully qualified domain name. If you want to order multiple servers, you need to specify each FQDN. Postinstall, userdata, and sshkeys are applied to all servers in an order. :: slcli order quote 12345 --fqdn testing.tester.com \\ --complex-type SoftLayer_Container_Product_Order_Virtual_Guest -k sshKeyNameLabel\\ -i https://domain.com/runthis.sh --userdata DataGoesHere """ table = formatting.Table([ 'Id', 'Name', 'Created', 'Expiration', 'Status' ]) create_args = _parse_create_args(env.client, args) manager = ordering.OrderingManager(env.client) quote_details = manager.get_quote_details(quote) package = quote_details['order']['items'][0]['package'] create_args['packageId'] = package['id'] if args.get('verify'): result = manager.verify_quote(quote, create_args) verify_table = formatting.Table(['keyName', 'description', 'cost']) verify_table.align['keyName'] = 'l' verify_table.align['description'] = 'l' for price in result['prices']: cost_key = 'hourlyRecurringFee' if result['useHourlyPricing'] is True else 'recurringFee' verify_table.add_row([ price['item']['keyName'], price['item']['description'], price[cost_key] if cost_key in price else formatting.blank() ]) env.fout(verify_table) else: result = manager.order_quote(quote, create_args) table = formatting.KeyValueTable(['name', 'value']) table.align['name'] = 'r' table.align['value'] = 'l' table.add_row(['id', result['orderId']]) table.add_row(['created', result['orderDate']]) table.add_row(['status', result['placedOrder']['status']]) env.fout(table)
[ "def", "cli", "(", "env", ",", "quote", ",", "*", "*", "args", ")", ":", "table", "=", "formatting", ".", "Table", "(", "[", "'Id'", ",", "'Name'", ",", "'Created'", ",", "'Expiration'", ",", "'Status'", "]", ")", "create_args", "=", "_parse_create_args", "(", "env", ".", "client", ",", "args", ")", "manager", "=", "ordering", ".", "OrderingManager", "(", "env", ".", "client", ")", "quote_details", "=", "manager", ".", "get_quote_details", "(", "quote", ")", "package", "=", "quote_details", "[", "'order'", "]", "[", "'items'", "]", "[", "0", "]", "[", "'package'", "]", "create_args", "[", "'packageId'", "]", "=", "package", "[", "'id'", "]", "if", "args", ".", "get", "(", "'verify'", ")", ":", "result", "=", "manager", ".", "verify_quote", "(", "quote", ",", "create_args", ")", "verify_table", "=", "formatting", ".", "Table", "(", "[", "'keyName'", ",", "'description'", ",", "'cost'", "]", ")", "verify_table", ".", "align", "[", "'keyName'", "]", "=", "'l'", "verify_table", ".", "align", "[", "'description'", "]", "=", "'l'", "for", "price", "in", "result", "[", "'prices'", "]", ":", "cost_key", "=", "'hourlyRecurringFee'", "if", "result", "[", "'useHourlyPricing'", "]", "is", "True", "else", "'recurringFee'", "verify_table", ".", "add_row", "(", "[", "price", "[", "'item'", "]", "[", "'keyName'", "]", ",", "price", "[", "'item'", "]", "[", "'description'", "]", ",", "price", "[", "cost_key", "]", "if", "cost_key", "in", "price", "else", "formatting", ".", "blank", "(", ")", "]", ")", "env", ".", "fout", "(", "verify_table", ")", "else", ":", "result", "=", "manager", ".", "order_quote", "(", "quote", ",", "create_args", ")", "table", "=", "formatting", ".", "KeyValueTable", "(", "[", "'name'", ",", "'value'", "]", ")", "table", ".", "align", "[", "'name'", "]", "=", "'r'", "table", ".", "align", "[", "'value'", "]", "=", "'l'", "table", ".", "add_row", "(", "[", "'id'", ",", "result", "[", "'orderId'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'created'", ",", "result", "[", "'orderDate'", "]", "]", ")", "table", ".", "add_row", "(", "[", "'status'", ",", "result", "[", "'placedOrder'", "]", "[", "'status'", "]", "]", ")", "env", ".", "fout", "(", "table", ")" ]
View and Order a quote \f :note: The hostname and domain are split out from the fully qualified domain name. If you want to order multiple servers, you need to specify each FQDN. Postinstall, userdata, and sshkeys are applied to all servers in an order. :: slcli order quote 12345 --fqdn testing.tester.com \\ --complex-type SoftLayer_Container_Product_Order_Virtual_Guest -k sshKeyNameLabel\\ -i https://domain.com/runthis.sh --userdata DataGoesHere
[ "View", "and", "Order", "a", "quote" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/quote.py#L81-L130
1,540
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.authorize_host_to_volume
def authorize_host_to_volume(self, volume_id, hardware_ids=None, virtual_guest_ids=None, ip_address_ids=None, **kwargs): """Authorizes hosts to Block Storage Volumes :param volume_id: The Block volume to authorize hosts to :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 :return: Returns an array of SoftLayer_Network_Storage_Allowed_Host objects which now have access to the given Block volume """ host_templates = [] storage_utils.populate_host_templates(host_templates, hardware_ids, virtual_guest_ids, ip_address_ids, None) return self.client.call('Network_Storage', 'allowAccessFromHostList', host_templates, id=volume_id, **kwargs)
python
def authorize_host_to_volume(self, volume_id, hardware_ids=None, virtual_guest_ids=None, ip_address_ids=None, **kwargs): """Authorizes hosts to Block Storage Volumes :param volume_id: The Block volume to authorize hosts to :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 :return: Returns an array of SoftLayer_Network_Storage_Allowed_Host objects which now have access to the given Block volume """ host_templates = [] storage_utils.populate_host_templates(host_templates, hardware_ids, virtual_guest_ids, ip_address_ids, None) return self.client.call('Network_Storage', 'allowAccessFromHostList', host_templates, id=volume_id, **kwargs)
[ "def", "authorize_host_to_volume", "(", "self", ",", "volume_id", ",", "hardware_ids", "=", "None", ",", "virtual_guest_ids", "=", "None", ",", "ip_address_ids", "=", "None", ",", "*", "*", "kwargs", ")", ":", "host_templates", "=", "[", "]", "storage_utils", ".", "populate_host_templates", "(", "host_templates", ",", "hardware_ids", ",", "virtual_guest_ids", ",", "ip_address_ids", ",", "None", ")", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'allowAccessFromHostList'", ",", "host_templates", ",", "id", "=", "volume_id", ",", "*", "*", "kwargs", ")" ]
Authorizes hosts to Block Storage Volumes :param volume_id: The Block volume to authorize hosts to :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 :return: Returns an array of SoftLayer_Network_Storage_Allowed_Host objects which now have access to the given Block volume
[ "Authorizes", "hosts", "to", "Block", "Storage", "Volumes" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L154-L177
1,541
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.order_replicant_volume
def order_replicant_volume(self, volume_id, snapshot_schedule, location, tier=None, os_type=None): """Places an order for a replicant block volume. :param volume_id: The ID of the primary volume to be replicated :param snapshot_schedule: The primary volume's snapshot schedule to use for replication :param location: The location for the ordered replicant volume :param tier: The tier (IOPS per GB) of the primary volume :param os_type: The OS type of the primary volume :return: Returns a SoftLayer_Container_Product_Order_Receipt """ block_mask = 'billingItem[activeChildren,hourlyFlag],'\ 'storageTierLevel,osType,staasVersion,'\ 'hasEncryptionAtRest,snapshotCapacityGb,schedules,'\ 'intervalSchedule,hourlySchedule,dailySchedule,'\ 'weeklySchedule,storageType[keyName],provisionedIops' block_volume = self.get_block_volume_details(volume_id, mask=block_mask) if os_type is None: if isinstance(utils.lookup(block_volume, 'osType', 'keyName'), str): os_type = block_volume['osType']['keyName'] else: raise exceptions.SoftLayerError( "Cannot find primary volume's os-type " "automatically; must specify manually") order = storage_utils.prepare_replicant_order_object( self, snapshot_schedule, location, tier, block_volume, 'block' ) order['osFormatType'] = {'keyName': os_type} return self.client.call('Product_Order', 'placeOrder', order)
python
def order_replicant_volume(self, volume_id, snapshot_schedule, location, tier=None, os_type=None): """Places an order for a replicant block volume. :param volume_id: The ID of the primary volume to be replicated :param snapshot_schedule: The primary volume's snapshot schedule to use for replication :param location: The location for the ordered replicant volume :param tier: The tier (IOPS per GB) of the primary volume :param os_type: The OS type of the primary volume :return: Returns a SoftLayer_Container_Product_Order_Receipt """ block_mask = 'billingItem[activeChildren,hourlyFlag],'\ 'storageTierLevel,osType,staasVersion,'\ 'hasEncryptionAtRest,snapshotCapacityGb,schedules,'\ 'intervalSchedule,hourlySchedule,dailySchedule,'\ 'weeklySchedule,storageType[keyName],provisionedIops' block_volume = self.get_block_volume_details(volume_id, mask=block_mask) if os_type is None: if isinstance(utils.lookup(block_volume, 'osType', 'keyName'), str): os_type = block_volume['osType']['keyName'] else: raise exceptions.SoftLayerError( "Cannot find primary volume's os-type " "automatically; must specify manually") order = storage_utils.prepare_replicant_order_object( self, snapshot_schedule, location, tier, block_volume, 'block' ) order['osFormatType'] = {'keyName': os_type} return self.client.call('Product_Order', 'placeOrder', order)
[ "def", "order_replicant_volume", "(", "self", ",", "volume_id", ",", "snapshot_schedule", ",", "location", ",", "tier", "=", "None", ",", "os_type", "=", "None", ")", ":", "block_mask", "=", "'billingItem[activeChildren,hourlyFlag],'", "'storageTierLevel,osType,staasVersion,'", "'hasEncryptionAtRest,snapshotCapacityGb,schedules,'", "'intervalSchedule,hourlySchedule,dailySchedule,'", "'weeklySchedule,storageType[keyName],provisionedIops'", "block_volume", "=", "self", ".", "get_block_volume_details", "(", "volume_id", ",", "mask", "=", "block_mask", ")", "if", "os_type", "is", "None", ":", "if", "isinstance", "(", "utils", ".", "lookup", "(", "block_volume", ",", "'osType'", ",", "'keyName'", ")", ",", "str", ")", ":", "os_type", "=", "block_volume", "[", "'osType'", "]", "[", "'keyName'", "]", "else", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"Cannot find primary volume's os-type \"", "\"automatically; must specify manually\"", ")", "order", "=", "storage_utils", ".", "prepare_replicant_order_object", "(", "self", ",", "snapshot_schedule", ",", "location", ",", "tier", ",", "block_volume", ",", "'block'", ")", "order", "[", "'osFormatType'", "]", "=", "{", "'keyName'", ":", "os_type", "}", "return", "self", ".", "client", ".", "call", "(", "'Product_Order'", ",", "'placeOrder'", ",", "order", ")" ]
Places an order for a replicant block volume. :param volume_id: The ID of the primary volume to be replicated :param snapshot_schedule: The primary volume's snapshot schedule to use for replication :param location: The location for the ordered replicant volume :param tier: The tier (IOPS per GB) of the primary volume :param os_type: The OS type of the primary volume :return: Returns a SoftLayer_Container_Product_Order_Receipt
[ "Places", "an", "order", "for", "a", "replicant", "block", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L224-L260
1,542
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.order_duplicate_volume
def order_duplicate_volume(self, origin_volume_id, origin_snapshot_id=None, duplicate_size=None, duplicate_iops=None, duplicate_tier_level=None, duplicate_snapshot_size=None, hourly_billing_flag=False): """Places an order for a duplicate block volume. :param origin_volume_id: The ID of the origin volume to be duplicated :param origin_snapshot_id: Origin snapshot ID to use for duplication :param duplicate_size: Size/capacity for the duplicate volume :param duplicate_iops: The IOPS per GB for the duplicate volume :param duplicate_tier_level: Tier level for the duplicate volume :param duplicate_snapshot_size: Snapshot space size for the duplicate :param hourly_billing_flag: Billing type, monthly (False) or hourly (True), default to monthly. :return: Returns a SoftLayer_Container_Product_Order_Receipt """ block_mask = 'id,billingItem[location,hourlyFlag],snapshotCapacityGb,'\ 'storageType[keyName],capacityGb,originalVolumeSize,'\ 'provisionedIops,storageTierLevel,osType[keyName],'\ 'staasVersion,hasEncryptionAtRest' origin_volume = self.get_block_volume_details(origin_volume_id, mask=block_mask) if isinstance(utils.lookup(origin_volume, 'osType', 'keyName'), str): os_type = origin_volume['osType']['keyName'] else: raise exceptions.SoftLayerError( "Cannot find origin volume's os-type") order = storage_utils.prepare_duplicate_order_object( self, origin_volume, duplicate_iops, duplicate_tier_level, duplicate_size, duplicate_snapshot_size, 'block', hourly_billing_flag ) order['osFormatType'] = {'keyName': os_type} if origin_snapshot_id is not None: order['duplicateOriginSnapshotId'] = origin_snapshot_id return self.client.call('Product_Order', 'placeOrder', order)
python
def order_duplicate_volume(self, origin_volume_id, origin_snapshot_id=None, duplicate_size=None, duplicate_iops=None, duplicate_tier_level=None, duplicate_snapshot_size=None, hourly_billing_flag=False): """Places an order for a duplicate block volume. :param origin_volume_id: The ID of the origin volume to be duplicated :param origin_snapshot_id: Origin snapshot ID to use for duplication :param duplicate_size: Size/capacity for the duplicate volume :param duplicate_iops: The IOPS per GB for the duplicate volume :param duplicate_tier_level: Tier level for the duplicate volume :param duplicate_snapshot_size: Snapshot space size for the duplicate :param hourly_billing_flag: Billing type, monthly (False) or hourly (True), default to monthly. :return: Returns a SoftLayer_Container_Product_Order_Receipt """ block_mask = 'id,billingItem[location,hourlyFlag],snapshotCapacityGb,'\ 'storageType[keyName],capacityGb,originalVolumeSize,'\ 'provisionedIops,storageTierLevel,osType[keyName],'\ 'staasVersion,hasEncryptionAtRest' origin_volume = self.get_block_volume_details(origin_volume_id, mask=block_mask) if isinstance(utils.lookup(origin_volume, 'osType', 'keyName'), str): os_type = origin_volume['osType']['keyName'] else: raise exceptions.SoftLayerError( "Cannot find origin volume's os-type") order = storage_utils.prepare_duplicate_order_object( self, origin_volume, duplicate_iops, duplicate_tier_level, duplicate_size, duplicate_snapshot_size, 'block', hourly_billing_flag ) order['osFormatType'] = {'keyName': os_type} if origin_snapshot_id is not None: order['duplicateOriginSnapshotId'] = origin_snapshot_id return self.client.call('Product_Order', 'placeOrder', order)
[ "def", "order_duplicate_volume", "(", "self", ",", "origin_volume_id", ",", "origin_snapshot_id", "=", "None", ",", "duplicate_size", "=", "None", ",", "duplicate_iops", "=", "None", ",", "duplicate_tier_level", "=", "None", ",", "duplicate_snapshot_size", "=", "None", ",", "hourly_billing_flag", "=", "False", ")", ":", "block_mask", "=", "'id,billingItem[location,hourlyFlag],snapshotCapacityGb,'", "'storageType[keyName],capacityGb,originalVolumeSize,'", "'provisionedIops,storageTierLevel,osType[keyName],'", "'staasVersion,hasEncryptionAtRest'", "origin_volume", "=", "self", ".", "get_block_volume_details", "(", "origin_volume_id", ",", "mask", "=", "block_mask", ")", "if", "isinstance", "(", "utils", ".", "lookup", "(", "origin_volume", ",", "'osType'", ",", "'keyName'", ")", ",", "str", ")", ":", "os_type", "=", "origin_volume", "[", "'osType'", "]", "[", "'keyName'", "]", "else", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"Cannot find origin volume's os-type\"", ")", "order", "=", "storage_utils", ".", "prepare_duplicate_order_object", "(", "self", ",", "origin_volume", ",", "duplicate_iops", ",", "duplicate_tier_level", ",", "duplicate_size", ",", "duplicate_snapshot_size", ",", "'block'", ",", "hourly_billing_flag", ")", "order", "[", "'osFormatType'", "]", "=", "{", "'keyName'", ":", "os_type", "}", "if", "origin_snapshot_id", "is", "not", "None", ":", "order", "[", "'duplicateOriginSnapshotId'", "]", "=", "origin_snapshot_id", "return", "self", ".", "client", ".", "call", "(", "'Product_Order'", ",", "'placeOrder'", ",", "order", ")" ]
Places an order for a duplicate block volume. :param origin_volume_id: The ID of the origin volume to be duplicated :param origin_snapshot_id: Origin snapshot ID to use for duplication :param duplicate_size: Size/capacity for the duplicate volume :param duplicate_iops: The IOPS per GB for the duplicate volume :param duplicate_tier_level: Tier level for the duplicate volume :param duplicate_snapshot_size: Snapshot space size for the duplicate :param hourly_billing_flag: Billing type, monthly (False) or hourly (True), default to monthly. :return: Returns a SoftLayer_Container_Product_Order_Receipt
[ "Places", "an", "order", "for", "a", "duplicate", "block", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L262-L304
1,543
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.order_modified_volume
def order_modified_volume(self, volume_id, new_size=None, new_iops=None, new_tier_level=None): """Places an order for modifying an existing block volume. :param volume_id: The ID of the volume to be modified :param new_size: The new size/capacity for the volume :param new_iops: The new IOPS for the volume :param new_tier_level: The new tier level for the volume :return: Returns a SoftLayer_Container_Product_Order_Receipt """ mask_items = [ 'id', 'billingItem', 'storageType[keyName]', 'capacityGb', 'provisionedIops', 'storageTierLevel', 'staasVersion', 'hasEncryptionAtRest', ] block_mask = ','.join(mask_items) volume = self.get_block_volume_details(volume_id, mask=block_mask) order = storage_utils.prepare_modify_order_object( self, volume, new_iops, new_tier_level, new_size ) return self.client.call('Product_Order', 'placeOrder', order)
python
def order_modified_volume(self, volume_id, new_size=None, new_iops=None, new_tier_level=None): """Places an order for modifying an existing block volume. :param volume_id: The ID of the volume to be modified :param new_size: The new size/capacity for the volume :param new_iops: The new IOPS for the volume :param new_tier_level: The new tier level for the volume :return: Returns a SoftLayer_Container_Product_Order_Receipt """ mask_items = [ 'id', 'billingItem', 'storageType[keyName]', 'capacityGb', 'provisionedIops', 'storageTierLevel', 'staasVersion', 'hasEncryptionAtRest', ] block_mask = ','.join(mask_items) volume = self.get_block_volume_details(volume_id, mask=block_mask) order = storage_utils.prepare_modify_order_object( self, volume, new_iops, new_tier_level, new_size ) return self.client.call('Product_Order', 'placeOrder', order)
[ "def", "order_modified_volume", "(", "self", ",", "volume_id", ",", "new_size", "=", "None", ",", "new_iops", "=", "None", ",", "new_tier_level", "=", "None", ")", ":", "mask_items", "=", "[", "'id'", ",", "'billingItem'", ",", "'storageType[keyName]'", ",", "'capacityGb'", ",", "'provisionedIops'", ",", "'storageTierLevel'", ",", "'staasVersion'", ",", "'hasEncryptionAtRest'", ",", "]", "block_mask", "=", "','", ".", "join", "(", "mask_items", ")", "volume", "=", "self", ".", "get_block_volume_details", "(", "volume_id", ",", "mask", "=", "block_mask", ")", "order", "=", "storage_utils", ".", "prepare_modify_order_object", "(", "self", ",", "volume", ",", "new_iops", ",", "new_tier_level", ",", "new_size", ")", "return", "self", ".", "client", ".", "call", "(", "'Product_Order'", ",", "'placeOrder'", ",", "order", ")" ]
Places an order for modifying an existing block volume. :param volume_id: The ID of the volume to be modified :param new_size: The new size/capacity for the volume :param new_iops: The new IOPS for the volume :param new_tier_level: The new tier level for the volume :return: Returns a SoftLayer_Container_Product_Order_Receipt
[ "Places", "an", "order", "for", "modifying", "an", "existing", "block", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L306-L333
1,544
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.order_block_volume
def order_block_volume(self, storage_type, location, size, os_type, iops=None, tier_level=None, snapshot_size=None, service_offering='storage_as_a_service', hourly_billing_flag=False): """Places an order for a block volume. :param storage_type: 'performance' or 'endurance' :param location: Datacenter in which to order iSCSI volume :param size: Size of the desired volume, in GB :param os_type: OS Type to use for volume alignment, see help for list :param iops: Number of IOPs for a "Performance" order :param tier_level: Tier level to use for an "Endurance" order :param snapshot_size: The size of optional snapshot space, if snapshot space should also be ordered (None if not ordered) :param service_offering: Requested offering package to use in the order ('storage_as_a_service', 'enterprise', or 'performance') :param hourly_billing_flag: Billing type, monthly (False) or hourly (True), default to monthly. """ order = storage_utils.prepare_volume_order_object( self, storage_type, location, size, iops, tier_level, snapshot_size, service_offering, 'block', hourly_billing_flag ) order['osFormatType'] = {'keyName': os_type} return self.client.call('Product_Order', 'placeOrder', order)
python
def order_block_volume(self, storage_type, location, size, os_type, iops=None, tier_level=None, snapshot_size=None, service_offering='storage_as_a_service', hourly_billing_flag=False): """Places an order for a block volume. :param storage_type: 'performance' or 'endurance' :param location: Datacenter in which to order iSCSI volume :param size: Size of the desired volume, in GB :param os_type: OS Type to use for volume alignment, see help for list :param iops: Number of IOPs for a "Performance" order :param tier_level: Tier level to use for an "Endurance" order :param snapshot_size: The size of optional snapshot space, if snapshot space should also be ordered (None if not ordered) :param service_offering: Requested offering package to use in the order ('storage_as_a_service', 'enterprise', or 'performance') :param hourly_billing_flag: Billing type, monthly (False) or hourly (True), default to monthly. """ order = storage_utils.prepare_volume_order_object( self, storage_type, location, size, iops, tier_level, snapshot_size, service_offering, 'block', hourly_billing_flag ) order['osFormatType'] = {'keyName': os_type} return self.client.call('Product_Order', 'placeOrder', order)
[ "def", "order_block_volume", "(", "self", ",", "storage_type", ",", "location", ",", "size", ",", "os_type", ",", "iops", "=", "None", ",", "tier_level", "=", "None", ",", "snapshot_size", "=", "None", ",", "service_offering", "=", "'storage_as_a_service'", ",", "hourly_billing_flag", "=", "False", ")", ":", "order", "=", "storage_utils", ".", "prepare_volume_order_object", "(", "self", ",", "storage_type", ",", "location", ",", "size", ",", "iops", ",", "tier_level", ",", "snapshot_size", ",", "service_offering", ",", "'block'", ",", "hourly_billing_flag", ")", "order", "[", "'osFormatType'", "]", "=", "{", "'keyName'", ":", "os_type", "}", "return", "self", ".", "client", ".", "call", "(", "'Product_Order'", ",", "'placeOrder'", ",", "order", ")" ]
Places an order for a block volume. :param storage_type: 'performance' or 'endurance' :param location: Datacenter in which to order iSCSI volume :param size: Size of the desired volume, in GB :param os_type: OS Type to use for volume alignment, see help for list :param iops: Number of IOPs for a "Performance" order :param tier_level: Tier level to use for an "Endurance" order :param snapshot_size: The size of optional snapshot space, if snapshot space should also be ordered (None if not ordered) :param service_offering: Requested offering package to use in the order ('storage_as_a_service', 'enterprise', or 'performance') :param hourly_billing_flag: Billing type, monthly (False) or hourly (True), default to monthly.
[ "Places", "an", "order", "for", "a", "block", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L343-L369
1,545
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.create_snapshot
def create_snapshot(self, volume_id, notes='', **kwargs): """Creates a snapshot on the given block volume. :param integer volume_id: The id of the volume :param string notes: The notes or "name" to assign the snapshot :return: Returns the id of the new snapshot """ return self.client.call('Network_Storage', 'createSnapshot', notes, id=volume_id, **kwargs)
python
def create_snapshot(self, volume_id, notes='', **kwargs): """Creates a snapshot on the given block volume. :param integer volume_id: The id of the volume :param string notes: The notes or "name" to assign the snapshot :return: Returns the id of the new snapshot """ return self.client.call('Network_Storage', 'createSnapshot', notes, id=volume_id, **kwargs)
[ "def", "create_snapshot", "(", "self", ",", "volume_id", ",", "notes", "=", "''", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'createSnapshot'", ",", "notes", ",", "id", "=", "volume_id", ",", "*", "*", "kwargs", ")" ]
Creates a snapshot on the given block volume. :param integer volume_id: The id of the volume :param string notes: The notes or "name" to assign the snapshot :return: Returns the id of the new snapshot
[ "Creates", "a", "snapshot", "on", "the", "given", "block", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L371-L380
1,546
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.order_snapshot_space
def order_snapshot_space(self, volume_id, capacity, tier, upgrade, **kwargs): """Orders snapshot space for the given block volume. :param integer volume_id: The id of the volume :param integer capacity: The capacity to order, in GB :param float tier: The tier level of the block volume, in IOPS per GB :param boolean upgrade: Flag to indicate if this order is an upgrade :return: Returns a SoftLayer_Container_Product_Order_Receipt """ block_mask = 'id,billingItem[location,hourlyFlag],'\ 'storageType[keyName],storageTierLevel,provisionedIops,'\ 'staasVersion,hasEncryptionAtRest' block_volume = self.get_block_volume_details(volume_id, mask=block_mask, **kwargs) order = storage_utils.prepare_snapshot_order_object( self, block_volume, capacity, tier, upgrade) return self.client.call('Product_Order', 'placeOrder', order)
python
def order_snapshot_space(self, volume_id, capacity, tier, upgrade, **kwargs): """Orders snapshot space for the given block volume. :param integer volume_id: The id of the volume :param integer capacity: The capacity to order, in GB :param float tier: The tier level of the block volume, in IOPS per GB :param boolean upgrade: Flag to indicate if this order is an upgrade :return: Returns a SoftLayer_Container_Product_Order_Receipt """ block_mask = 'id,billingItem[location,hourlyFlag],'\ 'storageType[keyName],storageTierLevel,provisionedIops,'\ 'staasVersion,hasEncryptionAtRest' block_volume = self.get_block_volume_details(volume_id, mask=block_mask, **kwargs) order = storage_utils.prepare_snapshot_order_object( self, block_volume, capacity, tier, upgrade) return self.client.call('Product_Order', 'placeOrder', order)
[ "def", "order_snapshot_space", "(", "self", ",", "volume_id", ",", "capacity", ",", "tier", ",", "upgrade", ",", "*", "*", "kwargs", ")", ":", "block_mask", "=", "'id,billingItem[location,hourlyFlag],'", "'storageType[keyName],storageTierLevel,provisionedIops,'", "'staasVersion,hasEncryptionAtRest'", "block_volume", "=", "self", ".", "get_block_volume_details", "(", "volume_id", ",", "mask", "=", "block_mask", ",", "*", "*", "kwargs", ")", "order", "=", "storage_utils", ".", "prepare_snapshot_order_object", "(", "self", ",", "block_volume", ",", "capacity", ",", "tier", ",", "upgrade", ")", "return", "self", ".", "client", ".", "call", "(", "'Product_Order'", ",", "'placeOrder'", ",", "order", ")" ]
Orders snapshot space for the given block volume. :param integer volume_id: The id of the volume :param integer capacity: The capacity to order, in GB :param float tier: The tier level of the block volume, in IOPS per GB :param boolean upgrade: Flag to indicate if this order is an upgrade :return: Returns a SoftLayer_Container_Product_Order_Receipt
[ "Orders", "snapshot", "space", "for", "the", "given", "block", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L382-L402
1,547
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.enable_snapshots
def enable_snapshots(self, volume_id, schedule_type, retention_count, minute, hour, day_of_week, **kwargs): """Enables snapshots for a specific block volume at a given schedule :param integer volume_id: The id of the volume :param string schedule_type: 'HOURLY'|'DAILY'|'WEEKLY' :param integer retention_count: Number of snapshots to be kept :param integer minute: Minute when to take snapshot :param integer hour: Hour when to take snapshot :param string day_of_week: Day when to take snapshot :return: Returns whether successfully scheduled or not """ return self.client.call('Network_Storage', 'enableSnapshots', schedule_type, retention_count, minute, hour, day_of_week, id=volume_id, **kwargs)
python
def enable_snapshots(self, volume_id, schedule_type, retention_count, minute, hour, day_of_week, **kwargs): """Enables snapshots for a specific block volume at a given schedule :param integer volume_id: The id of the volume :param string schedule_type: 'HOURLY'|'DAILY'|'WEEKLY' :param integer retention_count: Number of snapshots to be kept :param integer minute: Minute when to take snapshot :param integer hour: Hour when to take snapshot :param string day_of_week: Day when to take snapshot :return: Returns whether successfully scheduled or not """ return self.client.call('Network_Storage', 'enableSnapshots', schedule_type, retention_count, minute, hour, day_of_week, id=volume_id, **kwargs)
[ "def", "enable_snapshots", "(", "self", ",", "volume_id", ",", "schedule_type", ",", "retention_count", ",", "minute", ",", "hour", ",", "day_of_week", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'enableSnapshots'", ",", "schedule_type", ",", "retention_count", ",", "minute", ",", "hour", ",", "day_of_week", ",", "id", "=", "volume_id", ",", "*", "*", "kwargs", ")" ]
Enables snapshots for a specific block volume at a given schedule :param integer volume_id: The id of the volume :param string schedule_type: 'HOURLY'|'DAILY'|'WEEKLY' :param integer retention_count: Number of snapshots to be kept :param integer minute: Minute when to take snapshot :param integer hour: Hour when to take snapshot :param string day_of_week: Day when to take snapshot :return: Returns whether successfully scheduled or not
[ "Enables", "snapshots", "for", "a", "specific", "block", "volume", "at", "a", "given", "schedule" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L443-L463
1,548
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.disable_snapshots
def disable_snapshots(self, volume_id, schedule_type): """Disables snapshots for a specific block volume at a given schedule :param integer volume_id: The id of the volume :param string schedule_type: 'HOURLY'|'DAILY'|'WEEKLY' :return: Returns whether successfully disabled or not """ return self.client.call('Network_Storage', 'disableSnapshots', schedule_type, id=volume_id)
python
def disable_snapshots(self, volume_id, schedule_type): """Disables snapshots for a specific block volume at a given schedule :param integer volume_id: The id of the volume :param string schedule_type: 'HOURLY'|'DAILY'|'WEEKLY' :return: Returns whether successfully disabled or not """ return self.client.call('Network_Storage', 'disableSnapshots', schedule_type, id=volume_id)
[ "def", "disable_snapshots", "(", "self", ",", "volume_id", ",", "schedule_type", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'disableSnapshots'", ",", "schedule_type", ",", "id", "=", "volume_id", ")" ]
Disables snapshots for a specific block volume at a given schedule :param integer volume_id: The id of the volume :param string schedule_type: 'HOURLY'|'DAILY'|'WEEKLY' :return: Returns whether successfully disabled or not
[ "Disables", "snapshots", "for", "a", "specific", "block", "volume", "at", "a", "given", "schedule" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L465-L474
1,549
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.list_volume_schedules
def list_volume_schedules(self, volume_id): """Lists schedules for a given volume :param integer volume_id: The id of the volume :return: Returns list of schedules assigned to a given volume """ volume_detail = self.client.call( 'Network_Storage', 'getObject', id=volume_id, mask='schedules[type,properties[type]]') return utils.lookup(volume_detail, 'schedules')
python
def list_volume_schedules(self, volume_id): """Lists schedules for a given volume :param integer volume_id: The id of the volume :return: Returns list of schedules assigned to a given volume """ volume_detail = self.client.call( 'Network_Storage', 'getObject', id=volume_id, mask='schedules[type,properties[type]]') return utils.lookup(volume_detail, 'schedules')
[ "def", "list_volume_schedules", "(", "self", ",", "volume_id", ")", ":", "volume_detail", "=", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'getObject'", ",", "id", "=", "volume_id", ",", "mask", "=", "'schedules[type,properties[type]]'", ")", "return", "utils", ".", "lookup", "(", "volume_detail", ",", "'schedules'", ")" ]
Lists schedules for a given volume :param integer volume_id: The id of the volume :return: Returns list of schedules assigned to a given volume
[ "Lists", "schedules", "for", "a", "given", "volume" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L476-L488
1,550
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.restore_from_snapshot
def restore_from_snapshot(self, volume_id, snapshot_id): """Restores a specific volume from a snapshot :param integer volume_id: The id of the volume :param integer snapshot_id: The id of the restore point :return: Returns whether succesfully restored or not """ return self.client.call('Network_Storage', 'restoreFromSnapshot', snapshot_id, id=volume_id)
python
def restore_from_snapshot(self, volume_id, snapshot_id): """Restores a specific volume from a snapshot :param integer volume_id: The id of the volume :param integer snapshot_id: The id of the restore point :return: Returns whether succesfully restored or not """ return self.client.call('Network_Storage', 'restoreFromSnapshot', snapshot_id, id=volume_id)
[ "def", "restore_from_snapshot", "(", "self", ",", "volume_id", ",", "snapshot_id", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'restoreFromSnapshot'", ",", "snapshot_id", ",", "id", "=", "volume_id", ")" ]
Restores a specific volume from a snapshot :param integer volume_id: The id of the volume :param integer snapshot_id: The id of the restore point :return: Returns whether succesfully restored or not
[ "Restores", "a", "specific", "volume", "from", "a", "snapshot" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L490-L499
1,551
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.cancel_block_volume
def cancel_block_volume(self, volume_id, reason='No longer needed', immediate=False): """Cancels the given block storage volume. :param integer volume_id: The volume ID :param string reason: The reason for cancellation :param boolean immediate_flag: Cancel immediately or on anniversary date """ block_volume = self.get_block_volume_details( volume_id, mask='mask[id,billingItem[id,hourlyFlag]]') if 'billingItem' not in block_volume: raise exceptions.SoftLayerError("Block Storage was already cancelled") billing_item_id = block_volume['billingItem']['id'] if utils.lookup(block_volume, 'billingItem', 'hourlyFlag'): immediate = True return self.client['Billing_Item'].cancelItem( immediate, True, reason, id=billing_item_id)
python
def cancel_block_volume(self, volume_id, reason='No longer needed', immediate=False): """Cancels the given block storage volume. :param integer volume_id: The volume ID :param string reason: The reason for cancellation :param boolean immediate_flag: Cancel immediately or on anniversary date """ block_volume = self.get_block_volume_details( volume_id, mask='mask[id,billingItem[id,hourlyFlag]]') if 'billingItem' not in block_volume: raise exceptions.SoftLayerError("Block Storage was already cancelled") billing_item_id = block_volume['billingItem']['id'] if utils.lookup(block_volume, 'billingItem', 'hourlyFlag'): immediate = True return self.client['Billing_Item'].cancelItem( immediate, True, reason, id=billing_item_id)
[ "def", "cancel_block_volume", "(", "self", ",", "volume_id", ",", "reason", "=", "'No longer needed'", ",", "immediate", "=", "False", ")", ":", "block_volume", "=", "self", ".", "get_block_volume_details", "(", "volume_id", ",", "mask", "=", "'mask[id,billingItem[id,hourlyFlag]]'", ")", "if", "'billingItem'", "not", "in", "block_volume", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"Block Storage was already cancelled\"", ")", "billing_item_id", "=", "block_volume", "[", "'billingItem'", "]", "[", "'id'", "]", "if", "utils", ".", "lookup", "(", "block_volume", ",", "'billingItem'", ",", "'hourlyFlag'", ")", ":", "immediate", "=", "True", "return", "self", ".", "client", "[", "'Billing_Item'", "]", ".", "cancelItem", "(", "immediate", ",", "True", ",", "reason", ",", "id", "=", "billing_item_id", ")" ]
Cancels the given block storage volume. :param integer volume_id: The volume ID :param string reason: The reason for cancellation :param boolean immediate_flag: Cancel immediately or on anniversary date
[ "Cancels", "the", "given", "block", "storage", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L501-L526
1,552
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.failover_to_replicant
def failover_to_replicant(self, volume_id, replicant_id, immediate=False): """Failover to a volume replicant. :param integer volume_id: The id of the volume :param integer replicant_id: ID of replicant to failover to :param boolean immediate: Flag indicating if failover is immediate :return: Returns whether failover was successful or not """ return self.client.call('Network_Storage', 'failoverToReplicant', replicant_id, immediate, id=volume_id)
python
def failover_to_replicant(self, volume_id, replicant_id, immediate=False): """Failover to a volume replicant. :param integer volume_id: The id of the volume :param integer replicant_id: ID of replicant to failover to :param boolean immediate: Flag indicating if failover is immediate :return: Returns whether failover was successful or not """ return self.client.call('Network_Storage', 'failoverToReplicant', replicant_id, immediate, id=volume_id)
[ "def", "failover_to_replicant", "(", "self", ",", "volume_id", ",", "replicant_id", ",", "immediate", "=", "False", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'failoverToReplicant'", ",", "replicant_id", ",", "immediate", ",", "id", "=", "volume_id", ")" ]
Failover to a volume replicant. :param integer volume_id: The id of the volume :param integer replicant_id: ID of replicant to failover to :param boolean immediate: Flag indicating if failover is immediate :return: Returns whether failover was successful or not
[ "Failover", "to", "a", "volume", "replicant", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L528-L538
1,553
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.failback_from_replicant
def failback_from_replicant(self, volume_id, replicant_id): """Failback from a volume replicant. :param integer volume_id: The id of the volume :param integer replicant_id: ID of replicant to failback from :return: Returns whether failback was successful or not """ return self.client.call('Network_Storage', 'failbackFromReplicant', replicant_id, id=volume_id)
python
def failback_from_replicant(self, volume_id, replicant_id): """Failback from a volume replicant. :param integer volume_id: The id of the volume :param integer replicant_id: ID of replicant to failback from :return: Returns whether failback was successful or not """ return self.client.call('Network_Storage', 'failbackFromReplicant', replicant_id, id=volume_id)
[ "def", "failback_from_replicant", "(", "self", ",", "volume_id", ",", "replicant_id", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'failbackFromReplicant'", ",", "replicant_id", ",", "id", "=", "volume_id", ")" ]
Failback from a volume replicant. :param integer volume_id: The id of the volume :param integer replicant_id: ID of replicant to failback from :return: Returns whether failback was successful or not
[ "Failback", "from", "a", "volume", "replicant", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L540-L549
1,554
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.set_credential_password
def set_credential_password(self, access_id, password): """Sets the password for an access host :param integer access_id: id of the access host :param string password: password to set """ return self.client.call('Network_Storage_Allowed_Host', 'setCredentialPassword', password, id=access_id)
python
def set_credential_password(self, access_id, password): """Sets the password for an access host :param integer access_id: id of the access host :param string password: password to set """ return self.client.call('Network_Storage_Allowed_Host', 'setCredentialPassword', password, id=access_id)
[ "def", "set_credential_password", "(", "self", ",", "access_id", ",", "password", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage_Allowed_Host'", ",", "'setCredentialPassword'", ",", "password", ",", "id", "=", "access_id", ")" ]
Sets the password for an access host :param integer access_id: id of the access host :param string password: password to set
[ "Sets", "the", "password", "for", "an", "access", "host" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L551-L559
1,555
softlayer/softlayer-python
SoftLayer/managers/block.py
BlockStorageManager.create_or_update_lun_id
def create_or_update_lun_id(self, volume_id, lun_id): """Set the LUN ID on a volume. :param integer volume_id: The id of the volume :param integer lun_id: LUN ID to set on the volume :return: a SoftLayer_Network_Storage_Property object """ return self.client.call('Network_Storage', 'createOrUpdateLunId', lun_id, id=volume_id)
python
def create_or_update_lun_id(self, volume_id, lun_id): """Set the LUN ID on a volume. :param integer volume_id: The id of the volume :param integer lun_id: LUN ID to set on the volume :return: a SoftLayer_Network_Storage_Property object """ return self.client.call('Network_Storage', 'createOrUpdateLunId', lun_id, id=volume_id)
[ "def", "create_or_update_lun_id", "(", "self", ",", "volume_id", ",", "lun_id", ")", ":", "return", "self", ".", "client", ".", "call", "(", "'Network_Storage'", ",", "'createOrUpdateLunId'", ",", "lun_id", ",", "id", "=", "volume_id", ")" ]
Set the LUN ID on a volume. :param integer volume_id: The id of the volume :param integer lun_id: LUN ID to set on the volume :return: a SoftLayer_Network_Storage_Property object
[ "Set", "the", "LUN", "ID", "on", "a", "volume", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L561-L569
1,556
softlayer/softlayer-python
SoftLayer/CLI/summary.py
cli
def cli(env, sortby): """Account summary.""" mgr = SoftLayer.NetworkManager(env.client) datacenters = mgr.summary_by_datacenter() table = formatting.Table(COLUMNS) table.sortby = sortby for name, datacenter in datacenters.items(): table.add_row([ name, datacenter['hardware_count'], datacenter['virtual_guest_count'], datacenter['vlan_count'], datacenter['subnet_count'], datacenter['public_ip_count'], ]) env.fout(table)
python
def cli(env, sortby): """Account summary.""" mgr = SoftLayer.NetworkManager(env.client) datacenters = mgr.summary_by_datacenter() table = formatting.Table(COLUMNS) table.sortby = sortby for name, datacenter in datacenters.items(): table.add_row([ name, datacenter['hardware_count'], datacenter['virtual_guest_count'], datacenter['vlan_count'], datacenter['subnet_count'], datacenter['public_ip_count'], ]) env.fout(table)
[ "def", "cli", "(", "env", ",", "sortby", ")", ":", "mgr", "=", "SoftLayer", ".", "NetworkManager", "(", "env", ".", "client", ")", "datacenters", "=", "mgr", ".", "summary_by_datacenter", "(", ")", "table", "=", "formatting", ".", "Table", "(", "COLUMNS", ")", "table", ".", "sortby", "=", "sortby", "for", "name", ",", "datacenter", "in", "datacenters", ".", "items", "(", ")", ":", "table", ".", "add_row", "(", "[", "name", ",", "datacenter", "[", "'hardware_count'", "]", ",", "datacenter", "[", "'virtual_guest_count'", "]", ",", "datacenter", "[", "'vlan_count'", "]", ",", "datacenter", "[", "'subnet_count'", "]", ",", "datacenter", "[", "'public_ip_count'", "]", ",", "]", ")", "env", ".", "fout", "(", "table", ")" ]
Account summary.
[ "Account", "summary", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/summary.py#L25-L44
1,557
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_packages_of_type
def get_packages_of_type(self, package_types, mask=None): """Get packages that match a certain type. Each ordering package has a type, so return all packages that match the types we are looking for :param list package_types: List of strings representing the package type keynames we are interested in. :param string mask: Mask to specify the properties we want to retrieve """ _filter = { 'type': { 'keyName': { 'operation': 'in', 'options': [ {'name': 'data', 'value': package_types} ], }, }, } packages = self.package_svc.getAllObjects(mask=mask, filter=_filter) packages = self.filter_outlet_packages(packages) return packages
python
def get_packages_of_type(self, package_types, mask=None): """Get packages that match a certain type. Each ordering package has a type, so return all packages that match the types we are looking for :param list package_types: List of strings representing the package type keynames we are interested in. :param string mask: Mask to specify the properties we want to retrieve """ _filter = { 'type': { 'keyName': { 'operation': 'in', 'options': [ {'name': 'data', 'value': package_types} ], }, }, } packages = self.package_svc.getAllObjects(mask=mask, filter=_filter) packages = self.filter_outlet_packages(packages) return packages
[ "def", "get_packages_of_type", "(", "self", ",", "package_types", ",", "mask", "=", "None", ")", ":", "_filter", "=", "{", "'type'", ":", "{", "'keyName'", ":", "{", "'operation'", ":", "'in'", ",", "'options'", ":", "[", "{", "'name'", ":", "'data'", ",", "'value'", ":", "package_types", "}", "]", ",", "}", ",", "}", ",", "}", "packages", "=", "self", ".", "package_svc", ".", "getAllObjects", "(", "mask", "=", "mask", ",", "filter", "=", "_filter", ")", "packages", "=", "self", ".", "filter_outlet_packages", "(", "packages", ")", "return", "packages" ]
Get packages that match a certain type. Each ordering package has a type, so return all packages that match the types we are looking for :param list package_types: List of strings representing the package type keynames we are interested in. :param string mask: Mask to specify the properties we want to retrieve
[ "Get", "packages", "that", "match", "a", "certain", "type", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L40-L65
1,558
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.filter_outlet_packages
def filter_outlet_packages(packages): """Remove packages designated as OUTLET. Those type of packages must be handled in a different way, and they are not supported at the moment. :param packages: Dictionary of packages. Name and description keys must be present in each of them. """ non_outlet_packages = [] for package in packages: if all(['OUTLET' not in package.get('description', '').upper(), 'OUTLET' not in package.get('name', '').upper()]): non_outlet_packages.append(package) return non_outlet_packages
python
def filter_outlet_packages(packages): """Remove packages designated as OUTLET. Those type of packages must be handled in a different way, and they are not supported at the moment. :param packages: Dictionary of packages. Name and description keys must be present in each of them. """ non_outlet_packages = [] for package in packages: if all(['OUTLET' not in package.get('description', '').upper(), 'OUTLET' not in package.get('name', '').upper()]): non_outlet_packages.append(package) return non_outlet_packages
[ "def", "filter_outlet_packages", "(", "packages", ")", ":", "non_outlet_packages", "=", "[", "]", "for", "package", "in", "packages", ":", "if", "all", "(", "[", "'OUTLET'", "not", "in", "package", ".", "get", "(", "'description'", ",", "''", ")", ".", "upper", "(", ")", ",", "'OUTLET'", "not", "in", "package", ".", "get", "(", "'name'", ",", "''", ")", ".", "upper", "(", ")", "]", ")", ":", "non_outlet_packages", ".", "append", "(", "package", ")", "return", "non_outlet_packages" ]
Remove packages designated as OUTLET. Those type of packages must be handled in a different way, and they are not supported at the moment. :param packages: Dictionary of packages. Name and description keys must be present in each of them.
[ "Remove", "packages", "designated", "as", "OUTLET", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L68-L85
1,559
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_only_active_packages
def get_only_active_packages(packages): """Return only active packages. If a package is active, it is eligible for ordering This will inspect the 'isActive' property on the provided packages :param packages: Dictionary of packages, isActive key must be present """ active_packages = [] for package in packages: if package['isActive']: active_packages.append(package) return active_packages
python
def get_only_active_packages(packages): """Return only active packages. If a package is active, it is eligible for ordering This will inspect the 'isActive' property on the provided packages :param packages: Dictionary of packages, isActive key must be present """ active_packages = [] for package in packages: if package['isActive']: active_packages.append(package) return active_packages
[ "def", "get_only_active_packages", "(", "packages", ")", ":", "active_packages", "=", "[", "]", "for", "package", "in", "packages", ":", "if", "package", "[", "'isActive'", "]", ":", "active_packages", ".", "append", "(", "package", ")", "return", "active_packages" ]
Return only active packages. If a package is active, it is eligible for ordering This will inspect the 'isActive' property on the provided packages :param packages: Dictionary of packages, isActive key must be present
[ "Return", "only", "active", "packages", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L88-L103
1,560
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_package_by_type
def get_package_by_type(self, package_type, mask=None): """Get a single package of a given type. Syntactic sugar to retrieve a single package of a given type. If multiple packages share the given type, this will return the first one returned by the API. If no packages are found, returns None :param string package_type: representing the package type key name we are interested in """ packages = self.get_packages_of_type([package_type], mask) if len(packages) == 0: return None else: return packages.pop()
python
def get_package_by_type(self, package_type, mask=None): """Get a single package of a given type. Syntactic sugar to retrieve a single package of a given type. If multiple packages share the given type, this will return the first one returned by the API. If no packages are found, returns None :param string package_type: representing the package type key name we are interested in """ packages = self.get_packages_of_type([package_type], mask) if len(packages) == 0: return None else: return packages.pop()
[ "def", "get_package_by_type", "(", "self", ",", "package_type", ",", "mask", "=", "None", ")", ":", "packages", "=", "self", ".", "get_packages_of_type", "(", "[", "package_type", "]", ",", "mask", ")", "if", "len", "(", "packages", ")", "==", "0", ":", "return", "None", "else", ":", "return", "packages", ".", "pop", "(", ")" ]
Get a single package of a given type. Syntactic sugar to retrieve a single package of a given type. If multiple packages share the given type, this will return the first one returned by the API. If no packages are found, returns None :param string package_type: representing the package type key name we are interested in
[ "Get", "a", "single", "package", "of", "a", "given", "type", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L105-L119
1,561
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_package_id_by_type
def get_package_id_by_type(self, package_type): """Return the package ID of a Product Package with a given type. :param string package_type: representing the package type key name we are interested in :raises ValueError: when no package of the given type is found """ mask = "mask[id, name, description, isActive, type[keyName]]" package = self.get_package_by_type(package_type, mask) if package: return package['id'] else: raise ValueError("No package found for type: " + package_type)
python
def get_package_id_by_type(self, package_type): """Return the package ID of a Product Package with a given type. :param string package_type: representing the package type key name we are interested in :raises ValueError: when no package of the given type is found """ mask = "mask[id, name, description, isActive, type[keyName]]" package = self.get_package_by_type(package_type, mask) if package: return package['id'] else: raise ValueError("No package found for type: " + package_type)
[ "def", "get_package_id_by_type", "(", "self", ",", "package_type", ")", ":", "mask", "=", "\"mask[id, name, description, isActive, type[keyName]]\"", "package", "=", "self", ".", "get_package_by_type", "(", "package_type", ",", "mask", ")", "if", "package", ":", "return", "package", "[", "'id'", "]", "else", ":", "raise", "ValueError", "(", "\"No package found for type: \"", "+", "package_type", ")" ]
Return the package ID of a Product Package with a given type. :param string package_type: representing the package type key name we are interested in :raises ValueError: when no package of the given type is found
[ "Return", "the", "package", "ID", "of", "a", "Product", "Package", "with", "a", "given", "type", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L121-L133
1,562
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_quotes
def get_quotes(self): """Retrieve a list of active quotes. :returns: a list of SoftLayer_Billing_Order_Quote """ mask = "mask[order[id,items[id,package[id,keyName]]]]" quotes = self.client['Account'].getActiveQuotes(mask=mask) return quotes
python
def get_quotes(self): """Retrieve a list of active quotes. :returns: a list of SoftLayer_Billing_Order_Quote """ mask = "mask[order[id,items[id,package[id,keyName]]]]" quotes = self.client['Account'].getActiveQuotes(mask=mask) return quotes
[ "def", "get_quotes", "(", "self", ")", ":", "mask", "=", "\"mask[order[id,items[id,package[id,keyName]]]]\"", "quotes", "=", "self", ".", "client", "[", "'Account'", "]", ".", "getActiveQuotes", "(", "mask", "=", "mask", ")", "return", "quotes" ]
Retrieve a list of active quotes. :returns: a list of SoftLayer_Billing_Order_Quote
[ "Retrieve", "a", "list", "of", "active", "quotes", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L135-L142
1,563
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_quote_details
def get_quote_details(self, quote_id): """Retrieve quote details. :param quote_id: ID number of target quote """ mask = "mask[order[id,items[package[id,keyName]]]]" quote = self.client['Billing_Order_Quote'].getObject(id=quote_id, mask=mask) return quote
python
def get_quote_details(self, quote_id): """Retrieve quote details. :param quote_id: ID number of target quote """ mask = "mask[order[id,items[package[id,keyName]]]]" quote = self.client['Billing_Order_Quote'].getObject(id=quote_id, mask=mask) return quote
[ "def", "get_quote_details", "(", "self", ",", "quote_id", ")", ":", "mask", "=", "\"mask[order[id,items[package[id,keyName]]]]\"", "quote", "=", "self", ".", "client", "[", "'Billing_Order_Quote'", "]", ".", "getObject", "(", "id", "=", "quote_id", ",", "mask", "=", "mask", ")", "return", "quote" ]
Retrieve quote details. :param quote_id: ID number of target quote
[ "Retrieve", "quote", "details", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L144-L152
1,564
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_order_container
def get_order_container(self, quote_id): """Generate an order container from a quote object. :param quote_id: ID number of target quote """ quote = self.client['Billing_Order_Quote'] container = quote.getRecalculatedOrderContainer(id=quote_id) return container
python
def get_order_container(self, quote_id): """Generate an order container from a quote object. :param quote_id: ID number of target quote """ quote = self.client['Billing_Order_Quote'] container = quote.getRecalculatedOrderContainer(id=quote_id) return container
[ "def", "get_order_container", "(", "self", ",", "quote_id", ")", ":", "quote", "=", "self", ".", "client", "[", "'Billing_Order_Quote'", "]", "container", "=", "quote", ".", "getRecalculatedOrderContainer", "(", "id", "=", "quote_id", ")", "return", "container" ]
Generate an order container from a quote object. :param quote_id: ID number of target quote
[ "Generate", "an", "order", "container", "from", "a", "quote", "object", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L154-L162
1,565
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.generate_order_template
def generate_order_template(self, quote_id, extra, quantity=1): """Generate a complete order template. :param int quote_id: ID of target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Number of items to order. """ if not isinstance(extra, dict): raise ValueError("extra is not formatted properly") container = self.get_order_container(quote_id) container['quantity'] = quantity for key in extra.keys(): container[key] = extra[key] return container
python
def generate_order_template(self, quote_id, extra, quantity=1): """Generate a complete order template. :param int quote_id: ID of target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Number of items to order. """ if not isinstance(extra, dict): raise ValueError("extra is not formatted properly") container = self.get_order_container(quote_id) container['quantity'] = quantity for key in extra.keys(): container[key] = extra[key] return container
[ "def", "generate_order_template", "(", "self", ",", "quote_id", ",", "extra", ",", "quantity", "=", "1", ")", ":", "if", "not", "isinstance", "(", "extra", ",", "dict", ")", ":", "raise", "ValueError", "(", "\"extra is not formatted properly\"", ")", "container", "=", "self", ".", "get_order_container", "(", "quote_id", ")", "container", "[", "'quantity'", "]", "=", "quantity", "for", "key", "in", "extra", ".", "keys", "(", ")", ":", "container", "[", "key", "]", "=", "extra", "[", "key", "]", "return", "container" ]
Generate a complete order template. :param int quote_id: ID of target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Number of items to order.
[ "Generate", "a", "complete", "order", "template", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L164-L181
1,566
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.verify_quote
def verify_quote(self, quote_id, extra): """Verifies that a quote order is valid. :: extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.verify_quote(12345, extras) :param int quote_id: ID for the target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Quantity to override default """ container = self.generate_order_template(quote_id, extra) clean_container = {} # There are a few fields that wil cause exceptions in the XML endpoing if you send in '' # reservedCapacityId and hostId specifically. But we clean all just to be safe. # This for some reason is only a problem on verify_quote. for key in container.keys(): if container.get(key) != '': clean_container[key] = container[key] return self.client.call('SoftLayer_Billing_Order_Quote', 'verifyOrder', clean_container, id=quote_id)
python
def verify_quote(self, quote_id, extra): """Verifies that a quote order is valid. :: extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.verify_quote(12345, extras) :param int quote_id: ID for the target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Quantity to override default """ container = self.generate_order_template(quote_id, extra) clean_container = {} # There are a few fields that wil cause exceptions in the XML endpoing if you send in '' # reservedCapacityId and hostId specifically. But we clean all just to be safe. # This for some reason is only a problem on verify_quote. for key in container.keys(): if container.get(key) != '': clean_container[key] = container[key] return self.client.call('SoftLayer_Billing_Order_Quote', 'verifyOrder', clean_container, id=quote_id)
[ "def", "verify_quote", "(", "self", ",", "quote_id", ",", "extra", ")", ":", "container", "=", "self", ".", "generate_order_template", "(", "quote_id", ",", "extra", ")", "clean_container", "=", "{", "}", "# There are a few fields that wil cause exceptions in the XML endpoing if you send in ''", "# reservedCapacityId and hostId specifically. But we clean all just to be safe.", "# This for some reason is only a problem on verify_quote.", "for", "key", "in", "container", ".", "keys", "(", ")", ":", "if", "container", ".", "get", "(", "key", ")", "!=", "''", ":", "clean_container", "[", "key", "]", "=", "container", "[", "key", "]", "return", "self", ".", "client", ".", "call", "(", "'SoftLayer_Billing_Order_Quote'", ",", "'verifyOrder'", ",", "clean_container", ",", "id", "=", "quote_id", ")" ]
Verifies that a quote order is valid. :: extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.verify_quote(12345, extras) :param int quote_id: ID for the target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Quantity to override default
[ "Verifies", "that", "a", "quote", "order", "is", "valid", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L183-L210
1,567
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.order_quote
def order_quote(self, quote_id, extra): """Places an order using a quote :: extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.order_quote(12345, extras) :param int quote_id: ID for the target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Quantity to override default """ container = self.generate_order_template(quote_id, extra) return self.client.call('SoftLayer_Billing_Order_Quote', 'placeOrder', container, id=quote_id)
python
def order_quote(self, quote_id, extra): """Places an order using a quote :: extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.order_quote(12345, extras) :param int quote_id: ID for the target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Quantity to override default """ container = self.generate_order_template(quote_id, extra) return self.client.call('SoftLayer_Billing_Order_Quote', 'placeOrder', container, id=quote_id)
[ "def", "order_quote", "(", "self", ",", "quote_id", ",", "extra", ")", ":", "container", "=", "self", ".", "generate_order_template", "(", "quote_id", ",", "extra", ")", "return", "self", ".", "client", ".", "call", "(", "'SoftLayer_Billing_Order_Quote'", ",", "'placeOrder'", ",", "container", ",", "id", "=", "quote_id", ")" ]
Places an order using a quote :: extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.order_quote(12345, extras) :param int quote_id: ID for the target quote :param dictionary extra: Overrides for the defaults of SoftLayer_Container_Product_Order :param int quantity: Quantity to override default
[ "Places", "an", "order", "using", "a", "quote" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L212-L230
1,568
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_package_by_key
def get_package_by_key(self, package_keyname, mask=None): """Get a single package with a given key. If no packages are found, returns None :param package_keyname: string representing the package key name we are interested in. :param string mask: Mask to specify the properties we want to retrieve """ _filter = {'keyName': {'operation': package_keyname}} packages = self.package_svc.getAllObjects(mask=mask, filter=_filter) if len(packages) == 0: raise exceptions.SoftLayerError("Package {} does not exist".format(package_keyname)) return packages.pop()
python
def get_package_by_key(self, package_keyname, mask=None): """Get a single package with a given key. If no packages are found, returns None :param package_keyname: string representing the package key name we are interested in. :param string mask: Mask to specify the properties we want to retrieve """ _filter = {'keyName': {'operation': package_keyname}} packages = self.package_svc.getAllObjects(mask=mask, filter=_filter) if len(packages) == 0: raise exceptions.SoftLayerError("Package {} does not exist".format(package_keyname)) return packages.pop()
[ "def", "get_package_by_key", "(", "self", ",", "package_keyname", ",", "mask", "=", "None", ")", ":", "_filter", "=", "{", "'keyName'", ":", "{", "'operation'", ":", "package_keyname", "}", "}", "packages", "=", "self", ".", "package_svc", ".", "getAllObjects", "(", "mask", "=", "mask", ",", "filter", "=", "_filter", ")", "if", "len", "(", "packages", ")", "==", "0", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"Package {} does not exist\"", ".", "format", "(", "package_keyname", ")", ")", "return", "packages", ".", "pop", "(", ")" ]
Get a single package with a given key. If no packages are found, returns None :param package_keyname: string representing the package key name we are interested in. :param string mask: Mask to specify the properties we want to retrieve
[ "Get", "a", "single", "package", "with", "a", "given", "key", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L232-L246
1,569
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.list_categories
def list_categories(self, package_keyname, **kwargs): """List the categories for the given package. :param str package_keyname: The package for which to get the categories. :returns: List of categories associated with the package """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', CATEGORY_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] package = self.get_package_by_key(package_keyname, mask='id') categories = self.package_svc.getConfiguration(id=package['id'], **get_kwargs) return categories
python
def list_categories(self, package_keyname, **kwargs): """List the categories for the given package. :param str package_keyname: The package for which to get the categories. :returns: List of categories associated with the package """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', CATEGORY_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] package = self.get_package_by_key(package_keyname, mask='id') categories = self.package_svc.getConfiguration(id=package['id'], **get_kwargs) return categories
[ "def", "list_categories", "(", "self", ",", "package_keyname", ",", "*", "*", "kwargs", ")", ":", "get_kwargs", "=", "{", "}", "get_kwargs", "[", "'mask'", "]", "=", "kwargs", ".", "get", "(", "'mask'", ",", "CATEGORY_MASK", ")", "if", "'filter'", "in", "kwargs", ":", "get_kwargs", "[", "'filter'", "]", "=", "kwargs", "[", "'filter'", "]", "package", "=", "self", ".", "get_package_by_key", "(", "package_keyname", ",", "mask", "=", "'id'", ")", "categories", "=", "self", ".", "package_svc", ".", "getConfiguration", "(", "id", "=", "package", "[", "'id'", "]", ",", "*", "*", "get_kwargs", ")", "return", "categories" ]
List the categories for the given package. :param str package_keyname: The package for which to get the categories. :returns: List of categories associated with the package
[ "List", "the", "categories", "for", "the", "given", "package", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L248-L262
1,570
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.list_items
def list_items(self, package_keyname, **kwargs): """List the items for the given package. :param str package_keyname: The package for which to get the items. :returns: List of items in the package """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', ITEM_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] package = self.get_package_by_key(package_keyname, mask='id') items = self.package_svc.getItems(id=package['id'], **get_kwargs) return items
python
def list_items(self, package_keyname, **kwargs): """List the items for the given package. :param str package_keyname: The package for which to get the items. :returns: List of items in the package """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', ITEM_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] package = self.get_package_by_key(package_keyname, mask='id') items = self.package_svc.getItems(id=package['id'], **get_kwargs) return items
[ "def", "list_items", "(", "self", ",", "package_keyname", ",", "*", "*", "kwargs", ")", ":", "get_kwargs", "=", "{", "}", "get_kwargs", "[", "'mask'", "]", "=", "kwargs", ".", "get", "(", "'mask'", ",", "ITEM_MASK", ")", "if", "'filter'", "in", "kwargs", ":", "get_kwargs", "[", "'filter'", "]", "=", "kwargs", "[", "'filter'", "]", "package", "=", "self", ".", "get_package_by_key", "(", "package_keyname", ",", "mask", "=", "'id'", ")", "items", "=", "self", ".", "package_svc", ".", "getItems", "(", "id", "=", "package", "[", "'id'", "]", ",", "*", "*", "get_kwargs", ")", "return", "items" ]
List the items for the given package. :param str package_keyname: The package for which to get the items. :returns: List of items in the package
[ "List", "the", "items", "for", "the", "given", "package", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L264-L279
1,571
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.list_packages
def list_packages(self, **kwargs): """List active packages. :returns: List of active packages. """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', PACKAGE_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] packages = self.package_svc.getAllObjects(**get_kwargs) return [package for package in packages if package['isActive']]
python
def list_packages(self, **kwargs): """List active packages. :returns: List of active packages. """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', PACKAGE_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] packages = self.package_svc.getAllObjects(**get_kwargs) return [package for package in packages if package['isActive']]
[ "def", "list_packages", "(", "self", ",", "*", "*", "kwargs", ")", ":", "get_kwargs", "=", "{", "}", "get_kwargs", "[", "'mask'", "]", "=", "kwargs", ".", "get", "(", "'mask'", ",", "PACKAGE_MASK", ")", "if", "'filter'", "in", "kwargs", ":", "get_kwargs", "[", "'filter'", "]", "=", "kwargs", "[", "'filter'", "]", "packages", "=", "self", ".", "package_svc", ".", "getAllObjects", "(", "*", "*", "get_kwargs", ")", "return", "[", "package", "for", "package", "in", "packages", "if", "package", "[", "'isActive'", "]", "]" ]
List active packages. :returns: List of active packages.
[ "List", "active", "packages", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L281-L295
1,572
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.list_presets
def list_presets(self, package_keyname, **kwargs): """Gets active presets for the given package. :param str package_keyname: The package for which to get presets :returns: A list of package presets that can be used for ordering """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', PRESET_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] package = self.get_package_by_key(package_keyname, mask='id') acc_presets = self.package_svc.getAccountRestrictedActivePresets(id=package['id'], **get_kwargs) active_presets = self.package_svc.getActivePresets(id=package['id'], **get_kwargs) return active_presets + acc_presets
python
def list_presets(self, package_keyname, **kwargs): """Gets active presets for the given package. :param str package_keyname: The package for which to get presets :returns: A list of package presets that can be used for ordering """ get_kwargs = {} get_kwargs['mask'] = kwargs.get('mask', PRESET_MASK) if 'filter' in kwargs: get_kwargs['filter'] = kwargs['filter'] package = self.get_package_by_key(package_keyname, mask='id') acc_presets = self.package_svc.getAccountRestrictedActivePresets(id=package['id'], **get_kwargs) active_presets = self.package_svc.getActivePresets(id=package['id'], **get_kwargs) return active_presets + acc_presets
[ "def", "list_presets", "(", "self", ",", "package_keyname", ",", "*", "*", "kwargs", ")", ":", "get_kwargs", "=", "{", "}", "get_kwargs", "[", "'mask'", "]", "=", "kwargs", ".", "get", "(", "'mask'", ",", "PRESET_MASK", ")", "if", "'filter'", "in", "kwargs", ":", "get_kwargs", "[", "'filter'", "]", "=", "kwargs", "[", "'filter'", "]", "package", "=", "self", ".", "get_package_by_key", "(", "package_keyname", ",", "mask", "=", "'id'", ")", "acc_presets", "=", "self", ".", "package_svc", ".", "getAccountRestrictedActivePresets", "(", "id", "=", "package", "[", "'id'", "]", ",", "*", "*", "get_kwargs", ")", "active_presets", "=", "self", ".", "package_svc", ".", "getActivePresets", "(", "id", "=", "package", "[", "'id'", "]", ",", "*", "*", "get_kwargs", ")", "return", "active_presets", "+", "acc_presets" ]
Gets active presets for the given package. :param str package_keyname: The package for which to get presets :returns: A list of package presets that can be used for ordering
[ "Gets", "active", "presets", "for", "the", "given", "package", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L297-L313
1,573
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_preset_by_key
def get_preset_by_key(self, package_keyname, preset_keyname, mask=None): """Gets a single preset with the given key.""" preset_operation = '_= %s' % preset_keyname _filter = { 'activePresets': { 'keyName': { 'operation': preset_operation } }, 'accountRestrictedActivePresets': { 'keyName': { 'operation': preset_operation } } } presets = self.list_presets(package_keyname, mask=mask, filter=_filter) if len(presets) == 0: raise exceptions.SoftLayerError( "Preset {} does not exist in package {}".format(preset_keyname, package_keyname)) return presets[0]
python
def get_preset_by_key(self, package_keyname, preset_keyname, mask=None): """Gets a single preset with the given key.""" preset_operation = '_= %s' % preset_keyname _filter = { 'activePresets': { 'keyName': { 'operation': preset_operation } }, 'accountRestrictedActivePresets': { 'keyName': { 'operation': preset_operation } } } presets = self.list_presets(package_keyname, mask=mask, filter=_filter) if len(presets) == 0: raise exceptions.SoftLayerError( "Preset {} does not exist in package {}".format(preset_keyname, package_keyname)) return presets[0]
[ "def", "get_preset_by_key", "(", "self", ",", "package_keyname", ",", "preset_keyname", ",", "mask", "=", "None", ")", ":", "preset_operation", "=", "'_= %s'", "%", "preset_keyname", "_filter", "=", "{", "'activePresets'", ":", "{", "'keyName'", ":", "{", "'operation'", ":", "preset_operation", "}", "}", ",", "'accountRestrictedActivePresets'", ":", "{", "'keyName'", ":", "{", "'operation'", ":", "preset_operation", "}", "}", "}", "presets", "=", "self", ".", "list_presets", "(", "package_keyname", ",", "mask", "=", "mask", ",", "filter", "=", "_filter", ")", "if", "len", "(", "presets", ")", "==", "0", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"Preset {} does not exist in package {}\"", ".", "format", "(", "preset_keyname", ",", "package_keyname", ")", ")", "return", "presets", "[", "0", "]" ]
Gets a single preset with the given key.
[ "Gets", "a", "single", "preset", "with", "the", "given", "key", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L315-L338
1,574
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_price_id_list
def get_price_id_list(self, package_keyname, item_keynames, core=None): """Converts a list of item keynames to a list of price IDs. This function is used to convert a list of item keynames into a list of price IDs that are used in the Product_Order verifyOrder() and placeOrder() functions. :param str package_keyname: The package associated with the prices :param list item_keynames: A list of item keyname strings :param str core: preset guest core capacity. :returns: A list of price IDs associated with the given item keynames in the given package """ mask = 'id, itemCategory, keyName, prices[categories]' items = self.list_items(package_keyname, mask=mask) prices = [] category_dict = {"gpu0": -1, "pcie_slot0": -1} for item_keyname in item_keynames: try: # Need to find the item in the package that has a matching # keyName with the current item we are searching for matching_item = [i for i in items if i['keyName'] == item_keyname][0] except IndexError: raise exceptions.SoftLayerError( "Item {} does not exist for package {}".format(item_keyname, package_keyname)) # we want to get the price ID that has no location attached to it, # because that is the most generic price. verifyOrder/placeOrder # can take that ID and create the proper price for us in the location # in which the order is made item_category = matching_item['itemCategory']['categoryCode'] if item_category not in category_dict: price_id = self.get_item_price_id(core, matching_item['prices']) else: # GPU and PCIe items has two generic prices and they are added to the list # according to the number of items in the order. category_dict[item_category] += 1 category_code = item_category[:-1] + str(category_dict[item_category]) price_id = [p['id'] for p in matching_item['prices'] if not p['locationGroupId'] and p['categories'][0]['categoryCode'] == category_code][0] prices.append(price_id) return prices
python
def get_price_id_list(self, package_keyname, item_keynames, core=None): """Converts a list of item keynames to a list of price IDs. This function is used to convert a list of item keynames into a list of price IDs that are used in the Product_Order verifyOrder() and placeOrder() functions. :param str package_keyname: The package associated with the prices :param list item_keynames: A list of item keyname strings :param str core: preset guest core capacity. :returns: A list of price IDs associated with the given item keynames in the given package """ mask = 'id, itemCategory, keyName, prices[categories]' items = self.list_items(package_keyname, mask=mask) prices = [] category_dict = {"gpu0": -1, "pcie_slot0": -1} for item_keyname in item_keynames: try: # Need to find the item in the package that has a matching # keyName with the current item we are searching for matching_item = [i for i in items if i['keyName'] == item_keyname][0] except IndexError: raise exceptions.SoftLayerError( "Item {} does not exist for package {}".format(item_keyname, package_keyname)) # we want to get the price ID that has no location attached to it, # because that is the most generic price. verifyOrder/placeOrder # can take that ID and create the proper price for us in the location # in which the order is made item_category = matching_item['itemCategory']['categoryCode'] if item_category not in category_dict: price_id = self.get_item_price_id(core, matching_item['prices']) else: # GPU and PCIe items has two generic prices and they are added to the list # according to the number of items in the order. category_dict[item_category] += 1 category_code = item_category[:-1] + str(category_dict[item_category]) price_id = [p['id'] for p in matching_item['prices'] if not p['locationGroupId'] and p['categories'][0]['categoryCode'] == category_code][0] prices.append(price_id) return prices
[ "def", "get_price_id_list", "(", "self", ",", "package_keyname", ",", "item_keynames", ",", "core", "=", "None", ")", ":", "mask", "=", "'id, itemCategory, keyName, prices[categories]'", "items", "=", "self", ".", "list_items", "(", "package_keyname", ",", "mask", "=", "mask", ")", "prices", "=", "[", "]", "category_dict", "=", "{", "\"gpu0\"", ":", "-", "1", ",", "\"pcie_slot0\"", ":", "-", "1", "}", "for", "item_keyname", "in", "item_keynames", ":", "try", ":", "# Need to find the item in the package that has a matching", "# keyName with the current item we are searching for", "matching_item", "=", "[", "i", "for", "i", "in", "items", "if", "i", "[", "'keyName'", "]", "==", "item_keyname", "]", "[", "0", "]", "except", "IndexError", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"Item {} does not exist for package {}\"", ".", "format", "(", "item_keyname", ",", "package_keyname", ")", ")", "# we want to get the price ID that has no location attached to it,", "# because that is the most generic price. verifyOrder/placeOrder", "# can take that ID and create the proper price for us in the location", "# in which the order is made", "item_category", "=", "matching_item", "[", "'itemCategory'", "]", "[", "'categoryCode'", "]", "if", "item_category", "not", "in", "category_dict", ":", "price_id", "=", "self", ".", "get_item_price_id", "(", "core", ",", "matching_item", "[", "'prices'", "]", ")", "else", ":", "# GPU and PCIe items has two generic prices and they are added to the list", "# according to the number of items in the order.", "category_dict", "[", "item_category", "]", "+=", "1", "category_code", "=", "item_category", "[", ":", "-", "1", "]", "+", "str", "(", "category_dict", "[", "item_category", "]", ")", "price_id", "=", "[", "p", "[", "'id'", "]", "for", "p", "in", "matching_item", "[", "'prices'", "]", "if", "not", "p", "[", "'locationGroupId'", "]", "and", "p", "[", "'categories'", "]", "[", "0", "]", "[", "'categoryCode'", "]", "==", "category_code", "]", "[", "0", "]", "prices", ".", "append", "(", "price_id", ")", "return", "prices" ]
Converts a list of item keynames to a list of price IDs. This function is used to convert a list of item keynames into a list of price IDs that are used in the Product_Order verifyOrder() and placeOrder() functions. :param str package_keyname: The package associated with the prices :param list item_keynames: A list of item keyname strings :param str core: preset guest core capacity. :returns: A list of price IDs associated with the given item keynames in the given package
[ "Converts", "a", "list", "of", "item", "keynames", "to", "a", "list", "of", "price", "IDs", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L340-L389
1,575
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_item_price_id
def get_item_price_id(core, prices): """get item price id""" price_id = None for price in prices: if not price['locationGroupId']: capacity_min = int(price.get('capacityRestrictionMinimum', -1)) capacity_max = int(price.get('capacityRestrictionMaximum', -1)) # return first match if no restirction, or no core to check if capacity_min == -1 or core is None: price_id = price['id'] # this check is mostly to work nicely with preset configs elif capacity_min <= int(core) <= capacity_max: price_id = price['id'] return price_id
python
def get_item_price_id(core, prices): """get item price id""" price_id = None for price in prices: if not price['locationGroupId']: capacity_min = int(price.get('capacityRestrictionMinimum', -1)) capacity_max = int(price.get('capacityRestrictionMaximum', -1)) # return first match if no restirction, or no core to check if capacity_min == -1 or core is None: price_id = price['id'] # this check is mostly to work nicely with preset configs elif capacity_min <= int(core) <= capacity_max: price_id = price['id'] return price_id
[ "def", "get_item_price_id", "(", "core", ",", "prices", ")", ":", "price_id", "=", "None", "for", "price", "in", "prices", ":", "if", "not", "price", "[", "'locationGroupId'", "]", ":", "capacity_min", "=", "int", "(", "price", ".", "get", "(", "'capacityRestrictionMinimum'", ",", "-", "1", ")", ")", "capacity_max", "=", "int", "(", "price", ".", "get", "(", "'capacityRestrictionMaximum'", ",", "-", "1", ")", ")", "# return first match if no restirction, or no core to check", "if", "capacity_min", "==", "-", "1", "or", "core", "is", "None", ":", "price_id", "=", "price", "[", "'id'", "]", "# this check is mostly to work nicely with preset configs", "elif", "capacity_min", "<=", "int", "(", "core", ")", "<=", "capacity_max", ":", "price_id", "=", "price", "[", "'id'", "]", "return", "price_id" ]
get item price id
[ "get", "item", "price", "id" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L392-L405
1,576
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_preset_prices
def get_preset_prices(self, preset): """Get preset item prices. Retrieve a SoftLayer_Product_Package_Preset record. :param int preset: preset identifier. :returns: A list of price IDs associated with the given preset_id. """ mask = 'mask[prices[item]]' prices = self.package_preset.getObject(id=preset, mask=mask) return prices
python
def get_preset_prices(self, preset): """Get preset item prices. Retrieve a SoftLayer_Product_Package_Preset record. :param int preset: preset identifier. :returns: A list of price IDs associated with the given preset_id. """ mask = 'mask[prices[item]]' prices = self.package_preset.getObject(id=preset, mask=mask) return prices
[ "def", "get_preset_prices", "(", "self", ",", "preset", ")", ":", "mask", "=", "'mask[prices[item]]'", "prices", "=", "self", ".", "package_preset", ".", "getObject", "(", "id", "=", "preset", ",", "mask", "=", "mask", ")", "return", "prices" ]
Get preset item prices. Retrieve a SoftLayer_Product_Package_Preset record. :param int preset: preset identifier. :returns: A list of price IDs associated with the given preset_id.
[ "Get", "preset", "item", "prices", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L407-L419
1,577
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_item_prices
def get_item_prices(self, package_id): """Get item prices. Retrieve a SoftLayer_Product_Package item prices record. :param int package_id: package identifier. :returns: A list of price IDs associated with the given package. """ mask = 'mask[pricingLocationGroup[locations]]' prices = self.package_svc.getItemPrices(id=package_id, mask=mask) return prices
python
def get_item_prices(self, package_id): """Get item prices. Retrieve a SoftLayer_Product_Package item prices record. :param int package_id: package identifier. :returns: A list of price IDs associated with the given package. """ mask = 'mask[pricingLocationGroup[locations]]' prices = self.package_svc.getItemPrices(id=package_id, mask=mask) return prices
[ "def", "get_item_prices", "(", "self", ",", "package_id", ")", ":", "mask", "=", "'mask[pricingLocationGroup[locations]]'", "prices", "=", "self", ".", "package_svc", ".", "getItemPrices", "(", "id", "=", "package_id", ",", "mask", "=", "mask", ")", "return", "prices" ]
Get item prices. Retrieve a SoftLayer_Product_Package item prices record. :param int package_id: package identifier. :returns: A list of price IDs associated with the given package.
[ "Get", "item", "prices", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L421-L433
1,578
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.verify_order
def verify_order(self, package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1): """Verifies an order with the given package and prices. This function takes in parameters needed for an order and verifies the order to ensure the given items are compatible with the given package. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: 'virtualGuests': [{'hostname': 'test', 'domain': 'softlayer.com'}]} :param int quantity: The number of resources to order """ order = self.generate_order(package_keyname, location, item_keynames, complex_type=complex_type, hourly=hourly, preset_keyname=preset_keyname, extras=extras, quantity=quantity) return self.order_svc.verifyOrder(order)
python
def verify_order(self, package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1): """Verifies an order with the given package and prices. This function takes in parameters needed for an order and verifies the order to ensure the given items are compatible with the given package. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: 'virtualGuests': [{'hostname': 'test', 'domain': 'softlayer.com'}]} :param int quantity: The number of resources to order """ order = self.generate_order(package_keyname, location, item_keynames, complex_type=complex_type, hourly=hourly, preset_keyname=preset_keyname, extras=extras, quantity=quantity) return self.order_svc.verifyOrder(order)
[ "def", "verify_order", "(", "self", ",", "package_keyname", ",", "location", ",", "item_keynames", ",", "complex_type", "=", "None", ",", "hourly", "=", "True", ",", "preset_keyname", "=", "None", ",", "extras", "=", "None", ",", "quantity", "=", "1", ")", ":", "order", "=", "self", ".", "generate_order", "(", "package_keyname", ",", "location", ",", "item_keynames", ",", "complex_type", "=", "complex_type", ",", "hourly", "=", "hourly", ",", "preset_keyname", "=", "preset_keyname", ",", "extras", "=", "extras", ",", "quantity", "=", "quantity", ")", "return", "self", ".", "order_svc", ".", "verifyOrder", "(", "order", ")" ]
Verifies an order with the given package and prices. This function takes in parameters needed for an order and verifies the order to ensure the given items are compatible with the given package. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: 'virtualGuests': [{'hostname': 'test', 'domain': 'softlayer.com'}]} :param int quantity: The number of resources to order
[ "Verifies", "an", "order", "with", "the", "given", "package", "and", "prices", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L435-L464
1,579
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.place_order
def place_order(self, package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1): """Places an order with the given package and prices. This function takes in parameters needed for an order and places the order. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]} :param int quantity: The number of resources to order """ order = self.generate_order(package_keyname, location, item_keynames, complex_type=complex_type, hourly=hourly, preset_keyname=preset_keyname, extras=extras, quantity=quantity) return self.order_svc.placeOrder(order)
python
def place_order(self, package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1): """Places an order with the given package and prices. This function takes in parameters needed for an order and places the order. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]} :param int quantity: The number of resources to order """ order = self.generate_order(package_keyname, location, item_keynames, complex_type=complex_type, hourly=hourly, preset_keyname=preset_keyname, extras=extras, quantity=quantity) return self.order_svc.placeOrder(order)
[ "def", "place_order", "(", "self", ",", "package_keyname", ",", "location", ",", "item_keynames", ",", "complex_type", "=", "None", ",", "hourly", "=", "True", ",", "preset_keyname", "=", "None", ",", "extras", "=", "None", ",", "quantity", "=", "1", ")", ":", "order", "=", "self", ".", "generate_order", "(", "package_keyname", ",", "location", ",", "item_keynames", ",", "complex_type", "=", "complex_type", ",", "hourly", "=", "hourly", ",", "preset_keyname", "=", "preset_keyname", ",", "extras", "=", "extras", ",", "quantity", "=", "quantity", ")", "return", "self", ".", "order_svc", ".", "placeOrder", "(", "order", ")" ]
Places an order with the given package and prices. This function takes in parameters needed for an order and places the order. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]} :param int quantity: The number of resources to order
[ "Places", "an", "order", "with", "the", "given", "package", "and", "prices", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L466-L494
1,580
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.place_quote
def place_quote(self, package_keyname, location, item_keynames, complex_type=None, preset_keyname=None, extras=None, quantity=1, quote_name=None, send_email=False): """Place a quote with the given package and prices. This function takes in parameters needed for an order and places the quote. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]} :param int quantity: The number of resources to order :param string quote_name: A custom name to be assigned to the quote (optional). :param bool send_email: This flag indicates that the quote should be sent to the email address associated with the account or order. """ order = self.generate_order(package_keyname, location, item_keynames, complex_type=complex_type, hourly=False, preset_keyname=preset_keyname, extras=extras, quantity=quantity) order['quoteName'] = quote_name order['sendQuoteEmailFlag'] = send_email return self.order_svc.placeQuote(order)
python
def place_quote(self, package_keyname, location, item_keynames, complex_type=None, preset_keyname=None, extras=None, quantity=1, quote_name=None, send_email=False): """Place a quote with the given package and prices. This function takes in parameters needed for an order and places the quote. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]} :param int quantity: The number of resources to order :param string quote_name: A custom name to be assigned to the quote (optional). :param bool send_email: This flag indicates that the quote should be sent to the email address associated with the account or order. """ order = self.generate_order(package_keyname, location, item_keynames, complex_type=complex_type, hourly=False, preset_keyname=preset_keyname, extras=extras, quantity=quantity) order['quoteName'] = quote_name order['sendQuoteEmailFlag'] = send_email return self.order_svc.placeQuote(order)
[ "def", "place_quote", "(", "self", ",", "package_keyname", ",", "location", ",", "item_keynames", ",", "complex_type", "=", "None", ",", "preset_keyname", "=", "None", ",", "extras", "=", "None", ",", "quantity", "=", "1", ",", "quote_name", "=", "None", ",", "send_email", "=", "False", ")", ":", "order", "=", "self", ".", "generate_order", "(", "package_keyname", ",", "location", ",", "item_keynames", ",", "complex_type", "=", "complex_type", ",", "hourly", "=", "False", ",", "preset_keyname", "=", "preset_keyname", ",", "extras", "=", "extras", ",", "quantity", "=", "quantity", ")", "order", "[", "'quoteName'", "]", "=", "quote_name", "order", "[", "'sendQuoteEmailFlag'", "]", "=", "send_email", "return", "self", ".", "order_svc", ".", "placeQuote", "(", "order", ")" ]
Place a quote with the given package and prices. This function takes in parameters needed for an order and places the quote. :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]} :param int quantity: The number of resources to order :param string quote_name: A custom name to be assigned to the quote (optional). :param bool send_email: This flag indicates that the quote should be sent to the email address associated with the account or order.
[ "Place", "a", "quote", "with", "the", "given", "package", "and", "prices", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L496-L527
1,581
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.generate_order
def generate_order(self, package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1): """Generates an order with the given package and prices. This function takes in parameters needed for an order and generates an order dictionary. This dictionary can then be used in either verify or placeOrder(). :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', 'domain': 'softlayer.com'}]} :param int quantity: The number of resources to order """ container = {} order = {} extras = extras or {} package = self.get_package_by_key(package_keyname, mask='id') # if there was extra data given for the order, add it to the order # example: VSIs require hostname and domain set on the order, so # extras will be {'virtualGuests': [{'hostname': 'test', # 'domain': 'softlayer.com'}]} order.update(extras) order['packageId'] = package['id'] order['quantity'] = quantity order['location'] = self.get_location_id(location) order['useHourlyPricing'] = hourly preset_core = None if preset_keyname: preset_id = self.get_preset_by_key(package_keyname, preset_keyname)['id'] preset_items = self.get_preset_prices(preset_id) for item in preset_items['prices']: if item['item']['itemCategory']['categoryCode'] == "guest_core": preset_core = item['item']['capacity'] order['presetId'] = preset_id if not complex_type: raise exceptions.SoftLayerError("A complex type must be specified with the order") order['complexType'] = complex_type price_ids = self.get_price_id_list(package_keyname, item_keynames, preset_core) order['prices'] = [{'id': price_id} for price_id in price_ids] container['orderContainers'] = [order] return container
python
def generate_order(self, package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1): """Generates an order with the given package and prices. This function takes in parameters needed for an order and generates an order dictionary. This dictionary can then be used in either verify or placeOrder(). :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', 'domain': 'softlayer.com'}]} :param int quantity: The number of resources to order """ container = {} order = {} extras = extras or {} package = self.get_package_by_key(package_keyname, mask='id') # if there was extra data given for the order, add it to the order # example: VSIs require hostname and domain set on the order, so # extras will be {'virtualGuests': [{'hostname': 'test', # 'domain': 'softlayer.com'}]} order.update(extras) order['packageId'] = package['id'] order['quantity'] = quantity order['location'] = self.get_location_id(location) order['useHourlyPricing'] = hourly preset_core = None if preset_keyname: preset_id = self.get_preset_by_key(package_keyname, preset_keyname)['id'] preset_items = self.get_preset_prices(preset_id) for item in preset_items['prices']: if item['item']['itemCategory']['categoryCode'] == "guest_core": preset_core = item['item']['capacity'] order['presetId'] = preset_id if not complex_type: raise exceptions.SoftLayerError("A complex type must be specified with the order") order['complexType'] = complex_type price_ids = self.get_price_id_list(package_keyname, item_keynames, preset_core) order['prices'] = [{'id': price_id} for price_id in price_ids] container['orderContainers'] = [order] return container
[ "def", "generate_order", "(", "self", ",", "package_keyname", ",", "location", ",", "item_keynames", ",", "complex_type", "=", "None", ",", "hourly", "=", "True", ",", "preset_keyname", "=", "None", ",", "extras", "=", "None", ",", "quantity", "=", "1", ")", ":", "container", "=", "{", "}", "order", "=", "{", "}", "extras", "=", "extras", "or", "{", "}", "package", "=", "self", ".", "get_package_by_key", "(", "package_keyname", ",", "mask", "=", "'id'", ")", "# if there was extra data given for the order, add it to the order", "# example: VSIs require hostname and domain set on the order, so", "# extras will be {'virtualGuests': [{'hostname': 'test',", "# 'domain': 'softlayer.com'}]}", "order", ".", "update", "(", "extras", ")", "order", "[", "'packageId'", "]", "=", "package", "[", "'id'", "]", "order", "[", "'quantity'", "]", "=", "quantity", "order", "[", "'location'", "]", "=", "self", ".", "get_location_id", "(", "location", ")", "order", "[", "'useHourlyPricing'", "]", "=", "hourly", "preset_core", "=", "None", "if", "preset_keyname", ":", "preset_id", "=", "self", ".", "get_preset_by_key", "(", "package_keyname", ",", "preset_keyname", ")", "[", "'id'", "]", "preset_items", "=", "self", ".", "get_preset_prices", "(", "preset_id", ")", "for", "item", "in", "preset_items", "[", "'prices'", "]", ":", "if", "item", "[", "'item'", "]", "[", "'itemCategory'", "]", "[", "'categoryCode'", "]", "==", "\"guest_core\"", ":", "preset_core", "=", "item", "[", "'item'", "]", "[", "'capacity'", "]", "order", "[", "'presetId'", "]", "=", "preset_id", "if", "not", "complex_type", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"A complex type must be specified with the order\"", ")", "order", "[", "'complexType'", "]", "=", "complex_type", "price_ids", "=", "self", ".", "get_price_id_list", "(", "package_keyname", ",", "item_keynames", ",", "preset_core", ")", "order", "[", "'prices'", "]", "=", "[", "{", "'id'", ":", "price_id", "}", "for", "price_id", "in", "price_ids", "]", "container", "[", "'orderContainers'", "]", "=", "[", "order", "]", "return", "container" ]
Generates an order with the given package and prices. This function takes in parameters needed for an order and generates an order dictionary. This dictionary can then be used in either verify or placeOrder(). :param str package_keyname: The keyname for the package being ordered :param str location: The datacenter location string for ordering (Ex: DALLAS13) :param list item_keynames: The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or `slcli order item-list`) :param str complex_type: The complex type to send with the order. Typically begins with `SoftLayer_Container_Product_Order_`. :param bool hourly: If true, uses hourly billing, otherwise uses monthly billing :param string preset_keyname: If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or `slcli order preset-list`) :param dict extras: The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {'virtualGuests': [{'hostname': 'test', 'domain': 'softlayer.com'}]} :param int quantity: The number of resources to order
[ "Generates", "an", "order", "with", "the", "given", "package", "and", "prices", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L529-L588
1,582
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.package_locations
def package_locations(self, package_keyname): """List datacenter locations for a package keyname :param str package_keyname: The package for which to get the items. :returns: List of locations a package is orderable in """ mask = "mask[description, keyname, locations]" package = self.get_package_by_key(package_keyname, mask='id') regions = self.package_svc.getRegions(id=package['id'], mask=mask) return regions
python
def package_locations(self, package_keyname): """List datacenter locations for a package keyname :param str package_keyname: The package for which to get the items. :returns: List of locations a package is orderable in """ mask = "mask[description, keyname, locations]" package = self.get_package_by_key(package_keyname, mask='id') regions = self.package_svc.getRegions(id=package['id'], mask=mask) return regions
[ "def", "package_locations", "(", "self", ",", "package_keyname", ")", ":", "mask", "=", "\"mask[description, keyname, locations]\"", "package", "=", "self", ".", "get_package_by_key", "(", "package_keyname", ",", "mask", "=", "'id'", ")", "regions", "=", "self", ".", "package_svc", ".", "getRegions", "(", "id", "=", "package", "[", "'id'", "]", ",", "mask", "=", "mask", ")", "return", "regions" ]
List datacenter locations for a package keyname :param str package_keyname: The package for which to get the items. :returns: List of locations a package is orderable in
[ "List", "datacenter", "locations", "for", "a", "package", "keyname" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L590-L601
1,583
softlayer/softlayer-python
SoftLayer/managers/ordering.py
OrderingManager.get_location_id
def get_location_id(self, location): """Finds the location ID of a given datacenter This is mostly used so either a dc name, or regions keyname can be used when ordering :param str location: Region Keyname (DALLAS13) or datacenter name (dal13) :returns: integer id of the datacenter """ if isinstance(location, int): return location mask = "mask[id,name,regions[keyname]]" if match(r'[a-zA-Z]{3}[0-9]{2}', location) is not None: search = {'name': {'operation': location}} else: search = {'regions': {'keyname': {'operation': location}}} datacenter = self.client.call('SoftLayer_Location', 'getDatacenters', mask=mask, filter=search) if len(datacenter) != 1: raise exceptions.SoftLayerError("Unable to find location: %s" % location) return datacenter[0]['id']
python
def get_location_id(self, location): """Finds the location ID of a given datacenter This is mostly used so either a dc name, or regions keyname can be used when ordering :param str location: Region Keyname (DALLAS13) or datacenter name (dal13) :returns: integer id of the datacenter """ if isinstance(location, int): return location mask = "mask[id,name,regions[keyname]]" if match(r'[a-zA-Z]{3}[0-9]{2}', location) is not None: search = {'name': {'operation': location}} else: search = {'regions': {'keyname': {'operation': location}}} datacenter = self.client.call('SoftLayer_Location', 'getDatacenters', mask=mask, filter=search) if len(datacenter) != 1: raise exceptions.SoftLayerError("Unable to find location: %s" % location) return datacenter[0]['id']
[ "def", "get_location_id", "(", "self", ",", "location", ")", ":", "if", "isinstance", "(", "location", ",", "int", ")", ":", "return", "location", "mask", "=", "\"mask[id,name,regions[keyname]]\"", "if", "match", "(", "r'[a-zA-Z]{3}[0-9]{2}'", ",", "location", ")", "is", "not", "None", ":", "search", "=", "{", "'name'", ":", "{", "'operation'", ":", "location", "}", "}", "else", ":", "search", "=", "{", "'regions'", ":", "{", "'keyname'", ":", "{", "'operation'", ":", "location", "}", "}", "}", "datacenter", "=", "self", ".", "client", ".", "call", "(", "'SoftLayer_Location'", ",", "'getDatacenters'", ",", "mask", "=", "mask", ",", "filter", "=", "search", ")", "if", "len", "(", "datacenter", ")", "!=", "1", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"Unable to find location: %s\"", "%", "location", ")", "return", "datacenter", "[", "0", "]", "[", "'id'", "]" ]
Finds the location ID of a given datacenter This is mostly used so either a dc name, or regions keyname can be used when ordering :param str location: Region Keyname (DALLAS13) or datacenter name (dal13) :returns: integer id of the datacenter
[ "Finds", "the", "location", "ID", "of", "a", "given", "datacenter" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L603-L621
1,584
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.add_global_ip
def add_global_ip(self, version=4, test_order=False): """Adds a global IP address to the account. :param int version: Specifies whether this is IPv4 or IPv6 :param bool test_order: If true, this will only verify the order. """ # This method is here to improve the public interface from a user's # perspective since ordering a single global IP through the subnet # interface is not intuitive. return self.add_subnet('global', version=version, test_order=test_order)
python
def add_global_ip(self, version=4, test_order=False): """Adds a global IP address to the account. :param int version: Specifies whether this is IPv4 or IPv6 :param bool test_order: If true, this will only verify the order. """ # This method is here to improve the public interface from a user's # perspective since ordering a single global IP through the subnet # interface is not intuitive. return self.add_subnet('global', version=version, test_order=test_order)
[ "def", "add_global_ip", "(", "self", ",", "version", "=", "4", ",", "test_order", "=", "False", ")", ":", "# This method is here to improve the public interface from a user's", "# perspective since ordering a single global IP through the subnet", "# interface is not intuitive.", "return", "self", ".", "add_subnet", "(", "'global'", ",", "version", "=", "version", ",", "test_order", "=", "test_order", ")" ]
Adds a global IP address to the account. :param int version: Specifies whether this is IPv4 or IPv6 :param bool test_order: If true, this will only verify the order.
[ "Adds", "a", "global", "IP", "address", "to", "the", "account", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L58-L68
1,585
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.add_securitygroup_rule
def add_securitygroup_rule(self, group_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None): """Add a rule to a security group :param int group_id: The ID of the security group to add this rule to :param str remote_ip: The remote IP or CIDR to enforce the rule on :param int remote_group: The remote security group ID to enforce the rule on :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param int port_max: The upper port bound to enforce (icmp code if the protocol is icmp) :param int port_min: The lower port bound to enforce (icmp type if the protocol is icmp) :param str protocol: The protocol to enforce (icmp, udp, tcp) """ rule = {'direction': direction} if ethertype is not None: rule['ethertype'] = ethertype if port_max is not None: rule['portRangeMax'] = port_max if port_min is not None: rule['portRangeMin'] = port_min if protocol is not None: rule['protocol'] = protocol if remote_ip is not None: rule['remoteIp'] = remote_ip if remote_group is not None: rule['remoteGroupId'] = remote_group return self.add_securitygroup_rules(group_id, [rule])
python
def add_securitygroup_rule(self, group_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None): """Add a rule to a security group :param int group_id: The ID of the security group to add this rule to :param str remote_ip: The remote IP or CIDR to enforce the rule on :param int remote_group: The remote security group ID to enforce the rule on :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param int port_max: The upper port bound to enforce (icmp code if the protocol is icmp) :param int port_min: The lower port bound to enforce (icmp type if the protocol is icmp) :param str protocol: The protocol to enforce (icmp, udp, tcp) """ rule = {'direction': direction} if ethertype is not None: rule['ethertype'] = ethertype if port_max is not None: rule['portRangeMax'] = port_max if port_min is not None: rule['portRangeMin'] = port_min if protocol is not None: rule['protocol'] = protocol if remote_ip is not None: rule['remoteIp'] = remote_ip if remote_group is not None: rule['remoteGroupId'] = remote_group return self.add_securitygroup_rules(group_id, [rule])
[ "def", "add_securitygroup_rule", "(", "self", ",", "group_id", ",", "remote_ip", "=", "None", ",", "remote_group", "=", "None", ",", "direction", "=", "None", ",", "ethertype", "=", "None", ",", "port_max", "=", "None", ",", "port_min", "=", "None", ",", "protocol", "=", "None", ")", ":", "rule", "=", "{", "'direction'", ":", "direction", "}", "if", "ethertype", "is", "not", "None", ":", "rule", "[", "'ethertype'", "]", "=", "ethertype", "if", "port_max", "is", "not", "None", ":", "rule", "[", "'portRangeMax'", "]", "=", "port_max", "if", "port_min", "is", "not", "None", ":", "rule", "[", "'portRangeMin'", "]", "=", "port_min", "if", "protocol", "is", "not", "None", ":", "rule", "[", "'protocol'", "]", "=", "protocol", "if", "remote_ip", "is", "not", "None", ":", "rule", "[", "'remoteIp'", "]", "=", "remote_ip", "if", "remote_group", "is", "not", "None", ":", "rule", "[", "'remoteGroupId'", "]", "=", "remote_group", "return", "self", ".", "add_securitygroup_rules", "(", "group_id", ",", "[", "rule", "]", ")" ]
Add a rule to a security group :param int group_id: The ID of the security group to add this rule to :param str remote_ip: The remote IP or CIDR to enforce the rule on :param int remote_group: The remote security group ID to enforce the rule on :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param int port_max: The upper port bound to enforce (icmp code if the protocol is icmp) :param int port_min: The lower port bound to enforce (icmp type if the protocol is icmp) :param str protocol: The protocol to enforce (icmp, udp, tcp)
[ "Add", "a", "rule", "to", "a", "security", "group" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L70-L101
1,586
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.add_securitygroup_rules
def add_securitygroup_rules(self, group_id, rules): """Add rules to a security group :param int group_id: The ID of the security group to add the rules to :param list rules: The list of rule dictionaries to add """ if not isinstance(rules, list): raise TypeError("The rules provided must be a list of dictionaries") return self.security_group.addRules(rules, id=group_id)
python
def add_securitygroup_rules(self, group_id, rules): """Add rules to a security group :param int group_id: The ID of the security group to add the rules to :param list rules: The list of rule dictionaries to add """ if not isinstance(rules, list): raise TypeError("The rules provided must be a list of dictionaries") return self.security_group.addRules(rules, id=group_id)
[ "def", "add_securitygroup_rules", "(", "self", ",", "group_id", ",", "rules", ")", ":", "if", "not", "isinstance", "(", "rules", ",", "list", ")", ":", "raise", "TypeError", "(", "\"The rules provided must be a list of dictionaries\"", ")", "return", "self", ".", "security_group", ".", "addRules", "(", "rules", ",", "id", "=", "group_id", ")" ]
Add rules to a security group :param int group_id: The ID of the security group to add the rules to :param list rules: The list of rule dictionaries to add
[ "Add", "rules", "to", "a", "security", "group" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L103-L111
1,587
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.add_subnet
def add_subnet(self, subnet_type, quantity=None, vlan_id=None, version=4, test_order=False): """Orders a new subnet :param str subnet_type: Type of subnet to add: private, public, global :param int quantity: Number of IPs in the subnet :param int vlan_id: VLAN id for the subnet to be placed into :param int version: 4 for IPv4, 6 for IPv6 :param bool test_order: If true, this will only verify the order. """ package = self.client['Product_Package'] category = 'sov_sec_ip_addresses_priv' desc = '' if version == 4: if subnet_type == 'global': quantity = 0 category = 'global_ipv4' elif subnet_type == 'public': category = 'sov_sec_ip_addresses_pub' else: category = 'static_ipv6_addresses' if subnet_type == 'global': quantity = 0 category = 'global_ipv6' desc = 'Global' elif subnet_type == 'public': desc = 'Portable' # In the API, every non-server item is contained within package ID 0. # This means that we need to get all of the items and loop through them # looking for the items we need based upon the category, quantity, and # item description. price_id = None quantity_str = str(quantity) for item in package.getItems(id=0, mask='itemCategory'): category_code = utils.lookup(item, 'itemCategory', 'categoryCode') if all([category_code == category, item.get('capacity') == quantity_str, version == 4 or (version == 6 and desc in item['description'])]): price_id = item['prices'][0]['id'] break order = { 'packageId': 0, 'prices': [{'id': price_id}], 'quantity': 1, # This is necessary in order for the XML-RPC endpoint to select the # correct order container 'complexType': 'SoftLayer_Container_Product_Order_Network_Subnet', } if subnet_type != 'global': order['endPointVlanId'] = vlan_id if test_order: return self.client['Product_Order'].verifyOrder(order) else: return self.client['Product_Order'].placeOrder(order)
python
def add_subnet(self, subnet_type, quantity=None, vlan_id=None, version=4, test_order=False): """Orders a new subnet :param str subnet_type: Type of subnet to add: private, public, global :param int quantity: Number of IPs in the subnet :param int vlan_id: VLAN id for the subnet to be placed into :param int version: 4 for IPv4, 6 for IPv6 :param bool test_order: If true, this will only verify the order. """ package = self.client['Product_Package'] category = 'sov_sec_ip_addresses_priv' desc = '' if version == 4: if subnet_type == 'global': quantity = 0 category = 'global_ipv4' elif subnet_type == 'public': category = 'sov_sec_ip_addresses_pub' else: category = 'static_ipv6_addresses' if subnet_type == 'global': quantity = 0 category = 'global_ipv6' desc = 'Global' elif subnet_type == 'public': desc = 'Portable' # In the API, every non-server item is contained within package ID 0. # This means that we need to get all of the items and loop through them # looking for the items we need based upon the category, quantity, and # item description. price_id = None quantity_str = str(quantity) for item in package.getItems(id=0, mask='itemCategory'): category_code = utils.lookup(item, 'itemCategory', 'categoryCode') if all([category_code == category, item.get('capacity') == quantity_str, version == 4 or (version == 6 and desc in item['description'])]): price_id = item['prices'][0]['id'] break order = { 'packageId': 0, 'prices': [{'id': price_id}], 'quantity': 1, # This is necessary in order for the XML-RPC endpoint to select the # correct order container 'complexType': 'SoftLayer_Container_Product_Order_Network_Subnet', } if subnet_type != 'global': order['endPointVlanId'] = vlan_id if test_order: return self.client['Product_Order'].verifyOrder(order) else: return self.client['Product_Order'].placeOrder(order)
[ "def", "add_subnet", "(", "self", ",", "subnet_type", ",", "quantity", "=", "None", ",", "vlan_id", "=", "None", ",", "version", "=", "4", ",", "test_order", "=", "False", ")", ":", "package", "=", "self", ".", "client", "[", "'Product_Package'", "]", "category", "=", "'sov_sec_ip_addresses_priv'", "desc", "=", "''", "if", "version", "==", "4", ":", "if", "subnet_type", "==", "'global'", ":", "quantity", "=", "0", "category", "=", "'global_ipv4'", "elif", "subnet_type", "==", "'public'", ":", "category", "=", "'sov_sec_ip_addresses_pub'", "else", ":", "category", "=", "'static_ipv6_addresses'", "if", "subnet_type", "==", "'global'", ":", "quantity", "=", "0", "category", "=", "'global_ipv6'", "desc", "=", "'Global'", "elif", "subnet_type", "==", "'public'", ":", "desc", "=", "'Portable'", "# In the API, every non-server item is contained within package ID 0.", "# This means that we need to get all of the items and loop through them", "# looking for the items we need based upon the category, quantity, and", "# item description.", "price_id", "=", "None", "quantity_str", "=", "str", "(", "quantity", ")", "for", "item", "in", "package", ".", "getItems", "(", "id", "=", "0", ",", "mask", "=", "'itemCategory'", ")", ":", "category_code", "=", "utils", ".", "lookup", "(", "item", ",", "'itemCategory'", ",", "'categoryCode'", ")", "if", "all", "(", "[", "category_code", "==", "category", ",", "item", ".", "get", "(", "'capacity'", ")", "==", "quantity_str", ",", "version", "==", "4", "or", "(", "version", "==", "6", "and", "desc", "in", "item", "[", "'description'", "]", ")", "]", ")", ":", "price_id", "=", "item", "[", "'prices'", "]", "[", "0", "]", "[", "'id'", "]", "break", "order", "=", "{", "'packageId'", ":", "0", ",", "'prices'", ":", "[", "{", "'id'", ":", "price_id", "}", "]", ",", "'quantity'", ":", "1", ",", "# This is necessary in order for the XML-RPC endpoint to select the", "# correct order container", "'complexType'", ":", "'SoftLayer_Container_Product_Order_Network_Subnet'", ",", "}", "if", "subnet_type", "!=", "'global'", ":", "order", "[", "'endPointVlanId'", "]", "=", "vlan_id", "if", "test_order", ":", "return", "self", ".", "client", "[", "'Product_Order'", "]", ".", "verifyOrder", "(", "order", ")", "else", ":", "return", "self", ".", "client", "[", "'Product_Order'", "]", ".", "placeOrder", "(", "order", ")" ]
Orders a new subnet :param str subnet_type: Type of subnet to add: private, public, global :param int quantity: Number of IPs in the subnet :param int vlan_id: VLAN id for the subnet to be placed into :param int version: 4 for IPv4, 6 for IPv6 :param bool test_order: If true, this will only verify the order.
[ "Orders", "a", "new", "subnet" ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L113-L171
1,588
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.assign_global_ip
def assign_global_ip(self, global_ip_id, target): """Assigns a global IP address to a specified target. :param int global_ip_id: The ID of the global IP being assigned :param string target: The IP address to assign """ return self.client['Network_Subnet_IpAddress_Global'].route( target, id=global_ip_id)
python
def assign_global_ip(self, global_ip_id, target): """Assigns a global IP address to a specified target. :param int global_ip_id: The ID of the global IP being assigned :param string target: The IP address to assign """ return self.client['Network_Subnet_IpAddress_Global'].route( target, id=global_ip_id)
[ "def", "assign_global_ip", "(", "self", ",", "global_ip_id", ",", "target", ")", ":", "return", "self", ".", "client", "[", "'Network_Subnet_IpAddress_Global'", "]", ".", "route", "(", "target", ",", "id", "=", "global_ip_id", ")" ]
Assigns a global IP address to a specified target. :param int global_ip_id: The ID of the global IP being assigned :param string target: The IP address to assign
[ "Assigns", "a", "global", "IP", "address", "to", "a", "specified", "target", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L173-L180
1,589
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.attach_securitygroup_components
def attach_securitygroup_components(self, group_id, component_ids): """Attaches network components to a security group. :param int group_id: The ID of the security group :param list component_ids: The IDs of the network components to attach """ return self.security_group.attachNetworkComponents(component_ids, id=group_id)
python
def attach_securitygroup_components(self, group_id, component_ids): """Attaches network components to a security group. :param int group_id: The ID of the security group :param list component_ids: The IDs of the network components to attach """ return self.security_group.attachNetworkComponents(component_ids, id=group_id)
[ "def", "attach_securitygroup_components", "(", "self", ",", "group_id", ",", "component_ids", ")", ":", "return", "self", ".", "security_group", ".", "attachNetworkComponents", "(", "component_ids", ",", "id", "=", "group_id", ")" ]
Attaches network components to a security group. :param int group_id: The ID of the security group :param list component_ids: The IDs of the network components to attach
[ "Attaches", "network", "components", "to", "a", "security", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L191-L198
1,590
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.cancel_global_ip
def cancel_global_ip(self, global_ip_id): """Cancels the specified global IP address. :param int id: The ID of the global IP to be cancelled. """ service = self.client['Network_Subnet_IpAddress_Global'] ip_address = service.getObject(id=global_ip_id, mask='billingItem') billing_id = ip_address['billingItem']['id'] return self.client['Billing_Item'].cancelService(id=billing_id)
python
def cancel_global_ip(self, global_ip_id): """Cancels the specified global IP address. :param int id: The ID of the global IP to be cancelled. """ service = self.client['Network_Subnet_IpAddress_Global'] ip_address = service.getObject(id=global_ip_id, mask='billingItem') billing_id = ip_address['billingItem']['id'] return self.client['Billing_Item'].cancelService(id=billing_id)
[ "def", "cancel_global_ip", "(", "self", ",", "global_ip_id", ")", ":", "service", "=", "self", ".", "client", "[", "'Network_Subnet_IpAddress_Global'", "]", "ip_address", "=", "service", ".", "getObject", "(", "id", "=", "global_ip_id", ",", "mask", "=", "'billingItem'", ")", "billing_id", "=", "ip_address", "[", "'billingItem'", "]", "[", "'id'", "]", "return", "self", ".", "client", "[", "'Billing_Item'", "]", ".", "cancelService", "(", "id", "=", "billing_id", ")" ]
Cancels the specified global IP address. :param int id: The ID of the global IP to be cancelled.
[ "Cancels", "the", "specified", "global", "IP", "address", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L200-L209
1,591
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.cancel_subnet
def cancel_subnet(self, subnet_id): """Cancels the specified subnet. :param int subnet_id: The ID of the subnet to be cancelled. """ subnet = self.get_subnet(subnet_id, mask='id, billingItem.id') if "billingItem" not in subnet: raise exceptions.SoftLayerError("subnet %s can not be cancelled" " " % subnet_id) billing_id = subnet['billingItem']['id'] return self.client['Billing_Item'].cancelService(id=billing_id)
python
def cancel_subnet(self, subnet_id): """Cancels the specified subnet. :param int subnet_id: The ID of the subnet to be cancelled. """ subnet = self.get_subnet(subnet_id, mask='id, billingItem.id') if "billingItem" not in subnet: raise exceptions.SoftLayerError("subnet %s can not be cancelled" " " % subnet_id) billing_id = subnet['billingItem']['id'] return self.client['Billing_Item'].cancelService(id=billing_id)
[ "def", "cancel_subnet", "(", "self", ",", "subnet_id", ")", ":", "subnet", "=", "self", ".", "get_subnet", "(", "subnet_id", ",", "mask", "=", "'id, billingItem.id'", ")", "if", "\"billingItem\"", "not", "in", "subnet", ":", "raise", "exceptions", ".", "SoftLayerError", "(", "\"subnet %s can not be cancelled\"", "\" \"", "%", "subnet_id", ")", "billing_id", "=", "subnet", "[", "'billingItem'", "]", "[", "'id'", "]", "return", "self", ".", "client", "[", "'Billing_Item'", "]", ".", "cancelService", "(", "id", "=", "billing_id", ")" ]
Cancels the specified subnet. :param int subnet_id: The ID of the subnet to be cancelled.
[ "Cancels", "the", "specified", "subnet", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L211-L221
1,592
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.create_securitygroup
def create_securitygroup(self, name=None, description=None): """Creates a security group. :param string name: The name of the security group :param string description: The description of the security group """ create_dict = {'name': name, 'description': description} return self.security_group.createObject(create_dict)
python
def create_securitygroup(self, name=None, description=None): """Creates a security group. :param string name: The name of the security group :param string description: The description of the security group """ create_dict = {'name': name, 'description': description} return self.security_group.createObject(create_dict)
[ "def", "create_securitygroup", "(", "self", ",", "name", "=", "None", ",", "description", "=", "None", ")", ":", "create_dict", "=", "{", "'name'", ":", "name", ",", "'description'", ":", "description", "}", "return", "self", ".", "security_group", ".", "createObject", "(", "create_dict", ")" ]
Creates a security group. :param string name: The name of the security group :param string description: The description of the security group
[ "Creates", "a", "security", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L223-L231
1,593
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.detach_securitygroup_components
def detach_securitygroup_components(self, group_id, component_ids): """Detaches network components from a security group. :param int group_id: The ID of the security group :param list component_ids: The IDs of the network components to detach """ return self.security_group.detachNetworkComponents(component_ids, id=group_id)
python
def detach_securitygroup_components(self, group_id, component_ids): """Detaches network components from a security group. :param int group_id: The ID of the security group :param list component_ids: The IDs of the network components to detach """ return self.security_group.detachNetworkComponents(component_ids, id=group_id)
[ "def", "detach_securitygroup_components", "(", "self", ",", "group_id", ",", "component_ids", ")", ":", "return", "self", ".", "security_group", ".", "detachNetworkComponents", "(", "component_ids", ",", "id", "=", "group_id", ")" ]
Detaches network components from a security group. :param int group_id: The ID of the security group :param list component_ids: The IDs of the network components to detach
[ "Detaches", "network", "components", "from", "a", "security", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L248-L255
1,594
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.edit_rwhois
def edit_rwhois(self, abuse_email=None, address1=None, address2=None, city=None, company_name=None, country=None, first_name=None, last_name=None, postal_code=None, private_residence=None, state=None): """Edit rwhois record.""" update = {} for key, value in [('abuseEmail', abuse_email), ('address1', address1), ('address2', address2), ('city', city), ('companyName', company_name), ('country', country), ('firstName', first_name), ('lastName', last_name), ('privateResidenceFlag', private_residence), ('state', state), ('postalCode', postal_code)]: if value is not None: update[key] = value # If there's anything to update, update it if update: rwhois = self.get_rwhois() return self.client['Network_Subnet_Rwhois_Data'].editObject( update, id=rwhois['id']) return True
python
def edit_rwhois(self, abuse_email=None, address1=None, address2=None, city=None, company_name=None, country=None, first_name=None, last_name=None, postal_code=None, private_residence=None, state=None): """Edit rwhois record.""" update = {} for key, value in [('abuseEmail', abuse_email), ('address1', address1), ('address2', address2), ('city', city), ('companyName', company_name), ('country', country), ('firstName', first_name), ('lastName', last_name), ('privateResidenceFlag', private_residence), ('state', state), ('postalCode', postal_code)]: if value is not None: update[key] = value # If there's anything to update, update it if update: rwhois = self.get_rwhois() return self.client['Network_Subnet_Rwhois_Data'].editObject( update, id=rwhois['id']) return True
[ "def", "edit_rwhois", "(", "self", ",", "abuse_email", "=", "None", ",", "address1", "=", "None", ",", "address2", "=", "None", ",", "city", "=", "None", ",", "company_name", "=", "None", ",", "country", "=", "None", ",", "first_name", "=", "None", ",", "last_name", "=", "None", ",", "postal_code", "=", "None", ",", "private_residence", "=", "None", ",", "state", "=", "None", ")", ":", "update", "=", "{", "}", "for", "key", ",", "value", "in", "[", "(", "'abuseEmail'", ",", "abuse_email", ")", ",", "(", "'address1'", ",", "address1", ")", ",", "(", "'address2'", ",", "address2", ")", ",", "(", "'city'", ",", "city", ")", ",", "(", "'companyName'", ",", "company_name", ")", ",", "(", "'country'", ",", "country", ")", ",", "(", "'firstName'", ",", "first_name", ")", ",", "(", "'lastName'", ",", "last_name", ")", ",", "(", "'privateResidenceFlag'", ",", "private_residence", ")", ",", "(", "'state'", ",", "state", ")", ",", "(", "'postalCode'", ",", "postal_code", ")", "]", ":", "if", "value", "is", "not", "None", ":", "update", "[", "key", "]", "=", "value", "# If there's anything to update, update it", "if", "update", ":", "rwhois", "=", "self", ".", "get_rwhois", "(", ")", "return", "self", ".", "client", "[", "'Network_Subnet_Rwhois_Data'", "]", ".", "editObject", "(", "update", ",", "id", "=", "rwhois", "[", "'id'", "]", ")", "return", "True" ]
Edit rwhois record.
[ "Edit", "rwhois", "record", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L257-L283
1,595
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.edit_securitygroup
def edit_securitygroup(self, group_id, name=None, description=None): """Edit security group details. :param int group_id: The ID of the security group :param string name: The name of the security group :param string description: The description of the security group """ successful = False obj = {} if name: obj['name'] = name if description: obj['description'] = description if obj: successful = self.security_group.editObject(obj, id=group_id) return successful
python
def edit_securitygroup(self, group_id, name=None, description=None): """Edit security group details. :param int group_id: The ID of the security group :param string name: The name of the security group :param string description: The description of the security group """ successful = False obj = {} if name: obj['name'] = name if description: obj['description'] = description if obj: successful = self.security_group.editObject(obj, id=group_id) return successful
[ "def", "edit_securitygroup", "(", "self", ",", "group_id", ",", "name", "=", "None", ",", "description", "=", "None", ")", ":", "successful", "=", "False", "obj", "=", "{", "}", "if", "name", ":", "obj", "[", "'name'", "]", "=", "name", "if", "description", ":", "obj", "[", "'description'", "]", "=", "description", "if", "obj", ":", "successful", "=", "self", ".", "security_group", ".", "editObject", "(", "obj", ",", "id", "=", "group_id", ")", "return", "successful" ]
Edit security group details. :param int group_id: The ID of the security group :param string name: The name of the security group :param string description: The description of the security group
[ "Edit", "security", "group", "details", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L285-L302
1,596
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.edit_securitygroup_rule
def edit_securitygroup_rule(self, group_id, rule_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None): """Edit a security group rule. :param int group_id: The ID of the security group the rule belongs to :param int rule_id: The ID of the rule to edit :param str remote_ip: The remote IP or CIDR to enforce the rule on :param int remote_group: The remote security group ID to enforce the rule on :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param str port_max: The upper port bound to enforce :param str port_min: The lower port bound to enforce :param str protocol: The protocol to enforce (icmp, udp, tcp) """ successful = False obj = {} if remote_ip is not None: obj['remoteIp'] = remote_ip if remote_group is not None: obj['remoteGroupId'] = remote_group if direction is not None: obj['direction'] = direction if ethertype is not None: obj['ethertype'] = ethertype if port_max is not None: obj['portRangeMax'] = port_max if port_min is not None: obj['portRangeMin'] = port_min if protocol is not None: obj['protocol'] = protocol if obj: obj['id'] = rule_id successful = self.security_group.editRules([obj], id=group_id) return successful
python
def edit_securitygroup_rule(self, group_id, rule_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None): """Edit a security group rule. :param int group_id: The ID of the security group the rule belongs to :param int rule_id: The ID of the rule to edit :param str remote_ip: The remote IP or CIDR to enforce the rule on :param int remote_group: The remote security group ID to enforce the rule on :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param str port_max: The upper port bound to enforce :param str port_min: The lower port bound to enforce :param str protocol: The protocol to enforce (icmp, udp, tcp) """ successful = False obj = {} if remote_ip is not None: obj['remoteIp'] = remote_ip if remote_group is not None: obj['remoteGroupId'] = remote_group if direction is not None: obj['direction'] = direction if ethertype is not None: obj['ethertype'] = ethertype if port_max is not None: obj['portRangeMax'] = port_max if port_min is not None: obj['portRangeMin'] = port_min if protocol is not None: obj['protocol'] = protocol if obj: obj['id'] = rule_id successful = self.security_group.editRules([obj], id=group_id) return successful
[ "def", "edit_securitygroup_rule", "(", "self", ",", "group_id", ",", "rule_id", ",", "remote_ip", "=", "None", ",", "remote_group", "=", "None", ",", "direction", "=", "None", ",", "ethertype", "=", "None", ",", "port_max", "=", "None", ",", "port_min", "=", "None", ",", "protocol", "=", "None", ")", ":", "successful", "=", "False", "obj", "=", "{", "}", "if", "remote_ip", "is", "not", "None", ":", "obj", "[", "'remoteIp'", "]", "=", "remote_ip", "if", "remote_group", "is", "not", "None", ":", "obj", "[", "'remoteGroupId'", "]", "=", "remote_group", "if", "direction", "is", "not", "None", ":", "obj", "[", "'direction'", "]", "=", "direction", "if", "ethertype", "is", "not", "None", ":", "obj", "[", "'ethertype'", "]", "=", "ethertype", "if", "port_max", "is", "not", "None", ":", "obj", "[", "'portRangeMax'", "]", "=", "port_max", "if", "port_min", "is", "not", "None", ":", "obj", "[", "'portRangeMin'", "]", "=", "port_min", "if", "protocol", "is", "not", "None", ":", "obj", "[", "'protocol'", "]", "=", "protocol", "if", "obj", ":", "obj", "[", "'id'", "]", "=", "rule_id", "successful", "=", "self", ".", "security_group", ".", "editRules", "(", "[", "obj", "]", ",", "id", "=", "group_id", ")", "return", "successful" ]
Edit a security group rule. :param int group_id: The ID of the security group the rule belongs to :param int rule_id: The ID of the rule to edit :param str remote_ip: The remote IP or CIDR to enforce the rule on :param int remote_group: The remote security group ID to enforce the rule on :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param str port_max: The upper port bound to enforce :param str port_min: The lower port bound to enforce :param str protocol: The protocol to enforce (icmp, udp, tcp)
[ "Edit", "a", "security", "group", "rule", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L304-L342
1,597
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.ip_lookup
def ip_lookup(self, ip_address): """Looks up an IP address and returns network information about it. :param string ip_address: An IP address. Can be IPv4 or IPv6 :returns: A dictionary of information about the IP """ obj = self.client['Network_Subnet_IpAddress'] return obj.getByIpAddress(ip_address, mask='hardware, virtualGuest')
python
def ip_lookup(self, ip_address): """Looks up an IP address and returns network information about it. :param string ip_address: An IP address. Can be IPv4 or IPv6 :returns: A dictionary of information about the IP """ obj = self.client['Network_Subnet_IpAddress'] return obj.getByIpAddress(ip_address, mask='hardware, virtualGuest')
[ "def", "ip_lookup", "(", "self", ",", "ip_address", ")", ":", "obj", "=", "self", ".", "client", "[", "'Network_Subnet_IpAddress'", "]", "return", "obj", ".", "getByIpAddress", "(", "ip_address", ",", "mask", "=", "'hardware, virtualGuest'", ")" ]
Looks up an IP address and returns network information about it. :param string ip_address: An IP address. Can be IPv4 or IPv6 :returns: A dictionary of information about the IP
[ "Looks", "up", "an", "IP", "address", "and", "returns", "network", "information", "about", "it", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L344-L352
1,598
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.get_securitygroup
def get_securitygroup(self, group_id, **kwargs): """Returns the information about the given security group. :param string id: The ID for the security group :returns: A diction of information about the security group """ if 'mask' not in kwargs: kwargs['mask'] = ( 'id,' 'name,' 'description,' '''rules[id, remoteIp, remoteGroupId, direction, ethertype, portRangeMin, portRangeMax, protocol, createDate, modifyDate],''' '''networkComponentBindings[ networkComponent[ id, port, guest[ id, hostname, primaryBackendIpAddress, primaryIpAddress ] ] ]''' ) return self.security_group.getObject(id=group_id, **kwargs)
python
def get_securitygroup(self, group_id, **kwargs): """Returns the information about the given security group. :param string id: The ID for the security group :returns: A diction of information about the security group """ if 'mask' not in kwargs: kwargs['mask'] = ( 'id,' 'name,' 'description,' '''rules[id, remoteIp, remoteGroupId, direction, ethertype, portRangeMin, portRangeMax, protocol, createDate, modifyDate],''' '''networkComponentBindings[ networkComponent[ id, port, guest[ id, hostname, primaryBackendIpAddress, primaryIpAddress ] ] ]''' ) return self.security_group.getObject(id=group_id, **kwargs)
[ "def", "get_securitygroup", "(", "self", ",", "group_id", ",", "*", "*", "kwargs", ")", ":", "if", "'mask'", "not", "in", "kwargs", ":", "kwargs", "[", "'mask'", "]", "=", "(", "'id,'", "'name,'", "'description,'", "'''rules[id, remoteIp, remoteGroupId,\n direction, ethertype, portRangeMin,\n portRangeMax, protocol, createDate, modifyDate],'''", "'''networkComponentBindings[\n networkComponent[\n id,\n port,\n guest[\n id,\n hostname,\n primaryBackendIpAddress,\n primaryIpAddress\n ]\n ]\n ]'''", ")", "return", "self", ".", "security_group", ".", "getObject", "(", "id", "=", "group_id", ",", "*", "*", "kwargs", ")" ]
Returns the information about the given security group. :param string id: The ID for the security group :returns: A diction of information about the security group
[ "Returns", "the", "information", "about", "the", "given", "security", "group", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L361-L389
1,599
softlayer/softlayer-python
SoftLayer/managers/network.py
NetworkManager.get_subnet
def get_subnet(self, subnet_id, **kwargs): """Returns information about a single subnet. :param string id: Either the ID for the subnet or its network identifier :returns: A dictionary of information about the subnet """ if 'mask' not in kwargs: kwargs['mask'] = DEFAULT_SUBNET_MASK return self.subnet.getObject(id=subnet_id, **kwargs)
python
def get_subnet(self, subnet_id, **kwargs): """Returns information about a single subnet. :param string id: Either the ID for the subnet or its network identifier :returns: A dictionary of information about the subnet """ if 'mask' not in kwargs: kwargs['mask'] = DEFAULT_SUBNET_MASK return self.subnet.getObject(id=subnet_id, **kwargs)
[ "def", "get_subnet", "(", "self", ",", "subnet_id", ",", "*", "*", "kwargs", ")", ":", "if", "'mask'", "not", "in", "kwargs", ":", "kwargs", "[", "'mask'", "]", "=", "DEFAULT_SUBNET_MASK", "return", "self", ".", "subnet", ".", "getObject", "(", "id", "=", "subnet_id", ",", "*", "*", "kwargs", ")" ]
Returns information about a single subnet. :param string id: Either the ID for the subnet or its network identifier :returns: A dictionary of information about the subnet
[ "Returns", "information", "about", "a", "single", "subnet", "." ]
9f181be08cc3668353b05a6de0cb324f52cff6fa
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L391-L401