idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
45,600
def summary_by_datacenter ( self ) : datacenters = collections . defaultdict ( lambda : { 'hardware_count' : 0 , 'public_ip_count' : 0 , 'subnet_count' : 0 , 'virtual_guest_count' : 0 , 'vlan_count' : 0 , } ) for vlan in self . list_vlans ( ) : name = utils . lookup ( vlan , 'primaryRouter' , 'datacenter' , 'name' ) da...
Summary of the networks on the account grouped by data center .
45,601
def _list_global_ips_by_identifier ( self , identifier ) : results = self . list_global_ips ( identifier = identifier , mask = 'id' ) return [ result [ 'id' ] for result in results ]
Returns a list of IDs of the global IP matching the identifier .
45,602
def _list_subnets_by_identifier ( self , identifier ) : identifier = identifier . split ( '/' , 1 ) [ 0 ] results = self . list_subnets ( identifier = identifier , mask = 'id' ) return [ result [ 'id' ] for result in results ]
Returns a list of IDs of the subnet matching the identifier .
45,603
def cli ( env , columns , sortby , volume_id ) : file_storage_manager = SoftLayer . FileStorageManager ( env . client ) legal_volumes = file_storage_manager . get_replication_partners ( volume_id ) if not legal_volumes : click . echo ( "There are no replication partners for the given volume." ) else : table = formattin...
List existing replicant volumes for a file volume .
45,604
def get_ticket_results ( mgr , ticket_id , update_count = 1 ) : ticket = mgr . get_ticket ( ticket_id ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . align [ 'value' ] = 'l' table . add_row ( [ 'id' , ticket [ 'id' ] ] ) table . add_row ( [ 'title' , ticket [ 'title'...
Get output about a ticket .
45,605
def cli ( env , network , quantity , vlan_id , ipv6 , test ) : mgr = SoftLayer . NetworkManager ( env . client ) 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.' ) version = 4 ...
Add a new subnet to your account . Valid quantities vary by type .
45,606
def list_tickets ( self , open_status = True , closed_status = True ) : mask = call = 'getTickets' if not all ( [ open_status , closed_status ] ) : if open_status : call = 'getOpenTickets' elif closed_status : call = 'getClosedTickets' else : raise ValueError ( "open_status and closed_status cannot both be False" ) ret...
List all tickets .
45,607
def create_ticket ( self , title = None , body = None , subject = None , priority = None ) : current_user = self . account . getCurrentUser ( ) new_ticket = { 'subjectId' : subject , 'contents' : body , 'assignedUserId' : current_user [ 'id' ] , 'title' : title , } if priority is not None : new_ticket [ 'priority' ] = ...
Create a new ticket .
45,608
def update_ticket ( self , ticket_id = None , body = None ) : return self . ticket . addUpdate ( { 'entry' : body } , id = ticket_id )
Update a ticket .
45,609
def upload_attachment ( self , ticket_id = None , file_path = None , file_name = None ) : file_content = None with open ( file_path , 'rb' ) as attached_file : file_content = attached_file . read ( ) file_object = { "filename" : file_name , "data" : file_content } return self . ticket . addAttachedFile ( file_object , ...
Upload an attachment to a ticket .
45,610
def attach_hardware ( self , ticket_id = None , hardware_id = None ) : return self . ticket . addAttachedHardware ( hardware_id , id = ticket_id )
Attach hardware to a ticket .
45,611
def attach_virtual_server ( self , ticket_id = None , virtual_id = None ) : return self . ticket . addAttachedVirtualGuest ( virtual_id , id = ticket_id )
Attach a virtual server to a ticket .
45,612
def detach_hardware ( self , ticket_id = None , hardware_id = None ) : return self . ticket . removeAttachedHardware ( hardware_id , id = ticket_id )
Detach hardware from a ticket .
45,613
def detach_virtual_server ( self , ticket_id = None , virtual_id = None ) : return self . ticket . removeAttachedVirtualGuest ( virtual_id , id = ticket_id )
Detach a virtual server from a ticket .
45,614
def cli ( env , identifier , no_vs , no_hardware ) : mgr = SoftLayer . NetworkManager ( env . client ) subnet_id = helpers . resolve_id ( mgr . resolve_subnet_ids , identifier , name = 'subnet' ) subnet = mgr . get_subnet ( subnet_id ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ]...
Get subnet details .
45,615
def cli ( env , zonefile , dry_run ) : manager = SoftLayer . DNSManager ( env . client ) with open ( zonefile ) as zone_f : zone_contents = zone_f . read ( ) zone , records , bad_lines = parse_zone_details ( zone_contents ) env . out ( "Parsed: zone=%s" % zone ) for record in records : env . out ( "Parsed: %s" % RECORD...
Import zone based off a BIND zone file .
45,616
def parse_zone_details ( zone_contents ) : records = [ ] bad_lines = [ ] zone_lines = [ line . strip ( ) for line in zone_contents . split ( '\n' ) ] zone_search = re . search ( r'^\$ORIGIN (?P<zone>.*)\.' , zone_lines [ 0 ] ) zone = zone_search . group ( 'zone' ) for line in zone_lines [ 1 : ] : record_search = re . s...
Parses a zone file into python data - structures .
45,617
def cli ( env ) : mgr = SoftLayer . ObjectStorageManager ( env . client ) accounts = mgr . list_accounts ( ) table = formatting . Table ( [ 'id' , 'name' , 'apiType' ] ) table . sortby = 'id' api_type = None for account in accounts : if 'vendorName' in account and account [ 'vendorName' ] == 'Swift' : api_type = 'Swift...
List object storage accounts .
45,618
def cli ( env , zone ) : manager = SoftLayer . DNSManager ( env . client ) manager . create_zone ( zone )
Create a zone .
45,619
def cli ( env , billing_id , datacenter ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) if not formatting . confirm ( "This action will incur charges on your " "account. Continue?" ) : raise exceptions . CLIAbort ( 'Aborted.' ) mgr . add_local_lb ( billing_id , datacenter = datacenter ) env . fout ( "Load ba...
Adds a load balancer given the id returned from create - options .
45,620
def cli ( env , identifier ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) loadbal_id , group_id = loadbal . parse_id ( identifier ) mgr . reset_service_group ( loadbal_id , group_id ) env . fout ( 'Load balancer service group connections are being reset!' )
Reset connections on a certain service group .
45,621
def cli ( env , identifier , path , name ) : mgr = SoftLayer . TicketManager ( env . client ) ticket_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'ticket' ) if path is None : raise exceptions . ArgumentError ( "Missing argument --path" ) if not os . path . exists ( path ) : raise exceptions . ArgumentEr...
Adds an attachment to an existing ticket .
45,622
def has_firewall ( vlan ) : return bool ( vlan . get ( 'dedicatedFirewallFlag' , None ) or vlan . get ( 'highAvailabilityFirewallFlag' , None ) or vlan . get ( 'firewallInterfaces' , None ) or vlan . get ( 'firewallNetworkComponents' , None ) or vlan . get ( 'firewallGuestNetworkComponents' , None ) )
Helper to determine whether or not a VLAN has a firewall .
45,623
def get_standard_package ( self , server_id , is_virt = True ) : firewall_port_speed = self . _get_fwl_port_speed ( server_id , is_virt ) _value = "%s%s" % ( firewall_port_speed , "Mbps Hardware Firewall" ) _filter = { 'items' : { 'description' : utils . query_filter ( _value ) } } return self . prod_pkg . getItems ( i...
Retrieves the standard firewall package for the virtual server .
45,624
def get_dedicated_package ( self , ha_enabled = False ) : fwl_filter = 'Hardware Firewall (Dedicated)' ha_fwl_filter = 'Hardware Firewall (High Availability)' _filter = utils . NestedDict ( { } ) if ha_enabled : _filter [ 'items' ] [ 'description' ] = utils . query_filter ( ha_fwl_filter ) else : _filter [ 'items' ] [ ...
Retrieves the dedicated firewall package .
45,625
def cancel_firewall ( self , firewall_id , dedicated = False ) : fwl_billing = self . _get_fwl_billing_item ( firewall_id , dedicated ) billing_item_service = self . client [ 'Billing_Item' ] return billing_item_service . cancelService ( id = fwl_billing [ 'id' ] )
Cancels the specified firewall .
45,626
def add_vlan_firewall ( self , vlan_id , ha_enabled = False ) : package = self . get_dedicated_package ( ha_enabled ) product_order = { 'complexType' : 'SoftLayer_Container_Product_Order_Network_' 'Protection_Firewall_Dedicated' , 'quantity' : 1 , 'packageId' : 0 , 'vlanId' : vlan_id , 'prices' : [ { 'id' : package [ 0...
Creates a firewall for the specified vlan .
45,627
def _get_fwl_billing_item ( self , firewall_id , dedicated = False ) : mask = 'mask[id,billingItem[id]]' if dedicated : firewall_service = self . client [ 'Network_Vlan_Firewall' ] else : firewall_service = self . client [ 'Network_Component_Firewall' ] firewall = firewall_service . getObject ( id = firewall_id , mask ...
Retrieves the billing item of the firewall .
45,628
def _get_fwl_port_speed ( self , server_id , is_virt = True ) : fwl_port_speed = 0 if is_virt : mask = ( 'primaryNetworkComponent[maxSpeed]' ) svc = self . client [ 'Virtual_Guest' ] primary = svc . getObject ( mask = mask , id = server_id ) fwl_port_speed = primary [ 'primaryNetworkComponent' ] [ 'maxSpeed' ] else : m...
Determines the appropriate speed for a firewall .
45,629
def get_firewalls ( self ) : mask = ( 'firewallNetworkComponents,' 'networkVlanFirewall,' 'dedicatedFirewallFlag,' 'firewallGuestNetworkComponents,' 'firewallInterfaces,' 'firewallRules,' 'highAvailabilityFirewallFlag' ) return [ firewall for firewall in self . account . getNetworkVlans ( mask = mask ) if has_firewall ...
Returns a list of all firewalls on the account .
45,630
def get_standard_fwl_rules ( self , firewall_id ) : svc = self . client [ 'Network_Component_Firewall' ] return svc . getRules ( id = firewall_id , mask = RULE_MASK )
Get the rules of a standard firewall .
45,631
def edit_dedicated_fwl_rules ( self , firewall_id , rules ) : mask = ( 'mask[networkVlan[firewallInterfaces' '[firewallContextAccessControlLists]]]' ) svc = self . client [ 'Network_Vlan_Firewall' ] fwl = svc . getObject ( id = firewall_id , mask = mask ) network_vlan = fwl [ 'networkVlan' ] for fwl1 in network_vlan [ ...
Edit the rules for dedicated firewall .
45,632
def edit_standard_fwl_rules ( self , firewall_id , rules ) : rule_svc = self . client [ 'Network_Firewall_Update_Request' ] template = { 'networkComponentFirewallId' : firewall_id , 'rules' : rules } return rule_svc . createObject ( template )
Edit the rules for standard firewall .
45,633
def cli ( env , identifier , name , note , tag ) : image_mgr = SoftLayer . ImageManager ( env . client ) data = { } if name : data [ 'name' ] = name if note : data [ 'note' ] = note if tag : data [ 'tag' ] = tag image_id = helpers . resolve_id ( image_mgr . resolve_ids , identifier , 'image' ) if not image_mgr . edit (...
Edit details of an image .
45,634
def cli ( env , identifier , hardware_identifier , virtual_identifier ) : ticket_mgr = SoftLayer . TicketManager ( env . client ) if hardware_identifier and virtual_identifier : raise exceptions . ArgumentError ( "Cannot attach hardware and a virtual server at the same time" ) if hardware_identifier : hardware_mgr = So...
Attach devices to a ticket .
45,635
def get ( self , name , param = None ) : if name not in self . attribs : raise exceptions . SoftLayerError ( 'Unknown metadata attribute.' ) call_details = self . attribs [ name ] if call_details . get ( 'param_req' ) : if not param : raise exceptions . SoftLayerError ( 'Parameter required to get this attribute.' ) par...
Retreive a metadata attribute .
45,636
def _get_network ( self , kind , router = True , vlans = True , vlan_ids = True ) : network = { } macs = self . get ( '%s_mac' % kind ) network [ 'mac_addresses' ] = macs if len ( macs ) == 0 : return network if router : network [ 'router' ] = self . get ( 'router' , macs [ 0 ] ) if vlans : network [ 'vlans' ] = self ....
Wrapper for getting details about networks .
45,637
def cli ( env ) : filtered_vars = dict ( [ ( k , v ) for k , v in env . vars . items ( ) if not k . startswith ( '_' ) ] ) env . fout ( formatting . iter_to_table ( filtered_vars ) )
Print environment variables .
45,638
def cli ( env , volume_id , snapshot_id ) : block_manager = SoftLayer . BlockStorageManager ( env . client ) success = block_manager . restore_from_snapshot ( volume_id , snapshot_id ) if success : click . echo ( 'Block volume %s is being restored using snapshot %s' % ( volume_id , snapshot_id ) )
Restore block volume using a given snapshot
45,639
def cli ( env , crt , csr , icc , key , notes ) : template = { 'intermediateCertificate' : '' , 'certificateSigningRequest' : '' , 'notes' : notes , } template [ 'certificate' ] = open ( crt ) . read ( ) template [ 'privateKey' ] = open ( key ) . read ( ) if csr : body = open ( csr ) . read ( ) template [ 'certificateS...
Add and upload SSL certificate details .
45,640
def cli ( env , identifier , uri , ibm_api_key ) : image_mgr = SoftLayer . ImageManager ( env . client ) image_id = helpers . resolve_id ( image_mgr . resolve_ids , identifier , 'image' ) result = image_mgr . export_image_to_uri ( image_id , uri , ibm_api_key ) if not result : raise exceptions . CLIAbort ( "Failed to e...
Export an image to object storage .
45,641
def convert ( self , value , param , ctx ) : matches = MEMORY_RE . match ( value . lower ( ) ) if matches is None : self . fail ( '%s is not a valid value for memory amount' % value , param , ctx ) amount_str , unit = matches . groups ( ) amount = int ( amount_str ) if unit in [ None , 'm' , 'mb' ] : if amount < 1024 :...
Validate memory argument . Returns the memory value in megabytes .
45,642
def cli ( env , identifier ) : nw_mgr = SoftLayer . NetworkManager ( env . client ) result = nw_mgr . get_nas_credentials ( identifier ) table = formatting . Table ( [ 'username' , 'password' ] ) table . add_row ( [ result . get ( 'username' , 'None' ) , result . get ( 'password' , 'None' ) ] ) env . fout ( table )
List NAS account credentials .
45,643
def cli ( env , identifier ) : mgr = SoftLayer . FirewallManager ( env . client ) firewall_type , firewall_id = firewall . parse_id ( identifier ) if firewall_type == 'vlan' : rules = mgr . get_dedicated_fwl_rules ( firewall_id ) else : rules = mgr . get_standard_fwl_rules ( firewall_id ) env . fout ( get_rules_table (...
Detail firewall .
45,644
def get_rules_table ( rules ) : table = formatting . Table ( [ '#' , 'action' , 'protocol' , 'src_ip' , 'src_mask' , 'dest' , 'dest_mask' ] ) table . sortby = '#' for rule in rules : table . add_row ( [ rule [ 'orderValue' ] , rule [ 'action' ] , rule [ 'protocol' ] , rule [ 'sourceIpAddress' ] , utils . lookup ( rule ...
Helper to format the rules into a table .
45,645
def add_key ( self , key , label , notes = None ) : order = { 'key' : key , 'label' : label , 'notes' : notes , } return self . sshkey . createObject ( order )
Adds a new SSH key to the account .
45,646
def edit_key ( self , key_id , label = None , notes = None ) : data = { } if label : data [ 'label' ] = label if notes : data [ 'notes' ] = notes return self . sshkey . editObject ( data , id = key_id )
Edits information about an SSH key .
45,647
def list_keys ( self , label = None ) : _filter = utils . NestedDict ( { } ) if label : _filter [ 'sshKeys' ] [ 'label' ] = utils . query_filter ( label ) return self . client [ 'Account' ] . getSshKeys ( filter = _filter . to_dict ( ) )
Lists all SSH keys on the account .
45,648
def _get_ids_from_label ( self , label ) : keys = self . list_keys ( ) results = [ ] for key in keys : if key [ 'label' ] == label : results . append ( key [ 'id' ] ) return results
Return sshkey IDs which match the given label .
45,649
def cli ( env , identifier ) : manager = SoftLayer . SSLManager ( env . client ) certificate = manager . get_certificate ( identifier ) write_cert ( certificate [ 'commonName' ] + '.crt' , certificate [ 'certificate' ] ) write_cert ( certificate [ 'commonName' ] + '.key' , certificate [ 'privateKey' ] ) if 'intermediat...
Download SSL certificate and key file .
45,650
def cli ( env , identifier , name , all , note ) : vsi = SoftLayer . VSManager ( env . client ) vs_id = helpers . resolve_id ( vsi . resolve_ids , identifier , 'VS' ) capture = vsi . capture ( vs_id , name , all , note ) table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) table . align [ 'name' ] = 'r' table . ...
Capture one or all disks from a virtual server to a SoftLayer image .
45,651
def get_event_logs ( self , request_filter = None , log_limit = 20 , iterator = True ) : if iterator : return self . client . iter_call ( 'Event_Log' , 'getAllObjects' , filter = request_filter , limit = log_limit ) return self . client . call ( 'Event_Log' , 'getAllObjects' , filter = request_filter , limit = log_limi...
Returns a list of event logs
45,652
def build_filter ( date_min = None , date_max = None , obj_event = None , obj_id = None , obj_type = None , utc_offset = None ) : if not any ( [ date_min , date_max , obj_event , obj_id , obj_type ] ) : return { } request_filter = { } if date_min and date_max : request_filter [ 'eventCreateDate' ] = utils . event_log_f...
Returns a query filter that can be passed into EventLogManager . get_event_logs
45,653
def cli ( env , zone , data , record , ttl , type ) : manager = SoftLayer . DNSManager ( env . client ) table = formatting . Table ( [ 'id' , 'record' , 'type' , 'ttl' , 'data' ] ) table . align [ 'ttl' ] = 'l' table . align [ 'record' ] = 'r' table . align [ 'data' ] = 'l' zone_id = helpers . resolve_id ( manager . re...
List all records in a zone .
45,654
def cli ( env ) : ticket_mgr = SoftLayer . TicketManager ( env . client ) table = formatting . Table ( [ 'id' , 'subject' ] ) for subject in ticket_mgr . list_subjects ( ) : table . add_row ( [ subject [ 'id' ] , subject [ 'name' ] ] ) env . fout ( table )
List Subject IDs for ticket creation .
45,655
def cli ( env , ** args ) : manager = PlacementManager ( env . client ) backend_router_id = helpers . resolve_id ( manager . get_backend_router_id_from_hostname , args . get ( 'backend_router' ) , 'backendRouter' ) rule_id = helpers . resolve_id ( manager . get_rule_id_from_name , args . get ( 'rule' ) , 'Rule' ) place...
Create a placement group .
45,656
def cli ( env , identifier , keys , permissions , hardware , virtual , logins , events ) : mgr = SoftLayer . UserManager ( env . client ) user_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'username' ) object_mask = "userStatus[name], parent[id, username], apiAuthenticationKeys[authenticationKey], " "uns...
User details .
45,657
def basic_info ( user , keys ) : table = formatting . KeyValueTable ( [ 'Title' , 'Basic Information' ] ) table . align [ 'Title' ] = 'r' table . align [ 'Basic Information' ] = 'l' table . add_row ( [ 'Id' , user . get ( 'id' , '-' ) ] ) table . add_row ( [ 'Username' , user . get ( 'username' , '-' ) ] ) if keys : fo...
Prints a table of basic user information
45,658
def print_permissions ( permissions ) : table = formatting . Table ( [ 'keyName' , 'Description' ] ) for perm in permissions : table . add_row ( [ perm [ 'keyName' ] , perm [ 'name' ] ] ) return table
Prints out a users permissions
45,659
def print_access ( access , title ) : columns = [ 'id' , 'hostname' , 'Primary Public IP' , 'Primary Private IP' , 'Created' ] table = formatting . Table ( columns , title ) for host in access : host_id = host . get ( 'id' ) host_fqdn = host . get ( 'fullyQualifiedDomainName' , '-' ) host_primary = host . get ( 'primar...
Prints out the hardware or virtual guests a user can access
45,660
def print_dedicated_access ( access ) : table = formatting . Table ( [ 'id' , 'Name' , 'Cpus' , 'Memory' , 'Disk' , 'Created' ] , 'Dedicated Access' ) for host in access : host_id = host . get ( 'id' ) host_fqdn = host . get ( 'name' ) host_cpu = host . get ( 'cpuCount' ) host_mem = host . get ( 'memoryCapacity' ) host...
Prints out the dedicated hosts a user can access
45,661
def print_logins ( logins ) : table = formatting . Table ( [ 'Date' , 'IP Address' , 'Successufl Login?' ] ) for login in logins : table . add_row ( [ login . get ( 'createDate' ) , login . get ( 'ipAddress' ) , login . get ( 'successFlag' ) ] ) return table
Prints out the login history for a user
45,662
def print_events ( events ) : columns = [ 'Date' , 'Type' , 'IP Address' , 'label' , 'username' ] table = formatting . Table ( columns ) for event in events : table . add_row ( [ event . get ( 'eventCreateDate' ) , event . get ( 'eventName' ) , event . get ( 'ipAddress' ) , event . get ( 'label' ) , event . get ( 'user...
Prints out the event log for a user
45,663
def cli ( env , identifier ) : mgr = SoftLayer . UserManager ( env . client ) user_id = helpers . resolve_id ( mgr . resolve_ids , identifier , 'username' ) user_template = { 'userStatusId' : 1021 } result = mgr . edit_user ( user_id , user_template ) if result : click . secho ( "%s deleted successfully" % identifier ,...
Sets a user s status to CANCEL_PENDING which will immediately disable the account
45,664
def cli ( env , identifier , crt , csr , icc , key , notes ) : template = { 'id' : identifier } if crt : template [ 'certificate' ] = open ( crt ) . read ( ) if key : template [ 'privateKey' ] = open ( key ) . read ( ) if csr : template [ 'certificateSigningRequest' ] = open ( csr ) . read ( ) if icc : template [ 'inte...
Edit SSL certificate .
45,665
def cli ( env , account_id , content_url , type , cname ) : manager = SoftLayer . CDNManager ( env . client ) manager . add_origin ( account_id , type , content_url , cname )
Create an origin pull mapping .
45,666
def export_to_template ( filename , args , exclude = None ) : exclude = exclude or [ ] exclude . append ( 'config' ) exclude . append ( 'really' ) exclude . append ( 'format' ) exclude . append ( 'debug' ) with open ( filename , "w" ) as template_file : for k , val in args . items ( ) : if val and k not in exclude : if...
Exports given options to the given filename in INI format .
45,667
def list ( self , mask = None ) : if mask is None : mask = "mask[id, name, createDate, rule, guestCount, backendRouter[id, hostname]]" groups = self . client . call ( 'Account' , 'getPlacementGroups' , mask = mask , iter = True ) return groups
List existing placement groups
45,668
def get_object ( self , group_id , mask = None ) : if mask is None : mask = "mask[id, name, createDate, rule, backendRouter[id, hostname]," "guests[activeTransaction[id,transactionStatus[name,friendlyName]]]]" return self . client . call ( 'SoftLayer_Virtual_PlacementGroup' , 'getObject' , id = group_id , mask = mask )
Returns a PlacementGroup Object
45,669
def get_rule_id_from_name ( self , name ) : results = self . client . call ( 'SoftLayer_Virtual_PlacementGroup_Rule' , 'getAllObjects' ) return [ result [ 'id' ] for result in results if result [ 'keyName' ] == name . upper ( ) ]
Finds the rule that matches name .
45,670
def get_backend_router_id_from_hostname ( self , hostname ) : results = self . client . call ( 'SoftLayer_Network_Pod' , 'getAllObjects' ) return [ result [ 'backendRouterId' ] for result in results if result [ 'backendRouterName' ] == hostname . lower ( ) ]
Finds the backend router Id that matches the hostname given
45,671
def _get_id_from_name ( self , name ) : _filter = { 'placementGroups' : { 'name' : { 'operation' : name } } } mask = "mask[id, name]" results = self . client . call ( 'Account' , 'getPlacementGroups' , filter = _filter , mask = mask ) return [ result [ 'id' ] for result in results ]
List placement group ids which match the given name .
45,672
def cli ( env ) : manager = CapacityManager ( env . client ) items = manager . get_create_options ( ) items . sort ( key = lambda term : int ( term [ 'capacity' ] ) ) table = formatting . Table ( [ "KeyName" , "Description" , "Term" , "Default Hourly Price Per Instance" ] , title = "Reserved Capacity Options" ) table ....
List options for creating Reserved Capacity
45,673
def get_price ( item ) : the_price = "No Default Pricing" for price in item . get ( 'prices' , [ ] ) : if not price . get ( 'locationGroupId' ) : the_price = "%0.4f" % float ( price [ 'hourlyRecurringFee' ] ) return the_price
Finds the price with the default locationGroupId
45,674
def cli ( env , keyword , package_type ) : manager = ordering . OrderingManager ( env . client ) table = formatting . Table ( COLUMNS ) _filter = { 'type' : { 'keyName' : { 'operation' : '!= BLUEMIX_SERVICE' } } } if keyword : _filter [ 'name' ] = { 'operation' : '*= %s' % keyword } if package_type : _filter [ 'type' ]...
List packages that can be ordered via the placeOrder API .
45,675
def cli ( env ) : mgr = SoftLayer . LoadBalancerManager ( env . client ) load_balancers = mgr . get_local_lbs ( ) table = formatting . Table ( [ 'ID' , 'VIP Address' , 'Location' , 'SSL Offload' , 'Connections/second' , 'Type' ] ) table . align [ 'Connections/second' ] = 'r' for load_balancer in load_balancers : ssl_su...
List active load balancers .
45,676
def cli ( env , identifier ) : manager = SoftLayer . HardwareManager ( env . client ) hardware_id = helpers . resolve_id ( manager . resolve_ids , identifier , 'hardware' ) instance = manager . get_hardware ( hardware_id ) table = formatting . Table ( [ 'username' , 'password' ] ) for item in instance [ 'softwareCompon...
List server credentials .
45,677
def populate_host_templates ( host_templates , hardware_ids = None , virtual_guest_ids = None , ip_address_ids = None , subnet_ids = None ) : if hardware_ids is not None : for hardware_id in hardware_ids : host_templates . append ( { 'objectType' : 'SoftLayer_Hardware' , 'id' : hardware_id } ) if virtual_guest_ids is n...
Populate the given host_templates array with the IDs provided
45,678
def get_package ( manager , category_code ) : _filter = utils . NestedDict ( { } ) _filter [ 'categories' ] [ 'categoryCode' ] = ( utils . query_filter ( category_code ) ) _filter [ 'statusCode' ] = ( utils . query_filter ( 'ACTIVE' ) ) packages = manager . client . call ( 'Product_Package' , 'getAllObjects' , filter =...
Returns a product package based on type of storage .
45,679
def get_location_id ( manager , location ) : loc_svc = manager . client [ 'Location_Datacenter' ] datacenters = loc_svc . getDatacenters ( mask = 'mask[longName,id,name]' ) for datacenter in datacenters : if datacenter [ 'name' ] == location : location = datacenter [ 'id' ] return location raise ValueError ( 'Invalid d...
Returns location id
45,680
def find_price_by_category ( package , price_category ) : for item in package [ 'items' ] : price_id = _find_price_id ( item [ 'prices' ] , price_category ) if price_id : return price_id raise ValueError ( "Could not find price with the category, %s" % price_category )
Find the price in the given package that has the specified category
45,681
def find_ent_space_price ( package , category , size , tier_level ) : if category == 'snapshot' : category_code = 'storage_snapshot_space' elif category == 'replication' : category_code = 'performance_storage_replication' else : category_code = 'performance_storage_space' level = ENDURANCE_TIERS . get ( tier_level ) fo...
Find the space price for the given category size and tier
45,682
def find_ent_endurance_tier_price ( package , tier_level ) : for item in package [ 'items' ] : for attribute in item . get ( 'attributes' , [ ] ) : if int ( attribute [ 'value' ] ) == ENDURANCE_TIERS . get ( tier_level ) : break else : continue price_id = _find_price_id ( item [ 'prices' ] , 'storage_tier_level' ) if p...
Find the price in the given package with the specified tier level
45,683
def find_perf_space_price ( package , size ) : for item in package [ 'items' ] : if int ( item [ 'capacity' ] ) != size : continue price_id = _find_price_id ( item [ 'prices' ] , 'performance_storage_space' ) if price_id : return price_id raise ValueError ( "Could not find performance space price for this volume" )
Find the price in the given package with the specified size
45,684
def find_perf_iops_price ( package , size , iops ) : for item in package [ 'items' ] : if int ( item [ 'capacity' ] ) != int ( iops ) : continue price_id = _find_price_id ( item [ 'prices' ] , 'performance_storage_iops' , 'STORAGE_SPACE' , size ) if price_id : return price_id raise ValueError ( "Could not find price fo...
Find the price in the given package with the specified size and iops
45,685
def find_saas_endurance_space_price ( package , size , tier_level ) : if tier_level != 0.25 : tier_level = int ( tier_level ) key_name = 'STORAGE_SPACE_FOR_{0}_IOPS_PER_GB' . format ( tier_level ) key_name = key_name . replace ( "." , "_" ) for item in package [ 'items' ] : if key_name not in item [ 'keyName' ] : conti...
Find the SaaS endurance storage space price for the size and tier
45,686
def find_saas_endurance_tier_price ( package , tier_level ) : target_capacity = ENDURANCE_TIERS . get ( tier_level ) for item in package [ 'items' ] : if 'itemCategory' not in item or 'categoryCode' not in item [ 'itemCategory' ] or item [ 'itemCategory' ] [ 'categoryCode' ] != 'storage_tier_level' : continue if int ( ...
Find the SaaS storage tier level price for the specified tier level
45,687
def find_saas_perform_space_price ( package , size ) : for item in package [ 'items' ] : if 'itemCategory' not in item or 'categoryCode' not in item [ 'itemCategory' ] or item [ 'itemCategory' ] [ 'categoryCode' ] != 'performance_storage_space' : continue if 'capacityMinimum' not in item or 'capacityMaximum' not in ite...
Find the SaaS performance storage space price for the given size
45,688
def find_saas_perform_iops_price ( package , size , iops ) : for item in package [ 'items' ] : if 'itemCategory' not in item or 'categoryCode' not in item [ 'itemCategory' ] or item [ 'itemCategory' ] [ 'categoryCode' ] != 'performance_storage_iops' : continue if 'capacityMinimum' not in item or 'capacityMaximum' not i...
Find the SaaS IOPS price for the specified size and iops
45,689
def find_saas_snapshot_space_price ( package , size , tier = None , iops = None ) : if tier is not None : target_value = ENDURANCE_TIERS . get ( tier ) target_restriction_type = 'STORAGE_TIER_LEVEL' else : target_value = iops target_restriction_type = 'IOPS' for item in package [ 'items' ] : if int ( item [ 'capacity' ...
Find the price in the SaaS package for the desired snapshot space size
45,690
def find_saas_replication_price ( package , tier = None , iops = None ) : if tier is not None : target_value = ENDURANCE_TIERS . get ( tier ) target_item_keyname = 'REPLICATION_FOR_TIERBASED_PERFORMANCE' target_restriction_type = 'STORAGE_TIER_LEVEL' else : target_value = iops target_item_keyname = 'REPLICATION_FOR_IOP...
Find the price in the given package for the desired replicant volume
45,691
def find_snapshot_schedule_id ( volume , snapshot_schedule_keyname ) : for schedule in volume [ 'schedules' ] : if 'type' in schedule and 'keyname' in schedule [ 'type' ] : if schedule [ 'type' ] [ 'keyname' ] == snapshot_schedule_keyname : return schedule [ 'id' ] raise ValueError ( "The given snapshot schedule ID was...
Find the snapshot schedule ID for the given volume and keyname
45,692
def cli ( env , volume_id , reason , immediate ) : file_storage_manager = SoftLayer . FileStorageManager ( env . client ) if not ( env . skip_confirmations or formatting . no_going_back ( volume_id ) ) : raise exceptions . CLIAbort ( 'Aborted' ) cancelled = file_storage_manager . cancel_snapshot_space ( volume_id , rea...
Cancel existing snapshot space for a given volume .
45,693
def get_by_request_id ( env , request_id ) : mgr = SoftLayer . NetworkManager ( env . client ) logs = mgr . get_event_logs_by_request_id ( request_id ) table = formatting . Table ( COLUMNS ) table . align [ 'metadata' ] = "l" for log in logs : metadata = json . dumps ( json . loads ( log [ 'metaData' ] ) , indent = 4 ,...
Search for event logs by request id
45,694
def cli ( env , title , subject_id , body , hardware_identifier , virtual_identifier , priority ) : ticket_mgr = SoftLayer . TicketManager ( env . client ) if body is None : body = click . edit ( '\n\n' + ticket . TEMPLATE_MSG ) created_ticket = ticket_mgr . create_ticket ( title = title , body = body , subject = subje...
Create a support ticket .
45,695
def cli ( env , volume_id , replicant_id ) : file_storage_manager = SoftLayer . FileStorageManager ( env . client ) success = file_storage_manager . failback_from_replicant ( volume_id , replicant_id ) if success : click . echo ( "Failback from replicant is now in progress." ) else : click . echo ( "Failback operation ...
Failback a file volume from the given replicant volume .
45,696
def cli ( env , volume_id , snapshot_id ) : file_manager = SoftLayer . FileStorageManager ( env . client ) success = file_manager . restore_from_snapshot ( volume_id , snapshot_id ) if success : click . echo ( 'File volume %s is being restored using snapshot %s' % ( volume_id , snapshot_id ) )
Restore file volume using a given snapshot
45,697
def cli ( env ) : settings = config . get_settings_from_client ( env . client ) env . fout ( config . config_table ( settings ) )
Show current configuration .
45,698
def cli ( env , storage_type , size , iops , tier , location , snapshot_size , service_offering , billing ) : file_manager = SoftLayer . FileStorageManager ( env . client ) storage_type = storage_type . lower ( ) hourly_billing_flag = False if billing . lower ( ) == "hourly" : hourly_billing_flag = True if service_offe...
Order a file storage volume .
45,699
def cli ( env , ** args ) : create_args = _parse_create_args ( env . client , args ) create_args [ 'primary_disk' ] = args . get ( 'primary_disk' ) manager = CapacityManager ( env . client ) capacity_id = args . get ( 'capacity_id' ) test = args . get ( 'test' ) result = manager . create_guest ( capacity_id , test , cr...
Allows for creating a virtual guest in a reserved capacity .