コード例 #1
0
 def send_ifstatus_update(self, data):
     for dev in data:
         ifIndexOperStatusTable = []
         for ifidx in data[dev]:
             ifIndexOperStatusTable.append(IfIndexOperStatusTable(
                         ifIndex=ifidx, ifOperStatus=data[dev][ifidx][0]))
         PRouterUVE(data=PRouterEntry(
                 name=dev,
                 ifIndexOperStatusTable=ifIndexOperStatusTable)).send()
コード例 #2
0
 def delete(self, dev):
     PRouterUVE(data=PRouterEntry(**dict(name=dev, deleted=True))).send()
     PRouterFlowUVE(data=PRouterFlowEntry(
         **dict(name=dev, deleted=True))).send()
コード例 #3
0
    def make_uve(self, data):
        # print 'Building UVE:', data['name']
        if 'arpTable' in data:
            data['arpTable'] = map(lambda x: ArpTable(**x), data['arpTable'])
        if 'ifMib' in data:
            self.get_diff(data)
            if 'ifTable' in data['ifMib']:
                data['ifTable'] = map(lambda x: IfTable(**x),
                                      data['ifMib']['ifTable'])
            if 'ifXTable' in data['ifMib']:
                data['ifXTable'] = map(lambda x: IfXTable(**x),
                                       data['ifMib']['ifXTable'])
            del data['ifMib']
        if 'ipMib' in data:
            data['ipMib'] = map(lambda x: IpMib(**x), data['ipMib'])
        if 'lldpTable' in data:
            if 'lldpLocalSystemData' in data['lldpTable']:
                if 'lldpLocManAddrEntry' in data['lldpTable'][
                        'lldpLocalSystemData']:
                    data['lldpTable']['lldpLocalSystemData'][
                        'lldpLocManAddrEntry'] = LldpLocManAddrEntry(
                            **data['lldpTable']['lldpLocalSystemData']
                            ['lldpLocManAddrEntry'])
                if 'lldpLocSysCapEnabled' in data['lldpTable'][
                        'lldpLocalSystemData']:
                    data['lldpTable']['lldpLocalSystemData'][
                        'lldpLocSysCapEnabled'] = map(
                            self._to_cap_map, data['lldpTable']
                            ['lldpLocalSystemData']['lldpLocSysCapEnabled'])
                if 'lldpLocSysCapSupported' in data['lldpTable'][
                        'lldpLocalSystemData']:
                    data['lldpTable']['lldpLocalSystemData'][
                        'lldpLocSysCapSupported'] = map(
                            self._to_cap_map, data['lldpTable']
                            ['lldpLocalSystemData']['lldpLocSysCapSupported'])
                if 'lldpLocPortTable' in data['lldpTable'][
                        'lldpLocalSystemData']:
                    data['lldpTable']['lldpLocalSystemData'][
                        'lldpLocPortTable'] = [
                            LldpLocPortEntry(**x)
                            for x in data['lldpTable']['lldpLocalSystemData']
                            ['lldpLocPortTable'].values()
                        ]
                data['lldpTable']['lldpLocalSystemData'] = \
                    LldpLocalSystemData(**data['lldpTable'][
                            'lldpLocalSystemData'])

            rl = []
            if 'lldpRemoteSystemsData' in data['lldpTable']:
                for d in data['lldpTable']['lldpRemoteSystemsData']:

                    if 'lldpRemSysCapEnabled' in d:
                        d['lldpRemSysCapEnabled'] = map(
                            self._to_cap_map, d['lldpRemSysCapEnabled'])
                    if 'lldpRemSysCapSupported' in d:
                        d['lldpRemSysCapSupported'] = map(
                            self._to_cap_map, d['lldpRemSysCapSupported'])
                    if 'lldpRemOrgDefInfoEntry' in d:
                        if 'lldpRemOrgDefInfoTable' in d[
                                'lldpRemOrgDefInfoEntry']:
                            d['lldpRemOrgDefInfoEntry'][
                                 'lldpRemOrgDefInfoTable'] = map(lambda x: \
                                     LldpRemOrgDefInfoTable(**x),
                                     d['lldpRemOrgDefInfoEntry'][
                                        'lldpRemOrgDefInfoTable'])
                            d['lldpRemOrgDefInfoEntry'] = \
                                LldpRemOrgDefInfoEntry(**d[
                                        'lldpRemOrgDefInfoEntry'])
                    if 'lldpRemManAddrEntry' in d:
                        d['lldpRemManAddrEntry'] = LldpRemManAddrEntry(
                            **d['lldpRemManAddrEntry'])
                    rl.append(LldpRemoteSystemsData(**d))
                data['lldpTable']['lldpRemoteSystemsData'] = rl
            data['lldpTable'] = LldpTable(**data['lldpTable'])
        if 'qBridgeTable' in data:
            if 'dot1qTpFdbPortTable' in data['qBridgeTable']:
                data['fdbPortTable'] = map(
                    lambda x: dot1qTpFdbPortTable(**x),
                    data['qBridgeTable']['dot1qTpFdbPortTable'])
            if 'dot1dBasePortIfIndexTable' in data['qBridgeTable']:
                data['fdbPortIfIndexTable'] = map(
                    lambda x: dot1dBasePortIfIndexTable(**x),
                    data['qBridgeTable']['dot1dBasePortIfIndexTable'])
            del data['qBridgeTable']
        return PRouterUVE(data=PRouterEntry(**data))