Ejemplo n.º 1
0
 def testPodValidateMisingAllRequiredFields(self):
     pod = {}
     with self.assertRaises(ValueError) as ve:
         pod = Pod('testPod', **pod)
         pod.validateRequiredFields()
     error = ve.exception.message
     self.assertEqual(10, error.count(','))
Ejemplo n.º 2
0
 def testPodValidateMisingAllRequiredFields(self):
     pod = {}
     with self.assertRaises(ValueError) as ve:
         pod = Pod('testPod', **pod)
         pod.validateRequiredFields()
     error = ve.exception.message
     self.assertEqual(10, error.count(','))
Ejemplo n.º 3
0
 def testValidateEnum(self):
     with self.assertRaises(ValueError):
         Pod.validateEnum('Pod.TopologyTypeEnum', 'abcd',
                          Pod.TopologyTypeEnum)
     with self.assertRaises(ValueError):
         Pod.validateEnum('Pod.TopologyTypeEnum', ['abcd'],
                          Pod.TopologyTypeEnum)
Ejemplo n.º 4
0
 def testPodValidateMisingFewRequiredFields(self):
     pod = {}
     pod['interConnectPrefix'] = '1.2.0.0'
     pod['leafAS'] = '100'
     with self.assertRaises(ValueError) as ve:
         pod = Pod('testPod', **pod)
         pod.validateRequiredFields()
     error = ve.exception.message
     self.assertEqual(8, error.count(','), 'Number of missing field is not correct')
Ejemplo n.º 5
0
 def testPodValidateMisingFewRequiredFields(self):
     pod = {}
     pod['interConnectPrefix'] = '1.2.0.0'
     pod['leafAS'] = '100'
     with self.assertRaises(ValueError) as ve:
         pod = Pod('testPod', **pod)
         pod.validateRequiredFields()
     error = ve.exception.message
     self.assertEqual(8, error.count(','),
                      'Number of missing field is not correct')
Ejemplo n.º 6
0
 def testPodValidateMisingBadIpAddress(self):
     pod = {}
     pod['interConnectPrefix'] = '1.2.0.0.0'
     pod['vlanPrefix'] = '1.2.0.257'
     pod['loopbackPrefix'] = None
     with self.assertRaises(ValueError) as ve:
         pod = Pod('testPod', **pod)
         pod.validateIPaddr()
     error = ve.exception.message
     self.assertEqual(2, error.count(','), 'Number of bad Ip address format field is not correct')
Ejemplo n.º 7
0
 def testPodValidateMisingBadIpAddress(self):
     pod = {}
     pod['interConnectPrefix'] = '1.2.0.0.0'
     pod['vlanPrefix'] = '1.2.0.257'
     pod['loopbackPrefix'] = None
     with self.assertRaises(ValueError) as ve:
         pod = Pod('testPod', **pod)
         pod.validateIPaddr()
     error = ve.exception.message
     self.assertEqual(
         2, error.count(','),
         'Number of bad Ip address format field is not correct')
Ejemplo n.º 8
0
 def testOrm(self):
     pod = {}
     pod['spineCount'] = '2'
     pod['spineDeviceType'] = 'qfx-5100-24q-2p'
     pod['leafCount'] = '2'
     pod['leafSettings'] = [{'deviceType':'qfx-5100-48s-6q'}]
     pod['interConnectPrefix'] = '1.2.0.0'
     pod['vlanPrefix'] = '1.3.0.0'
     pod['loopbackPrefix'] = '1.4.0.0'
     pod['managementPrefix'] = '172.32.30.101/24'
     pod['spineAS'] = '100'
     pod['leafAS'] = '100'
     pod['topologyType'] = 'threeStage'
     pod['inventory'] = 'inventoryLabKurt.json'
     pod['outOfBandAddressList'] = ['1.2.3.4', '5.6.7.8']
     pod['devicePassword'] = '******'
     podOne = Pod('testPod', pod)
     self.session.add(podOne)
     self.session.commit()
     
     fetched = self.session.query(Pod).one()
     self.assertEqual(podOne, fetched)
     #delete object
     self.session.delete(podOne)
     self.session.commit()
     self.assertEqual(0, self.session.query(Pod).count())
