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
def __str__(self): estat_str = '' for stat in self.entry_stats: estat_str = estat_str + str(stat) return '\n Policy Statistics\n -----------------\n storage_type - %s\n async_handle - %d\n pmap_handle - %d\n interfaces - %s\n total_count - %d\n entry_count - %d\n more - %d\n %s' % ( StorageType.enumval(self.storage_type), self.async_handle, self.pmap_handle, str(self.interfaces), self.total_count, self.entry_count, self.more, estat_str)
def __str__(self): match_str = '' for m in self.match_result_list: match_str = match_str + str(m) + '\n' return '\n Class Result\n ------------\n storage_type - %s\n handle - %d\n opid - %d\n opcode - %s\n result - %s\n\n Match results\n -------------\n %s' % ( StorageType.enumval(self.storage_type), self.handle, self.opid, ClassMap.ClassOperation.enumval( self.opcode), OnepStatus.enumval(self.result), match_str)
def __str__(self): policy_result_str = '' for pol in self.policy_result: policy_result_str = policy_result_str + str(pol) if not self.policy_result: policy_result_str = str([]) return '\n policy_type - %s\n storage_type - %s\n policy_handle - %d\n interfaces - %s\n target direction - %s\n max_entry_count - %d\n entry_start - %s\n -----------------------\n policy_result - %s\n ' % ( PolicyCapabilitiesType.enumval(self.policy_type), StorageType.enumval(self.storage_type), self.policy_handle, [ tgt.network_interface.name for tgt in self._targets ], Target.TargetLocation.enumval(self._direction), self.max_entry_count, str(self._entry_start), policy_result_str)
def __str__(self): stat_result_str = '' for stat in self.stats_result: stat_result_str = stat_result_str + str(stat) if not self.stats_result: stat_result_str = str([]) return ' \n policy_type - %s\n storage_type - %s\n policy_handle - %d\n interfaces - %s\n target direction - %s\n statistic_category - %s\n poll_interval_sec - %d\n poll_interval_msec - %d\n max_entry_count - %d\n entry_start - %d\n -----------------------\n stats_result - %s\n ' % ( PolicyCapabilitiesType.enumval( self.policy.capabilities.policy_type), StorageType.enumval(self.policy.storage_type), self.policy.handle, [tgt.network_interface.name for tgt in self._targets ], Target.TargetLocation.enumval(self._direction), StatisticCategory.enumval(self.statistic_category), self.poll_interval_sec, self.poll_interval_msec, self.max_entry_count, self.entry_start, stat_result_str)
def __init__(self, result): self.storage_type = result.dsid self.handle = result.handle self.opid = result.opid self.opcode = result.opcode self.result = result.result self.match_result_list = [] for rslt in result.matchResultList: mtch = { 'storage_type': StorageType.enumval(rslt.dsid), 'handle': rslt.handle, 'opcode': ClassMap.ClassOperation.enumval(rslt.opcode), 'opid': rslt.opId, 'result': OnepStatus.enumval(rslt.result), 'result_text': rslt.resultString } self.match_result_list.append(mtch)