Пример #1
0
    def _addEntries(self, **kwargs):
        """
        Adds csv entries from file.
        """
        #
        fn = kwargs.get("local_file", None)
        #
        def p(x):
            sys.stderr.write("[%s]\r" % (x.getKey('inserted-rows'))),
        #
        r = self.dbh.importFile(fn, p, 10000)
        #
        # calculate new columns
        # mif = lambda x: self._populate_columns("type", x)
        mif = lambda x: str.strip(str(x['origin_as']),"AS")
        p = self.dbh.calculateMetaColumn("origin_as2", mif)

        # mif = lambda x: pfxExplode(x['pfx'])['istart']
        def pif(x):
            y = pfxExplode(x['prefix'])
            return y['istart']
        p = self.dbh.calculateMetaColumn("istart", pif)

        #
        mif = lambda x: pfxExplode(x['prefix'])['iend']
        p = self.dbh.calculateMetaColumn("iend", mif)
        mif = lambda x: pfxExplode(x['prefix'])['type']
        p = self.dbh.calculateMetaColumn("type", mif)
        #
        return
    def _addEntries(self, **kwargs):
        """
        Adds csv entries from file.
        """
        #
        fn = kwargs.get("local_file", None)
        #
        def p(x):
            sys.stderr.write("[%s]\r" % (x.getKey('inserted-rows'))),
        #
        r = self.dbh.importFile(fn, p, 10000)
        #
        # calculate new columns: origin_as2 strips the leading AS from origin_as
        # mif = lambda x: self._populate_columns("type", x)
        mif = lambda x: str.strip(str(x['origin_as']),"AS")
        p = self.dbh.calculateMetaColumn("origin_as2", mif)

        # mif = lambda x: pfxExplode(x['pfx'])['istart']
        def pif(x):
            y = pfxExplode(x['prefix'])
            return y['istart']
        p = self.dbh.calculateMetaColumn("istart", pif)

        #
        mif = lambda x: pfxExplode(x['prefix'])['iend']
        p = self.dbh.calculateMetaColumn("iend", mif)
        mif = lambda x: pfxExplode(x['prefix'])['type']
        p = self.dbh.calculateMetaColumn("type", mif)
        mif = lambda x: pfxExplode(x['prefix'])['equiv']
        p = self.dbh.calculateMetaColumn("equiv", mif)
        mif = lambda x: pfxExplode(x['prefix'])['pfxlen']
        p = self.dbh.calculateMetaColumn("pfxlen", mif)
        #
        return
Пример #3
0
 def testExplodev6(self):
     e = pfxExplode("2001:db8:1::/48")
     self.assertTrue(e['type'] == 'ipv6', "Type should be ipv6")
     self.assertTrue(e['istart'] == 2306139568115613696L,
                     "istart should be 2306139568115613696L")
     self.assertTrue(e['pfxlen'] == 48, "pfxlen should be 48")
Пример #4
0
 def testExplodev4(self):
     e = pfxExplode("192.168.1.0/24")
     self.assertTrue(e['type'] == 'ipv4', "Type should be ipv4")
     self.assertTrue(e['istart'] == 3232235776,
                     "istart should be 3232235776")
     self.assertTrue(e['pfxlen'] == 24, "pfxlen should be 24")
Пример #5
0
 def pif(x):
     y = pfxExplode(x['prefix'])
     return y['istart']
 def pif(x):
     y = pfxExplode(x['prefix'])
     return y['istart']
Пример #7
0
	def testExplodev6(self):
		e = pfxExplode("2001:db8:1::/48")
		self.assertTrue(e['type']=='ipv6', "Type should be ipv6")
		self.assertTrue(e['istart']==2306139568115613696L, "istart should be 2306139568115613696L")
		self.assertTrue(e['pfxlen']==48, "pfxlen should be 48")
Пример #8
0
	def testExplodev4(self):
		e = pfxExplode("192.168.1.0/24")
		self.assertTrue(e['type']=='ipv4', "Type should be ipv4")
		self.assertTrue(e['istart']==3232235776, "istart should be 3232235776")
		self.assertTrue(e['pfxlen']==24, "pfxlen should be 24")