Ejemplo n.º 9
0
    def testProcessTopology(self):
        l3ClosMediation = L3ClosMediation(self.conf)
        podDict = {
            "hostOrVmCountPerLeaf": 100,
            "leafDeviceType": "QFX5100-48S",
            "spineAS": 100,
            "spineDeviceType": "QFX5100-24Q",
            "leafCount": 6,
            "interConnectPrefix": "192.168.0.0",
            "spineCount": 4,
            "vlanPrefix": "172.16.0.0",
            "topologyType": "threeStage",
            "loopbackPrefix": "10.0.0.0",
            "leafAS": 200,
            "inventory": "inventoryLabLeafSpine.json"
        }
        l3ClosMediation.dao.createObjects([Pod('pod1', **podDict)])

        l3ClosMediation = flexmock(l3ClosMediation)
        l3ClosMediation.should_receive('createSpineIFDs').once()
        l3ClosMediation.should_receive('createLeafIFDs').once()
        l3ClosMediation.should_receive('createLinkBetweenIFDs').once()
        l3ClosMediation.should_receive('allocateResource').once()

        self.assertEqual(True, l3ClosMediation.processTopology('pod1'))
Ejemplo n.º 10
0
    def testPodValidateSuccess(self):
        pod = {}
        pod['spineCount'] = '3'
        pod['spineDeviceType'] = 'QFX5100-24Q'
        pod['leafCount'] = '5'
        pod['leafDeviceType'] = 'QFX5100-48S'
        pod['hostOrVmCountPerLeaf'] = 100
        pod['interConnectPrefix'] = '1.2.0.0'
        pod['vlanPrefix'] = '1.3.0.0'
        pod['loopbackPrefix'] = '1.4.0.0'
        pod['spineAS'] = '100'
        pod['leafAS'] = '100'
        pod['topologyType'] = 'threeStage'
        pod['inventory'] = 'inventoryLabKurt.json'
        pod = Pod("test", **pod)

        pod.validate()
Ejemplo n.º 11
0
 def testPodValidateSuccess(self):
     pod = {}
     pod['spineCount'] = '3'
     pod['spineDeviceType'] = 'QFX5100-24Q'
     pod['leafCount'] = '5'
     pod['leafDeviceType'] = 'QFX5100-48S'
     pod['hostOrVmCountPerLeaf'] = 100
     pod['interConnectPrefix'] = '1.2.0.0'
     pod['vlanPrefix'] = '1.3.0.0'
     pod['loopbackPrefix'] = '1.4.0.0'
     pod['spineAS'] = '100'
     pod['leafAS'] = '100'
     pod['topologyType'] = 'threeStage'
     pod['inventory'] = 'inventoryLabKurt.json'
     pod = Pod("test", **pod)
     
     pod.validate()
Ejemplo n.º 12
0
    def testPodValidateSuccess(self):
        pod = {}
        pod["spineCount"] = "2"
        pod["spineDeviceType"] = "qfx-5100-24q-2p"
        pod["leafCount"] = "2"
        pod["leafSettings"] = [{"deviceType": "qfx-5100-48s-6q"}]
        pod["hostOrVmCountPerLeaf"] = 100
        pod["interConnectPrefix"] = "1.2.0.0"
        pod["vlanPrefix"] = "1.3.0.0"
        pod["loopbackPrefix"] = "1.4.0.0"
        pod["managementPrefix"] = "172.32.30.101/24"
        pod["spineAS"] = "100"
        pod["leafAS"] = "100"
        pod["topologyType"] = "threeStage"
        pod["inventory"] = "inventoryUnitTest.json"
        pod["devicePassword"] = "******"
        pod = Pod("test", pod)

        pod.validate()
Ejemplo n.º 13
0
 def testPodValidateSuccess(self):
     pod = {}
     pod['spineCount'] = '2'
     pod['spineDeviceType'] = 'qfx-5100-24q-2p'
     pod['leafCount'] = '2'
     pod['leafSettings'] = [{'deviceType':'qfx-5100-48s-6q'}]
     pod['hostOrVmCountPerLeaf'] = 100
     pod['interConnectPrefix'] = '1.2.0.0'
     pod['vlanPrefix'] = '1.3.0.0'
     pod['loopbackPrefix'] = '1.4.0.0'
     pod['managementPrefix'] = '172.32.30.101/24'
     pod['spineAS'] = '100'
     pod['leafAS'] = '100'
     pod['topologyType'] = 'threeStage'
     pod['inventory'] = 'inventoryUnitTest.json'
     pod['devicePassword'] = '******'
     pod = Pod("test", pod)
     
     pod.validate()
