idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
62,500
def isFresh ( self ) : "returns True if cached object is still fresh" max_age = self . getMaxAge ( ) date = self . getDate ( ) is_fresh = False if max_age and date : delta_time = datetime . now ( ) - date is_fresh = delta_time . total_seconds ( ) < max_age return is_fresh
returns True if cached object is still fresh
62,501
async def _on_response_prepare ( self , request : web . Request , response : web . StreamResponse ) : if ( not self . _router_adapter . is_cors_enabled_on_request ( request ) or self . _router_adapter . is_preflight_request ( request ) ) : return config = self . _router_adapter . get_non_preflight_request_config ( request ) origin = request . headers . get ( hdrs . ORIGIN ) if origin is None : return options = config . get ( origin , config . get ( "*" ) ) if options is None : return assert hdrs . ACCESS_CONTROL_ALLOW_ORIGIN not in response . headers assert hdrs . ACCESS_CONTROL_ALLOW_CREDENTIALS not in response . headers assert hdrs . ACCESS_CONTROL_EXPOSE_HEADERS not in response . headers if options . expose_headers == "*" : exposed_headers = frozenset ( response . headers . keys ( ) ) - _SIMPLE_RESPONSE_HEADERS response . headers [ hdrs . ACCESS_CONTROL_EXPOSE_HEADERS ] = "," . join ( exposed_headers ) elif options . expose_headers : response . headers [ hdrs . ACCESS_CONTROL_EXPOSE_HEADERS ] = "," . join ( options . expose_headers ) response . headers [ hdrs . ACCESS_CONTROL_ALLOW_ORIGIN ] = origin if options . allow_credentials : response . headers [ hdrs . ACCESS_CONTROL_ALLOW_CREDENTIALS ] = _TRUE
Non - preflight CORS request response processor .
62,502
def _is_proper_sequence ( seq ) : return ( isinstance ( seq , collections . abc . Sequence ) and not isinstance ( seq , str ) )
Returns is seq is sequence and not string .
62,503
def setup ( app : web . Application , * , defaults : Mapping [ str , Union [ ResourceOptions , Mapping [ str , Any ] ] ] = None ) -> CorsConfig : cors = CorsConfig ( app , defaults = defaults ) app [ APP_CONFIG_KEY ] = cors return cors
Setup CORS processing for the application .
62,504
def _parse_request_method ( request : web . Request ) : method = request . headers . get ( hdrs . ACCESS_CONTROL_REQUEST_METHOD ) if method is None : raise web . HTTPForbidden ( text = "CORS preflight request failed: " "'Access-Control-Request-Method' header is not specified" ) return method
Parse Access - Control - Request - Method header of the preflight request
62,505
def _parse_request_headers ( request : web . Request ) : headers = request . headers . get ( hdrs . ACCESS_CONTROL_REQUEST_HEADERS ) if headers is None : return frozenset ( ) headers = ( h . strip ( " \t" ) . upper ( ) for h in headers . split ( "," ) ) return frozenset ( filter ( None , headers ) )
Parse Access - Control - Request - Headers header or the preflight request
62,506
async def _preflight_handler ( self , request : web . Request ) : origin = request . headers . get ( hdrs . ORIGIN ) if origin is None : raise web . HTTPForbidden ( text = "CORS preflight request failed: " "origin header is not specified in the request" ) request_method = self . _parse_request_method ( request ) try : config = await self . _get_config ( request , origin , request_method ) except KeyError : raise web . HTTPForbidden ( text = "CORS preflight request failed: " "request method {!r} is not allowed " "for {!r} origin" . format ( request_method , origin ) ) if not config : raise web . HTTPForbidden ( text = "CORS preflight request failed: " "no origins are allowed" ) options = config . get ( origin , config . get ( "*" ) ) if options is None : raise web . HTTPForbidden ( text = "CORS preflight request failed: " "origin '{}' is not allowed" . format ( origin ) ) request_headers = self . _parse_request_headers ( request ) if options . allow_headers == "*" : pass else : disallowed_headers = request_headers - options . allow_headers if disallowed_headers : raise web . HTTPForbidden ( text = "CORS preflight request failed: " "headers are not allowed: {}" . format ( ", " . join ( disallowed_headers ) ) ) response = web . Response ( ) response . headers [ hdrs . ACCESS_CONTROL_ALLOW_ORIGIN ] = origin if options . allow_credentials : response . headers [ hdrs . ACCESS_CONTROL_ALLOW_CREDENTIALS ] = _TRUE if options . max_age is not None : response . headers [ hdrs . ACCESS_CONTROL_MAX_AGE ] = str ( options . max_age ) response . headers [ hdrs . ACCESS_CONTROL_ALLOW_METHODS ] = request_method if request_headers : response . headers [ hdrs . ACCESS_CONTROL_ALLOW_HEADERS ] = "," . join ( request_headers ) return response
CORS preflight request handler
62,507
def add_preflight_handler ( self , routing_entity : Union [ web . Resource , web . StaticResource , web . ResourceRoute ] , handler ) : if isinstance ( routing_entity , web . Resource ) : resource = routing_entity if resource in self . _resources_with_preflight_handlers : return for route_obj in resource : if route_obj . method == hdrs . METH_OPTIONS : if route_obj . handler is handler : return else : raise ValueError ( "{!r} already has OPTIONS handler {!r}" . format ( resource , route_obj . handler ) ) elif route_obj . method == hdrs . METH_ANY : if _is_web_view ( route_obj ) : self . _preflight_routes . add ( route_obj ) self . _resources_with_preflight_handlers . add ( resource ) return else : raise ValueError ( "{!r} already has a '*' handler " "for all methods" . format ( resource ) ) preflight_route = resource . add_route ( hdrs . METH_OPTIONS , handler ) self . _preflight_routes . add ( preflight_route ) self . _resources_with_preflight_handlers . add ( resource ) elif isinstance ( routing_entity , web . StaticResource ) : resource = routing_entity if resource in self . _resources_with_preflight_handlers : return resource . set_options_route ( handler ) preflight_route = resource . _routes [ hdrs . METH_OPTIONS ] self . _preflight_routes . add ( preflight_route ) self . _resources_with_preflight_handlers . add ( resource ) elif isinstance ( routing_entity , web . ResourceRoute ) : route = routing_entity if not self . is_cors_for_resource ( route . resource ) : self . add_preflight_handler ( route . resource , handler ) else : raise ValueError ( "Resource or ResourceRoute expected, got {!r}" . format ( routing_entity ) )
Add OPTIONS handler for all routes defined by routing_entity .
62,508
def is_preflight_request ( self , request : web . Request ) -> bool : route = self . _request_route ( request ) if _is_web_view ( route , strict = False ) : return request . method == 'OPTIONS' return route in self . _preflight_routes
Is request is a CORS preflight request .
62,509
def is_cors_enabled_on_request ( self , request : web . Request ) -> bool : return self . _request_resource ( request ) in self . _resource_config
Is request is a request for CORS - enabled resource .
62,510
def set_config_for_routing_entity ( self , routing_entity : Union [ web . Resource , web . StaticResource , web . ResourceRoute ] , config ) : if isinstance ( routing_entity , ( web . Resource , web . StaticResource ) ) : resource = routing_entity if resource in self . _resource_config : raise ValueError ( "CORS is already configured for {!r} resource." . format ( resource ) ) self . _resource_config [ resource ] = _ResourceConfig ( default_config = config ) elif isinstance ( routing_entity , web . ResourceRoute ) : route = routing_entity if route . resource not in self . _resource_config : self . set_config_for_routing_entity ( route . resource , config ) if route . resource not in self . _resource_config : raise ValueError ( "Can't setup CORS for {!r} request, " "CORS must be enabled for route's resource first." . format ( route ) ) resource_config = self . _resource_config [ route . resource ] if route . method in resource_config . method_config : raise ValueError ( "Can't setup CORS for {!r} route: CORS already " "configured on resource {!r} for {} method" . format ( route , route . resource , route . method ) ) resource_config . method_config [ route . method ] = config else : raise ValueError ( "Resource or ResourceRoute expected, got {!r}" . format ( routing_entity ) )
Record configuration for resource or it s route .
62,511
def get_non_preflight_request_config ( self , request : web . Request ) : assert self . is_cors_enabled_on_request ( request ) resource = self . _request_resource ( request ) resource_config = self . _resource_config [ resource ] route = request . match_info . route if _is_web_view ( route , strict = False ) : method_config = request . match_info . handler . get_request_config ( request , request . method ) else : method_config = resource_config . method_config . get ( request . method , { } ) defaulted_config = collections . ChainMap ( method_config , resource_config . default_config , self . _default_config ) return defaulted_config
Get stored CORS configuration for routing entity that handles specified request .
62,512
def add ( self , information , timeout = - 1 ) : return self . _client . create ( information , timeout = timeout )
Adds a data center resource based upon the attributes specified .
62,513
def update ( self , resource , timeout = - 1 ) : return self . _client . update ( resource , timeout = timeout )
Updates the specified data center resource .
62,514
def remove_all ( self , filter , force = False , timeout = - 1 ) : return self . _client . delete_all ( filter = filter , force = force , timeout = timeout )
Deletes the set of datacenters according to the specified parameters . A filter is required to identify the set of resources to be deleted .
62,515
def get_by ( self , field , value ) : return self . _client . get_by ( field = field , value = value )
Gets all drive enclosures that match the filter .
62,516
def refresh_state ( self , id_or_uri , configuration , timeout = - 1 ) : uri = self . _client . build_uri ( id_or_uri ) + self . REFRESH_STATE_PATH return self . _client . update ( resource = configuration , uri = uri , timeout = timeout )
Refreshes a drive enclosure .
62,517
def get_all ( self , start = 0 , count = - 1 , filter = '' , fields = '' , query = '' , sort = '' , view = '' ) : return self . _client . get_all ( start , count , filter = filter , sort = sort , query = query , fields = fields , view = view )
Gets a list of Deployment Servers based on optional sorting and filtering and constrained by start and count parameters .
62,518
def delete ( self , resource , force = False , timeout = - 1 ) : return self . _client . delete ( resource , force = force , timeout = timeout )
Deletes a Deployment Server object based on its UUID or URI .
62,519
def get_appliances ( self , start = 0 , count = - 1 , filter = '' , fields = '' , query = '' , sort = '' , view = '' ) : uri = self . URI + '/image-streamer-appliances' return self . _client . get_all ( start , count , filter = filter , sort = sort , query = query , fields = fields , view = view , uri = uri )
Gets a list of all the Image Streamer resources based on optional sorting and filtering and constrained by start and count parameters .
62,520
def get_appliance ( self , id_or_uri , fields = '' ) : uri = self . URI + '/image-streamer-appliances/' + extract_id_from_uri ( id_or_uri ) if fields : uri += '?fields=' + fields return self . _client . get ( uri )
Gets the particular Image Streamer resource based on its ID or URI .
62,521
def get_appliance_by_name ( self , appliance_name ) : appliances = self . get_appliances ( ) if appliances : for appliance in appliances : if appliance [ 'name' ] == appliance_name : return appliance return None
Gets the particular Image Streamer resource based on its name .
62,522
def get_managed_ports ( self , id_or_uri , port_id_or_uri = '' ) : if port_id_or_uri : uri = self . _client . build_uri ( port_id_or_uri ) if "/managedPorts" not in uri : uri = self . _client . build_uri ( id_or_uri ) + "/managedPorts" + "/" + port_id_or_uri else : uri = self . _client . build_uri ( id_or_uri ) + "/managedPorts" return self . _client . get_collection ( uri )
Gets all ports or a specific managed target port for the specified storage system .
62,523
def get_by_ip_hostname ( self , ip_hostname ) : resources = self . _client . get_all ( ) resources_filtered = [ x for x in resources if x [ 'credentials' ] [ 'ip_hostname' ] == ip_hostname ] if resources_filtered : return resources_filtered [ 0 ] else : return None
Retrieve a storage system by its IP .
62,524
def get_by_hostname ( self , hostname ) : resources = self . _client . get_all ( ) resources_filtered = [ x for x in resources if x [ 'hostname' ] == hostname ] if resources_filtered : return resources_filtered [ 0 ] else : return None
Retrieve a storage system by its hostname .
62,525
def get_reachable_ports ( self , id_or_uri , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , networks = [ ] ) : uri = self . _client . build_uri ( id_or_uri ) + "/reachable-ports" if networks : elements = "\'" for n in networks : elements += n + ',' elements = elements [ : - 1 ] + "\'" uri = uri + "?networks=" + elements return self . _client . get ( self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri ) )
Gets the storage ports that are connected on the specified networks based on the storage system port s expected network connectivity .
62,526
def get_templates ( self , id_or_uri , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' ) : uri = self . _client . build_uri ( id_or_uri ) + "/templates" return self . _client . get ( self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri ) )
Gets a list of volume templates . Returns a list of storage templates belonging to the storage system .
62,527
def get_reserved_vlan_range ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/reserved-vlan-range" return self . _client . get ( uri )
Gets the reserved vlan ID range for the fabric .
62,528
def update_reserved_vlan_range ( self , id_or_uri , vlan_pool , force = False ) : uri = self . _client . build_uri ( id_or_uri ) + "/reserved-vlan-range" return self . _client . update ( resource = vlan_pool , uri = uri , force = force , default_values = self . DEFAULT_VALUES )
Updates the reserved vlan ID range for the fabric .
62,529
def get ( self , name_or_uri ) : name_or_uri = quote ( name_or_uri ) return self . _client . get ( name_or_uri )
Get the role by its URI or Name .
62,530
def get_drives ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri = id_or_uri ) + self . DRIVES_PATH return self . _client . get ( id_or_uri = uri )
Gets the list of drives allocated to this SAS logical JBOD .
62,531
def enable ( self , information , id_or_uri , timeout = - 1 ) : uri = self . _client . build_uri ( id_or_uri ) return self . _client . update ( information , uri , timeout = timeout )
Enables or disables a range .
62,532
def get_allocated_fragments ( self , id_or_uri , count = - 1 , start = 0 ) : uri = self . _client . build_uri ( id_or_uri ) + "/allocated-fragments?start={0}&count={1}" . format ( start , count ) return self . _client . get_collection ( uri )
Gets all fragments that have been allocated in range .
62,533
def get_all ( self , start = 0 , count = - 1 , sort = '' ) : return self . _helper . get_all ( start , count , sort = sort )
Gets a list of logical interconnects based on optional sorting and filtering and is constrained by start and count parameters .
62,534
def update_compliance ( self , timeout = - 1 ) : uri = "{}/compliance" . format ( self . data [ "uri" ] ) return self . _helper . update ( None , uri , timeout = timeout )
Returns logical interconnects to a consistent state . The current logical interconnect state is compared to the associated logical interconnect group .
62,535
def update_ethernet_settings ( self , configuration , force = False , timeout = - 1 ) : uri = "{}/ethernetSettings" . format ( self . data [ "uri" ] ) return self . _helper . update ( configuration , uri = uri , force = force , timeout = timeout )
Updates the Ethernet interconnect settings for the logical interconnect .
62,536
def update_internal_networks ( self , network_uri_list , force = False , timeout = - 1 ) : uri = "{}/internalNetworks" . format ( self . data [ "uri" ] ) return self . _helper . update ( network_uri_list , uri = uri , force = force , timeout = timeout )
Updates internal networks on the logical interconnect .
62,537
def update_configuration ( self , timeout = - 1 ) : uri = "{}/configuration" . format ( self . data [ "uri" ] ) return self . _helper . update ( None , uri = uri , timeout = timeout )
Asynchronously applies or re - applies the logical interconnect configuration to all managed interconnects .
62,538
def get_snmp_configuration ( self ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . SNMP_CONFIGURATION_PATH ) return self . _helper . do_get ( uri )
Gets the SNMP configuration for a logical interconnect .
62,539
def update_snmp_configuration ( self , configuration , timeout = - 1 ) : data = configuration . copy ( ) if 'type' not in data : data [ 'type' ] = 'snmp-configuration' uri = "{}{}" . format ( self . data [ "uri" ] , self . SNMP_CONFIGURATION_PATH ) return self . _helper . update ( data , uri = uri , timeout = timeout )
Updates the SNMP configuration of a logical interconnect . Changes to the SNMP configuration are asynchronously applied to all managed interconnects .
62,540
def get_unassigned_ports ( self ) : uri = "{}/unassignedPortsForPortMonitor" . format ( self . data [ "uri" ] ) response = self . _helper . do_get ( uri ) return self . _helper . get_members ( response )
Gets the collection ports from the member interconnects which are eligible for assignment to an anlyzer port
62,541
def get_port_monitor ( self ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . PORT_MONITOR_PATH ) return self . _helper . do_get ( uri )
Gets the port monitor configuration of a logical interconnect .
62,542
def update_port_monitor ( self , resource , timeout = - 1 ) : data = resource . copy ( ) if 'type' not in data : data [ 'type' ] = 'port-monitor' uri = "{}{}" . format ( self . data [ "uri" ] , self . PORT_MONITOR_PATH ) return self . _helper . update ( data , uri = uri , timeout = timeout )
Updates the port monitor configuration of a logical interconnect .
62,543
def create_interconnect ( self , location_entries , timeout = - 1 ) : return self . _helper . create ( location_entries , uri = self . locations_uri , timeout = timeout )
Creates an interconnect at the given location .
62,544
def delete_interconnect ( self , enclosure_uri , bay , timeout = - 1 ) : uri = "{path}?location=Enclosure:{enclosure_uri},Bay:{bay}" . format ( path = self . LOCATIONS_PATH , enclosure_uri = enclosure_uri , bay = bay ) return self . _helper . delete ( uri , timeout = timeout )
Deletes an interconnect from a location .
62,545
def get_firmware ( self ) : firmware_uri = self . _helper . build_subresource_uri ( self . data [ "uri" ] , subresource_path = self . FIRMWARE_PATH ) return self . _helper . do_get ( firmware_uri )
Gets the installed firmware for a logical interconnect .
62,546
def get_forwarding_information_base ( self , filter = '' ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . FORWARDING_INFORMATION_PATH ) return self . _helper . get_collection ( uri , filter = filter )
Gets the forwarding information base data for a logical interconnect . A maximum of 100 entries is returned . Optional filtering criteria might be specified .
62,547
def create_forwarding_information_base ( self , timeout = - 1 ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . FORWARDING_INFORMATION_PATH ) return self . _helper . do_post ( uri , None , timeout , None )
Generates the forwarding information base dump file for a logical interconnect .
62,548
def get_qos_aggregated_configuration ( self ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . QOS_AGGREGATED_CONFIGURATION ) return self . _helper . do_get ( uri )
Gets the QoS aggregated configuration for the logical interconnect .
62,549
def update_qos_aggregated_configuration ( self , qos_configuration , timeout = - 1 ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . QOS_AGGREGATED_CONFIGURATION ) return self . _helper . update ( qos_configuration , uri = uri , timeout = timeout )
Updates the QoS aggregated configuration for the logical interconnect .
62,550
def update_telemetry_configurations ( self , configuration , timeout = - 1 ) : telemetry_conf_uri = self . _get_telemetry_configuration_uri ( ) default_values = self . _get_default_values ( self . SETTINGS_TELEMETRY_CONFIG_DEFAULT_VALUES ) configuration = self . _helper . update_resource_fields ( configuration , default_values ) return self . _helper . update ( configuration , uri = telemetry_conf_uri , timeout = timeout )
Updates the telemetry configuration of a logical interconnect . Changes to the telemetry configuration are asynchronously applied to all managed interconnects .
62,551
def get_ethernet_settings ( self ) : uri = "{}/ethernetSettings" . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri )
Gets the Ethernet interconnect settings for the Logical Interconnect .
62,552
def download_archive ( self , name , file_path ) : uri = self . URI + "/archive/" + name return self . _client . download ( uri , file_path )
Download archived logs of the OS Volume .
62,553
def get_storage ( self , id_or_uri ) : uri = self . URI + "/{}/storage" . format ( extract_id_from_uri ( id_or_uri ) ) return self . _client . get ( uri )
Get storage details of an OS Volume .
62,554
def get_device_topology ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/deviceTopology" return self . _client . get ( uri )
Retrieves the topology information for the rack resource specified by ID or URI .
62,555
def get_by_name ( self , name ) : managed_sans = self . get_all ( ) result = [ x for x in managed_sans if x [ 'name' ] == name ] resource = result [ 0 ] if result else None if resource : resource = self . new ( self . _connection , resource ) return resource
Gets a Managed SAN by name .
62,556
def get_endpoints ( self , start = 0 , count = - 1 , filter = '' , sort = '' ) : uri = "{}/endpoints/" . format ( self . data [ "uri" ] ) return self . _helper . get_all ( start , count , filter = filter , sort = sort , uri = uri )
Gets a list of endpoints in a SAN .
62,557
def create_endpoints_csv_file ( self , timeout = - 1 ) : uri = "{}/endpoints/" . format ( self . data [ "uri" ] ) return self . _helper . do_post ( uri , { } , timeout , None )
Creates an endpoints CSV file for a SAN .
62,558
def create_issues_report ( self , timeout = - 1 ) : uri = "{}/issues/" . format ( self . data [ "uri" ] ) return self . _helper . create_report ( uri , timeout )
Creates an unexpected zoning report for a SAN .
62,559
def create ( self , resource , id = None , timeout = - 1 ) : if not id : available_id = self . __get_first_available_id ( ) uri = '%s/%s' % ( self . URI , str ( available_id ) ) else : uri = '%s/%s' % ( self . URI , str ( id ) ) return self . _client . create ( resource , uri = uri , timeout = timeout )
Adds the specified trap forwarding destination . The trap destination associated with the specified id will be created if trap destination with that id does not exists . The id can only be an integer greater than 0 .
62,560
def __findFirstMissing ( self , array , start , end ) : if ( start > end ) : return end + 1 if ( start != array [ start ] ) : return start mid = int ( ( start + end ) / 2 ) if ( array [ mid ] == mid ) : return self . __findFirstMissing ( array , mid + 1 , end ) return self . __findFirstMissing ( array , start , mid )
Find the smallest elements missing in a sorted array .
62,561
def __get_first_available_id ( self ) : traps = self . get_all ( ) if traps : used_ids = [ 0 ] for trap in traps : used_uris = trap . get ( 'uri' ) used_ids . append ( int ( used_uris . split ( '/' ) [ - 1 ] ) ) used_ids . sort ( ) return self . __findFirstMissing ( used_ids , 0 , len ( used_ids ) - 1 ) else : return 1
Private method to get the first available id . The id can only be an integer greater than 0 .
62,562
def update ( self , information , timeout = - 1 ) : return self . _client . update ( information , timeout = timeout )
Edit an IPv4 Range .
62,563
def wait_for_task ( self , task , timeout = - 1 ) : self . __wait_task_completion ( task , timeout ) task = self . get ( task ) logger . debug ( "Waiting for task. Percentage complete: " + str ( task . get ( 'computedPercentComplete' ) ) ) logger . debug ( "Waiting for task. Task state: " + str ( task . get ( 'taskState' ) ) ) task_response = self . __get_task_response ( task ) logger . debug ( 'Task completed' ) return task_response
Wait for task execution and return associated resource .
62,564
def get_completed_task ( self , task , timeout = - 1 ) : self . __wait_task_completion ( task , timeout ) return self . get ( task )
Waits until the task is completed and returns the task resource .
62,565
def get_associated_resource ( self , task ) : if not task : raise HPOneViewUnknownType ( MSG_INVALID_TASK ) if task [ 'category' ] != 'tasks' and task [ 'category' ] != 'backups' : raise HPOneViewUnknownType ( MSG_UNKNOWN_OBJECT_TYPE ) if task [ 'type' ] == 'TaskResourceV2' : resource_uri = task [ 'associatedResource' ] [ 'resourceUri' ] if resource_uri and resource_uri . startswith ( "/rest/appliance/support-dumps/" ) : return task , resource_uri elif task [ 'type' ] == 'BACKUP' : task = self . _connection . get ( task [ 'taskUri' ] ) resource_uri = task [ 'uri' ] else : raise HPOneViewInvalidResource ( MSG_TASK_TYPE_UNRECONIZED % task [ 'type' ] ) entity = { } if resource_uri : entity = self . _connection . get ( resource_uri ) return task , entity
Retrieve a resource associated with a task .
62,566
def update_config ( self , config , timeout = - 1 ) : return self . _client . update ( config , uri = self . URI + "/config" , timeout = timeout )
Updates the remote server configuration and the automatic backup schedule for backup .
62,567
def update_remote_archive ( self , save_uri , timeout = - 1 ) : return self . _client . update_with_zero_body ( uri = save_uri , timeout = timeout )
Saves a backup of the appliance to a previously - configured remote location .
62,568
def get_ethernet_networks ( self ) : network_uris = self . data . get ( 'networkUris' ) networks = [ ] if network_uris : for uri in network_uris : networks . append ( self . _ethernet_networks . get_by_uri ( uri ) ) return networks
Gets a list of associated ethernet networks of an uplink set .
62,569
def __set_ethernet_uris ( self , ethernet_names , operation = "add" ) : if not isinstance ( ethernet_names , list ) : ethernet_names = [ ethernet_names ] associated_enets = self . data . get ( 'networkUris' , [ ] ) ethernet_uris = [ ] for i , enet in enumerate ( ethernet_names ) : enet_exists = self . _ethernet_networks . get_by_name ( enet ) if enet_exists : ethernet_uris . append ( enet_exists . data [ 'uri' ] ) else : raise HPOneViewResourceNotFound ( "Ethernet: {} does not exist" . foramt ( enet ) ) if operation == "remove" : enets_to_update = sorted ( list ( set ( associated_enets ) - set ( ethernet_uris ) ) ) elif operation == "add" : enets_to_update = sorted ( list ( set ( associated_enets ) . union ( set ( ethernet_uris ) ) ) ) else : raise ValueError ( "Value {} is not supported as operation. The supported values are: ['add', 'remove']" ) if set ( enets_to_update ) != set ( associated_enets ) : updated_network = { 'networkUris' : enets_to_update } self . update ( updated_network )
Updates network uris .
62,570
def get_settings ( self ) : uri = "{}/settings" . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri )
Gets the interconnect settings for a logical interconnect group .
62,571
def upload ( self , file_path , timeout = - 1 ) : return self . _client . upload ( file_path , timeout = timeout )
Upload an SPP ISO image file or a hotfix file to the appliance . The API supports upload of one hotfix at a time into the system . For the successful upload of a hotfix ensure its original name and extension are not altered .
62,572
def get ( self , uri ) : uri = self . URI + uri return self . _client . get ( uri )
Gets an index resource by URI .
62,573
def get_reachable_storage_pools ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , networks = None , scope_exclusions = None , scope_uris = '' ) : uri = self . URI + "/reachable-storage-pools" if networks : elements = "\'" for n in networks : elements += n + ',' elements = elements [ : - 1 ] + "\'" uri = uri + "?networks=" + elements if scope_exclusions : storage_pools_uris = "," . join ( scope_exclusions ) uri = uri + "?" if "?" not in uri else uri + "&" uri += "scopeExclusions={}" . format ( storage_pools_uris ) return self . _client . get ( self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri , scope_uris = scope_uris ) )
Gets the storage pools that are connected on the specified networks based on the storage system port s expected network connectivity .
62,574
def generate ( self , information , timeout = - 1 ) : return self . _client . create ( information , timeout = timeout )
Generates a self signed certificate or an internal CA signed certificate for RabbitMQ clients .
62,575
def get_key_pair ( self , alias_name ) : uri = self . URI + "/keypair/" + alias_name return self . _client . get ( uri )
Retrieves the public and private key pair associated with the specified alias name .
62,576
def get_keys ( self , alias_name , key_format ) : uri = self . URI + "/keys/" + alias_name + "?format=" + key_format return self . _client . get ( uri )
Retrieves the contents of PKCS12 file in the format specified . This PKCS12 formatted file contains both the certificate as well as the key file data . Valid key formats are Base64 and PKCS12 .
62,577
def validate_id_pool ( self , id_or_uri , ids_pools ) : uri = self . _client . build_uri ( id_or_uri ) + "/validate?idList=" + "&idList=" . join ( ids_pools ) return self . _client . get ( uri )
Validates an ID pool .
62,578
def generate ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/generate" return self . _client . get ( uri )
Generates and returns a random range .
62,579
def get_connectable_volume_templates ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' ) : uri = self . URI + "/connectable-volume-templates" get_uri = self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri ) return self . _client . get ( get_uri )
Gets the storage volume templates that are available on the specified networks based on the storage system port s expected network connectivity . If there are no storage volume templates that meet the specified connectivity criteria an empty collection will be returned .
62,580
def get_reachable_volume_templates ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , networks = None , scope_uris = '' , private_allowed_only = False ) : uri = self . URI + "/reachable-volume-templates" uri += "?networks={}&privateAllowedOnly={}" . format ( networks , private_allowed_only ) get_uri = self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri , scope_uris = scope_uris ) return self . _client . get ( get_uri )
Gets the storage templates that are connected on the specified networks based on the storage system port s expected network connectivity .
62,581
def get_compatible_systems ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/compatible-systems" return self . _client . get ( uri )
Retrieves a collection of all storage systems that is applicable to this storage volume template .
62,582
def add_from_existing ( self , resource , timeout = - 1 ) : uri = self . URI + "/from-existing" return self . _client . create ( resource , uri = uri , timeout = timeout )
Adds a volume that already exists in the Storage system
62,583
def create_from_snapshot ( self , data , timeout = - 1 ) : uri = self . URI + "/from-snapshot" return self . _client . create ( data , uri = uri , timeout = timeout )
Creates a new volume on the storage system from a snapshot of a volume . A volume template must also be specified when creating a volume from a snapshot .
62,584
def delete ( self , resource , force = False , export_only = None , suppress_device_updates = None , timeout = - 1 ) : custom_headers = { 'If-Match' : '*' } if 'uri' in resource : uri = resource [ 'uri' ] else : uri = self . _client . build_uri ( resource ) if suppress_device_updates : uri += '?suppressDeviceUpdates=true' if export_only : custom_headers [ 'exportOnly' ] = True return self . _client . delete ( uri , force = force , timeout = timeout , custom_headers = custom_headers )
Deletes a managed volume .
62,585
def get_snapshots ( self , volume_id_or_uri , start = 0 , count = - 1 , filter = '' , sort = '' ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri ) return self . _client . get_all ( start , count , filter = filter , sort = sort , uri = uri )
Gets all snapshots of a volume . Returns a list of snapshots based on optional sorting and filtering and constrained by start and count parameters .
62,586
def create_snapshot ( self , volume_id_or_uri , snapshot , timeout = - 1 ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri ) return self . _client . create ( snapshot , uri = uri , timeout = timeout , default_values = self . DEFAULT_VALUES_SNAPSHOT )
Creates a snapshot for the specified volume .
62,587
def get_snapshot ( self , snapshot_id_or_uri , volume_id_or_uri = None ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri , snapshot_id_or_uri ) return self . _client . get ( uri )
Gets a snapshot of a volume .
62,588
def get_snapshot_by ( self , volume_id_or_uri , field , value ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri ) return self . _client . get_by ( field , value , uri = uri )
Gets all snapshots that match the filter .
62,589
def get_extra_managed_storage_volume_paths ( self , start = 0 , count = - 1 , filter = '' , sort = '' ) : uri = self . URI + '/repair?alertFixType=ExtraManagedStorageVolumePaths' return self . _client . get_all ( start , count , filter = filter , sort = sort , uri = uri )
Gets the list of extra managed storage volume paths .
62,590
def repair ( self , volume_id_or_uri , timeout = - 1 ) : data = { "type" : "ExtraManagedStorageVolumePaths" , "resourceUri" : self . _client . build_uri ( volume_id_or_uri ) } custom_headers = { 'Accept-Language' : 'en_US' } uri = self . URI + '/repair' return self . _client . create ( data , uri = uri , timeout = timeout , custom_headers = custom_headers )
Removes extra presentations from a specified volume on the storage system .
62,591
def get_attachable_volumes ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , scope_uris = '' , connections = '' ) : uri = self . URI + '/attachable-volumes' if connections : uri += str ( '?' + 'connections=' + connections . __str__ ( ) ) return self . _client . get_all ( start , count , filter = filter , query = query , sort = sort , uri = uri , scope_uris = scope_uris )
Gets the volumes that are connected on the specified networks based on the storage system port s expected network connectivity .
62,592
def update_configuration ( self , timeout = - 1 ) : uri = "{}/configuration" . format ( self . data [ 'uri' ] ) return self . update_with_zero_body ( uri = uri , timeout = timeout )
Reapplies the appliance s configuration on the enclosure . This includes running the same configure steps that were performed as part of the enclosure add .
62,593
def get_by_hostname ( self , hostname ) : def filter_by_hostname ( hostname , enclosure ) : is_primary_ip = ( 'activeOaPreferredIP' in enclosure and enclosure [ 'activeOaPreferredIP' ] == hostname ) is_standby_ip = ( 'standbyOaPreferredIP' in enclosure and enclosure [ 'standbyOaPreferredIP' ] == hostname ) return is_primary_ip or is_standby_ip enclosures = self . get_all ( ) result = [ x for x in enclosures if filter_by_hostname ( hostname , x ) ] if result : new_resource = self . new ( self . _connection , result [ 0 ] ) else : new_resource = None return new_resource
Get enclosure by it s hostname
62,594
def update_environmental_configuration ( self , configuration , timeout = - 1 ) : uri = '{}/environmentalConfiguration' . format ( self . data [ 'uri' ] ) return self . _helper . do_put ( uri , configuration , timeout , None )
Sets the calibrated max power of an unmanaged or unsupported enclosure .
62,595
def import_certificate ( self , certificate_data , bay_number = None ) : uri = "{}/https/certificaterequest" . format ( self . data [ 'uri' ] ) if bay_number : uri += "?bayNumber=%d" % ( bay_number ) headers = { 'Content-Type' : 'application/json' } return self . _helper . do_put ( uri , certificate_data , - 1 , headers )
Imports a signed server certificate into the enclosure .
62,596
def delete ( self , alias_name , timeout = - 1 ) : uri = self . URI + "/" + alias_name return self . _client . delete ( uri , timeout = timeout )
Revokes a certificate signed by the internal CA . If client certificate to be revoked is RabbitMQ_readonly then the internal CA root certificate RabbitMQ client certificate and RabbitMQ server certificate will be regenerated . This will invalidate the previous version of RabbitMQ client certificate and the RabbitMQ server will be restarted to read the latest certificates .
62,597
def get_by_name ( self , name ) : scopes = self . _client . get_all ( ) result = [ x for x in scopes if x [ 'name' ] == name ] return result [ 0 ] if result else None
Gets a Scope by name .
62,598
def create ( self , resource , timeout = - 1 ) : return self . _client . create ( resource , timeout = timeout , default_values = self . DEFAULT_VALUES )
Creates a scope .
62,599
def delete ( self , resource , timeout = - 1 ) : if type ( resource ) is dict : headers = { 'If-Match' : resource . get ( 'eTag' , '*' ) } else : headers = { 'If-Match' : '*' } return self . _client . delete ( resource , timeout = timeout , custom_headers = headers )
Deletes a Scope .