idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
234,200
def get_api_key ( client , username , secret ) : if len ( secret ) == 64 : try : client [ 'Account' ] . getCurrentUser ( ) return secret except SoftLayer . SoftLayerAPIError as ex : if 'invalid api token' not in ex . faultString . lower ( ) : raise else : client . authenticate_with_password ( username , secret ) user_r...
Attempts API - Key and password auth to get an API key .
234,201
def cli ( env ) : username , secret , endpoint_url , timeout = get_user_input ( env ) new_client = SoftLayer . Client ( username = username , api_key = secret , endpoint_url = endpoint_url , timeout = timeout ) api_key = get_api_key ( new_client , username , secret ) path = '~/.softlayer' if env . config_file : path = ...
Edit configuration .
234,202
def cli ( env , ** kwargs ) : mgr = SoftLayer . DedicatedHostManager ( env . client ) tables = [ ] if not kwargs [ 'flavor' ] and not kwargs [ 'datacenter' ] : options = mgr . get_create_options ( ) dc_table = formatting . Table ( [ 'datacenter' , 'value' ] ) dc_table . sortby = 'value' for location in options [ 'locat...
host order options for a given dedicated host .
234,203
def cli ( env ) : table = formatting . Table ( [ 'Code' , 'Reason' ] ) table . align [ 'Code' ] = 'r' table . align [ 'Reason' ] = 'l' mgr = SoftLayer . HardwareManager ( env . client ) for code , reason in mgr . get_cancellation_reasons ( ) . items ( ) : table . add_row ( [ code , reason ] ) env . fout ( table )
Display a list of cancellation reasons .
234,204
def cli ( env ) : manager = SoftLayer . IPSECManager ( env . client ) contexts = manager . get_tunnel_contexts ( ) table = formatting . Table ( [ 'id' , 'name' , 'friendly name' , 'internal peer IP address' , 'remote peer IP address' , 'created' ] ) for context in contexts : table . add_row ( [ context . get ( 'id' , '...
List IPSec VPN tunnel contexts
234,205
def cli ( env , columns , sortby , volume_id ) : file_storage_manager = SoftLayer . FileStorageManager ( env . client ) legal_centers = file_storage_manager . get_replication_locations ( volume_id ) if not legal_centers : click . echo ( "No data centers compatible for replication." ) else : table = formatting . KeyValu...
List suitable replication datacenters for the given volume .
234,206
def cli ( env , identifier , sortby , cpu , domain , hostname , memory , tag , columns ) : mgr = SoftLayer . DedicatedHostManager ( env . client ) guests = mgr . list_guests ( host_id = identifier , cpus = cpu , hostname = hostname , domain = domain , memory = memory , tags = tag , mask = columns . mask ( ) ) table = f...
List guests which are in a dedicated host server .
234,207
def cli ( env , identifier , count ) : mgr = SoftLayer . TicketManager ( env . client ) ticket_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'ticket' ) env . fout ( ticket . get_ticket_results ( mgr , ticket_id , update_count = count ) )
Get details for a ticket .
234,208
def get_session ( user_agent ) : client = requests . Session ( ) client . headers . update ( { 'Content-Type' : 'application/json' , 'User-Agent' : user_agent , } ) retry = Retry ( connect = 3 , backoff_factor = 3 ) adapter = HTTPAdapter ( max_retries = retry ) client . mount ( 'https://' , adapter ) return client
Sets up urllib sessions
234,209
def _format_object_mask ( objectmask ) : objectmask = objectmask . strip ( ) if ( not objectmask . startswith ( 'mask' ) and not objectmask . startswith ( '[' ) ) : objectmask = "mask[%s]" % objectmask return objectmask
Format the new style object mask .
234,210
def client ( self ) : if self . _client is None : self . _client = get_session ( self . user_agent ) return self . _client
Returns client session object
234,211
def cli ( env , identifier , enable ) : mgr = SoftLayer . HardwareManager ( env . client ) hw_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'hardware' ) result = env . client [ 'Hardware_Server' ] . toggleManagementInterface ( enable , id = hw_id ) env . fout ( result )
Toggle the IPMI interface on and off
234,212
def cli ( env , record_id ) : manager = SoftLayer . DNSManager ( env . client ) if not ( env . skip_confirmations or formatting . no_going_back ( 'yes' ) ) : raise exceptions . CLIAbort ( "Aborted." ) manager . delete_record ( record_id )
Remove resource record .
234,213
def cli ( env , sortby , datacenter ) : block_manager = SoftLayer . BlockStorageManager ( env . client ) mask = "mask[serviceResource[datacenter[name]]," "replicationPartners[serviceResource[datacenter[name]]]]" block_volumes = block_manager . list_block_volumes ( datacenter = datacenter , mask = mask ) datacenters = d...
List number of block storage volumes per datacenter .
234,214
def cli ( env , account_id , content_url ) : manager = SoftLayer . CDNManager ( env . client ) manager . load_content ( account_id , content_url )
Cache one or more files on all edge nodes .
234,215
def cli ( env , identifier , no_vs , no_hardware ) : mgr = SoftLayer . NetworkManager ( env . client ) vlan_id = helpers . resolve_id ( mgr . resolve_vlan_ids , identifier , 'VLAN' ) vlan = mgr . get_vlan ( vlan_id ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . alig...
Get details about a VLAN .
234,216
def cli ( env , volume_id , lun_id ) : block_storage_manager = SoftLayer . BlockStorageManager ( env . client ) res = block_storage_manager . create_or_update_lun_id ( volume_id , lun_id ) if 'value' in res and lun_id == res [ 'value' ] : click . echo ( 'Block volume with id %s is reporting LUN ID %s' % ( res [ 'volume...
Set the LUN ID on an existing block storage volume .
234,217
def cli ( env , identifier ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) _ , loadbal_id = loadbal . parse_id ( identifier ) load_balancer = mgr . get_local_lb ( loadbal_id ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'l' table . align [ 'value' ] = 'l' table . ad...
Get Load balancer details .
234,218
def cli ( env , format = 'table' , config = None , verbose = 0 , proxy = None , really = False , demo = False , ** kwargs ) : env . skip_confirmations = really env . config_file = config env . format = format env . ensure_client ( config_file = config , is_demo = demo , proxy = proxy ) env . vars [ '_start' ] = time . ...
Main click CLI entry - point .
234,219
def output_diagnostics ( env , result , verbose = 0 , ** kwargs ) : if verbose > 0 : diagnostic_table = formatting . Table ( [ 'name' , 'value' ] ) diagnostic_table . add_row ( [ 'execution_time' , '%fs' % ( time . time ( ) - START_TIME ) ] ) api_call_value = [ ] for call in env . client . transport . get_last_calls ( ...
Output diagnostic information .
234,220
def main ( reraise_exceptions = False , ** kwargs ) : exit_status = 0 try : cli . main ( ** kwargs ) except SoftLayer . SoftLayerAPIError as ex : if 'invalid api token' in ex . faultString . lower ( ) : print ( "Authentication Failed: To update your credentials, use 'slcli config setup'" ) exit_status = 1 else : print ...
Main program . Catches several common errors and displays them nicely .
234,221
def cli ( env , volume_id , hardware_id , virtual_id , ip_address_id , ip_address ) : block_manager = SoftLayer . BlockStorageManager ( env . client ) ip_address_id_list = list ( ip_address_id ) if ip_address is not None : network_manager = SoftLayer . NetworkManager ( env . client ) for ip_address_value in ip_address ...
Revokes authorization for hosts accessing a given volume
234,222
def cli ( env , identifier , allocation , port , routing_type , routing_method ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) _ , loadbal_id = loadbal . parse_id ( identifier ) mgr . add_service_group ( loadbal_id , allocation = allocation , port = port , routing_type = routing_type , routing_method = routi...
Adds a new load_balancer service .
234,223
def cli ( env , identifier ) : dh_mgr = SoftLayer . DedicatedHostManager ( env . client ) host_id = helpers . resolve_id ( dh_mgr . resolve_ids , identifier , 'dedicated host' ) if not ( env . skip_confirmations or formatting . no_going_back ( host_id ) ) : raise exceptions . CLIAbort ( 'Aborted' ) table = formatting ....
Cancel all virtual guests of the dedicated host immediately .
234,224
def cli ( env , sortby , columns , datacenter , username , storage_type ) : file_manager = SoftLayer . FileStorageManager ( env . client ) file_volumes = file_manager . list_file_volumes ( datacenter = datacenter , username = username , storage_type = storage_type , mask = columns . mask ( ) ) table = formatting . Tabl...
List file storage .
234,225
def cli ( env , origin_volume_id , origin_snapshot_id , duplicate_size , duplicate_iops , duplicate_tier , duplicate_snapshot_size , billing ) : file_manager = SoftLayer . FileStorageManager ( env . client ) hourly_billing_flag = False if billing . lower ( ) == "hourly" : hourly_billing_flag = True if duplicate_tier is...
Order a duplicate file storage volume .
234,226
def cli ( env , context_id , subnet_id , subnet_type ) : manager = SoftLayer . IPSECManager ( env . client ) manager . get_tunnel_context ( context_id ) succeeded = False if subnet_type == 'internal' : succeeded = manager . remove_internal_subnet ( context_id , subnet_id ) elif subnet_type == 'remote' : succeeded = man...
Remove a subnet from an IPSEC tunnel context .
234,227
def cli ( env , is_open ) : ticket_mgr = SoftLayer . TicketManager ( env . client ) table = formatting . Table ( [ 'id' , 'assigned_user' , 'title' , 'last_edited' , 'status' , 'updates' , 'priority' ] ) tickets = ticket_mgr . list_tickets ( open_status = is_open , closed_status = not is_open ) for ticket in tickets : ...
List tickets .
234,228
def cli ( env , identifier ) : mgr = SoftLayer . NetworkManager ( env . client ) secgroup = mgr . get_securitygroup ( identifier ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . align [ 'value' ] = 'l' table . add_row ( [ 'id' , secgroup [ 'id' ] ] ) table . add_row (...
Get details about a security group .
234,229
def cli ( env , record , record_type , data , zone , ttl , priority , protocol , port , service , weight ) : manager = SoftLayer . DNSManager ( env . client ) record_type = record_type . upper ( ) if zone and record_type != 'PTR' : zone_id = helpers . resolve_id ( manager . resolve_ids , zone , name = 'zone' ) if recor...
Add resource record .
234,230
def cli ( env , identifier ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) _ , loadbal_id = loadbal . parse_id ( identifier ) if not ( env . skip_confirmations or formatting . confirm ( "This action will cancel a load balancer. " "Continue?" ) ) : raise exceptions . CLIAbort ( 'Aborted.' ) mgr . cancel_lb ( ...
Cancel an existing load balancer .
234,231
def cli ( env , package_keyname , keyword ) : table = formatting . Table ( COLUMNS ) manager = ordering . OrderingManager ( env . client ) _filter = { } if keyword : _filter = { 'activePresets' : { 'name' : { 'operation' : '*= %s' % keyword } } } presets = manager . list_presets ( package_keyname , filter = _filter ) f...
List package presets .
234,232
def permission_table ( user_permissions , all_permissions ) : table = formatting . Table ( [ 'Description' , 'KeyName' , 'Assigned' ] ) table . align [ 'KeyName' ] = 'l' table . align [ 'Description' ] = 'l' table . align [ 'Assigned' ] = 'l' for perm in all_permissions : assigned = user_permissions . get ( perm [ 'key...
Creates a table of available permissions
234,233
def roles_table ( user ) : table = formatting . Table ( [ 'id' , 'Role Name' , 'Description' ] ) for role in user [ 'roles' ] : table . add_row ( [ role [ 'id' ] , role [ 'name' ] , role [ 'description' ] ] ) return table
Creates a table for a users roles
234,234
def _update_with_like_args ( ctx , _ , value ) : if value is None : return env = ctx . ensure_object ( environment . Environment ) vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , value , 'VS' ) like_details = vsi . get_instance ( vs_id ) like_args = { 'hostname' : like_de...
Update arguments with options taken from a currently running VS .
234,235
def _build_receipt_table ( result , billing = "hourly" , test = False ) : title = "OrderId: %s" % ( result . get ( 'orderId' , 'No order placed' ) ) table = formatting . Table ( [ 'Cost' , 'Description' ] , title = title ) table . align [ 'Cost' ] = 'r' table . align [ 'Description' ] = 'l' total = 0.000 if test : pric...
Retrieve the total recurring fee of the items prices
234,236
def _validate_args ( env , args ) : if all ( [ args [ 'cpu' ] , args [ 'flavor' ] ] ) : raise exceptions . ArgumentError ( '[-c | --cpu] not allowed with [-f | --flavor]' ) if all ( [ args [ 'memory' ] , args [ 'flavor' ] ] ) : raise exceptions . ArgumentError ( '[-m | --memory] not allowed with [-f | --flavor]' ) if a...
Raises an ArgumentError if the given arguments are not valid .
234,237
def cli ( env , identifier , cpu , private , memory , network , flavor ) : vsi = SoftLayer . VSManager ( env . client ) if not any ( [ cpu , memory , network , flavor ] ) : raise exceptions . ArgumentError ( "Must provide [--cpu], [--memory], [--network], or [--flavor] to upgrade" ) if private and not cpu : raise excep...
Upgrade a virtual server .
234,238
def reboot ( env , identifier , hard ) : hardware_server = env . client [ 'Hardware_Server' ] mgr = SoftLayer . HardwareManager ( env . client ) hw_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'hardware' ) if not ( env . skip_confirmations or formatting . confirm ( 'This will power off the server with i...
Reboot an active server .
234,239
def power_on ( env , identifier ) : mgr = SoftLayer . HardwareManager ( env . client ) hw_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'hardware' ) env . client [ 'Hardware_Server' ] . powerOn ( id = hw_id )
Power on a server .
234,240
def power_cycle ( env , identifier ) : mgr = SoftLayer . HardwareManager ( env . client ) hw_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'hardware' ) if not ( env . skip_confirmations or formatting . confirm ( 'This will power off the server with id %s. ' 'Continue?' % hw_id ) ) : raise exceptions . CL...
Power cycle a server .
234,241
def cli ( env , group_id , name , description ) : mgr = SoftLayer . NetworkManager ( env . client ) data = { } if name : data [ 'name' ] = name if description : data [ 'description' ] = description if not mgr . edit_securitygroup ( group_id , ** data ) : raise exceptions . CLIAbort ( "Failed to edit security group" )
Edit details of a security group .
234,242
def cli ( env , date_min , date_max , obj_event , obj_id , obj_type , utc_offset , metadata , limit ) : columns = [ 'Event' , 'Object' , 'Type' , 'Date' , 'Username' ] event_mgr = SoftLayer . EventLogManager ( env . client ) user_mgr = SoftLayer . UserManager ( env . client ) request_filter = event_mgr . build_filter (...
Get Event Logs
234,243
def cli ( env , volume_id , new_size , new_iops , new_tier ) : file_manager = SoftLayer . FileStorageManager ( env . client ) if new_tier is not None : new_tier = float ( new_tier ) try : order = file_manager . order_modified_volume ( volume_id , new_size = new_size , new_iops = new_iops , new_tier_level = new_tier , )...
Modify an existing file storage volume .
234,244
def add_permissions ( self , user_id , permissions ) : pretty_permissions = self . format_permission_object ( permissions ) LOGGER . warning ( "Adding the following permissions to %s: %s" , user_id , pretty_permissions ) return self . user_service . addBulkPortalPermission ( pretty_permissions , id = user_id )
Enables a list of permissions for a user
234,245
def remove_permissions ( self , user_id , permissions ) : pretty_permissions = self . format_permission_object ( permissions ) LOGGER . warning ( "Removing the following permissions to %s: %s" , user_id , pretty_permissions ) return self . user_service . removeBulkPortalPermission ( pretty_permissions , id = user_id )
Disables a list of permissions for a user
234,246
def permissions_from_user ( self , user_id , from_user_id ) : from_permissions = self . get_user_permissions ( from_user_id ) self . add_permissions ( user_id , from_permissions ) all_permissions = self . get_all_permissions ( ) remove_permissions = [ ] for permission in all_permissions : if _keyname_search ( from_perm...
Sets user_id s permission to be the same as from_user_id s
234,247
def get_user_permissions ( self , user_id ) : permissions = self . user_service . getPermissions ( id = user_id ) return sorted ( permissions , key = itemgetter ( 'keyName' ) )
Returns a sorted list of a users permissions
234,248
def get_logins ( self , user_id , start_date = None ) : if start_date is None : date_object = datetime . datetime . today ( ) - datetime . timedelta ( days = 30 ) start_date = date_object . strftime ( "%m/%d/%Y 0:0:0" ) date_filter = { 'loginAttempts' : { 'createDate' : { 'operation' : 'greaterThanDate' , 'options' : [...
Gets the login history for a user default start_date is 30 days ago
234,249
def get_events ( self , user_id , start_date = None ) : if start_date is None : date_object = datetime . datetime . today ( ) - datetime . timedelta ( days = 30 ) start_date = date_object . strftime ( "%Y-%m-%dT00:00:00" ) object_filter = { 'userId' : { 'operation' : user_id } , 'eventCreateDate' : { 'operation' : 'gre...
Gets the event log for a specific user default start_date is 30 days ago
234,250
def _get_id_from_username ( self , username ) : _mask = "mask[id, username]" _filter = { 'users' : { 'username' : utils . query_filter ( username ) } } user = self . list_users ( _mask , _filter ) if len ( user ) == 1 : return [ user [ 0 ] [ 'id' ] ] elif len ( user ) > 1 : raise exceptions . SoftLayerError ( "Multiple...
Looks up a username s id
234,251
def format_permission_object ( self , permissions ) : pretty_permissions = [ ] available_permissions = self . get_all_permissions ( ) for permission in permissions : if isinstance ( permission , dict ) : permission = permission [ 'keyName' ] permission = permission . upper ( ) if permission == 'ALL' : return available_...
Formats a list of permission key names into something the SLAPI will respect .
234,252
def cli ( env , identifier ) : mgr = SoftLayer . NetworkManager ( env . client ) global_ip_id = helpers . resolve_id ( mgr . resolve_global_ip_ids , identifier , name = 'global ip' ) mgr . unassign_global_ip ( global_ip_id )
Unassigns a global IP from a target .
234,253
def cli ( env , context_id ) : manager = SoftLayer . IPSECManager ( env . client ) manager . get_tunnel_context ( context_id ) succeeded = manager . apply_configuration ( context_id ) if succeeded : env . out ( 'Configuration request received for context #{}' . format ( context_id ) ) else : raise CLIHalt ( 'Failed to ...
Request configuration of a tunnel context .
234,254
def _get_zone_id_from_name ( self , name ) : results = self . client [ 'Account' ] . getDomains ( filter = { "domains" : { "name" : utils . query_filter ( name ) } } ) return [ x [ 'id' ] for x in results ]
Return zone ID based on a zone .
234,255
def get_zone ( self , zone_id , records = True ) : mask = None if records : mask = 'resourceRecords' return self . service . getObject ( id = zone_id , mask = mask )
Get a zone and its records .
234,256
def create_zone ( self , zone , serial = None ) : return self . service . createObject ( { 'name' : zone , 'serial' : serial or time . strftime ( '%Y%m%d01' ) , "resourceRecords" : { } } )
Create a zone for the specified zone .
234,257
def create_record_mx ( self , zone_id , record , data , ttl = 60 , priority = 10 ) : resource_record = self . _generate_create_dict ( record , 'MX' , data , ttl , domainId = zone_id , mxPriority = priority ) return self . record . createObject ( resource_record )
Create a mx resource record on a domain .
234,258
def create_record_ptr ( self , record , data , ttl = 60 ) : resource_record = self . _generate_create_dict ( record , 'PTR' , data , ttl ) return self . record . createObject ( resource_record )
Create a reverse record .
234,259
def get_records ( self , zone_id , ttl = None , data = None , host = None , record_type = None ) : _filter = utils . NestedDict ( ) if ttl : _filter [ 'resourceRecords' ] [ 'ttl' ] = utils . query_filter ( ttl ) if host : _filter [ 'resourceRecords' ] [ 'host' ] = utils . query_filter ( host ) if data : _filter [ 'reso...
List and optionally filter records within a zone .
234,260
def cancel_guests ( self , host_id ) : result = [ ] guests = self . host . getGuests ( id = host_id , mask = 'id,fullyQualifiedDomainName' ) if guests : for vs in guests : status_info = { 'id' : vs [ 'id' ] , 'fqdn' : vs [ 'fullyQualifiedDomainName' ] , 'status' : self . _delete_guest ( vs [ 'id' ] ) } result . append ...
Cancel all guests into the dedicated host immediately .
234,261
def list_guests ( self , host_id , tags = None , cpus = None , memory = None , hostname = None , domain = None , local_disk = None , nic_speed = None , public_ip = None , private_ip = None , ** kwargs ) : if 'mask' not in kwargs : items = [ 'id' , 'globalIdentifier' , 'hostname' , 'domain' , 'fullyQualifiedDomainName' ...
Retrieve a list of all virtual servers on the dedicated host .
234,262
def list_instances ( self , tags = None , cpus = None , memory = None , hostname = None , disk = None , datacenter = None , ** kwargs ) : if 'mask' not in kwargs : items = [ 'id' , 'name' , 'cpuCount' , 'diskCapacity' , 'memoryCapacity' , 'datacenter' , 'guestCount' , ] kwargs [ 'mask' ] = "mask[%s]" % ',' . join ( ite...
Retrieve a list of all dedicated hosts on the account
234,263
def get_host ( self , host_id , ** kwargs ) : if 'mask' not in kwargs : kwargs [ 'mask' ] = ( ) return self . host . getObject ( id = host_id , ** kwargs )
Get details about a dedicated host .
234,264
def place_order ( self , hostname , domain , location , flavor , hourly , router = None ) : create_options = self . _generate_create_dict ( hostname = hostname , router = router , domain = domain , flavor = flavor , datacenter = location , hourly = hourly ) return self . client [ 'Product_Order' ] . placeOrder ( create...
Places an order for a dedicated host .
234,265
def verify_order ( self , hostname , domain , location , hourly , flavor , router = None ) : create_options = self . _generate_create_dict ( hostname = hostname , router = router , domain = domain , flavor = flavor , datacenter = location , hourly = hourly ) return self . client [ 'Product_Order' ] . verifyOrder ( crea...
Verifies an order for a dedicated host .
234,266
def _generate_create_dict ( self , hostname = None , domain = None , flavor = None , router = None , datacenter = None , hourly = True ) : package = self . _get_package ( ) item = self . _get_item ( package , flavor ) location = self . _get_location ( package [ 'regions' ] , datacenter ) price = self . _get_price ( ite...
Translates args into a dictionary for creating a dedicated host .
234,267
def get_create_options ( self ) : package = self . _get_package ( ) locations = [ ] for region in package [ 'regions' ] : locations . append ( { 'name' : region [ 'location' ] [ 'location' ] [ 'longName' ] , 'key' : region [ 'location' ] [ 'location' ] [ 'name' ] , } ) dedicated_host = [ ] for item in package [ 'items'...
Returns valid options for ordering a dedicated host .
234,268
def _get_price ( self , package ) : for price in package [ 'prices' ] : if not price . get ( 'locationGroupId' ) : return price [ 'id' ] raise SoftLayer . SoftLayerError ( "Could not find valid price" )
Returns valid price for ordering a dedicated host .
234,269
def _get_item ( self , package , flavor ) : for item in package [ 'items' ] : if item [ 'keyName' ] == flavor : return item raise SoftLayer . SoftLayerError ( "Could not find valid item for: '%s'" % flavor )
Returns the item for ordering a dedicated host .
234,270
def _get_backend_router ( self , locations , item ) : mask = cpu_count = item [ 'capacity' ] for capacity in item [ 'bundleItems' ] : for category in capacity [ 'categories' ] : if category [ 'categoryCode' ] == 'dedicated_host_ram' : mem_capacity = capacity [ 'capacity' ] if category [ 'categoryCode' ] == 'dedicated_h...
Returns valid router options for ordering a dedicated host .
234,271
def _get_default_router ( self , routers , router_name = None ) : if router_name is None : for router in routers : if router [ 'id' ] is not None : return router [ 'id' ] else : for router in routers : if router [ 'hostname' ] == router_name : return router [ 'id' ] raise SoftLayer . SoftLayerError ( "Could not find va...
Returns the default router for ordering a dedicated host .
234,272
def get_router_options ( self , datacenter = None , flavor = None ) : package = self . _get_package ( ) location = self . _get_location ( package [ 'regions' ] , datacenter ) item = self . _get_item ( package , flavor ) return self . _get_backend_router ( location [ 'location' ] [ 'locationPackageDetails' ] , item )
Returns available backend routers for the dedicated host .
234,273
def _delete_guest ( self , guest_id ) : msg = 'Cancelled' try : self . guest . deleteObject ( id = guest_id ) except SoftLayer . SoftLayerAPIError as e : msg = 'Exception: ' + e . faultString return msg
Deletes a guest and returns Cancelled or and Exception message
234,274
def _click_autocomplete ( root , text ) : try : parts = shlex . split ( text ) except ValueError : raise StopIteration location , incomplete = _click_resolve_command ( root , parts ) if not text . endswith ( ' ' ) and not incomplete and text : raise StopIteration if incomplete and not incomplete [ 0 : 2 ] . isalnum ( )...
Completer generator for click applications .
234,275
def _click_resolve_command ( root , parts ) : location = root incomplete = '' for part in parts : incomplete = part if not part [ 0 : 2 ] . isalnum ( ) : continue try : next_location = location . get_command ( click . Context ( location ) , part ) if next_location is not None : location = next_location incomplete = '' ...
Return the click command and the left over text given some vargs .
234,276
def cli ( env , identifier , enable , permission , from_user ) : mgr = SoftLayer . UserManager ( env . client ) user_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'username' ) result = False if from_user : from_user_id = helpers . resolve_id ( mgr . resolve_ids , from_user , 'username' ) result = mgr . p...
Enable or Disable specific permissions .
234,277
def list_accounts ( self ) : account = self . client [ 'Account' ] mask = 'cdnAccounts[%s]' % ', ' . join ( [ 'id' , 'createDate' , 'cdnAccountName' , 'cdnSolutionName' , 'cdnAccountNote' , 'status' ] ) return account . getObject ( mask = mask ) . get ( 'cdnAccounts' , [ ] )
Lists CDN accounts for the active user .
234,278
def get_account ( self , account_id , ** kwargs ) : if 'mask' not in kwargs : kwargs [ 'mask' ] = 'status' return self . account . getObject ( id = account_id , ** kwargs )
Retrieves a CDN account with the specified account ID .
234,279
def get_origins ( self , account_id , ** kwargs ) : return self . account . getOriginPullMappingInformation ( id = account_id , ** kwargs )
Retrieves list of origin pull mappings for a specified CDN account .
234,280
def add_origin ( self , account_id , media_type , origin_url , cname = None , secure = False ) : config = { 'mediaType' : media_type , 'originUrl' : origin_url , 'isSecureContent' : secure } if cname : config [ 'cname' ] = cname return self . account . createOriginPullMapping ( config , id = account_id )
Adds an original pull mapping to an origin - pull .
234,281
def remove_origin ( self , account_id , origin_id ) : return self . account . deleteOriginPullRule ( origin_id , id = account_id )
Removes an origin pull mapping with the given origin pull ID .
234,282
def load_content ( self , account_id , urls ) : if isinstance ( urls , six . string_types ) : urls = [ urls ] for i in range ( 0 , len ( urls ) , MAX_URLS_PER_LOAD ) : result = self . account . loadContent ( urls [ i : i + MAX_URLS_PER_LOAD ] , id = account_id ) if not result : return result return True
Prefetches one or more URLs to the CDN edge nodes .
234,283
def purge_content ( self , account_id , urls ) : if isinstance ( urls , six . string_types ) : urls = [ urls ] content_list = [ ] for i in range ( 0 , len ( urls ) , MAX_URLS_PER_PURGE ) : content = self . account . purgeCache ( urls [ i : i + MAX_URLS_PER_PURGE ] , id = account_id ) content_list . extend ( content ) r...
Purges one or more URLs from the CDN edge nodes .
234,284
def get_lb_pkgs ( self ) : _filter = { 'items' : { 'description' : utils . query_filter ( '*Load Balancer*' ) } } packages = self . prod_pkg . getItems ( id = 0 , filter = _filter ) pkgs = [ ] for package in packages : if not package [ 'description' ] . startswith ( 'Global' ) : pkgs . append ( package ) return pkgs
Retrieves the local load balancer packages .
234,285
def _get_location ( self , datacenter_name ) : datacenters = self . client [ 'Location' ] . getDataCenters ( ) for datacenter in datacenters : if datacenter [ 'name' ] == datacenter_name : return datacenter [ 'id' ] return 'FIRST_AVAILABLE'
Returns the location of the specified datacenter .
234,286
def cancel_lb ( self , loadbal_id ) : lb_billing = self . lb_svc . getBillingItem ( id = loadbal_id ) billing_id = lb_billing [ 'id' ] billing_item = self . client [ 'Billing_Item' ] return billing_item . cancelService ( id = billing_id )
Cancels the specified load balancer .
234,287
def add_local_lb ( self , price_item_id , datacenter ) : product_order = { 'complexType' : 'SoftLayer_Container_Product_Order_Network_' 'LoadBalancer' , 'quantity' : 1 , 'packageId' : 0 , "location" : self . _get_location ( datacenter ) , 'prices' : [ { 'id' : price_item_id } ] } return self . client [ 'Product_Order' ...
Creates a local load balancer in the specified data center .
234,288
def get_local_lb ( self , loadbal_id , ** kwargs ) : if 'mask' not in kwargs : kwargs [ 'mask' ] = ( 'loadBalancerHardware[datacenter], ' 'ipAddress, virtualServers[serviceGroups' '[routingMethod,routingType,services' '[healthChecks[type], groupReferences,' ' ipAddress]]]' ) return self . lb_svc . getObject ( id = load...
Returns a specified local load balancer given the id .
234,289
def delete_service ( self , service_id ) : svc = self . client [ 'Network_Application_Delivery_Controller_' 'LoadBalancer_Service' ] return svc . deleteObject ( id = service_id )
Deletes a service from the loadbal_id .
234,290
def delete_service_group ( self , group_id ) : svc = self . client [ 'Network_Application_Delivery_Controller_' 'LoadBalancer_VirtualServer' ] return svc . deleteObject ( id = group_id )
Deletes a service group from the loadbal_id .
234,291
def toggle_service_status ( self , service_id ) : svc = self . client [ 'Network_Application_Delivery_Controller_' 'LoadBalancer_Service' ] return svc . toggleStatus ( id = service_id )
Toggles the service status .
234,292
def edit_service ( self , loadbal_id , service_id , ip_address_id = None , port = None , enabled = None , hc_type = None , weight = None ) : _filter = { 'virtualServers' : { 'serviceGroups' : { 'services' : { 'id' : utils . query_filter ( service_id ) } } } } mask = 'serviceGroups[services[groupReferences,healthChecks]...
Edits an existing service properties .
234,293
def add_service ( self , loadbal_id , service_group_id , ip_address_id , port = 80 , enabled = True , hc_type = 21 , weight = 1 ) : kwargs = utils . NestedDict ( { } ) kwargs [ 'mask' ] = ( 'virtualServers[' 'serviceGroups[services[groupReferences]]]' ) load_balancer = self . lb_svc . getObject ( id = loadbal_id , ** k...
Adds a new service to the service group .
234,294
def add_service_group ( self , lb_id , allocation = 100 , port = 80 , routing_type = 2 , routing_method = 10 ) : mask = 'virtualServers[serviceGroups[services[groupReferences]]]' load_balancer = self . lb_svc . getObject ( id = lb_id , mask = mask ) service_template = { 'port' : port , 'allocation' : allocation , 'serv...
Adds a new service group to the load balancer .
234,295
def edit_service_group ( self , loadbal_id , group_id , allocation = None , port = None , routing_type = None , routing_method = None ) : mask = 'virtualServers[serviceGroups[services[groupReferences]]]' load_balancer = self . lb_svc . getObject ( id = loadbal_id , mask = mask ) virtual_servers = load_balancer [ 'virtu...
Edit an existing service group .
234,296
def reset_service_group ( self , loadbal_id , group_id ) : _filter = { 'virtualServers' : { 'id' : utils . query_filter ( group_id ) } } virtual_servers = self . lb_svc . getVirtualServers ( id = loadbal_id , filter = _filter , mask = 'serviceGroups' ) actual_id = virtual_servers [ 0 ] [ 'serviceGroups' ] [ 0 ] [ 'id' ...
Resets all the connections on the service group .
234,297
def cli ( env , identifier ) : image_mgr = SoftLayer . ImageManager ( env . client ) image_id = helpers . resolve_id ( image_mgr . resolve_ids , identifier , 'image' ) image = image_mgr . get_image ( image_id , mask = image_mod . DETAIL_MASK ) disk_space = 0 datacenters = [ ] for child in image . get ( 'children' ) : d...
Get details for an image .
234,298
def cli ( env , volume_id , schedule_type , retention_count , minute , hour , day_of_week ) : file_manager = SoftLayer . FileStorageManager ( env . client ) valid_schedule_types = { 'INTERVAL' , 'HOURLY' , 'DAILY' , 'WEEKLY' } valid_days = { 'SUNDAY' , 'MONDAY' , 'TUESDAY' , 'WEDNESDAY' , 'THURSDAY' , 'FRIDAY' , 'SATUR...
Enables snapshots for a given volume on the specified schedule
234,299
def get_upcoming_events ( self ) : mask = "mask[id, subject, startDate, endDate, statusCode, acknowledgedFlag, impactedResourceCount, updateCount]" _filter = { 'endDate' : { 'operation' : '> sysdate' } , 'startDate' : { 'operation' : 'orderBy' , 'options' : [ { 'name' : 'sort' , 'value' : [ 'ASC' ] } ] } } return self ...
Retreives a list of Notification_Occurrence_Events that have not ended yet