idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
45,500
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 .
45,501
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 .
45,502
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 .
45,503
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 .
45,504
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 .
45,505
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 .
45,506
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 .
45,507
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
45,508
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 .
45,509
def list ( self ) : mask = results = self . client . call ( 'Account' , 'getReservedCapacityGroups' , mask = mask ) return results
List Reserved Capacities
45,510
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
45,511
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
45,512
def get_available_routers ( self , dc = None ) : mask = "mask[locations]" package = self . ordering_manager . get_package_by_key ( self . capacity_package , mask = "id" ) 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 } } 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 ) return regions
Pulls down all backendRouterIds that are available
45,513
def create ( self , name , backend_router_id , flavor , instances , test = False ) : 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
45,514
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' ] 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
45,515
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' ] 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 .
45,516
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 .
45,517
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
45,518
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 .
45,519
def cli ( env , identifier , enabled , port , weight , healthcheck_type , ip_address ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) loadbal_id , group_id = loadbal . parse_id ( identifier ) 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 .
45,520
def cli ( ctx , env ) : 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 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 ( ) , ) try : args = shlex . split ( line ) except ValueError as ex : print ( "Invalid Command: %s" % ex ) continue if not args : continue try : 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 .
45,521
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 .
45,522
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 .
45,523
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 .
45,524
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 .
45,525
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 .
45,526
def cli ( env , identifier , enabled , port , weight , healthcheck_type , ip_address ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) loadbal_id , service_id = loadbal . parse_id ( identifier ) 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!' ) 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 .
45,527
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 .
45,528
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 .
45,529
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 .
45,530
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 .
45,531
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 .
45,532
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
45,533
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
45,534
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 .
45,535
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 .
45,536
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 .
45,537
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 .
45,538
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 .
45,539
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 .
45,540
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
45,541
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
45,542
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
45,543
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
45,544
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 .
45,545
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 .
45,546
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 .
45,547
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
45,548
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 .
45,549
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 .
45,550
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 .
45,551
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 .
45,552
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 .
45,553
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 .
45,554
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 .
45,555
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 .
45,556
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 .
45,557
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 .
45,558
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 .
45,559
def verify_quote ( self , quote_id , extra ) : container = self . generate_order_template ( quote_id , extra ) clean_container = { } 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 .
45,560
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
45,561
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 .
45,562
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 .
45,563
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 .
45,564
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 .
45,565
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 .
45,566
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 .
45,567
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 : 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 ) ) 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 : 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 .
45,568
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 ) ) if capacity_min == - 1 or core is None : price_id = price [ 'id' ] elif capacity_min <= int ( core ) <= capacity_max : price_id = price [ 'id' ] return price_id
get item price id
45,569
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 .
45,570
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 .
45,571
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 .
45,572
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 .
45,573
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 .
45,574
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' ) 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 .
45,575
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
45,576
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
45,577
def add_global_ip ( self , version = 4 , test_order = False ) : return self . add_subnet ( 'global' , version = version , test_order = test_order )
Adds a global IP address to the account .
45,578
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
45,579
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
45,580
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' 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 , '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
45,581
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 .
45,582
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 .
45,583
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 .
45,584
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 .
45,585
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 .
45,586
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 .
45,587
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 update : rwhois = self . get_rwhois ( ) return self . client [ 'Network_Subnet_Rwhois_Data' ] . editObject ( update , id = rwhois [ 'id' ] ) return True
Edit rwhois record .
45,588
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 .
45,589
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 .
45,590
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 .
45,591
def get_securitygroup ( self , group_id , ** kwargs ) : if 'mask' not in kwargs : kwargs [ 'mask' ] = ( 'id,' 'name,' 'description,' ) return self . security_group . getObject ( id = group_id , ** kwargs )
Returns the information about the given security group .
45,592
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 .
45,593
def get_vlan ( self , vlan_id ) : return self . vlan . getObject ( id = vlan_id , mask = DEFAULT_GET_VLAN_MASK )
Returns information about a single VLAN .
45,594
def list_global_ips ( self , version = None , identifier = None , ** kwargs ) : if 'mask' not in kwargs : mask = [ 'destinationIpAddress[hardware, virtualGuest]' , 'ipAddress' ] kwargs [ 'mask' ] = ',' . join ( mask ) _filter = utils . NestedDict ( { } ) if version : ver = utils . query_filter ( version ) _filter [ 'globalIpRecords' ] [ 'ipAddress' ] [ 'subnet' ] [ 'version' ] = ver if identifier : subnet_filter = _filter [ 'globalIpRecords' ] [ 'ipAddress' ] [ 'subnet' ] subnet_filter [ 'networkIdentifier' ] = utils . query_filter ( identifier ) kwargs [ 'filter' ] = _filter . to_dict ( ) return self . account . getGlobalIpRecords ( ** kwargs )
Returns a list of all global IP address records on the account .
45,595
def list_subnets ( self , identifier = None , datacenter = None , version = 0 , subnet_type = None , network_space = None , ** kwargs ) : if 'mask' not in kwargs : kwargs [ 'mask' ] = DEFAULT_SUBNET_MASK _filter = utils . NestedDict ( kwargs . get ( 'filter' ) or { } ) if identifier : _filter [ 'subnets' ] [ 'networkIdentifier' ] = ( utils . query_filter ( identifier ) ) if datacenter : _filter [ 'subnets' ] [ 'datacenter' ] [ 'name' ] = ( utils . query_filter ( datacenter ) ) if version : _filter [ 'subnets' ] [ 'version' ] = utils . query_filter ( version ) if subnet_type : _filter [ 'subnets' ] [ 'subnetType' ] = utils . query_filter ( subnet_type ) else : _filter [ 'subnets' ] [ 'subnetType' ] = { 'operation' : '!= GLOBAL_IP' } if network_space : _filter [ 'subnets' ] [ 'networkVlan' ] [ 'networkSpace' ] = ( utils . query_filter ( network_space ) ) kwargs [ 'filter' ] = _filter . to_dict ( ) kwargs [ 'iter' ] = True return self . client . call ( 'Account' , 'getSubnets' , ** kwargs )
Display a list of all subnets on the account .
45,596
def list_vlans ( self , datacenter = None , vlan_number = None , name = None , ** kwargs ) : _filter = utils . NestedDict ( kwargs . get ( 'filter' ) or { } ) if vlan_number : _filter [ 'networkVlans' ] [ 'vlanNumber' ] = ( utils . query_filter ( vlan_number ) ) if name : _filter [ 'networkVlans' ] [ 'name' ] = utils . query_filter ( name ) if datacenter : _filter [ 'networkVlans' ] [ 'primaryRouter' ] [ 'datacenter' ] [ 'name' ] = ( utils . query_filter ( datacenter ) ) kwargs [ 'filter' ] = _filter . to_dict ( ) if 'mask' not in kwargs : kwargs [ 'mask' ] = DEFAULT_VLAN_MASK kwargs [ 'iter' ] = True return self . account . getNetworkVlans ( ** kwargs )
Display a list of all VLANs on the account .
45,597
def list_securitygroup_rules ( self , group_id ) : return self . security_group . getRules ( id = group_id , iter = True )
List security group rules associated with a security group .
45,598
def remove_securitygroup_rules ( self , group_id , rules ) : return self . security_group . removeRules ( rules , id = group_id )
Remove rules from a security group .
45,599
def get_event_logs_by_request_id ( self , request_id ) : unfiltered_logs = self . _get_cci_event_logs ( ) + self . _get_security_group_event_logs ( ) filtered_logs = [ ] for unfiltered_log in unfiltered_logs : try : metadata = json . loads ( unfiltered_log [ 'metaData' ] ) if 'requestId' in metadata : if metadata [ 'requestId' ] == request_id : filtered_logs . append ( unfiltered_log ) except ValueError : continue return filtered_logs
Gets all event logs by the given request id