Ejemplo n.º 14
0
    def testProcessTopologyMultiplePods(self):
        l3ClosMediation = L3ClosMediation(self.conf)

        podDict = {
            "hostOrVmCountPerLeaf": 100,
            "leafDeviceType": "QFX5100-24Q",
            "spineAS": 100,
            "spineDeviceType": "QFX5100",
            "leafCount": 6,
            "interConnectPrefix": "192.168.0.0",
            "spineCount": 4,
            "vlanPrefix": "172.16.0.0",
            "topologyType": "threeStage",
            "loopbackPrefix": "10.0.0.0",
            "leafAS": 200
        }
        pod1 = Pod('pod1', **podDict)
        podDict = {
            "hostOrVmCountPerLeaf": 100,
            "leafDeviceType": "QFX5100-48S",
            "spineAS": 100,
            "spineDeviceType": "QFX5100",
            "leafCount": 6,
            "interConnectPrefix": "192.168.0.0",
            "spineCount": 4,
            "vlanPrefix": "172.16.0.0",
            "topologyType": "threeStage",
            "loopbackPrefix": "10.0.0.0",
            "leafAS": 200
        }
        pod2 = Pod('pod1', **podDict)
        l3ClosMediation.dao.createObjects([pod1, pod2])

        with self.assertRaises(ValueError) as ve:
            l3ClosMediation.processTopology("pod1")
        error = ve.exception.message
        self.assertEqual(1, error.count('MultipleResultsFound'))
Ejemplo n.º 15
0
 def testConstructorPass(self):
     pod = {}
     pod['spineCount'] = '3'
     pod['spineDeviceType'] = 'QFX5100-24Q'
     pod['leafCount'] = '5'
     pod['leafDeviceType'] = 'QFX5100-48S'
     pod['interConnectPrefix'] = '1.2.0.0'
     pod['vlanPrefix'] = '1.3.0.0'
     pod['loopbackPrefix'] = '1.4.0.0'
     pod['spineAS'] = '100'
     pod['leafAS'] = '100'
     pod['topologyType'] = 'threeStage'
     pod['inventory'] = 'inventoryLabKurt.json'
     pod['outOfBandAddressList'] = ['1.2.3.4', '5.6.7.8']
     self.assertTrue(Pod('testPod', **pod) is not None)
Ejemplo n.º 16
0
def createPodObj(name):  
    pod = {}
    pod['spineCount'] = '2'
    pod['spineDeviceType'] = 'qfx-5100-24q-2p'
    pod['leafCount'] = '2'
    pod['leafSettings'] = [{'deviceType':'qfx-5100-48s-6q'}]
    pod['interConnectPrefix'] = '1.2.0.0'
    pod['vlanPrefix'] = '1.3.0.0'
    pod['hostOrVmCountPerLeaf'] = 100
    pod['loopbackPrefix'] = '1.4.0.0'
    pod['managementPrefix'] = '172.32.30.101/24'
    pod['spineAS'] = '100'
    pod['leafAS'] = '100'
    pod['topologyType'] = 'threeStage'
    pod['inventory'] = 'inventoryAnotherPod.json'
    pod['devicePassword'] = '******'
    return Pod(name, pod)
Ejemplo n.º 17
0
def createPod(name, session):
    pod = {}
    pod['spineCount'] = '3'
    pod['spineDeviceType'] = 'QFX5100-24Q'
    pod['leafCount'] = '5'
    pod['leafDeviceType'] = 'QFX5100-48S'
    pod['interConnectPrefix'] = '1.2.0.0'
    pod['vlanPrefix'] = '1.3.0.0'
    pod['loopbackPrefix'] = '1.4.0.0'
    pod['spineAS'] = '100'
    pod['leafAS'] = '100'
    pod['topologyType'] = 'threeStage'
    pod['inventory'] = 'inventoryLabKurt.json'
    pod = Pod(name, **pod)
    session.add(pod)
    session.commit()
    return pod
Ejemplo n.º 18
0
    def createPod(self, l3ClosMediation):
        podDict = {
            "hostOrVmCountPerLeaf": 254,
            "leafDeviceType": "QFX5100-48S",
            "spineAS": 100,
            "spineDeviceType": "QFX5100-24Q",
            "leafCount": 6,
            "interConnectPrefix": "192.168.0.0",
            "spineCount": 4,
            "vlanPrefix": "172.16.0.0",
            "topologyType": "threeStage",
            "loopbackPrefix": "10.0.0.0",
            "leafAS": 200,
            "inventory": "inventoryLabLeafSpine.json"
        }
        l3ClosMediation.dao.createObjects([Pod('pod1', **podDict)])

        return l3ClosMediation.dao.getUniqueObjectByName(Pod, 'pod1')
