コード例 #1
0
    def create_ipv4_ipv6_record(self, test_count=1000):
        sessRec = DepiMcastSessionRecord()
        print "#########: write %s session in db." % (test_count * 2)
        current_time = time.time()
        print "current time is: " + str(
            datetime.datetime.fromtimestamp(current_time))
        for test_session in range(0, test_count):
            sessRec.updateDepiMcastSessionKey(IpAddrType=1,
                                              GroupIpAddr="10.79.31.1",
                                              SrcIpAddr="10.90.31.1",
                                              SessionId=test_session + 1)
            test_time = Convert.pack_timestamp_to_string(time.time())

            sessRec.updateDepiMcastSessionData("10.1.1.1", "1.1.1.1",
                                               time.time())
            sessRec.write()
            sessRec.updateDepiMcastSessionKey(IpAddrType=2,
                                              GroupIpAddr="2001::1",
                                              SrcIpAddr="2001::2",
                                              SessionId=test_session + 1)

            sessRec.updateDepiMcastSessionData("2001::1", "2001::1", test_time)
            sessRec.write()
        current_time = time.time()
        print "end time is: " + str(
            datetime.datetime.fromtimestamp(current_time))
        return True
コード例 #2
0
    def update_mcast_session_to_db(self, session):
        """

        :param session: (local_ip, remote_ip, local_session, remote_session)
        :return:
        """
        try:
            local_ip, remote_ip, local_session, remote_session, = session
            record = DepiMcastSessionRecord()
            record.updateDepiMcastSessionKey(
                IpAddrType=DepiMcastSessionRecord.get_inetaddr_type(
                    self.grp_ip),
                GroupIpAddr=self.grp_ip,
                SrcIpAddr=self.src_ip,
                SessionId=local_session)

            record.updateDepiMcastSessionData(
                LocalLcceIpAddr=local_ip,
                RemoteLcceIpAddr=remote_ip,
                JoinTime=Convert.pack_timestamp_to_string(self.lastchange))
            record.write()
        except Exception as e:
            self.logger.warning(
                "%s failed to update ses:%s into db for exception %s",
                str(self), str(session), str(e))
コード例 #3
0
    def test_readwrite(self):
        sessRec = DepiMcastSessionRecord()
        sessRec.updateDepiMcastSessionKey(IpAddrType=1,
                                          GroupIpAddr="10.79.31.1",
                                          SrcIpAddr="10.79.31.1",
                                          SessionId=1)
        self.assertEquals(sessRec.index.IpAddrType, 1)
        self.assertEquals(sessRec.index.SrcIpAddr, "10.79.31.1")
        self.assertEquals(sessRec.index.SessionId, 1)
        sessRec.write()

        # get_all
        ret = []
        for ses in sessRec.get_all():
            ret.append(ses)
        self.assertEquals(len(ret), 1)

        sessRec = None
        sessRec = DepiMcastSessionRecord()
        sessRec.updateDepiMcastSessionKey(IpAddrType=1,
                                          GroupIpAddr="10.79.31.1",
                                          SrcIpAddr="10.79.31.1",
                                          SessionId=1)
        sessRec.read()
        self.assertEquals(sessRec.index.IpAddrType, 1)
        self.assertEquals(sessRec.index.GroupIpAddr, "10.79.31.1")
        self.assertEquals(sessRec.index.SrcIpAddr, "10.79.31.1")
        self.assertEquals(sessRec.index.SessionId, 1)
        self.assertEquals(sessRec.JoinTime, "")
        self.assertEquals(sessRec.LocalLcceIpAddr, "")
        self.assertEquals(sessRec.RemoteLcceIpAddr, "")

        # modify the property
        currtime = Convert.pack_timestamp_to_string(time.time())
        sessRec.JoinTime = currtime
        sessRec.write()
        sessRec.read()
        self.assertEquals(sessRec.index.IpAddrType, 1)
        self.assertEquals(sessRec.index.GroupIpAddr, "10.79.31.1")
        self.assertEquals(sessRec.index.SrcIpAddr, "10.79.31.1")
        self.assertEquals(sessRec.index.SessionId, 1)
        self.assertEquals(sessRec.JoinTime, currtime)
        self.assertEquals(sessRec.LocalLcceIpAddr, "")
        self.assertEquals(sessRec.RemoteLcceIpAddr, "")

        # get_all
        ret = []
        for ses in sessRec.get_all():
            ret.append(ses)
        self.assertEquals(len(ret), 1)
