def _from_idl(attr_idl, network_element): """For internal use only""" if attr_idl == None: return attr = None attrName = None if not network_element.is_connected(): log.debug('Application is not connected to network element ' + network_element.host_address) return if network_element.session_handle == None: log.debug('Application is not connected to network element ' + network_element.host_address) return format = attr_idl.format attr_type = attr_idl.type if not isValidEnum(OnepAAAAttributeType, attr_type): raise OnepException('Error in attr type ' + str(attr_type)) if attr_idl.type == OnepAAAAttributeType.ONEP_AAA_AT_APP_ATTR: app_attr_value = attr_idl.str_value if app_attr_value.startswith('"') and app_attr_value.endswith('"'): app_attr_value = app_attr_value.substring[1:-1] app_value = app_attr_value.split(':') if len(app_value) < 3: raise OnepException('Invalid app attribute format ' + str(app_value)) attrName = app_value[0] try: if app_value[1].lower() == 'string': attr = StringAttribute(attr_type, attrName, app_value[2]) else: attr = IntAttribute(attr_type, attrName, int(app_value[2])) except OnepIllegalArgumentException as e: raise OnepException( 'Error adding a Application attribute type ' + str(app_value), e) else: result = { AttrFormat_e.AAA_TYPE_FORMAT_ULONG: lambda _type, _idl: IntAttribute(_type, None, _idl.ulong_value), AttrFormat_e.AAA_TYPE_FORMAT_STRING: lambda _type, _idl: StringAttribute(_type, None, _idl.str_value), AttrFormat_e.AAA_TYPE_FORMAT_BINARY: lambda _type, _idl: BinaryAttribute(_type, None, _idl.binary_value ), AttrFormat_e.AAA_TYPE_FORMAT_IP_ADDR: lambda _type, _idl: BinaryAttribute(_type, None, _idl.binary_value ), AttrFormat_e.AAA_TYPE_FORMAT_IPV6_ADDR: lambda _type, _idl: BinaryAttribute(_type, None, _idl.binary_value) } attr = result[format](attr_type, attr_idl) if attr == None: raise OnepException('Unsupported Attribute Format') return attr
def _validate_element_connection(self): if not self.network_element.is_connected(): raise OnepException( 'Application is not connected to network element ' + self.network_element.host_address) if self.network_element.session_handle is None: raise OnepException( 'Application is not connected to network element ' + self.network_element.host_address) if self.user_client._iprot is not self.network_element.api_protocol: self.user_client = AaaIDL.Client(self.network_element.api_protocol)
def is_action_authorized(self, action): """ Verify if action is authorized for user. This method verifies whether a particular action is authorized for a user. The action-name string must exactly match one of the action-names in the user's profile on the AAA Server. The search space is limited to actions listed for the application that invoked L{authenticate}. Action-names are case-sensitive. @param action: Action name @return: True if action is authorized, False otherwise. @raise OnepException: if action is not present in the attribute list returned by {@link #authenticate} API """ if self.attr_original == None: raise OnepException('User authorization profile does not exist ') if action == None: raise OnepIllegalArgumentException('action') for attr in self.attr_original: if attr.type_ != OnepAAAAttributeType.ONEP_AAA_AT_ALLOWED_ACTION: continue actionStr = attr.str_value.split(':') if len(actionStr) < 2: self.log.error('Invalid Allowed Action attribute format') continue if actionStr[1].lower() == action.lower(): return True return False
def set_output_format(self, format): """ Set the output format for vty This API can only be used before the vty is opened. It will raise an exception if vty is already open. @param format: The vty output format to be set on the network element @type format: L{OnepVtyOutputFormat<onep.vty.VtyService.OnepVtyOutputFormat>} @raise OnepConnectionException: The exception is thrown when the connection to a network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element. @raise OnepException: The exception is thrown when the vty is already open and this API is called. """ if not VtyService.OnepVtyOutputFormat._is_valid(format): raise OnepIllegalArgumentException("The input parameter 'format' is invalid.") if self.state is not self.OnepVtyState.ONEP_VTY_STATE_DISCONNECTED: raise OnepException('VTY is already open. Please, close it before changing the output format.') try: self.api_client.ExecutionCmd_setOutputFormatIDL(self.element.session_handle._id, self.exec_handle, format) except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e.message, e)
def apply_to_interface(self, nif, nif_direction): """ Apply an ACL to the Interface. ACL is applied to network interface in inbound,outbound or in both direction. @param nif: Network Interface instance. @type nif: L{NetworkInterface<onep.interfaces.NetworkInterface.NetworkInterface>} @param nif_direction: Direction inbound,outbound or both. @type nif_direction: L{Direction} @raise OnepIllegalArgumentException: If nif or direction is invalid. @raise OnepRemoteProcedureException: If error occurs when remote procedure call is made to network element. @raise OnepConnectionException: If connection to network element fails. """ try: self._validate_nif_and_dir(nif, nif_direction) if self._acl_header: self._acl_client.applyNamedAclToInterface_IDL(self._acl_header.name, self._acl_header.type, nif.xos_handle, nif_direction, self._acl_header.addrFamily) else: self._acl_client.applyAclToInterface_IDL(self._acl_handle, nif.xos_handle, nif_direction) self.log.info('Returned from applyAclToInterface_IDL idl call to apply acl to interface') except OnepIllegalArgumentException as e: raise e except ExceptionIDL as e: raise OnepException('apply_to_interface', e) except TException as e: raise OnepConnectionException(e.message, e) nif_tuple = (nif, self.Direction.enumval(nif_direction)) if nif_tuple not in self._nif_acl_info: self._nif_acl_info.append(nif_tuple)
def __init__(self, ne, username, password): """ Create a User instance. @param ne: Network Element which is used to access AAA server. @param username: User name. @param password: User password. @raise OnepIllegalArgumentException: if username, password or network element is null @raise OnepException: if application is not connected to network element """ self.server = None self.userID = 0 self.is_auto_acct_enabled = False self.attr_original = [] self.auth_profile = [] User.log = logging.getLogger(__name__) if ne == None: raise OnepIllegalArgumentException('ne') if username == None: raise OnepIllegalArgumentException('username') if password == None: raise OnepIllegalArgumentException('password') if not ne.is_connected(): raise OnepException('Application is not connected to ' + ne.host_address) self.network_element = ne self.username = username self.password = password self.user_client = AaaIDL.Client(ne.api_protocol)
def close(self): """ Close a vty. @raise OnepConnectionException: The exception is thrown when the connection to a network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element. @raise OnepException: The exception is thrown when the server returns an invalid CPU sampling interval value. """ if self.state == self.OnepVtyState.ONEP_VTY_STATE_DISCONNECTED or self.state == self.OnepVtyState.ONEP_VTY_STATE_IDLE_TIMEOUT: raise OnepException('VTY is already closed') try: self.api_client.ExecutionCmd_closeIDL( self.element.session_handle._id, self.exec_handle) except TException as e: raise OnepConnectionException(e.message, e) except ExceptionIDL as e: raise OnepRemoteProcedureException(e) self.state = self.OnepVtyState.ONEP_VTY_STATE_DISCONNECTED
def set_network_element(self, network_element): """ Set the network element to be used for the AAA Service. This method updates the Network Element to be used to access the AAA Service for an existing AAA User instance. It overwrites the Network Element that was set in the call to User(NetworkElement,String,String). If auto-accounting is enabled for the user and if an accounting session is active between the existing Network Element and the AAA Server, then this API will result into sending an Accounting-Stop over the accounting session. Auto-accounting session will not be initiated from the new Network Element until the AAA User is authenticated on the new Network Element and the Authorization Profile has auto-accounting enabled. @param network_element: the Network Element to set @raise OnepIllegalArgumentException: if the network element is null """ if network_element == None: raise OnepIllegalArgumentException('network_element') if not network_element.is_connected(): raise OnepException('Application is not connected to ' + network_element.host_address) self.network_element = network_element self.user_client = AaaIDL.Client(network_element.api_protocol) if self.is_auto_acct_enabled: self.send_accounting_record( self.OnepAAAAcctAction.ONEP_AAA_ACCT_ACTION_STOP, []) self.is_auto_acct_enabled = False
def add_replay_route_event_listener(self, listener, scope, client_data): """ Adds a replay route event listener to the RIB object. @param listener: The ReplayRouteEventListener object that handles the events. @type listener: L{ReplayRouteEventListener<onep.routing.ReplayRouteEventListener>} @param scope: Indicate which table in the Application Route Table get notification from. @type scope: L{L3UnicastScope<onep.routing.L3UnicastScope>} @param client_data: The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked. @return: EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the remove_route_state_listener method If registration fails, -1 is returned. @rtype: C{int} @raise OnepIllegalArgumentException: The exception is thrown when the listener or other parameters is not valid. @raise OnepConnectionException: The exception is thrown when connection to a network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element """ if listener == None: raise OnepIllegalArgumentException('ReplayRouteEventListener', 'null') scopeIdl = None if isinstance(scope, (L3UnicastScope, )): scopeIdl = scope._to_idl() if scopeIdl == None: raise OnepIllegalArgumentException('scope', 'invalid') try: eventProp = self._parent_rss._routing_client.RoutingReplayRouteEvent_registerIDL( self._parent_rss.network_element.session_handle._id, scopeIdl) self.log.info( 'Returning from RoutingReplayRouteEvent_registerIDL ') if eventProp != None: self._parent_rss.network_element.event_manager.add_listener( eventProp.eventHandle, listener, client_data) self.log.debug( 'Registered ReplayRouteEventListener listener, eventHandle=' + str(eventProp.eventHandle)) return eventProp.eventHandle raise OnepException( 'Internal error while registering the Listener') except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e)
def open(self): """ Open a vty on the network element with the default cmd interpreter - no control messages @note: On XR, "aaa authorization eventmanager default local" must be configured in config mode, otherwise open() will fail to get a valid handle. Also, the device should have "hostname <whatever-hostname>" config. aaa authorization commands default <group | none>" is recommended to config prior to use. @raise OnepConnectionException: The exception is thrown when the connection to a network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element. @raise OnepException: The exception is thrown when the server returns an invalid CPU sampling interval value. """ if self.is_open(): raise OnepException('VTY is already opened') try: self.api_client.ExecutionCmd_openIDL( self.element.session_handle._id, self.exec_handle) elapsedTime = 0 while not self.data_available: if self.timeout > 0 and elapsedTime >= self.timeout * 100: break elapsedTime += 1 time.sleep(0.01) if not self.data_available: raise OnepException('VTY Open timed out') except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e.message, e) self.data_available = False self.log.debug('open: open compelete')
def write(self, s): """ Write a String to a vty on the network element @raise OnepConnectionException: The exception is thrown when the connection to a network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element. @raise OnepException: The exception is thrown when the server returns an invalid CPU sampling interval value. @param s: The String to write to the vty @return: The interpreted result from the Network Element """ if self.state == self.OnepVtyState.ONEP_VTY_STATE_DISCONNECTED or self.state == self.OnepVtyState.ONEP_VTY_STATE_IDLE_TIMEOUT: raise OnepConnectionException('VTY must be connected to write') if not s: raise OnepIllegalArgumentException( 'Input command string is null or empty.') try: self.data_available = False self.cli_result = '' self.api_client.ExecutionCmd_writeIDL( self.element.session_handle._id, self.exec_handle, s, self.typeahead, self._max_response) elapsedTime = 0 while not self.data_available: if self.timeout > 0 and elapsedTime >= self.timeout * 100: break elapsedTime += 1 time.sleep(0.01) if not self.data_available: self.api_client.ExecutionCmd_stopIDL( self.element.session_handle._id, self.exec_handle) raise OnepException('VTY Write timed out') except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e.message, e) self.data_available = False return self.cli_result
def send_accounting_record(self, action, accntRecord): """ Send an accounting record for a user using AAA Service on the Network Element. This method is used for sending an accounting record to the AAA (Accounting) Server. Note: This method must not be used to send Accounting messages if auto-accounting is enabled for the AAA User. Note: If auto-accounting is enabled for a user then this API will not be allowed to be executed. Note: The AAA Server that was used to service this request can be retrieved by calling L{authenticate} @param action: Accounting action type L{OnepAAAAcctAction}, START, STOP,or UPDATE. @param accntRecord: Attribute list containing Application-specific attributes (including byte/packet counters as per RFC2866) to be included in the accounting records. This argument can be specified as None if there are no Application-specific attributes to be sent. @raise OnepConnectionException: The exception is thrown when connection to a network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when error has occurred in the remote- procedure call made to a network element. @raise OnepConnectionException: The exception is thrown when connection to a network element has failed @raise OnepIllegalArgumentException: if accntRecord is null. """ try: self._validate_element_connection() except OnepException: raise if self.is_auto_acct_enabled: raise OnepException('Auto accounting is already enabled') idlList = self.AttrListToIDL(accntRecord) try: acctResult = self.user_client.account_IDL(self.userID, action, idlList) self.userID = acctResult.aaa_user_id except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(arg_cause=e)
def add_service_status_listener(self, listener, client_data): """ Adds a routing service status listener. @param listener: The RoutingServiceStatusListener object that handles the events. @type listener: L{RoutingServiceStatusListener<onep.routing.RoutingServiceStatusListener>} @param client_data: The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked. @return event_handle: a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the remove listener method. If registration fails, -1 is returned. @rtype: C{int} @raise OnepIllegalArgumentException: The exception is thrown when scope, filter or range is invalid @raise OnepConnectionException: The exception is thrown when connection to the network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element @raise OnepException: This occurs when an internal exception occurs """ if listener == None: raise OnepIllegalArgumentException('listener', 'null') try: event_prop = self._routing_client.RoutingServiceStatusEvent_registerIDL( self._network_element.session_handle._id) if event_prop != None: self._network_element.event_manager.add_listener( event_prop.eventHandle, listener, client_data) self.log.debug( 'Registered Service status listener with event handle : ' + str(event_prop.eventHandle)) return event_prop.eventHandle raise OnepException( 'Internal error while registering the Listener') except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e)
def remove_user(self): """ Remove the user record maintained by ONEP Infrastructure. This API removes all the information that is maintained by ONEP session infrastructure for the given user. If accounting has started for the given user, an accounting STOP request is sent to the AAA server. Note: The API below does not remove user records from the AAA server, nor does it invalidate the existing user instance. The application can reuse the existing User instance to re-authenticate with the AAA Server. @raise OnepConnectionException: The exception is thrown when connection to a network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element. @raise OnepException: The exception is thrown when the removal of user session fails. """ if self.userID == 0: self.log.debug('User session does not exist') return try: self._validate_element_connection() except OnepException: raise try: if self.user_client.deallocate_aaa_user_IDL( self.userID, 1 if self.is_auto_acct_enabled else 0) == 0: raise OnepException('Error removing user ' + self.username) self.is_auto_acct_enabled = False self.attr_original = None self.userID = 0 except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(arg_cause=e)
def __init__(self, element, afi, lifetime, header = None): """ Constructor of class L3Acl. Instantiate a new L3 Access Control List(ACL). @param element: Network Element instance. @type element: L{NetworkElement<onep.element.NetworkElement.NetworkElement>} @param afi: Address Family. It can be OnepAddressFamilyType.ONEP_AF_INET or OnepAddressFamilyType.ONEP_AF_INET6 @type afi: L{OnepAddressFamilyType<onep.core.util.OnepConstants.OnepConstants.OnepAddressFamilyType>} @param lifetime: Life time of L3 Acl. @type lifetime: L{OnepLifetime<OnepLifetime>} @raise OnepIllegalArgumentException: If element,address family or lifetime is invalid. @raise OnepRemoteProcedureException: If error occurs when remote procedure call is made to network element. @raise OnepConnectionException: If connection to network element fails. """ self.log = logging.getLogger(__name__) super(L3Acl, self).__init__(element) self._l3_ace_list = [] try: self._validate_afi(afi) self._validate_lifetime(lifetime) except OnepIllegalArgumentException as e: raise e self._afi = afi self._app_id = element.session_handle._id self._lifetime = lifetime self._acl_client = Client(element.api_protocol) if header: self._acl_header = header return try: try: self._acl_handle = self._acl_client.createAcl_IDL(element.session_handle._id, self._ONEP_L3ACL, self._lifetime, afi) self.log.debug('Created ACL') self._element._l3_acl_list.append(self) except ExceptionIDL as e: raise OnepException('L3Acl init', e) except TException as e: raise OnepConnectionException(e.message, e)
def add_change_listener(self, listener, loc_filter, client_data): """ Add a location change listener to the Location object. Multiple listeners can be associate with an instance of Location. @param listener The LocationChangeListener object that handles the events. @type listener: L{LocationChangeListener<onep.location.location.LocationChangeListener>} @param loc_filter The LocationChangeFilter to specify criteria of interested location change events. @type loc_filter: L{LocationChangeFilter<onep.location.location.LocationChangeFilter>} @param clientData The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked. @type clientData: L{object} @return EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the removeLocationChangeListener method. If registration fails, -1 is returned. @throws OnepConnectionException The exception is thrown when connection to a network element has failed. @throws OnepRemoteProcedureException The exception is thrown when error has occurred in the remote procedure call made to a network element @throws OnepException The exception is thrown when an internal error occurs """ if not listener: raise OnepIllegalArgumentException('listener', 'None') if not loc_filter: raise OnepIllegalArgumentException('filter', 'None or empty') if self._loc_handle_type == None: raise OnepException('Location instance is not attached to' + 'NetworkElement or NetworkInterface') if self._loc_handle_type == LocationHandleType.LocElementHandle: if not self._element: raise OnepException('Location instance is not attached to' + 'NetworkElement') loc_client = self._element.location_client session = self._element.session_handle attachement_handle = 0 self._event_manager = self._element.event_manager elif self._loc_handle_type == LocationHandleType.LocInterfaceHandle: if not self._network_intf: raise OnepException('Location instance is not attached to' + 'NetworkElement') loc_client = self._network_intf._network_element.location_client session = self._network_intf._network_element.session_handle attachement_handle = self._network_intf._xos_handle self._event_manager = self._network_intf._network_element.event_manager if not (loc_client and session and self._event_manager): raise OnepConnectionException() try: event_prop = loc_client.LocationChangeEvent_registerIDL( session.id, self._loc_handle_type, attachement_handle, self._location_handle, loc_filter._toIDL()) if event_prop: self._event_manager.add_listener(event_prop.eventHandle, listener, client_data) self.log.info('Registered Location Listener with event handle') return event_prop.eventHandle except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e.message, e)
def add_route_state_listener(self, route_state_listener, scope, filter, flag, client_data): """ Adds a route state listener to the RIB object. @param route_state_listener: The RouteStateListener object that handles the events. @type route_state_listener: L{RIBRouteStateListener<onep.routing.RIBRouteStateListener>} @param scope: Indicates which table in the RIB to retrieve route from. @type scope: L{L3UnicastScope<onep.routing.L3UnicastScope>} @param filter: Specifies characteristic of a route must match for it to be retrieved @type filter: L{L3UnicastRIBFilter<onep.routing.L3UnicastRIBFilter>} @param client_data: The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked. @type client_data: C{str} @param flag: Additional request when the listener is installed. If TRIGER_INITIAL_WALK is set, triggers an initial walk of the RIB and reports an UP event to the application for each route that matches rib_filter. The TRIGER_INITIAL_WALK flag is supported only on network elements that run IOS Classic or IOS-XE. On IOS-XR and NXOS, TRIGER_INITIAL_WALK is ignored; an initial walk is always performed. @type flag : C{int} @return: EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the removeRouteStateListener method. If registration fails, -1 is returned. @rtype: C{int} @raise OnepIllegalArgumentException: The exception is thrown when scope, filter or range is invalid @raise OnepConnectionException: The exception is thrown when connection to the network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element @raise OnepException: The exception is thrown when an internal error occurs """ if route_state_listener == None: raise OnepIllegalArgumentException('routeStateListener', 'null') if not isinstance(route_state_listener, RIBRouteStateListener): OnepIllegalArgumentException('routeStateListener', 'invalid') scope_idl = None if isinstance(scope, (L3UnicastScope, )): scope_idl = scope._to_idl() if scope_idl == None: raise OnepIllegalArgumentException('scope', 'invalid') filter_idl = None if isinstance(filter, (L3UnicastRIBFilter, )): if scope.afi == L3UnicastScope.AFIType.IPV6 and filter.subnet.address == '0.0.0.0' and filter.subnet.prefix_length == 0: filter.subnet = NetworkPrefix('0::0', 0) filter_idl = filter._to_idl() if filter_idl == None: raise OnepIllegalArgumentException('filter', 'invalid') try: event_prop = self._parent_rss._routing_client.L3UcastRibRouteEvent_registerIDL( self._parent_rss.network_element.session_handle._id, scope_idl, filter_idl, flag) if event_prop != None: self._parent_rss.network_element.event_manager.add_listener( event_prop.eventHandle, route_state_listener, client_data) self.log.debug( 'Registered RIBRoute listener with event handle : ' + str(event_prop.eventHandle)) return event_prop.eventHandle raise OnepException( 'Internal error while registering the Listener') except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e)
def async_update_routes(self, scope, op_list, listener, client_data): """ Asynchronously update a route. It is an asynchronous API that will return immediately and the application provided listener will be invoked when the all the route update requests are processed by the network element. It is used to add, delete and replace single route in the Application Route Table. The type of operation is indicated by RouteOperationType parameter. For route addition: If the route do not exist, create route with the provided next hops. If the route already exist in the table, any new next hop specified is added to the route Duplicated next hop is ignored. For route replace: If the route do not exist, it act like route addition operation. If the route already exist in the table, the all the old next hops are removed and new next hops specified are added to the route. If no next hop is specified, then all next hops are removed. The route will be removed when no more next hops exist. Return error if the scope and route is not consistent. This method will make remote procedure call and response time may be long. @param scope: Indicate which table in the Application Route Table to send the route operation too. @type scope: L{Scope<onep.routing.Scope>} @param op_list: The list of route operation. If API succeeds, per route per next hop status are returned and could be accessed using Route.error_code and NextHop.error_code @type op_list: C{list} of L{L3UnicastRouteOperation<onep.routing.L3UnicastRouteOperation>} @param listener: The UpdateRouteResponseListener object that handles the events. @type listener: L{UpdateRouteResponseListener<onep.routing.UpdateRouteResponse>} @param client_data: The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked. @return: An identifier for this asynchronous update request. Could be used to monitor the status or cancel the request. @rtype: C{int} @raise OnepIllegalArgumentException: This exception is thrown if the scope and route are not consistent @raise OnepConnectionException: The exception is thrown when connection to the network element has failed. @raise OnepRemoteProcedureException: The exception is thrown when an error has occurred in the remote procedure call made to a network element """ if op_list == None or len(op_list) == 0: raise OnepIllegalArgumentException('opList', 'empty') scope_idl = None if isinstance(scope, L3UnicastScope): scope_idl = scope._to_idl() if scope_idl == None: raise OnepIllegalArgumentException('scope', 'Invalid') op_list_idl = list() for rop in op_list: if rop != None and isinstance(rop, L3UnicastRouteOperation): op_list_idl.append(rop._to_idl()) try: event_prop = self._parent_rss._routing_client.Routing_L3UcastARTUpdateRoutesAsyncIDL( self._parent_rss.network_element.session_handle._id, scope_idl, op_list_idl) self.log.debug( 'Done calling Routing_L3UcastARTUpdateRoutesAsyncIDL') if event_prop != None: self._parent_rss.network_element.event_manager.add_listener( event_prop.eventHandle, listener, client_data) self.log.debug( 'Registered UpdateResponseListener with handle' + str(event_prop.eventHandle)) self._parent_rss.network_element.event_manager.register_dedicated_queue( event_prop.eventHandle, self._async_queue_size) return event_prop.eventHandle raise OnepException( 'Internal error while registering the Listener') except ExceptionIDL as e: raise OnepRemoteProcedureException(e) except TException as e: raise OnepConnectionException(e)