idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
232,200
def _update ( self , ** kwargs ) : legacy = kwargs . pop ( 'legacy' , False ) tmos_ver = self . _meta_data [ 'bigip' ] . _meta_data [ 'tmos_version' ] self . _filter_version_specific_options ( tmos_ver , ** kwargs ) if 'Drafts' not in self . _meta_data [ 'uri' ] and LooseVersion ( tmos_ver ) >= LooseVersion ( '12.1.0' ...
Update only draft or legacy policies
232,201
def publish ( self , ** kwargs ) : assert 'Drafts' in self . _meta_data [ 'uri' ] assert self . status . lower ( ) == 'draft' base_uri = self . _meta_data [ 'container' ] . _meta_data [ 'uri' ] requests_params = self . _handle_requests_params ( kwargs ) session = self . _meta_data [ 'bigip' ] . _meta_data [ 'icr_sessio...
Publishing a draft policy is only applicable in TMOS 12 . 1 and up .
232,202
def draft ( self , ** kwargs ) : tmos_ver = self . _meta_data [ 'bigip' ] . _meta_data [ 'tmos_version' ] legacy = kwargs . pop ( 'legacy' , False ) if LooseVersion ( tmos_ver ) < LooseVersion ( '12.1.0' ) or legacy : raise DraftPolicyNotSupportedInTMOSVersion ( "Drafting on this version of BIG-IP is not supported" ) k...
Allows for easily re - drafting a policy
232,203
def delete ( self , ** kwargs ) : if 'uuid' not in kwargs : kwargs [ 'uuid' ] = str ( self . uuid ) requests_params = self . _handle_requests_params ( kwargs ) kwargs = self . _check_for_python_keywords ( kwargs ) kwargs = self . _prepare_request_json ( kwargs ) delete_uri = self . _meta_data [ 'uri' ] session = self ....
Deletes a member from an unmanaged license pool
232,204
def exec_cmd ( self , command , ** kwargs ) : kwargs = self . _reduce_boolean_pair ( kwargs , 'online' , 'offline' ) if 'offline' in kwargs : self . _meta_data [ 'exclusive_attributes' ] . append ( ( 'offline' , 'standby' ) ) if 'online' in kwargs : self . _meta_data [ 'exclusive_attributes' ] . append ( ( 'online' , '...
Defining custom method to append exclusive_attributes .
232,205
def toggle_standby ( self , ** kwargs ) : trafficgroup = kwargs . pop ( 'trafficgroup' ) state = kwargs . pop ( 'state' ) if kwargs : raise TypeError ( 'Unexpected **kwargs: %r' % kwargs ) arguments = { 'standby' : state , 'traffic-group' : trafficgroup } return self . exec_cmd ( 'run' , ** arguments )
Toggle the standby status of a traffic group .
232,206
def update ( self , ** kwargs ) : if 'useProxyServer' in kwargs and kwargs [ 'useProxyServer' ] == 'enabled' : if 'proxyServerPool' not in kwargs : error = 'Missing proxyServerPool parameter value.' raise MissingUpdateParameter ( error ) if hasattr ( self , 'useProxyServer' ) : if getattr ( self , 'useProxyServer' ) ==...
When setting useProxyServer to enable we need to supply
232,207
def _check_tagmode_and_tmos_version ( self , ** kwargs ) : tmos_version = self . _meta_data [ 'bigip' ] . _meta_data [ 'tmos_version' ] if LooseVersion ( tmos_version ) < LooseVersion ( '11.6.0' ) : msg = "The parameter, 'tagMode', is not allowed against the " "following version of TMOS: %s" % ( tmos_version ) if 'tagM...
Raise an exception if tagMode in kwargs and tmos version < 11 . 6 . 0
232,208
def load ( self , ** kwargs ) : tmos_v = self . _meta_data [ 'bigip' ] . _meta_data [ 'tmos_version' ] if self . _check_existence_by_collection ( self . _meta_data [ 'container' ] , kwargs [ 'name' ] ) : if LooseVersion ( tmos_v ) == LooseVersion ( '11.5.4' ) : return self . _load_11_5_4 ( ** kwargs ) else : return sel...
Override load to retrieve object based on exists above .
232,209
def _load_11_5_4 ( self , ** kwargs ) : if 'uri' in self . _meta_data : error = "There was an attempt to assign a new uri to this " "resource, the _meta_data['uri'] is %s and it should" " not be changed." % ( self . _meta_data [ 'uri' ] ) raise URICreationCollision ( error ) requests_params = self . _handle_requests_pa...
Custom _load method to accommodate for issue in 11 . 5 . 4
232,210
def create ( self , ** kwargs ) : tmos_v = self . _meta_data [ 'bigip' ] . _meta_data [ 'tmos_version' ] if LooseVersion ( tmos_v ) == LooseVersion ( '11.5.4' ) or LooseVersion ( tmos_v ) == LooseVersion ( '12.1.1' ) : if 'uri' in self . _meta_data : error = "There was an attempt to assign a new uri to this " "resource...
Custom _create method to accommodate for issue 11 . 5 . 4 and 12 . 1 . 1
232,211
def get_collection ( self , ** kwargs ) : list_of_contents = [ ] self . refresh ( ** kwargs ) if 'items' in self . __dict__ : for item in self . items : if 'kind' not in item : list_of_contents . append ( item ) continue kind = item [ 'kind' ] if kind in self . _meta_data [ 'attribute_registry' ] : instance = self . _m...
We need special get collection method to address issue in 11 . 5 . 4
232,212
def get_device_names_to_objects ( devices ) : name_to_object = { } for device in devices : device_name = get_device_info ( device ) . name name_to_object [ device_name ] = device return name_to_object
Map a list of devices to their hostnames .
232,213
def create ( self , ** kwargs ) : if LooseVersion ( self . tmos_v ) < LooseVersion ( '12.0.0' ) : return self . _create ( ** kwargs ) else : new_instance = self . _create ( ** kwargs ) tmp_name = str ( new_instance . id ) tmp_path = new_instance . _meta_data [ 'container' ] . _meta_data [ 'uri' ] finalurl = tmp_path + ...
Custom create method for v12 . x and above .
232,214
def _format_monitor_parameter ( param ) : if '{' in param and '}' : tmp = param . strip ( '}' ) . split ( '{' ) monitor = '' . join ( tmp ) . rstrip ( ) return monitor else : return param
This is a workaround for a known issue ID645289 which affects
232,215
def create ( self , ** kwargs ) : if 'monitor' in kwargs : value = self . _format_monitor_parameter ( kwargs [ 'monitor' ] ) kwargs [ 'monitor' ] = value return super ( Pool , self ) . _create ( ** kwargs )
Custom create method to implement monitor parameter formatting .
232,216
def update ( self , ** kwargs ) : if 'monitor' in kwargs : value = self . _format_monitor_parameter ( kwargs [ 'monitor' ] ) kwargs [ 'monitor' ] = value elif 'monitor' in self . __dict__ : value = self . _format_monitor_parameter ( self . __dict__ [ 'monitor' ] ) self . __dict__ [ 'monitor' ] = value return super ( Po...
Custom update method to implement monitor parameter formatting .
232,217
def modify ( self , ** patch ) : if 'monitor' in patch : value = self . _format_monitor_parameter ( patch [ 'monitor' ] ) patch [ 'monitor' ] = value return super ( Pool , self ) . _modify ( ** patch )
Custom modify method to implement monitor parameter formatting .
232,218
def exists ( self , ** kwargs ) : requests_params = self . _handle_requests_params ( kwargs ) self . _check_load_parameters ( ** kwargs ) kwargs [ 'uri_as_parts' ] = True session = self . _meta_data [ 'bigip' ] . _meta_data [ 'icr_session' ] base_uri = self . _meta_data [ 'container' ] . _meta_data [ 'uri' ] kwargs . u...
Check for the existence of the named object on the BigIP
232,219
def exec_cmd ( self , command , ** kwargs ) : self . _is_allowed_command ( command ) self . _check_command_parameters ( ** kwargs ) if command == 'load' : kwargs [ 'command' ] = command self . _check_exclusive_parameters ( ** kwargs ) requests_params = self . _handle_requests_params ( kwargs ) session = self . _meta_da...
Due to ID476518 the load command need special treatment .
232,220
def load ( self , ** kwargs ) : self . _is_version_supported_method ( '12.1.0' ) newinst = self . _stamp_out_core ( ) newinst . _refresh ( ** kwargs ) return newinst
Method to list the UCS on the system
232,221
def _set_attributes ( self , ** kwargs ) : try : self . devices = kwargs [ 'devices' ] [ : ] self . name = kwargs [ 'device_group_name' ] self . type = kwargs [ 'device_group_type' ] self . partition = kwargs [ 'device_group_partition' ] except KeyError as ex : raise MissingRequiredDeviceGroupParameter ( ex )
Set instance attributes based on kwargs
232,222
def validate ( self , ** kwargs ) : self . _set_attributes ( ** kwargs ) self . _check_type ( ) self . dev_group_uri_res = self . _get_device_group ( self . devices [ 0 ] ) if self . dev_group_uri_res . type != self . type : msg = 'Device group type found: %r does not match expected ' 'device group type: %r' % ( self ....
Validate device group state among given devices .
232,223
def _check_type ( self ) : if self . type not in self . available_types : msg = 'Unsupported cluster type was given: %s' % self . type raise DeviceGroupNotSupported ( msg ) elif self . type == 'sync-only' and self . name != 'device_trust_group' : msg = "Management of sync-only device groups only supported for " "built-...
Check that the device group type is correct .
232,224
def create ( self , ** kwargs ) : self . _set_attributes ( ** kwargs ) self . _check_type ( ) pollster ( self . _check_all_devices_in_sync ) ( ) dg = self . devices [ 0 ] . tm . cm . device_groups . device_group dg . create ( name = self . name , partition = self . partition , type = self . type ) for device in self . ...
Create the device service cluster group and add devices to it .
232,225
def teardown ( self ) : self . ensure_all_devices_in_sync ( ) for device in self . devices : self . _delete_device_from_device_group ( device ) self . _sync_to_group ( device ) pollster ( self . _ensure_device_active ) ( device ) self . ensure_all_devices_in_sync ( ) dg = pollster ( self . _get_device_group ) ( self . ...
Teardown device service cluster group .
232,226
def _get_device_group ( self , device ) : return device . tm . cm . device_groups . device_group . load ( name = self . name , partition = self . partition )
Get the device group through a device .
232,227
def _add_device_to_device_group ( self , device ) : device_name = get_device_info ( device ) . name dg = pollster ( self . _get_device_group ) ( device ) dg . devices_s . devices . create ( name = device_name , partition = self . partition ) pollster ( self . _check_device_exists_in_device_group ) ( device_name )
Add device to device service cluster group .
232,228
def _check_device_exists_in_device_group ( self , device_name ) : dg = self . _get_device_group ( self . devices [ 0 ] ) dg . devices_s . devices . load ( name = device_name , partition = self . partition )
Check whether a device exists in the device group
232,229
def _delete_device_from_device_group ( self , device ) : device_name = get_device_info ( device ) . name dg = pollster ( self . _get_device_group ) ( device ) device_to_remove = dg . devices_s . devices . load ( name = device_name , partition = self . partition ) device_to_remove . delete ( )
Remove device from device service cluster group .
232,230
def _ensure_device_active ( self , device ) : act = device . tm . cm . devices . device . load ( name = get_device_info ( device ) . name , partition = self . partition ) if act . failoverState != 'active' : msg = "A device in the cluster was not in the 'Active' state." raise UnexpectedDeviceGroupState ( msg )
Ensure a single device is in an active state
232,231
def _sync_to_group ( self , device ) : config_sync_cmd = 'config-sync to-group %s' % self . name device . tm . cm . exec_cmd ( 'run' , utilCmdArgs = config_sync_cmd )
Sync the device to the cluster group
232,232
def _check_all_devices_in_sync ( self ) : if len ( self . _get_devices_by_failover_status ( 'In Sync' ) ) != len ( self . devices ) : msg = "Expected all devices in group to have 'In Sync' status." raise UnexpectedDeviceGroupState ( msg )
Wait until all devices have failover status of In Sync .
232,233
def _get_devices_by_failover_status ( self , status ) : devices_with_status = [ ] for device in self . devices : if ( self . _check_device_failover_status ( device , status ) ) : devices_with_status . append ( device ) return devices_with_status
Get a list of bigips by failover status .
232,234
def _check_device_failover_status ( self , device , status ) : sync_status = device . tm . cm . sync_status sync_status . refresh ( ) current_status = ( sync_status . entries [ self . sync_status_entry ] [ 'nestedStats' ] [ 'entries' ] [ 'status' ] [ 'description' ] ) if status == current_status : return True return Fa...
Determine if a device has a specific failover status .
232,235
def _get_devices_by_activation_state ( self , state ) : devices_with_state = [ ] for device in self . devices : act = device . tm . cm . devices . device . load ( name = get_device_info ( device ) . name , partition = self . partition ) if act . failoverState == state : devices_with_state . append ( device ) return dev...
Get a list of bigips by activation statue .
232,236
def _set_attr_reg ( self ) : tmos_v = self . _meta_data [ 'bigip' ] . _meta_data [ 'tmos_version' ] attributes = self . _meta_data [ 'attribute_registry' ] v12kind = 'tm:asm:policies:blocking-settings:blocking-settingcollectionstate' v11kind = 'tm:asm:policies:blocking-settings' builderv11 = 'tm:asm:policies:policy-bui...
Helper method .
232,237
def create ( self , ** kwargs ) : for x in range ( 0 , 30 ) : try : return self . _create ( ** kwargs ) except iControlUnexpectedHTTPError as ex : if self . _check_exception ( ex ) : continue else : raise
Custom creation logic to handle edge cases
232,238
def delete ( self , ** kwargs ) : for x in range ( 0 , 30 ) : try : return self . _delete ( ** kwargs ) except iControlUnexpectedHTTPError as ex : if self . _check_exception ( ex ) : continue else : raise
Custom deletion logic to handle edge cases
232,239
def reset ( self ) : Y , D , X = self . old_data [ 'Y' ] , self . old_data [ 'D' ] , self . old_data [ 'X' ] self . raw_data = Data ( Y , D , X ) self . summary_stats = Summary ( self . raw_data ) self . propensity = None self . cutoff = None self . blocks = None self . strata = None self . estimates = Estimators ( )
Reinitializes data to original inputs and drops any estimated results .
232,240
def est_propensity ( self , lin = 'all' , qua = None ) : lin_terms = parse_lin_terms ( self . raw_data [ 'K' ] , lin ) qua_terms = parse_qua_terms ( self . raw_data [ 'K' ] , qua ) self . propensity = Propensity ( self . raw_data , lin_terms , qua_terms ) self . raw_data . _dict [ 'pscore' ] = self . propensity [ 'fitt...
Estimates the propensity scores given list of covariates to include linearly or quadratically .
232,241
def trim ( self ) : if 0 < self . cutoff <= 0.5 : pscore = self . raw_data [ 'pscore' ] keep = ( pscore >= self . cutoff ) & ( pscore <= 1 - self . cutoff ) Y_trimmed = self . raw_data [ 'Y' ] [ keep ] D_trimmed = self . raw_data [ 'D' ] [ keep ] X_trimmed = self . raw_data [ 'X' ] [ keep ] self . raw_data = Data ( Y_t...
Trims data based on propensity score to create a subsample with better covariate balance . The default cutoff value is set to 0 . 1 . To set a custom cutoff value modify the object attribute named cutoff directly .
232,242
def stratify ( self ) : Y , D , X = self . raw_data [ 'Y' ] , self . raw_data [ 'D' ] , self . raw_data [ 'X' ] pscore = self . raw_data [ 'pscore' ] if isinstance ( self . blocks , int ) : blocks = split_equal_bins ( pscore , self . blocks ) else : blocks = self . blocks [ : ] blocks [ 0 ] = 0 def subset ( p_low , p_h...
Stratifies the sample based on propensity score . By default the sample is divided into five equal - sized bins . The number of bins can be set by modifying the object attribute named blocks . Alternatively custom - sized bins can be created by setting blocks equal to a sorted list of numbers between 0 and 1 indicating...
232,243
def est_via_matching ( self , weights = 'inv' , matches = 1 , bias_adj = False ) : X , K = self . raw_data [ 'X' ] , self . raw_data [ 'K' ] X_c , X_t = self . raw_data [ 'X_c' ] , self . raw_data [ 'X_t' ] if weights == 'inv' : W = 1 / X . var ( 0 ) elif weights == 'maha' : V_c = np . cov ( X_c , rowvar = False , ddof...
Estimates average treatment effects using nearest - neighborhood matching .
232,244
def random_data ( N = 5000 , K = 3 , unobservables = False , ** kwargs ) : mu = kwargs . get ( 'mu' , np . zeros ( K ) ) beta = kwargs . get ( 'beta' , np . ones ( K ) ) theta = kwargs . get ( 'theta' , np . ones ( K ) ) delta = kwargs . get ( 'delta' , 3 ) Sigma = kwargs . get ( 'Sigma' , np . identity ( K ) ) Gamma =...
Function that generates data according to one of two simple models that satisfies the unconfoundedness assumption .
232,245
def _summarize_pscore ( self , pscore_c , pscore_t ) : self . _dict [ 'p_min' ] = min ( pscore_c . min ( ) , pscore_t . min ( ) ) self . _dict [ 'p_max' ] = max ( pscore_c . max ( ) , pscore_t . max ( ) ) self . _dict [ 'p_c_mean' ] = pscore_c . mean ( ) self . _dict [ 'p_t_mean' ] = pscore_t . mean ( )
Called by Strata class during initialization .
232,246
def lookup_bulk ( self , ResponseGroup = "Large" , ** kwargs ) : response = self . api . ItemLookup ( ResponseGroup = ResponseGroup , ** kwargs ) root = objectify . fromstring ( response ) if not hasattr ( root . Items , 'Item' ) : return [ ] return list ( AmazonProduct ( item , self . aws_associate_tag , self , region...
Lookup Amazon Products in bulk .
232,247
def similarity_lookup ( self , ResponseGroup = "Large" , ** kwargs ) : response = self . api . SimilarityLookup ( ResponseGroup = ResponseGroup , ** kwargs ) root = objectify . fromstring ( response ) if root . Items . Request . IsValid == 'False' : code = root . Items . Request . Errors . Error . Code msg = root . Ite...
Similarty Lookup .
232,248
def browse_node_lookup ( self , ResponseGroup = "BrowseNodeInfo" , ** kwargs ) : response = self . api . BrowseNodeLookup ( ResponseGroup = ResponseGroup , ** kwargs ) root = objectify . fromstring ( response ) if root . BrowseNodes . Request . IsValid == 'False' : code = root . BrowseNodes . Request . Errors . Error ....
Browse Node Lookup .
232,249
def search_n ( self , n , ** kwargs ) : region = kwargs . get ( 'region' , self . region ) kwargs . update ( { 'region' : region } ) items = AmazonSearch ( self . api , self . aws_associate_tag , ** kwargs ) return list ( islice ( items , n ) )
Search and return first N results ..
232,250
def _safe_get_element_date ( self , path , root = None ) : value = self . _safe_get_element_text ( path = path , root = root ) if value is not None : try : value = dateutil . parser . parse ( value ) if value : value = value . date ( ) except ValueError : value = None return value
Safe get elemnent date .
232,251
def iterate_pages ( self ) : try : while not self . is_last_page : self . current_page += 1 yield self . _query ( ItemPage = self . current_page , ** self . kwargs ) except NoMorePages : pass
Iterate Pages .
232,252
def ancestor ( self ) : ancestors = getattr ( self . parsed_response , 'Ancestors' , None ) if hasattr ( ancestors , 'BrowseNode' ) : return AmazonBrowseNode ( ancestors [ 'BrowseNode' ] ) return None
This browse node s immediate ancestor in the browse node tree .
232,253
def ancestors ( self ) : ancestors = [ ] node = self . ancestor while node is not None : ancestors . append ( node ) node = node . ancestor return ancestors
A list of this browse node s ancestors in the browse node tree .
232,254
def children ( self ) : children = [ ] child_nodes = getattr ( self . parsed_response , 'Children' ) for child in getattr ( child_nodes , 'BrowseNode' , [ ] ) : children . append ( AmazonBrowseNode ( child ) ) return children
This browse node s children in the browse node tree .
232,255
def price_and_currency ( self ) : price = self . _safe_get_element_text ( 'Offers.Offer.OfferListing.SalePrice.Amount' ) if price : currency = self . _safe_get_element_text ( 'Offers.Offer.OfferListing.SalePrice.CurrencyCode' ) else : price = self . _safe_get_element_text ( 'Offers.Offer.OfferListing.Price.Amount' ) if...
Get Offer Price and Currency .
232,256
def reviews ( self ) : iframe = self . _safe_get_element_text ( 'CustomerReviews.IFrameURL' ) has_reviews = self . _safe_get_element_text ( 'CustomerReviews.HasReviews' ) if has_reviews is not None and has_reviews == 'true' : has_reviews = True else : has_reviews = False return has_reviews , iframe
Customer Reviews .
232,257
def editorial_reviews ( self ) : result = [ ] reviews_node = self . _safe_get_element ( 'EditorialReviews' ) if reviews_node is not None : for review_node in reviews_node . iterchildren ( ) : content_node = getattr ( review_node , 'Content' ) if content_node is not None : result . append ( content_node . text ) return ...
Editorial Review .
232,258
def list_price ( self ) : price = self . _safe_get_element_text ( 'ItemAttributes.ListPrice.Amount' ) currency = self . _safe_get_element_text ( 'ItemAttributes.ListPrice.CurrencyCode' ) if price : dprice = Decimal ( price ) / 100 if 'JP' not in self . region else Decimal ( price ) return dprice , currency else : retur...
List Price .
232,259
def get_parent ( self ) : if not self . parent : parent = self . _safe_get_element ( 'ParentASIN' ) if parent : self . parent = self . api . lookup ( ItemId = parent ) return self . parent
Get Parent .
232,260
def browse_nodes ( self ) : root = self . _safe_get_element ( 'BrowseNodes' ) if root is None : return [ ] return [ AmazonBrowseNode ( child ) for child in root . iterchildren ( ) ]
Browse Nodes .
232,261
def images ( self ) : try : images = [ image for image in self . _safe_get_element ( 'ImageSets.ImageSet' ) ] except TypeError : images = [ ] return images
List of images for a response . When using lookup with RespnoseGroup Images you ll get a list of images . Parse them so they are returned in an easily used list format .
232,262
def actors ( self ) : result = [ ] actors = self . _safe_get_element ( 'ItemAttributes.Actor' ) or [ ] for actor in actors : result . append ( actor . text ) return result
Movie Actors .
232,263
def directors ( self ) : result = [ ] directors = self . _safe_get_element ( 'ItemAttributes.Director' ) or [ ] for director in directors : result . append ( director . text ) return result
Movie Directors .
232,264
def getMibSymbol ( self ) : if self . _state & self . ST_CLEAN : return self . _modName , self . _symName , self . _indices else : raise SmiError ( '%s object not fully initialized' % self . __class__ . __name__ )
Returns MIB variable symbolic identification .
232,265
def getOid ( self ) : if self . _state & self . ST_CLEAN : return self . _oid else : raise SmiError ( '%s object not fully initialized' % self . __class__ . __name__ )
Returns OID identifying MIB variable .
232,266
def getLabel ( self ) : if self . _state & self . ST_CLEAN : return self . _label else : raise SmiError ( '%s object not fully initialized' % self . __class__ . __name__ )
Returns symbolic path to this MIB variable .
232,267
def addMibSource ( self , * mibSources ) : if self . _mibSourcesToAdd is None : self . _mibSourcesToAdd = mibSources else : self . _mibSourcesToAdd += mibSources return self
Adds path to repository to search PySNMP MIB files .
232,268
def loadMibs ( self , * modNames ) : if self . _modNamesToLoad is None : self . _modNamesToLoad = modNames else : self . _modNamesToLoad += modNames return self
Schedules search and load of given MIB modules .
232,269
def resolveWithMib ( self , mibViewController ) : if self . _state & self . ST_CLEAM : return self self . _args [ 0 ] . resolveWithMib ( mibViewController ) MibScalar , MibTableColumn = mibViewController . mibBuilder . importSymbols ( 'SNMPv2-SMI' , 'MibScalar' , 'MibTableColumn' ) if not isinstance ( self . _args [ 0 ...
Perform MIB variable ID and associated value conversion .
232,270
def addVarBinds ( self , * varBinds ) : debug . logger & debug . FLAG_MIB and debug . logger ( 'additional var-binds: %r' % ( varBinds , ) ) if self . _state & self . ST_CLEAN : raise SmiError ( '%s object is already sealed' % self . __class__ . __name__ ) else : self . _additionalVarBinds . extend ( varBinds ) return ...
Appends variable - binding to notification .
232,271
def resolveWithMib ( self , mibViewController ) : if self . _state & self . ST_CLEAN : return self self . _objectIdentity . resolveWithMib ( mibViewController ) self . _varBinds . append ( ObjectType ( ObjectIdentity ( v2c . apiTrapPDU . snmpTrapOID ) , self . _objectIdentity ) . resolveWithMib ( mibViewController ) ) ...
Perform MIB variable ID conversion and notification objects expansion .
232,272
def withValues ( cls , * values ) : class X ( cls ) : subtypeSpec = cls . subtypeSpec + constraint . SingleValueConstraint ( * values ) X . __name__ = cls . __name__ return X
Creates a subclass with discreet values constraint .
232,273
def withRange ( cls , minimum , maximum ) : class X ( cls ) : subtypeSpec = cls . subtypeSpec + constraint . ValueRangeConstraint ( minimum , maximum ) X . __name__ = cls . __name__ return X
Creates a subclass with value range constraint .
232,274
def withNamedValues ( cls , ** values ) : enums = set ( cls . namedValues . items ( ) ) enums . update ( values . items ( ) ) class X ( cls ) : namedValues = namedval . NamedValues ( * enums ) subtypeSpec = cls . subtypeSpec + constraint . SingleValueConstraint ( * values . values ( ) ) X . __name__ = cls . __name__ re...
Create a subclass with discreet named values constraint .
232,275
def withSize ( cls , minimum , maximum ) : class X ( cls ) : subtypeSpec = cls . subtypeSpec + constraint . ValueSizeConstraint ( minimum , maximum ) X . __name__ = cls . __name__ return X
Creates a subclass with value size constraint .
232,276
def withNamedBits ( cls , ** values ) : enums = set ( cls . namedValues . items ( ) ) enums . update ( values . items ( ) ) class X ( cls ) : namedValues = namedval . NamedValues ( * enums ) X . __name__ = cls . __name__ return X
Creates a subclass with discreet named bits constraint .
232,277
def loadModule ( self , modName , ** userCtx ) : for mibSource in self . _mibSources : debug . logger & debug . FLAG_BLD and debug . logger ( 'loadModule: trying %s at %s' % ( modName , mibSource ) ) try : codeObj , sfx = mibSource . read ( modName ) except IOError as exc : debug . logger & debug . FLAG_BLD and debug ....
Load and execute MIB modules as Python code
232,278
def nextCmd ( snmpDispatcher , authData , transportTarget , * varBinds , ** options ) : def cbFun ( * args , ** kwargs ) : response [ : ] = args + ( kwargs . get ( 'nextVarBinds' , ( ) ) , ) options [ 'cbFun' ] = cbFun lexicographicMode = options . pop ( 'lexicographicMode' , True ) maxRows = options . pop ( 'maxRows' ...
Create a generator to perform one or more SNMP GETNEXT queries .
232,279
def registerContextEngineId ( self , contextEngineId , pduTypes , processPdu ) : for pduType in pduTypes : k = contextEngineId , pduType if k in self . _appsRegistration : raise error . ProtocolError ( 'Duplicate registration %r/%s' % ( contextEngineId , pduType ) ) self . _appsRegistration [ k ] = processPdu debug . l...
Register application with dispatcher
232,280
def unregisterContextEngineId ( self , contextEngineId , pduTypes ) : if contextEngineId is None : contextEngineId , = self . mibInstrumController . mibBuilder . importSymbols ( '__SNMP-FRAMEWORK-MIB' , 'snmpEngineID' ) for pduType in pduTypes : k = contextEngineId , pduType if k in self . _appsRegistration : del self ...
Unregister application with dispatcher
232,281
def sendNotification ( snmpEngine , authData , transportTarget , contextData , notifyType , * varBinds , ** options ) : def __cbFun ( snmpEngine , sendRequestHandle , errorIndication , errorStatus , errorIndex , varBinds , cbCtx ) : lookupMib , deferred = cbCtx if errorIndication : deferred . errback ( Failure ( errorI...
Sends SNMP notification .
232,282
def nextCmd ( snmpEngine , authData , transportTarget , contextData , * varBinds , ** options ) : def __cbFun ( snmpEngine , sendRequestHandle , errorIndication , errorStatus , errorIndex , varBindTable , cbCtx ) : lookupMib , deferred = cbCtx if ( options . get ( 'ignoreNonIncreasingOid' , False ) and errorIndication ...
Performs SNMP GETNEXT query .
232,283
def getBranch ( self , name , ** context ) : for keyLen in self . _vars . getKeysLens ( ) : subName = name [ : keyLen ] if subName in self . _vars : return self . _vars [ subName ] raise error . NoSuchObjectError ( name = name , idx = context . get ( 'idx' ) )
Return a branch of this tree where the name OID may reside
232,284
def getNode ( self , name , ** context ) : if name == self . name : return self else : return self . getBranch ( name , ** context ) . getNode ( name , ** context )
Return tree node found by name
232,285
def getNextNode ( self , name , ** context ) : try : nextNode = self . getBranch ( name , ** context ) except ( error . NoSuchInstanceError , error . NoSuchObjectError ) : return self . getNextBranch ( name , ** context ) else : try : return nextNode . getNextNode ( name , ** context ) except ( error . NoSuchInstanceEr...
Return tree node next to name
232,286
def writeCommit ( self , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: writeCommit(%s, %r)' % ( self , name , val ) ) ) cbFun = context [ 'cbFun' ] instances = context [ 'instances' ] . setdefault ( self . name , { self . ST_CREATE : { } , self . ST_DESTROY ...
Commit new value of the Managed Object Instance .
232,287
def readGet ( self , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: readGet(%s, %r)' % ( self , name , val ) ) ) cbFun = context [ 'cbFun' ] if name == self . name : cbFun ( ( name , exval . noSuchInstance ) , ** context ) return acFun = context . get ( 'acFu...
Read Managed Object Instance .
232,288
def readGetNext ( self , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: readGetNext(%s, %r)' % ( self , name , val ) ) ) acFun = context . get ( 'acFun' ) if acFun : if ( self . maxAccess not in ( 'readonly' , 'readwrite' , 'readcreate' ) or acFun ( 'read' , ...
Read the next Managed Object Instance .
232,289
def createCommit ( self , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: writeCommit(%s, %r)' % ( self , name , val ) ) ) cbFun = context [ 'cbFun' ] instances = context [ 'instances' ] . setdefault ( self . name , { self . ST_CREATE : { } , self . ST_DESTROY...
Create Managed Object Instance .
232,290
def createCleanup ( self , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: createCleanup(%s, %r)' % ( self , name , val ) ) ) instances = context [ 'instances' ] . setdefault ( self . name , { self . ST_CREATE : { } , self . ST_DESTROY : { } } ) idx = context ...
Finalize Managed Object Instance creation .
232,291
def destroyCommit ( self , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: destroyCommit(%s, %r)' % ( self , name , val ) ) ) instances = context [ 'instances' ] . setdefault ( self . name , { self . ST_CREATE : { } , self . ST_DESTROY : { } } ) idx = context ...
Destroy Managed Object Instance .
232,292
def oidToValue ( self , syntax , identifier , impliedFlag = False , parentIndices = None ) : if not identifier : raise error . SmiError ( 'Short OID for index %r' % ( syntax , ) ) if hasattr ( syntax , 'cloneFromName' ) : return syntax . cloneFromName ( identifier , impliedFlag , parentRow = self , parentIndices = pare...
Turn SMI table instance identifier into a value object .
232,293
def valueToOid ( self , value , impliedFlag = False , parentIndices = None ) : if hasattr ( value , 'cloneAsName' ) : return value . cloneAsName ( impliedFlag , parentRow = self , parentIndices = parentIndices ) baseTag = value . getTagSet ( ) . getBaseTag ( ) if baseTag == Integer . tagSet . getBaseTag ( ) : return in...
Turn value object into SMI table instance identifier .
232,294
def announceManagementEvent ( self , action , varBind , ** context ) : name , val = varBind cbFun = context [ 'cbFun' ] if not self . _augmentingRows : cbFun ( varBind , ** context ) return instId = name [ len ( self . name ) + 1 : ] baseIndices = [ ] indices = [ ] for impliedFlag , modName , symName in self . _indexNa...
Announce mass operation on parent table s row .
232,295
def receiveManagementEvent ( self , action , varBind , ** context ) : baseIndices , val = varBind instId = ( ) for impliedFlag , modName , symName in self . _indexNames : mibObj , = mibBuilder . importSymbols ( modName , symName ) parentIndices = [ ] for name , syntax in baseIndices : if name == mibObj . name : instId ...
Apply mass operation on extending table s row .
232,296
def registerAugmentation ( self , * names ) : for name in names : if name in self . _augmentingRows : raise error . SmiError ( 'Row %s already augmented by %s::%s' % ( self . name , name [ 0 ] , name [ 1 ] ) ) self . _augmentingRows . add ( name ) return self
Register table extension .
232,297
def _manageColumns ( self , action , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: _manageColumns(%s, %s, %r)' % ( self , action , name , val ) ) ) cbFun = context [ 'cbFun' ] colLen = len ( self . name ) + 1 indexVals = { } instId = name [ colLen : ] indice...
Apply a management action on all columns
232,298
def _checkColumns ( self , varBind , ** context ) : name , val = varBind ( debug . logger & debug . FLAG_INS and debug . logger ( '%s: _checkColumns(%s, %r)' % ( self , name , val ) ) ) cbFun = context [ 'cbFun' ] if val != 1 : cbFun ( varBind , ** context ) return count = [ len ( self . _vars ) ] def _cbFun ( varBind ...
Check the consistency of all columns .
232,299
def getIndicesFromInstId ( self , instId ) : if instId in self . _idToIdxCache : return self . _idToIdxCache [ instId ] indices = [ ] for impliedFlag , modName , symName in self . _indexNames : mibObj , = mibBuilder . importSymbols ( modName , symName ) try : syntax , instId = self . oidToValue ( mibObj . syntax , inst...
Return index values for instance identification