Esempio n. 1
0
    def testcreateLinksInGraph(self):
        testLinksInTopology = pydot.Dot(graph_type='graph')
        pod = createPod('pod1', self.dao.Session())
        cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao)
        deviceOne = Device('spine01', "", 'admin', 'admin', 'spine', "", "",
                           pod)
        deviceOne.id = 'spine01'
        IF1 = InterfaceDefinition('IF1', deviceOne, 'downlink')
        IF1.id = 'IF1'

        deviceTwo = Device('leaf01', "", 'admin', 'admin', 'leaf', "", "", pod)
        deviceTwo.id = 'leaf01'
        IF21 = InterfaceDefinition('IF1', deviceTwo, 'uplink')
        IF21.id = 'IF21'

        IF1.peer = IF21
        IF21.peer = IF1
        linkLabel = {deviceOne.id + ':' + IF1.id: deviceTwo.id + ':' + IF21.id}
        cablingPlanWriter.createLinksInGraph(linkLabel, testLinksInTopology,
                                             'red')
        path = cablingPlanWriter.outputDir + '/testLinklabel.dot'
        testLinksInTopology.write_raw(path)
        data = open(path, 'r').read()
        #check generated label for links
        self.assertTrue('spine01:IF1 -- leaf01:IF21  [color=red];' in data)
Esempio n. 2
0
    def testcreateDOTFile(self):
        # create pod
        # create device
        #create interface
        session = self.dao.Session()
        pod = createPod('pod1', session)
        cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao)
        deviceOne = Device('spine01', "", 'admin', 'admin', 'spine', "", "",
                           pod)
        session.add(deviceOne)
        IF1 = InterfaceDefinition('IF1', deviceOne, 'downlink')
        session.add(IF1)
        IF2 = InterfaceDefinition('IF2', deviceOne, 'downlink')
        session.add(IF2)

        deviceTwo = Device('leaf01', "", 'admin', 'admin', 'leaf', "", "", pod)
        session.add(deviceTwo)
        IF21 = InterfaceDefinition('IF1', deviceTwo, 'uplink')
        session.add(IF21)
        IF22 = InterfaceDefinition('IF2', deviceTwo, 'uplink')
        session.add(IF22)
        IF23 = InterfaceDefinition('IF3', deviceTwo, 'downlink')
        session.add(IF23)
        IF24 = InterfaceDefinition('IF3', deviceTwo, 'downlink')
        session.add(IF24)

        deviceThree = Device('Access01', "", 'admin', 'admin', 'leaf', "", "",
                             pod)
        session.add(deviceThree)
        IF31 = InterfaceDefinition('IF1', deviceThree, 'uplink')
        session.add(IF31)
        IF32 = InterfaceDefinition('IF2', deviceThree, 'uplink')
        session.add(IF32)

        IF1.peer = IF21
        IF2.peer = IF22
        IF21.peer = IF1
        IF22.peer = IF2
        IF23.peer = IF31
        IF31.peer = IF23
        IF24.peer = IF32
        IF32.peer = IF24

        session.commit()
        devices = session.query(Device).all()
        #check the DOT file is generated
        cablingPlanWriter.writeDOT()
        data = open(cablingPlanWriter.outputDir + '/cablingPlan.dot',
                    'r').read()
        #check generated label for links
        self.assertTrue('splines=polyline;' in data)
Esempio n. 3
0
 def testcreateDOTFile(self):
     # create pod
     # create device
     #create interface
     session = self.dao.Session()
     pod = createPod('pod1', session)
     cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao)
     deviceOne = Device('spine01',"", 'admin', 'admin',  'spine', "", "", pod)
     session.add(deviceOne)
     IF1 = InterfaceDefinition('IF1', deviceOne, 'downlink')
     session.add(IF1)
     IF2 = InterfaceDefinition('IF2', deviceOne, 'downlink')
     session.add(IF2)
     
     deviceTwo = Device('leaf01',"", 'admin', 'admin',  'leaf', "", "", pod)
     session.add(deviceTwo)
     IF21 = InterfaceDefinition('IF1', deviceTwo, 'uplink')
     session.add(IF21)
     IF22 = InterfaceDefinition('IF2', deviceTwo, 'uplink')
     session.add(IF22)
     IF23 = InterfaceDefinition('IF3', deviceTwo, 'downlink')
     session.add(IF23)
     IF24 = InterfaceDefinition('IF3', deviceTwo, 'downlink')
     session.add(IF24)
     
     deviceThree = Device('Access01', "",'admin', 'admin',  'leaf', "", "", pod)
     session.add(deviceThree)
     IF31 = InterfaceDefinition('IF1', deviceThree, 'uplink')
     session.add(IF31)
     IF32 = InterfaceDefinition('IF2', deviceThree, 'uplink')
     session.add(IF32)
     
     IF1.peer = IF21
     IF2.peer = IF22
     IF21.peer = IF1
     IF22.peer = IF2
     IF23.peer = IF31
     IF31.peer = IF23
     IF24.peer = IF32
     IF32.peer = IF24   
     
     session.commit()
     devices = session.query(Device).all()
     #check the DOT file is generated
     cablingPlanWriter.writeDOT()
     data = open(cablingPlanWriter.outputDir + '/cablingPlan.dot', 'r').read()
     #check generated label for links
     self.assertTrue('splines=polyline;' in data)
     
Esempio n. 4
0
 def testcreateLinksInGraph(self):
     testLinksInTopology = pydot.Dot(graph_type='graph')
     pod = createPod('pod1', self.dao.Session())
     cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao)
     deviceOne = Device('spine01',"", 'admin', 'admin',  'spine', "", "", pod)
     deviceOne.id = 'spine01'
     IF1 = InterfaceDefinition('IF1', deviceOne, 'downlink')
     IF1.id = 'IF1'
     
     deviceTwo = Device('leaf01',"", 'admin', 'admin',  'leaf', "", "", pod)
     deviceTwo.id = 'leaf01'
     IF21 = InterfaceDefinition('IF1', deviceTwo, 'uplink')
     IF21.id = 'IF21'
     
     IF1.peer = IF21
     IF21.peer = IF1
     linkLabel = {deviceOne.id + ':' + IF1.id : deviceTwo.id + ':' + IF21.id}
     cablingPlanWriter.createLinksInGraph(linkLabel, testLinksInTopology, 'red')
     path = cablingPlanWriter.outputDir + '/testLinklabel.dot'
     testLinksInTopology.write_raw(path)
     data = open(path, 'r').read()
     #check generated label for links
     self.assertTrue('spine01:IF1 -- leaf01:IF21  [color=red];' in data)