Exemplo 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)
Exemplo n.º 2
0
 def testcreateDOTFile(self):
     # create pod
     # create device
     #create interface
     with self._dao.getReadWriteSession() as session:
         pod = createPod('pod1', session)
         cablingPlanWriter = CablingPlanWriter(self._conf, pod, self._dao)
         #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)
Exemplo n.º 3
0
 def testCreateDeviceInGraph(self):
     testDeviceTopology = pydot.Dot(graph_type='graph', )
     pod = createPod('pod1', self.dao.Session())
     cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao)
     device = createPodDevice(self.dao.Session(), 'Preethi', pod)
     device.id = 'preethi-1'
     cablingPlanWriter.createDeviceInGraph(device.name, device, testDeviceTopology)
     path = cablingPlanWriter.outputDir + '/testDevicelabel.dot'
     testDeviceTopology.write_raw(path)
     data = open(path, 'r').read()
     #check the generated label for device
     self.assertTrue('"preethi-1" [shape=record, label=Preethi];' in data)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
     
Exemplo n.º 6
0
 def testInitWithTemplate(self):
     from jinja2 import TemplateNotFound
     pod = createPod('pod1', self.dao.Session())
     cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao)
     self.assertIsNotNone(cablingPlanWriter.template)
     with self.assertRaises(TemplateNotFound) as e:
         cablingPlanWriter.templateEnv.get_template('unknown-template')
     self.assertTrue('unknown-template' in e.exception.message)
Exemplo n.º 7
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)