コード例 #4
0
    def test_performance(self):
        sessRec = DepiMcastSessionRecord()
        test_count = 1000
        print "#########: perfermance test about %s session in store" % test_count
        current_time = time.time()
        print "current time is: " + str(
            datetime.datetime.fromtimestamp(current_time))
        for test_session in range(0, test_count):
            sessRec.updateDepiMcastSessionKey(IpAddrType=1,
                                              GroupIpAddr="10.79.31.1",
                                              SrcIpAddr="10.90.31.1",
                                              SessionId=test_session)
            test_time = Convert.pack_timestamp_to_string(time.time())
            sessRec.updateDepiMcastSessionData("10.1.1.1", "1.1.1.1",
                                               test_time)
            sessRec.write()
        print "Write " + str(test_count) + " records need : " + str(
            time.time() - current_time)
        current_time = time.time()
        ret = []
        for record in sessRec.get_next_n(count=test_count):
            ret.append(record)
        self.assertEquals(len(ret), test_count)
        print "get_next_n " + str(test_count) + " records need : " + str(
            time.time() - current_time)

        print "current time is: " + str(
            datetime.datetime.fromtimestamp(time.time()))
        current_time = time.time()
        ret = []
        for record in sessRec.get_next_n(count=20):
            ret.append(record)
        self.assertEquals(len(ret), 20)
        end_time = time.time()
        print "get_next_n " + str(20) + " records need : " + str(end_time -
                                                                 current_time)
        print "End time is: " + str(datetime.datetime.fromtimestamp(end_time))
        self.assertEquals(len(ret), 20)

        current_time = time.time()
        ret = []
        for ses in sessRec.get_all():
            ret.append(ses)
        print "get_next_all " + str(test_count) + " records need : " + str(
            time.time() - current_time)
        self.assertEquals(len(ret), test_count)
コード例 #5
0
 def test_updateDepiMcastSessionData(self):
     sessRec = DepiMcastSessionRecord()
     sessRec.updateDepiMcastSessionKey(IpAddrType=1,
                                       GroupIpAddr="10.79.31.1",
                                       SrcIpAddr="10.79.31.1",
                                       SessionId=1)
     self.assertEquals(sessRec.index.IpAddrType, 1)
     self.assertEquals(sessRec.index.SrcIpAddr, "10.79.31.1")
     self.assertEquals(sessRec.index.SessionId, 1)
     testIP1 = "127.0.0.1"
     testIP2 = "127.0.0.2"
     testTime = Convert.pack_timestamp_to_string(time.time())
     sessRec.updateDepiMcastSessionData(LocalLcceIpAddr=testIP1,
                                        RemoteLcceIpAddr=testIP2,
                                        JoinTime=testTime)
     self.assertEquals(sessRec.LocalLcceIpAddr, testIP1)
     self.assertEquals(sessRec.RemoteLcceIpAddr, testIP2)
     self.assertEquals(sessRec.JoinTime, testTime)
