idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
45,300 | def action_draft ( self ) : for rec in self : if not rec . state == 'cancelled' : raise UserError ( _ ( 'You need to cancel it before reopening.' ) ) if not ( rec . am_i_owner or rec . am_i_approver ) : raise UserError ( _ ( 'You are not authorized to do this.\r\n' 'Only owners or approvers can reopen Change Requests.'... | Set a change request as draft |
45,301 | def action_to_approve ( self ) : template = self . env . ref ( 'document_page_approval.email_template_new_draft_need_approval' ) approver_gid = self . env . ref ( 'document_page_approval.group_document_approver_user' ) for rec in self : if rec . state != 'draft' : raise UserError ( _ ( "Can't approve pages in '%s' stat... | Set a change request as to approve |
45,302 | def action_approve ( self ) : for rec in self : if rec . state not in [ 'draft' , 'to approve' ] : raise UserError ( _ ( "Can't approve page in '%s' state." ) % rec . state ) if not rec . am_i_approver : raise UserError ( _ ( 'You are not authorized to do this.\r\n' 'Only approvers with these groups can approve this: '... | Set a change request as approved . |
45,303 | def action_cancel ( self ) : self . write ( { 'state' : 'cancelled' } ) for rec in self : rec . message_post ( subtype = 'mt_comment' , body = _ ( 'Change request <b>%s</b> has been cancelled by %s.' ) % ( rec . display_name , self . env . user . name ) ) | Set a change request as cancelled . |
45,304 | def _compute_am_i_owner ( self ) : for rec in self : rec . am_i_owner = ( rec . create_uid == self . env . user ) | Check if current user is the owner |
45,305 | def _compute_page_url ( self ) : for page in self : base_url = self . env [ 'ir.config_parameter' ] . sudo ( ) . get_param ( 'web.base.url' , default = 'http://localhost:8069' ) page . page_url = ( '{}/web#db={}&id={}&view_type=form&' 'model=document.page.history' ) . format ( base_url , self . env . cr . dbname , page... | Compute the page url . |
45,306 | def _compute_diff ( self ) : history = self . env [ 'document.page.history' ] for rec in self : domain = [ ( 'page_id' , '=' , rec . page_id . id ) , ( 'state' , '=' , 'approved' ) ] if rec . approved_date : domain . append ( ( 'approved_date' , '<' , rec . approved_date ) ) prev = history . search ( domain , limit = 1... | Shows a diff between this version and the previous version |
45,307 | def action_add_url ( self ) : if not self . env . context . get ( 'active_model' ) : return attachment_obj = self . env [ 'ir.attachment' ] for form in self : url = parse . urlparse ( form . url ) if not url . scheme : url = parse . urlparse ( '%s%s' % ( 'http://' , form . url ) ) for active_id in self . env . context ... | Adds the URL with the given name as an ir . attachment record . |
45,308 | def _compute_is_approval_required ( self ) : for page in self : res = page . approval_required if page . parent_id : res = res or page . parent_id . is_approval_required page . is_approval_required = res | Check if the document required approval based on his parents . |
45,309 | def _compute_approver_group_ids ( self ) : for page in self : res = page . approver_gid if page . parent_id : res = res | page . parent_id . approver_group_ids page . approver_group_ids = res | Compute the approver groups based on his parents . |
45,310 | def _compute_am_i_approver ( self ) : for rec in self : rec . am_i_approver = rec . can_user_approve_this_page ( self . env . user ) | Check if the current user can approve changes to this page . |
45,311 | def can_user_approve_this_page ( self , user ) : self . ensure_one ( ) if not self . is_approval_required : return True if user . has_group ( 'document_page.group_document_manager' ) : return True if not user . has_group ( 'document_page_approval.group_document_approver_user' ) : return False if not self . approver_gro... | Check if a user can approve this page . |
45,312 | def status ( self ) : response = requests . get ( "https://tccna.honeywell.com/WebAPI/emea/api/v1/" "location/%s/status?includeTemperatureControlSystems=True" % self . locationId , headers = self . client . _headers ( ) ) response . raise_for_status ( ) data = response . json ( ) for gw_data in data [ 'gateways' ] : ga... | Retrieves the location status . |
45,313 | def set_dhw_on ( self , until = None ) : if until is None : data = { "Mode" : "PermanentOverride" , "State" : "On" , "UntilTime" : None } else : data = { "Mode" : "TemporaryOverride" , "State" : "On" , "UntilTime" : until . strftime ( '%Y-%m-%dT%H:%M:%SZ' ) } self . _set_dhw ( data ) | Sets the DHW on until a given time or permanently . |
45,314 | def set_dhw_off ( self , until = None ) : if until is None : data = { "Mode" : "PermanentOverride" , "State" : "Off" , "UntilTime" : None } else : data = { "Mode" : "TemporaryOverride" , "State" : "Off" , "UntilTime" : until . strftime ( '%Y-%m-%dT%H:%M:%SZ' ) } self . _set_dhw ( data ) | Sets the DHW off until a given time or permanently . |
45,315 | def schedule ( self ) : response = requests . get ( "https://tccna.honeywell.com/WebAPI/emea/api/v1" "/%s/%s/schedule" % ( self . zone_type , self . zoneId ) , headers = self . client . _headers ( ) ) response . raise_for_status ( ) mapping = [ ( 'dailySchedules' , 'DailySchedules' ) , ( 'dayOfWeek' , 'DayOfWeek' ) , (... | Gets the schedule for the given zone |
45,316 | def set_schedule ( self , zone_info ) : try : json . loads ( zone_info ) except ValueError as error : raise ValueError ( "zone_info must be valid JSON: " , error ) headers = dict ( self . client . _headers ( ) ) headers [ 'Content-Type' ] = 'application/json' response = requests . put ( "https://tccna.honeywell.com/Web... | Sets the schedule for this zone |
45,317 | def temperatures ( self , force_refresh = False ) : self . _populate_full_data ( force_refresh ) for device in self . full_data [ 'devices' ] : set_point = 0 status = "" if 'heatSetpoint' in device [ 'thermostat' ] [ 'changeableValues' ] : set_point = float ( device [ 'thermostat' ] [ 'changeableValues' ] [ "heatSetpoi... | Retrieve the current details for each zone . Returns a generator . |
45,318 | def get_modes ( self , zone ) : self . _populate_full_data ( ) device = self . _get_device ( zone ) return device [ 'thermostat' ] [ 'allowedModes' ] | Returns the set of modes the device can be assigned . |
45,319 | def set_temperature ( self , zone , temperature , until = None ) : if until is None : data = { "Value" : temperature , "Status" : "Hold" , "NextTime" : None } else : data = { "Value" : temperature , "Status" : "Temporary" , "NextTime" : until . strftime ( '%Y-%m-%dT%H:%M:%SZ' ) } self . _set_heat_setpoint ( zone , data... | Sets the temperature of the given zone . |
45,320 | def _set_dhw ( self , status = "Scheduled" , mode = None , next_time = None ) : data = { "Status" : status , "Mode" : mode , "NextTime" : next_time , "SpecialModes" : None , "HeatSetpoint" : None , "CoolSetpoint" : None } self . _populate_full_data ( ) dhw_zone = self . _get_dhw_zone ( ) if dhw_zone is None : raise Exc... | Set DHW to On Off or Auto either indefinitely or until a specified time . |
45,321 | def set_dhw_on ( self , until = None ) : time_until = None if until is None else until . strftime ( '%Y-%m-%dT%H:%M:%SZ' ) self . _set_dhw ( status = "Hold" , mode = "DHWOn" , next_time = time_until ) | Set DHW to on either indefinitely or until a specified time . |
45,322 | def _headers ( self ) : if not self . access_token or not self . access_token_expires : self . _basic_login ( ) elif datetime . now ( ) > self . access_token_expires - timedelta ( seconds = 30 ) : self . _basic_login ( ) return { 'Accept' : HEADER_ACCEPT , 'Authorization' : 'bearer ' + self . access_token } | Ensure the Authorization Header has a valid Access Token . |
45,323 | def _basic_login ( self ) : _LOGGER . debug ( "No/Expired/Invalid access_token, re-authenticating..." ) self . access_token = self . access_token_expires = None if self . refresh_token : _LOGGER . debug ( "Trying refresh_token..." ) credentials = { 'grant_type' : "refresh_token" , 'scope' : "EMEA-V1-Basic EMEA-V1-Anony... | Obtain a new access token from the vendor . |
45,324 | def user_account ( self ) : self . account_info = None url = 'https://tccna.honeywell.com/WebAPI/emea/api/v1/userAccount' response = requests . get ( url , headers = self . _headers ( ) ) response . raise_for_status ( ) self . account_info = response . json ( ) return self . account_info | Return the user account information . |
45,325 | def installation ( self ) : self . locations = [ ] url = ( "https://tccna.honeywell.com/WebAPI/emea/api/v1/location" "/installationInfo?userId=%s" "&includeTemperatureControlSystems=True" % self . account_info [ 'userId' ] ) response = requests . get ( url , headers = self . _headers ( ) ) response . raise_for_status (... | Return the details of the installation . |
45,326 | def full_installation ( self , location = None ) : url = ( "https://tccna.honeywell.com/WebAPI/emea/api/v1/location" "/%s/installationInfo?includeTemperatureControlSystems=True" % self . _get_location ( location ) ) response = requests . get ( url , headers = self . _headers ( ) ) response . raise_for_status ( ) return... | Return the full details of the installation . |
45,327 | def gateway ( self ) : url = 'https://tccna.honeywell.com/WebAPI/emea/api/v1/gateway' response = requests . get ( url , headers = self . _headers ( ) ) response . raise_for_status ( ) return response . json ( ) | Return the detail of the gateway . |
45,328 | def temperatures ( self ) : self . location . status ( ) if self . hotwater : yield { 'thermostat' : 'DOMESTIC_HOT_WATER' , 'id' : self . hotwater . dhwId , 'name' : '' , 'temp' : self . hotwater . temperatureStatus [ 'temperature' ] , 'setpoint' : '' } for zone in self . _zones : zone_info = { 'thermostat' : 'EMEA_ZON... | Return a generator with the details of each zone . |
45,329 | def zone_schedules_backup ( self , filename ) : _LOGGER . info ( "Backing up schedules from ControlSystem: %s (%s)..." , self . systemId , self . location . name ) schedules = { } if self . hotwater : _LOGGER . info ( "Retrieving DHW schedule: %s..." , self . hotwater . zoneId ) schedule = self . hotwater . schedule ( ... | Backup all zones on control system to the given file . |
45,330 | def zone_schedules_restore ( self , filename ) : _LOGGER . info ( "Restoring schedules to ControlSystem %s (%s)..." , self . systemId , self . location ) _LOGGER . info ( "Reading from backup file: %s..." , filename ) with open ( filename , 'r' ) as file_input : schedule_db = file_input . read ( ) schedules = json . lo... | Restore all zones on control system from the given file . |
45,331 | def cli ( env , package_keyname , keyword , category ) : table = formatting . Table ( COLUMNS ) manager = ordering . OrderingManager ( env . client ) _filter = { 'items' : { } } if keyword : _filter [ 'items' ] [ 'description' ] = { 'operation' : '*= %s' % keyword } if category : _filter [ 'items' ] [ 'categories' ] = ... | List package items used for ordering . |
45,332 | def sort_items ( items ) : sorted_items = { } for item in items : category = lookup ( item , 'itemCategory' , 'categoryCode' ) if sorted_items . get ( category ) is None : sorted_items [ category ] = [ ] sorted_items [ category ] . append ( item ) return sorted_items | sorts the items into a dictionary of categories with a list of items |
45,333 | def cli ( env , sortby , datacenter , number , name , limit ) : mgr = SoftLayer . NetworkManager ( env . client ) table = formatting . Table ( COLUMNS ) table . sortby = sortby vlans = mgr . list_vlans ( datacenter = datacenter , vlan_number = number , name = name , limit = limit ) for vlan in vlans : table . add_row (... | List VLANs . |
45,334 | def cli ( env ) : account = env . client [ 'Account' ] nas_accounts = account . getNasNetworkStorage ( mask = 'eventCount,serviceResource[datacenter.name]' ) table = formatting . Table ( [ 'id' , 'datacenter' , 'size' , 'server' ] ) for nas_account in nas_accounts : table . add_row ( [ nas_account [ 'id' ] , utils . lo... | List NAS accounts . |
45,335 | 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 . |
45,336 | 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 . |
45,337 | 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 . |
45,338 | 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 . |
45,339 | 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 |
45,340 | 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 . |
45,341 | 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 . |
45,342 | 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 . |
45,343 | 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 |
45,344 | 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 . |
45,345 | def client ( self ) : if self . _client is None : self . _client = get_session ( self . user_agent ) return self . _client | Returns client session object |
45,346 | 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 |
45,347 | 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 . |
45,348 | 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 . |
45,349 | 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 . |
45,350 | 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 . |
45,351 | 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 . |
45,352 | 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 . |
45,353 | 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 . |
45,354 | 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 . |
45,355 | 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 . |
45,356 | 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 |
45,357 | 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 . |
45,358 | 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 . |
45,359 | 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 . |
45,360 | 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 . |
45,361 | 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 . |
45,362 | 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 . |
45,363 | 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 . |
45,364 | 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 . |
45,365 | 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 . |
45,366 | 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 . |
45,367 | 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 |
45,368 | 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 |
45,369 | 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 . |
45,370 | 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 |
45,371 | 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 . |
45,372 | 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 . |
45,373 | 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 . |
45,374 | 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 . |
45,375 | 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 . |
45,376 | 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 . |
45,377 | 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 |
45,378 | 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 . |
45,379 | 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 |
45,380 | 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 |
45,381 | 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 |
45,382 | 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 |
45,383 | 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 |
45,384 | 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 |
45,385 | 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 |
45,386 | 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 . |
45,387 | 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 . |
45,388 | 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 . |
45,389 | 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 . |
45,390 | 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 . |
45,391 | 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 . |
45,392 | 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 . |
45,393 | 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 . |
45,394 | 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 . |
45,395 | 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 . |
45,396 | 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 . |
45,397 | 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 |
45,398 | 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 . |
45,399 | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.