コード例 #1
0
ファイル: policymap.py プロジェクト: neoyogi/onepk
 def __init__(self,
              capabilities,
              name=None,
              storage_type=StorageType.TRANSIENT):
     """ Constructs an instance of PolicyMap with specified capability.
     
     @param capabilities: Policy Capability.
     @type capabilities: L{PolicyCapabilities<onep.policyservice.PolicyCapabilities.PolicyCapabilities>}
     
     @raise OnepIllegalArgumentException: If constructor parameter is invalid.
     """
     self.log = logging.getLogger(__name__)
     validate(capabilities, PolicyCapabilities)
     if not StorageType._is_valid(storage_type):
         raise OnepInvalidArgumentException('Invalid storage type')
     table = [
         table for table in capabilities.all.tables
         if table.type == capabilities.policy_type
     ]
     if not table:
         raise OnepNotSupportedException(
             'Policy type %s' %
             PolicyCapabilitiesType.enumval(capabilities.policy_type))
     self.storage_type = storage_type
     self.capabilities = capabilities
     self._element = capabilities.network_element
     self._actions = table[0].actions
     self.name = name
     self._handle = 0
     self._entries = []
     self._result = None
     self._op_code = None
     self.op_id = None
コード例 #2
0
ファイル: policymap.py プロジェクト: neoyogi/onepk
 def add_match(self, *matches, **kwargs):
     """
             Adds match(es) to the entry.
         
             @param matches: The matches.
             @type matches: Variable length argument list of Match
     
             """
     if self._class_map:
         raise OnepIllegalArgumentException('ClassMap object in Entry')
     negate = False
     if kwargs:
         negate = kwargs[negate]
     for match in matches:
         if isinstance(match, Match):
             if not match.check_match_support(self.cap_matches):
                 raise OnepNotSupportedException(
                     MatchType.enumval(match.get_match_type()))
             if match not in self._match_list:
                 if match.dependent_match:
                     match.dependent_match.set_negate(negate)
                     match.dependent_match._op_code = Match.MatchOpCode.ADD
                     self._match_list.append(match.dependent_match)
                 match.set_negate(negate)
                 match._op_code = Match.MatchOpCode.ADD
                 self._match_list.append(match)
コード例 #3
0
ファイル: policymap.py プロジェクト: neoyogi/onepk
    def add_action(self, *actions):
        """
                Adds actions to the Entry class.
                
                @param actions: One or more Action classes
                @type actions: L{Action<action.Action>}
        
                """
        if not actions:
            raise OnepIllegalArgumentException('Missing actions parameter')
        for action in actions:
            if isinstance(action, Action) and action not in self._action_list:
                if not action.check_action_support(self.cap_actions):
                    raise OnepNotSupportedException(
                        'Action ' +
                        ActionType.enumval(action.get_action_type()))
            else:
                raise OnepIllegalArgumentException(type(Action), type(action))

        for action in actions:
            if action.dependent_action:
                action.dependent_action.op_code = Action.ActionOpCode.CREATE
                self._action_list.append(action.dependent_action)
                self.log.info('Entry.add_action dependent ' + str(action))
            action.op_code = Action.ActionOpCode.CREATE
            self._action_list.append(action)
            self.log.info('Entry.add_action ' + str(action))
コード例 #4
0
ファイル: location.py プロジェクト: neoyogi/onepk
 def __init__(self, elin=None, civic_list=None, custom_list=None, geo=None):
     """
           @param elin: The ELIN phone number string containing ELIN information. 
               It can be None if the information is not specified. This is not supported on asr1k
           @param civic_list: A list of LocationCivic containing civic location information.
               It can be None if the information is not specified. 
           @param custom_list: A list of LocationCustom containing custom location information.
               It can be None if the information is not specified. 
           @param geo: The GeoLocation object containing Geo location information.
               It can be None if the information is not specified. 
           
     
           """
     self.log = logging.getLogger(__name__)
     if elin:
         self.log.error('elin is not supported')
         from onep.core.exception.OnepException import OnepNotSupportedException
         raise OnepNotSupportedException('elin is not supported')
     self._elin = ''
     self._civic_list = civic_list
     self._custom_list = custom_list
     self._geo = geo
     self._loc_handle_type = None
     self._element = None
     self._network_intf = None
     self._event_manager = None
     self._location_handle = int(uuid.uuid1()) & 4294967295L
     self._location_handle_dict[self._location_handle] = self
コード例 #5
0
 def add_match(self, *matches):
     """ Adds match(es) to the class map.
     
     @param matches: The matches.
     @type matches: Variable length argument list of Match
     """
     for mtch in matches:
         if isinstance(mtch, match.Match):
             if not mtch.check_match_support(self.capabilities.matches):
                 raise OnepNotSupportedException(
                     'Match ' +
                     match.MatchType.enumval(mtch.get_match_type()))
             if mtch not in self._match_list:
                 mtch.set_negate(False)
                 self._match_list.append(mtch)
コード例 #6
0
 def add_match_not(self, *matches):
     """ Adds match(es) which specify the match criterion as an unsuccessful match criterion. 
     
     This is equivalent to CLI "match not <match-criterion>"
     
     @param matches: The matches.
     @type matches: Variable length argument list of Match      
     """
     for mtch in matches:
         if isinstance(mtch, match.Match):
             if not mtch.check_match_support(self.capabilities.matches):
                 raise OnepNotSupportedException(
                     'Match ' +
                     match.MatchType.enumval(mtch.get_match_type()))
             if mtch not in self._match_list:
                 mtch.set_negate(True)
                 self._match_list.append(mtch)
コード例 #7
0
 def __init__(self, remote_cause = None):
     if remote_cause and isinstance(remote_cause, ExceptionIDL):
         from onep.core.util.OnepStatus import OnepStatus
         if remote_cause.code == OnepStatus.ONEP_ERR_NOT_SUPPORTED:
             raise OnepNotSupportedException(remote_cause.text)
         elif remote_cause.code == OnepStatus.ONEP_ERR_SERVICE_DISABLED:
             raise OnepServiceNotEnabledException(remote_cause.text)
         elif remote_cause.code == OnepStatus.ONEP_ERR_NO_DATA:
             raise OnepNoDataException(remote_cause.text)
         elif remote_cause.code == OnepStatus.ONEP_ERR_DUPLICATE:
             raise OnepDataExistsException(remote_cause.text)
         elif remote_cause.code == OnepStatus.ONEP_ERR_INVALID_VRF:
             raise OnepInvalidVrfException(remote_cause.text)
         elif remote_cause.code == OnepStatus.ONEP_ERR_EXCEEDS_MAX_ALLOWANCE:
             raise OnepExceedMaxAllowanceException(remote_cause.text)
         self.__errorCode = remote_cause.code
         super(OnepRemoteProcedureException, self).__init__(remote_cause.text, remote_cause)
     else:
         super(OnepRemoteProcedureException, self).__init__(self.__defaultMessage)
コード例 #8
0
ファイル: VtyProxy.py プロジェクト: neoyogi/onepk
 def prepare(self):
     raise OnepNotSupportedException('Internal development API')
コード例 #9
0
ファイル: location.py プロジェクト: neoyogi/onepk
 def _get_elin(self):
     from onep.core.exception import OnepNotSupportedException
     raise OnepNotSupportedException('elin is not supported')
     return self._elin