idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
234,600
def is_ready ( instance , pending = False ) : last_reload = lookup ( instance , 'lastOperatingSystemReload' , 'id' ) active_transaction = lookup ( instance , 'activeTransaction' , 'id' ) reloading = all ( ( active_transaction , last_reload , last_reload == active_transaction , ) ) outstanding = False if pending : outst...
Returns True if instance is ready to be used
234,601
def clean_time ( sltime , in_format = '%Y-%m-%dT%H:%M:%S%z' , out_format = '%Y-%m-%d %H:%M' ) : try : clean = datetime . datetime . strptime ( sltime , in_format ) return clean . strftime ( out_format ) except ValueError : return sltime
Easy way to format time strings
234,602
def to_dict ( self ) : return { key : val . to_dict ( ) if isinstance ( val , NestedDict ) else val for key , val in self . items ( ) }
Converts a NestedDict instance into a real dictionary .
234,603
def cli ( env , identifier ) : mgr = SoftLayer . FirewallManager ( env . client ) firewall_type , firewall_id = firewall . parse_id ( identifier ) if not ( env . skip_confirmations or formatting . confirm ( "This action will cancel a firewall from your " "account. Continue?" ) ) : raise exceptions . CLIAbort ( 'Aborted...
Cancels a firewall .
234,604
def cli ( env , label , in_file , key , note ) : if in_file is None and key is None : raise exceptions . ArgumentError ( 'Either [-f | --in-file] or [-k | --key] arguments are required to add a key' ) if in_file and key : raise exceptions . ArgumentError ( '[-f | --in-file] is not allowed with [-k | --key]' ) if key : ...
Add a new SSH key .
234,605
def cli ( env ) : mgr = SoftLayer . NetworkManager ( env . client ) result = mgr . get_rwhois ( ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . align [ 'value' ] = 'l' table . add_row ( [ 'Name' , result [ 'firstName' ] + ' ' + result [ 'lastName' ] ] ) table . add_r...
Display the RWhois information for your account .
234,606
def cli ( env , context_id , static_ip , remote_ip , note ) : manager = SoftLayer . IPSECManager ( env . client ) manager . get_tunnel_context ( context_id ) translation = manager . create_translation ( context_id , static_ip = static_ip , remote_ip = remote_ip , notes = note ) env . out ( 'Created translation from {} ...
Add an address translation to an IPSEC tunnel context .
234,607
def cli ( env , status , sortby ) : manager = SoftLayer . SSLManager ( env . client ) certificates = manager . list_certs ( status ) table = formatting . Table ( [ 'id' , 'common_name' , 'days_until_expire' , 'notes' ] ) for certificate in certificates : table . add_row ( [ certificate [ 'id' ] , certificate [ 'commonN...
List SSL certificates .
234,608
def cli ( env ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) hc_types = mgr . get_hc_types ( ) table = formatting . KeyValueTable ( [ 'ID' , 'Name' ] ) table . align [ 'ID' ] = 'l' table . align [ 'Name' ] = 'l' table . sortby = 'ID' for hc_type in hc_types : table . add_row ( [ hc_type [ 'id' ] , hc_type [...
List health check types .
234,609
def cli ( env , identifier ) : mgr = SoftLayer . ObjectStorageManager ( env . client ) credential_limit = mgr . limit_credential ( identifier ) table = formatting . Table ( [ 'limit' ] ) table . add_row ( [ credential_limit , ] ) env . fout ( table )
Credential limits for this IBM Cloud Object Storage account .
234,610
def cli ( env , context_id , include ) : mask = _get_tunnel_context_mask ( ( 'at' in include ) , ( 'is' in include ) , ( 'rs' in include ) , ( 'sr' in include ) , ( 'ss' in include ) ) manager = SoftLayer . IPSECManager ( env . client ) context = manager . get_tunnel_context ( context_id , mask = mask ) env . out ( 'Co...
List IPSEC VPN tunnel context details .
234,611
def _get_address_translations_table ( address_translations ) : table = formatting . Table ( [ 'id' , 'static IP address' , 'static IP address id' , 'remote IP address' , 'remote IP address id' , 'note' ] ) for address_translation in address_translations : table . add_row ( [ address_translation . get ( 'id' , '' ) , ad...
Yields a formatted table to print address translations .
234,612
def _get_subnets_table ( subnets ) : table = formatting . Table ( [ 'id' , 'network identifier' , 'cidr' , 'note' ] ) for subnet in subnets : table . add_row ( [ subnet . get ( 'id' , '' ) , subnet . get ( 'networkIdentifier' , '' ) , subnet . get ( 'cidr' , '' ) , subnet . get ( 'note' , '' ) ] ) return table
Yields a formatted table to print subnet details .
234,613
def _get_tunnel_context_mask ( address_translations = False , internal_subnets = False , remote_subnets = False , static_subnets = False , service_subnets = False ) : entries = [ 'id' , 'accountId' , 'advancedConfigurationFlag' , 'createDate' , 'customerPeerIpAddress' , 'modifyDate' , 'name' , 'friendlyName' , 'interna...
Yields a mask object for a tunnel context .
234,614
def _get_context_table ( context ) : table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . align [ 'value' ] = 'l' table . add_row ( [ 'id' , context . get ( 'id' , '' ) ] ) table . add_row ( [ 'name' , context . get ( 'name' , '' ) ] ) table . add_row ( [ 'friendly name' , ...
Yields a formatted table to print context details .
234,615
def cli ( env , volume_id , replicant_id , immediate ) : file_storage_manager = SoftLayer . FileStorageManager ( env . client ) success = file_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 a file volume to the given replicant volume .
234,616
def cli ( env , sortby , datacenter ) : file_manager = SoftLayer . FileStorageManager ( env . client ) mask = "mask[serviceResource[datacenter[name]]," "replicationPartners[serviceResource[datacenter[name]]]]" file_volumes = file_manager . list_file_volumes ( datacenter = datacenter , mask = mask ) datacenters = dict (...
List number of file storage volumes per datacenter .
234,617
def cli ( env ) : hardware_manager = hardware . HardwareManager ( env . client ) options = hardware_manager . get_create_options ( ) tables = [ ] dc_table = formatting . Table ( [ 'datacenter' , 'value' ] ) dc_table . sortby = 'value' for location in options [ 'locations' ] : dc_table . add_row ( [ location [ 'name' ] ...
Server order options for a given chassis .
234,618
def parse_id ( input_id ) : key_value = input_id . split ( ':' ) if len ( key_value ) != 2 : raise exceptions . CLIAbort ( 'Invalid ID %s: ID should be of the form xxx:yyy' % input_id ) return key_value [ 0 ] , int ( key_value [ 1 ] )
Helper package to retrieve the actual IDs .
234,619
def _build_filters ( _filters ) : root = utils . NestedDict ( { } ) for _filter in _filters : operation = None for operation , token in SPLIT_TOKENS : top_parts = _filter . split ( token , 1 ) if len ( top_parts ) == 2 : break else : raise exceptions . CLIAbort ( 'Failed to find valid operation for: %s' % _filter ) key...
Builds filters using the filter options passed into the CLI .
234,620
def cli ( env , service , method , parameters , _id , _filters , mask , limit , offset , output_python = False ) : args = [ service , method ] + list ( parameters ) kwargs = { 'id' : _id , 'filter' : _build_filters ( _filters ) , 'mask' : mask , 'limit' : limit , 'offset' : offset , } if output_python : env . out ( _bu...
Call arbitrary API endpoints with the given SERVICE and METHOD .
234,621
def cli ( env , volume_id , sortby , columns ) : block_manager = SoftLayer . BlockStorageManager ( env . client ) snapshots = block_manager . get_block_volume_snapshot_list ( volume_id , mask = columns . mask ( ) ) table = formatting . Table ( columns . columns ) table . sortby = sortby for snapshot in snapshots : tabl...
List block storage snapshots .
234,622
def cli ( env , package_keyname , location , preset , verify , billing , complex_type , quantity , 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 t...
Place or verify an order .
234,623
def cli ( env , identifier , label , note ) : mgr = SoftLayer . SshKeyManager ( env . client ) key_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'SshKey' ) if not mgr . edit_key ( key_id , label = label , notes = note ) : raise exceptions . CLIAbort ( 'Failed to edit SSH key' )
Edits an SSH key .
234,624
def cli ( env , securitygroup_id ) : mgr = SoftLayer . NetworkManager ( env . client ) if not mgr . delete_securitygroup ( securitygroup_id ) : raise exceptions . CLIAbort ( "Failed to delete security group" )
Deletes the given security group
234,625
def cli ( env , ipv6 , test ) : mgr = SoftLayer . NetworkManager ( env . client ) version = 4 if ipv6 : version = 6 if not ( test or env . skip_confirmations ) : if not formatting . confirm ( "This action will incur charges on your " "account. Continue?" ) : raise exceptions . CLIAbort ( 'Cancelling order.' ) result = ...
Creates a global IP .
234,626
def cli ( env , context_id , translation_id ) : manager = SoftLayer . IPSECManager ( env . client ) manager . get_translation ( context_id , translation_id ) succeeded = manager . remove_translation ( context_id , translation_id ) if succeeded : env . out ( 'Removed translation #{}' . format ( translation_id ) ) else :...
Remove a translation entry from an IPSEC tunnel context .
234,627
def cli ( env , sortby , cpu , domain , datacenter , hostname , memory , network , hourly , monthly , tag , columns , limit ) : vsi = SoftLayer . VSManager ( env . client ) guests = vsi . list_instances ( hourly = hourly , monthly = monthly , hostname = hostname , domain = domain , cpus = cpu , memory = memory , datace...
List virtual servers .
234,628
def cli ( env , identifier ) : mgr = SoftLayer . SshKeyManager ( env . client ) key_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'SshKey' ) if not ( env . skip_confirmations or formatting . no_going_back ( key_id ) ) : raise exceptions . CLIAbort ( 'Aborted' ) mgr . delete_key ( key_id )
Permanently removes an SSH key .
234,629
def format_output ( data , fmt = 'table' ) : if isinstance ( data , utils . string_types ) : if fmt in ( 'json' , 'jsonraw' ) : return json . dumps ( data ) return data if hasattr ( data , 'prettytable' ) : if fmt == 'table' : return str ( format_prettytable ( data ) ) elif fmt == 'raw' : return str ( format_no_tty ( d...
Given some data will format it for console output .
234,630
def transaction_status ( transaction ) : if not transaction or not transaction . get ( 'transactionStatus' ) : return blank ( ) return FormattedItem ( transaction [ 'transactionStatus' ] . get ( 'name' ) , transaction [ 'transactionStatus' ] . get ( 'friendlyName' ) )
Returns a FormattedItem describing the given transaction .
234,631
def tags ( tag_references ) : if not tag_references : return blank ( ) tag_row = [ ] for tag_detail in tag_references : tag = utils . lookup ( tag_detail , 'tag' , 'name' ) if tag is not None : tag_row . append ( tag ) return listing ( tag_row , separator = ', ' )
Returns a formatted list of tags .
234,632
def confirm ( prompt_str , default = False ) : if default : default_str = 'y' prompt = '%s [Y/n]' % prompt_str else : default_str = 'n' prompt = '%s [y/N]' % prompt_str ans = click . prompt ( prompt , default = default_str , show_default = False ) if ans . lower ( ) in ( 'y' , 'yes' , 'yeah' , 'yup' , 'yolo' ) : return...
Show a confirmation prompt to a command - line user .
234,633
def no_going_back ( confirmation ) : if not confirmation : confirmation = 'yes' prompt = ( 'This action cannot be undone! Type "%s" or press Enter ' 'to abort' % confirmation ) ans = click . prompt ( prompt , default = '' , show_default = False ) if ans . lower ( ) == str ( confirmation ) : return True return False
Show a confirmation to a user .
234,634
def iter_to_table ( value ) : if isinstance ( value , list ) : return _format_list ( value ) if isinstance ( value , dict ) : return _format_dict ( value ) return value
Convert raw API responses to response tables .
234,635
def _format_dict ( result ) : table = KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . align [ 'value' ] = 'l' for key , value in result . items ( ) : value = iter_to_table ( value ) table . add_row ( [ key , value ] ) return table
Format dictionary responses into key - value table .
234,636
def _format_list ( result ) : if not result : return result if isinstance ( result [ 0 ] , dict ) : return _format_list_objects ( result ) table = Table ( [ 'value' ] ) for item in result : table . add_row ( [ iter_to_table ( item ) ] ) return table
Format list responses into a table .
234,637
def _format_list_objects ( result ) : all_keys = set ( ) for item in result : all_keys = all_keys . union ( item . keys ( ) ) all_keys = sorted ( all_keys ) table = Table ( all_keys ) for item in result : values = [ ] for key in all_keys : value = iter_to_table ( item . get ( key ) ) values . append ( value ) table . a...
Format list of objects into a table .
234,638
def to_python ( self ) : items = [ ] for row in self . rows : formatted_row = [ _format_python_value ( v ) for v in row ] items . append ( dict ( zip ( self . columns , formatted_row ) ) ) return items
Decode this Table object to standard Python types .
234,639
def prettytable ( self ) : table = prettytable . PrettyTable ( self . columns ) if self . sortby : if self . sortby in self . columns : table . sortby = self . sortby else : msg = "Column (%s) doesn't exist to sort by" % self . sortby raise exceptions . CLIAbort ( msg ) for a_col , alignment in self . align . items ( )...
Returns a new prettytable instance .
234,640
def to_python ( self ) : mapping = { } for row in self . rows : mapping [ row [ 0 ] ] = _format_python_value ( row [ 1 ] ) return mapping
Decode this KeyValueTable object to standard Python types .
234,641
def cli ( env , username , email , password , from_user , template , api_key ) : mgr = SoftLayer . UserManager ( env . client ) user_mask = ( "mask[id, firstName, lastName, email, companyName, address1, city, country, postalCode, " "state, userStatusId, timezoneId]" ) from_user_id = None if from_user is None : user_tem...
Creates a user Users .
234,642
def generate_password ( ) : if sys . version_info > ( 3 , 6 ) : import secrets alphabet = string . ascii_letters + string . digits password = '' . join ( secrets . choice ( alphabet ) for i in range ( 20 ) ) special = '' . join ( secrets . choice ( string . punctuation ) for i in range ( 3 ) ) return password + special...
Returns a 23 character random string with 3 special characters at the end
234,643
def cli ( env ) : mgr = SoftLayer . EventLogManager ( env . client ) event_log_types = mgr . get_event_log_types ( ) table = formatting . Table ( COLUMNS ) for event_log_type in event_log_types : table . add_row ( [ event_log_type ] ) env . fout ( table )
Get Event Log Types
234,644
def _get_extra_price_id ( items , key_name , hourly , location ) : for item in items : if utils . lookup ( item , 'keyName' ) != key_name : continue for price in item [ 'prices' ] : if not _matches_billing ( price , hourly ) : continue if not _matches_location ( price , location ) : continue return price [ 'id' ] raise...
Returns a price id attached to item with the given key_name .
234,645
def _get_default_price_id ( items , option , hourly , location ) : for item in items : if utils . lookup ( item , 'itemCategory' , 'categoryCode' ) != option : continue for price in item [ 'prices' ] : if all ( [ float ( price . get ( 'hourlyRecurringFee' , 0 ) ) == 0.0 , float ( price . get ( 'recurringFee' , 0 ) ) ==...
Returns a free price id given an option .
234,646
def _get_bandwidth_price_id ( items , hourly = True , no_public = False , location = None ) : for item in items : capacity = float ( item . get ( 'capacity' , 0 ) ) if any ( [ utils . lookup ( item , 'itemCategory' , 'categoryCode' ) != 'bandwidth' , ( hourly or no_public ) and capacity != 0.0 , not ( hourly or no_publ...
Choose a valid price id for bandwidth .
234,647
def _get_os_price_id ( items , os , location ) : for item in items : if any ( [ utils . lookup ( item , 'itemCategory' , 'categoryCode' ) != 'os' , utils . lookup ( item , 'softwareDescription' , 'referenceCode' ) != os ] ) : continue for price in item [ 'prices' ] : if not _matches_location ( price , location ) : cont...
Returns the price id matching .
234,648
def _get_port_speed_price_id ( items , port_speed , no_public , location ) : for item in items : if utils . lookup ( item , 'itemCategory' , 'categoryCode' ) != 'port_speed' : continue if any ( [ int ( utils . lookup ( item , 'capacity' ) ) != port_speed , _is_private_port_speed_item ( item ) != no_public , not _is_bon...
Choose a valid price id for port speed .
234,649
def _matches_location ( price , location ) : if not price . get ( 'locationGroupId' ) : return True for group in location [ 'location' ] [ 'location' ] [ 'priceGroups' ] : if group [ 'id' ] == price [ 'locationGroupId' ] : return True return False
Return True if the price object matches the location .
234,650
def _get_location ( package , location ) : for region in package [ 'regions' ] : if region [ 'location' ] [ 'location' ] [ 'name' ] == location : return region raise SoftLayer . SoftLayerError ( "Could not find valid location for: '%s'" % location )
Get the longer key with a short location name .
234,651
def _get_preset_id ( package , size ) : for preset in package [ 'activePresets' ] + package [ 'accountRestrictedActivePresets' ] : if preset [ 'keyName' ] == size or preset [ 'id' ] == size : return preset [ 'id' ] raise SoftLayer . SoftLayerError ( "Could not find valid size for: '%s'" % size )
Get the preset id given the keyName of the preset .
234,652
def cancel_hardware ( self , hardware_id , reason = 'unneeded' , comment = '' , immediate = False ) : reasons = self . get_cancellation_reasons ( ) cancel_reason = reasons . get ( reason , reasons [ 'unneeded' ] ) ticket_mgr = SoftLayer . TicketManager ( self . client ) mask = 'mask[id, hourlyBillingFlag, billingItem[i...
Cancels the specified dedicated server .
234,653
def get_hardware ( self , hardware_id , ** kwargs ) : if 'mask' not in kwargs : kwargs [ 'mask' ] = ( 'id,' 'globalIdentifier,' 'fullyQualifiedDomainName,' 'hostname,' 'domain,' 'provisionDate,' 'hardwareStatus,' 'processorPhysicalCoreAmount,' 'memoryCapacity,' 'notes,' 'privateNetworkOnlyFlag,' 'primaryBackendIpAddres...
Get details about a hardware device .
234,654
def reload ( self , hardware_id , post_uri = None , ssh_keys = None ) : config = { } if post_uri : config [ 'customProvisionScriptUri' ] = post_uri if ssh_keys : config [ 'sshKeyIds' ] = [ key_id for key_id in ssh_keys ] return self . hardware . reloadOperatingSystem ( 'FORCE' , config , id = hardware_id )
Perform an OS reload of a server with its current configuration .
234,655
def change_port_speed ( self , hardware_id , public , speed ) : if public : return self . client . call ( 'Hardware_Server' , 'setPublicNetworkInterfaceSpeed' , speed , id = hardware_id ) else : return self . client . call ( 'Hardware_Server' , 'setPrivateNetworkInterfaceSpeed' , speed , id = hardware_id )
Allows you to change the port speed of a server s NICs .
234,656
def place_order ( self , ** kwargs ) : create_options = self . _generate_create_dict ( ** kwargs ) return self . client [ 'Product_Order' ] . placeOrder ( create_options )
Places an order for a piece of hardware .
234,657
def verify_order ( self , ** kwargs ) : create_options = self . _generate_create_dict ( ** kwargs ) return self . client [ 'Product_Order' ] . verifyOrder ( create_options )
Verifies an order for a piece of hardware .
234,658
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' ] , } ) sizes = [ ] for preset in package [ 'activePresets...
Returns valid options for ordering hardware .
234,659
def _get_package ( self ) : mask = package_keyname = 'BARE_METAL_SERVER' package = self . ordering_manager . get_package_by_key ( package_keyname , mask = mask ) return package
Get the package related to simple hardware ordering .
234,660
def _generate_create_dict ( self , size = None , hostname = None , domain = None , location = None , os = None , port_speed = None , ssh_keys = None , post_uri = None , hourly = True , no_public = False , extras = None ) : extras = extras or [ ] package = self . _get_package ( ) location = _get_location ( package , loc...
Translates arguments into a dictionary for creating a server .
234,661
def _get_ids_from_hostname ( self , hostname ) : results = self . list_hardware ( hostname = hostname , mask = "id" ) return [ result [ 'id' ] for result in results ]
Returns list of matching hardware IDs for a given hostname .
234,662
def _get_ids_from_ip ( self , ip ) : try : socket . inet_aton ( ip ) except socket . error : return [ ] results = self . list_hardware ( public_ip = ip , mask = "id" ) if results : return [ result [ 'id' ] for result in results ] results = self . list_hardware ( private_ip = ip , mask = "id" ) if results : return [ res...
Returns list of matching hardware IDs for a given ip address .
234,663
def edit ( self , hardware_id , userdata = None , hostname = None , domain = None , notes = None , tags = None ) : obj = { } if userdata : self . hardware . setUserMetadata ( [ userdata ] , id = hardware_id ) if tags is not None : self . hardware . setTags ( tags , id = hardware_id ) if hostname : obj [ 'hostname' ] = ...
Edit hostname domain name notes user data of the hardware .
234,664
def update_firmware ( self , hardware_id , ipmi = True , raid_controller = True , bios = True , hard_drive = True ) : return self . hardware . createFirmwareUpdateTransaction ( bool ( ipmi ) , bool ( raid_controller ) , bool ( bios ) , bool ( hard_drive ) , id = hardware_id )
Update hardware firmware .
234,665
def reflash_firmware ( self , hardware_id , ipmi = True , raid_controller = True , bios = True ) : return self . hardware . createFirmwareReflashTransaction ( bool ( ipmi ) , bool ( raid_controller ) , bool ( bios ) , id = hardware_id )
Reflash hardware firmware .
234,666
def wait_for_ready ( self , instance_id , limit = 14400 , delay = 10 , pending = False ) : now = time . time ( ) until = now + limit mask = "mask[id, lastOperatingSystemReload[id], activeTransaction, provisionDate]" instance = self . get_hardware ( instance_id , mask = mask ) while now <= until : if utils . is_ready ( ...
Determine if a Server is ready .
234,667
def cli ( env , identifier , immediate , comment , reason ) : mgr = SoftLayer . HardwareManager ( env . client ) hw_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'hardware' ) if not ( env . skip_confirmations or formatting . no_going_back ( hw_id ) ) : raise exceptions . CLIAbort ( 'Aborted' ) mgr . canc...
Cancel a dedicated server .
234,668
def cli ( env , identifier , postinstall , key , image ) : vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , identifier , 'VS' ) keys = [ ] if key : for single_key in key : resolver = SoftLayer . SshKeyManager ( env . client ) . resolve_ids key_id = helpers . resolve_id ( r...
Reload operating system on a virtual server .
234,669
def cli ( env , identifier , columns ) : manager = CapacityManager ( env . client ) mask = result = manager . get_object ( identifier , mask ) try : flavor = result [ 'instances' ] [ 0 ] [ 'billingItem' ] [ 'description' ] except KeyError : flavor = "Pending Approval..." table = formatting . Table ( columns . columns ,...
Reserved Capacity Group details . Will show which guests are assigned to a reservation .
234,670
def get_client_settings_args ( ** kwargs ) : timeout = kwargs . get ( 'timeout' ) if timeout is not None : timeout = float ( timeout ) return { 'endpoint_url' : kwargs . get ( 'endpoint_url' ) , 'timeout' : timeout , 'proxy' : kwargs . get ( 'proxy' ) , 'username' : kwargs . get ( 'username' ) , 'api_key' : kwargs . ge...
Retrieve client settings from user - supplied arguments .
234,671
def get_client_settings_env ( ** _ ) : return { 'proxy' : os . environ . get ( 'https_proxy' ) , 'username' : os . environ . get ( 'SL_USERNAME' ) , 'api_key' : os . environ . get ( 'SL_API_KEY' ) , }
Retrieve client settings from environment settings .
234,672
def get_client_settings_config_file ( ** kwargs ) : config_files = [ '/etc/softlayer.conf' , '~/.softlayer' ] if kwargs . get ( 'config_file' ) : config_files . append ( kwargs . get ( 'config_file' ) ) config_files = [ os . path . expanduser ( f ) for f in config_files ] config = utils . configparser . RawConfigParser...
Retrieve client settings from the possible config file locations .
234,673
def get_client_settings ( ** kwargs ) : all_settings = { } for setting_method in SETTING_RESOLVERS : settings = setting_method ( ** kwargs ) if settings : settings . update ( ( k , v ) for k , v in all_settings . items ( ) if v ) all_settings = settings return all_settings
Parse client settings .
234,674
def cli ( env , package_keyname , required ) : client = env . client manager = ordering . OrderingManager ( client ) table = formatting . Table ( COLUMNS ) categories = manager . list_categories ( package_keyname ) if required : categories = [ cat for cat in categories if cat [ 'isRequired' ] ] for cat in categories : ...
List the categories of a package .
234,675
def list_certs ( self , method = 'all' ) : ssl = self . client [ 'Account' ] methods = { 'all' : 'getSecurityCertificates' , 'expired' : 'getExpiredSecurityCertificates' , 'valid' : 'getValidSecurityCertificates' } mask = "mask[id, commonName, validityDays, notes]" func = getattr ( ssl , methods [ method ] ) return fun...
List all certificates .
234,676
def cli ( env ) : manager = SoftLayer . DNSManager ( env . client ) zones = manager . list_zones ( ) table = formatting . Table ( [ 'id' , 'zone' , 'serial' , 'updated' ] ) table . align [ 'serial' ] = 'c' table . align [ 'updated' ] = 'c' for zone in zones : table . add_row ( [ zone [ 'id' ] , zone [ 'name' ] , zone [...
List all zones .
234,677
def list_file_volumes ( self , datacenter = None , username = None , storage_type = None , ** kwargs ) : if 'mask' not in kwargs : items = [ 'id' , 'username' , 'capacityGb' , 'bytesUsed' , 'serviceResource.datacenter[name]' , 'serviceResourceBackendIpAddress' , 'activeTransactionCount' , 'fileNetworkMountAddress' , 'r...
Returns a list of file volumes .
234,678
def get_file_volume_details ( self , volume_id , ** kwargs ) : if 'mask' not in kwargs : items = [ 'id' , 'username' , 'password' , 'capacityGb' , 'bytesUsed' , 'snapshotCapacityGb' , 'parentVolume.snapshotSizeBytes' , 'storageType.keyName' , 'serviceResource.datacenter[name]' , 'serviceResourceBackendIpAddress' , 'fil...
Returns details about the specified volume .
234,679
def order_replicant_volume ( self , volume_id , snapshot_schedule , location , tier = None ) : file_mask = 'billingItem[activeChildren,hourlyFlag],' 'storageTierLevel,osType,staasVersion,' 'hasEncryptionAtRest,snapshotCapacityGb,schedules,' 'intervalSchedule,hourlySchedule,dailySchedule,' 'weeklySchedule,storageType[ke...
Places an order for a replicant file volume .
234,680
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 ) : file_mask = 'id,billingItem[location,hourlyFlag],snapshotCapacityGb,' 'storageType[keyName],ca...
Places an order for a duplicate file volume .
234,681
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' , ] file_mask = ',' . join ( mask_items ) volume = se...
Places an order for modifying an existing file volume .
234,682
def order_snapshot_space ( self , volume_id , capacity , tier , upgrade , ** kwargs ) : file_mask = 'id,billingItem[location,hourlyFlag],' 'storageType[keyName],storageTierLevel,provisionedIops,' 'staasVersion,hasEncryptionAtRest' file_volume = self . get_file_volume_details ( volume_id , mask = file_mask , ** kwargs )...
Orders snapshot space for the given file volume .
234,683
def cli ( env , zone ) : manager = SoftLayer . DNSManager ( env . client ) zone_id = helpers . resolve_id ( manager . resolve_ids , zone , name = 'zone' ) env . fout ( manager . dump_zone ( zone_id ) )
Print zone in BIND format .
234,684
def rescue ( env , identifier ) : vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , identifier , 'VS' ) if not ( env . skip_confirmations or formatting . confirm ( "This action will reboot this VSI. Continue?" ) ) : raise exceptions . CLIAbort ( 'Aborted' ) vsi . rescue ( v...
Reboot into a rescue image .
234,685
def reboot ( env , identifier , hard ) : virtual_guest = env . client [ 'Virtual_Guest' ] mgr = SoftLayer . HardwareManager ( env . client ) vs_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'VS' ) if not ( env . skip_confirmations or formatting . confirm ( 'This will reboot the VS with id %s. ' 'Continue...
Reboot an active virtual server .
234,686
def power_off ( env , identifier , hard ) : virtual_guest = env . client [ 'Virtual_Guest' ] vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , identifier , 'VS' ) if not ( env . skip_confirmations or formatting . confirm ( 'This will power off the VS with id %s. ' 'Continue...
Power off an active virtual server .
234,687
def power_on ( env , identifier ) : vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , identifier , 'VS' ) env . client [ 'Virtual_Guest' ] . powerOn ( id = vs_id )
Power on a virtual server .
234,688
def pause ( env , identifier ) : vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , identifier , 'VS' ) if not ( env . skip_confirmations or formatting . confirm ( 'This will pause the VS with id %s. Continue?' % vs_id ) ) : raise exceptions . CLIAbort ( 'Aborted.' ) env . c...
Pauses an active virtual server .
234,689
def resume ( env , identifier ) : vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , identifier , 'VS' ) env . client [ 'Virtual_Guest' ] . resume ( id = vs_id )
Resumes a paused virtual server .
234,690
def cli ( env ) : manager = AccountManager ( env . client ) summary = manager . get_summary ( ) env . fout ( get_snapshot_table ( summary ) )
Prints some various bits of information about an account
234,691
def get_snapshot_table ( account ) : table = formatting . KeyValueTable ( [ "Name" , "Value" ] , title = "Account Snapshot" ) table . align [ 'Name' ] = 'r' table . align [ 'Value' ] = 'l' table . add_row ( [ 'Company Name' , account . get ( 'companyName' , '-' ) ] ) table . add_row ( [ 'Balance' , utils . lookup ( acc...
Generates a table for printing account summary data
234,692
def cli ( env , prop ) : try : if prop == 'network' : env . fout ( get_network ( ) ) return meta_prop = META_MAPPING . get ( prop ) or prop env . fout ( SoftLayer . MetadataManager ( ) . get ( meta_prop ) ) except SoftLayer . TransportError : raise exceptions . CLIAbort ( 'Cannot connect to the backend service address....
Find details about this machine .
234,693
def get_network ( ) : meta = SoftLayer . MetadataManager ( ) network_tables = [ ] for network_func in [ meta . public_network , meta . private_network ] : network = network_func ( ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . align [ 'value' ] = 'l' table . add_row...
Returns a list of tables with public and private network details .
234,694
def get_formatter ( columns ) : column_map = dict ( ( column . name , column ) for column in columns ) def validate ( ctx , param , value ) : if value == '' : raise click . BadParameter ( 'At least one column is required.' ) formatter = ColumnFormatter ( ) for column in [ col . strip ( ) for col in value . split ( ',' ...
This function returns a callback to use with click options .
234,695
def add_column ( self , column ) : self . columns . append ( column . name ) self . column_funcs . append ( column . path ) if column . mask is not None : self . mask_parts . add ( column . mask )
Add a new column along with a formatting function .
234,696
def row ( self , data ) : for column in self . column_funcs : if callable ( column ) : yield column ( data ) else : yield utils . lookup ( data , * column )
Return a formatted row for the given data .
234,697
def cli ( env , account_id , origin_id ) : manager = SoftLayer . CDNManager ( env . client ) manager . remove_origin ( account_id , origin_id )
Remove an origin pull mapping .
234,698
def cli ( env , sortby ) : manager = SoftLayer . CDNManager ( env . client ) accounts = manager . list_accounts ( ) table = formatting . Table ( [ 'id' , 'account_name' , 'type' , 'created' , 'notes' ] ) for account in accounts : table . add_row ( [ account [ 'id' ] , account [ 'cdnAccountName' ] , account [ 'cdnSoluti...
List all CDN accounts .
234,699
def cli ( env , volume_id , sortby , columns ) : file_manager = SoftLayer . FileStorageManager ( env . client ) snapshots = file_manager . get_file_volume_snapshot_list ( volume_id , mask = columns . mask ( ) ) table = formatting . Table ( columns . columns ) table . sortby = sortby for snapshot in snapshots : table . ...
List file storage snapshots .