Ejemplo n.º 19
0
    def testProcessTopologyNoInventory(self):
        l3ClosMediation = L3ClosMediation(self.conf)

        podDict = {
            "hostOrVmCountPerLeaf": 100,
            "leafDeviceType": "QFX5100-24Q",
            "spineAS": 100,
            "spineDeviceType": "QFX5100",
            "leafCount": 6,
            "interConnectPrefix": "192.168.0.0",
            "spineCount": 4,
            "vlanPrefix": "172.16.0.0",
            "topologyType": "threeStage",
            "loopbackPrefix": "10.0.0.0",
            "leafAS": 200
        }
        l3ClosMediation.dao.createObjects([Pod('pod1', **podDict)])

        with self.assertRaises(ValueError):
            l3ClosMediation.processTopology("pod1")
Ejemplo n.º 20
0
 def testConstructorPass(self):
     pod = {}
     pod['spineCount'] = '2'
     pod['spineDeviceType'] = 'qfx-5100-24q-2p'
     pod['leafCount'] = '2'
     pod['leafSettings'] = [{'deviceType':'qfx-5100-48s-6q'}]
     pod['interConnectPrefix'] = '1.2.0.0'
     pod['vlanPrefix'] = '1.3.0.0'
     pod['loopbackPrefix'] = '1.4.0.0'
     pod['managementPrefix'] = '172.32.30.101/24'
     pod['spineAS'] = '100'
     pod['leafAS'] = '4294967295'
     pod['topologyType'] = 'threeStage'
     pod['inventory'] = 'inventoryUnitTest.json'
     pod['outOfBandAddressList'] = ['1.2.3.4', '5.6.7.8']
     pod['outOfBandGateway'] = '1.3.5.254'
     pod['devicePassword'] = '******'
     
     constructedPod = Pod('testPod', pod) 
     self.assertTrue(constructedPod is not None)
     self.assertEqual(','.join(['1.2.3.4', '5.6.7.8']), constructedPod.outOfBandAddressList)
     self.assertEqual('1.3.5.254', constructedPod.outOfBandGateway)
     self.assertEqual(4294967295, constructedPod.leafAS)
Ejemplo n.º 21
0
    def testOrm(self):
        pod = {}
        pod['spineCount'] = '3'
        pod['spineDeviceType'] = 'QFX5100-24Q'
        pod['leafCount'] = '5'
        pod['leafDeviceType'] = 'QFX5100-48S'
        pod['interConnectPrefix'] = '1.2.0.0'
        pod['vlanPrefix'] = '1.3.0.0'
        pod['loopbackPrefix'] = '1.4.0.0'
        pod['spineAS'] = '100'
        pod['leafAS'] = '100'
        pod['topologyType'] = 'threeStage'
        pod['inventory'] = 'inventoryLabKurt.json'
        pod['outOfBandAddressList'] = ['1.2.3.4', '5.6.7.8']
        podOne = Pod('testPod', **pod)
        self.session.add(podOne)
        self.session.commit()

        fetched = self.session.query(Pod).one()
        self.assertEqual(podOne, fetched)
        #delete object
        self.session.delete(podOne)
        self.session.commit()
        self.assertEqual(0, self.session.query(Pod).count())
Ejemplo n.º 22
0
 def testValidateEnum(self):
     with self.assertRaises(ValueError) :
         Pod.validateEnum('Pod.TopologyTypeEnum', 'abcd', Pod.TopologyTypeEnum)
     with self.assertRaises(ValueError) :
         Pod.validateEnum('Pod.TopologyTypeEnum', ['abcd'], Pod.TopologyTypeEnum)
Ejemplo n.º 23
0
 def testDeleteNonExistingPod(self):
     dict = {'devicePassword': '******'}
     pod = Pod('unknown', dict)
     with self.assertRaises(exc.InvalidRequestError):
         with self.__dao.getReadWriteSession() as session:
             self.__dao.deleteObject(session, pod)
Ejemplo n.º 24
0
 def testDeleteNonExistingPod(self):
     dao = Dao(self.conf)
     dict = {}
     pod = Pod('unknown', **dict)
     with self.assertRaises(exc.InvalidRequestError):
         dao.deleteObject(pod)