コード例 #6
0
ファイル: HalDriver0.py プロジェクト: hujiangyi/or
    def dummy_rpd_cap(self, cap):
        cap.NumBdirPorts = 3
        cap.NumDsRfPorts = 1
        cap.NumUsRfPorts = 2
        cap.NumTenGeNsPorts = 2
        cap.NumOneGeNsPorts = 1
        cap.NumDsScQamChannels = 158
        cap.NumDsOfdmChannels = 1
        cap.NumUsScQamChannels = 12
        cap.NumUsOfdmaChannels = 4
        cap.NumDsOob55d1Channels = 1
        cap.NumUsOob55d1Channels = 3
        cap.NumOob55d2Modules = 0
        cap.NumUsOob55d2Demodulators = 0
        cap.NumNdfChannels = 1
        cap.NumNdrChannels = 1
        cap.SupportsUdpEncap = 0
        cap.NumDsPspFlows = 8
        cap.NumUsPspFlows = 4

        cap.RpdIdentification.VendorName = "Cisco"
        cap.RpdIdentification.VendorId = 9
        cap.RpdIdentification.ModelNumber = "0"
        cap.RpdIdentification.DeviceMacAddress = SysTools.get_mac_address(
            "eth0")
        cap.RpdIdentification.CurrentSwVersion = "dummy_cur_sw_ver"
        cap.RpdIdentification.BootRomVersion = "dummy_boot_rom_version"
        cap.RpdIdentification.DeviceDescription = "RPD"
        cap.RpdIdentification.DeviceAlias = "RPD"
        cap.RpdIdentification.SerialNumber = "NA"
        cap.RpdIdentification.UsBurstReceiverVendorId = 4413
        cap.RpdIdentification.UsBurstReceiverModelNumber = "NA"
        cap.RpdIdentification.UsBurstReceiverDriverVersion = "NA"
        cap.RpdIdentification.UsBurstReceiverSerialNumber = "00000000"
        cap.RpdIdentification.RpdRcpProtocolVersion = "1.0"
        cap.RpdIdentification.RpdRcpSchemaVersion = "1.0.8"
        cap.RpdIdentification.HwRevision = "NA"
        cap.RpdIdentification.AssetId = "NA"
        cap.RpdIdentification.VspSelector = ""
        cap.RpdIdentification.CurrentSwImageLastUpdate = Convert.pack_timestamp_to_string(
            0)
        cap.RpdIdentification.CurrentSwImageName = ""
        cap.RpdIdentification.CurrentSwImageServer = "0.0.0.0"

        cap.PilotToneCapabilities.NumCwToneGens = 4
        cap.PilotToneCapabilities.LowestCwToneFreq = 50000000
        cap.PilotToneCapabilities.HighestCwToneFreq = 1218000000
        cap.PilotToneCapabilities.MaxPowerDedCwTone = 100
        cap.PilotToneCapabilities.QamAsPilot = True
        cap.PilotToneCapabilities.MinPowerDedCwTone = -330
        cap.PilotToneCapabilities.MaxPowerQamCwTone = 90
        cap.PilotToneCapabilities.MinPowerQamCwTone = -30

        cap.DeviceLocation.DeviceLocationDescription = "NA"
        cap.DeviceLocation.GeoLocationLatitude = "+000000.0"
        cap.DeviceLocation.GeoLocationLongitude = "+0000000.0"

        cap.NumAsyncVideoChannels = 160
        cap.SupportsFlowTags = True
        cap.SupportsFrequencyTilt = True
        cap.TiltRange = 0
        cap.BufferDepthMonitorAlertSupport = 0
        cap.BufferDepthConfigurationSupport = 0
        cap.RpdUcdProcessingTime = 50
        cap.RpdUcdChangeNullGrantTime = 50
        cap.SupportMultiSectionTimingMerReporting = 0

        cap.RdtiCapabilities.NumPtpPortsPerEnetPort = 11

        cap.MaxDsPspSegCount = 10
        cap.DirectDsFlowQueueMapping = 1
        cap.DsSchedulerPhbIdList = "0 10 12 14 18 20 22 26 28 30 34 36 38 46"
        cap.RpdPendingEvRepQueueSize = 1000
        cap.RpdLocalEventLogSize = 1000
        cap.SupportsOpticalNodeRf = False
        cap.MaxDsFrequency = 1218000000
        cap.MinDsFrequency = 5700000
        cap.MaxBasePower = 0
        cap.MinTiltValue = 0
        cap.MinPowerAdjustScQam = 0
        cap.MaxPowerAdjustScQam = 0
        cap.MinPowerAdjustOfdm = 0
        cap.MaxPowerAdjustOfdm = 0
        cap.OfdmConfigurationCapabilities.RequiresOfdmaImDurationConfig = True