Пример #1
0
def create_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org
    print 'Creating org %s' % data['name']
    org = Org(data['name'])
    org.save(session)


    # create partitions
    for partition in data['partitions']:
        print 'Creating paritition %s' % partition['name']
        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Creating Network %s' % network['name']
            num = network['segment']
            gw = '{0}.{0}.{0}.1/24'.format(num)
            vni = '{0}{0}'.format(num)
            vlan = '2{}'.format(num)
            n = Network('net{}'.format(num), part)
            n.set_gateway(gw)
            n.segmentId = vni
            n.vlanId = vlan
            n.save(session)
Пример #2
0
def create_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org
    print 'Creating org %s' % data['name']
    org = Org(data['name'])
    org.save(session)

    # create partitions
    for partition in data['partitions']:
        print 'Creating paritition %s' % partition['name']
        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Creating Network %s' % network['name']
            num = network['segment']
            gw = '{0}.{0}.{0}.1/24'.format(num)
            vni = '{0}{0}'.format(num)
            vlan = '2{}'.format(num)
            n = Network('net{}'.format(num), part)
            n.set_gateway(gw)
            n.segmentId = vni
            n.vlanId = vlan
            n.save(session)
Пример #3
0
    def test_create_valid_org(self):
        """
        Test basic Org creation
        """
        org = Org(name='testorg')
        data = '{"organizationName": "testorg"}'

        self.assertIsInstance(org, Org)
        self.assertEqual(org.get_json(), data)
Пример #4
0
    def test_create_valid_org(self):
        """
        Test basic Org creation
        """
        org = Org(name='testorg')
        data = '{"organizationName": "testorg"}'

        self.assertIsInstance(org, Org)
        self.assertEqual(org.get_json(), data)
Пример #5
0
def main():
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    test = Org('sample-org')
    session.post(test.get_url(), test.get_json())

    p1 = Partition('sample', test)
    session.post(p1.get_url(), p1.get_json())
    n1 = Network('net1', p1)
    n1.segmentId = 333
    n1.vlanId = n1.segmentId
    session.post(n1.get_url(), n1.get_json())
Пример #6
0
def main():
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    test = Org('sample-org')
    session.push_to_dcnm(test.get_url(), test.get_json())

    p1 = Partition('sample', test)
    session.push_to_dcnm(p1.get_url(), p1.get_json())
    n1 = Network('net1', p1)
    n1.segmentId = 333
    n1.vlanId = n1.segmentId
    session.push_to_dcnm(n1.get_url(), n1.get_json())
Пример #7
0
    def test_create_org_from_json(self):
        """
        Test basic Org creation
        """
        data = '{"organizationName": "testorg-json"}'
        org = Org._from_json(json.loads(data))

        self.assertIsInstance(org, Org)
        self.assertEqual(org.get_json(), data)
Пример #8
0
    def test_create_org_from_json(self):
        """
        Test basic Org creation
        """
        data = '{"organizationName": "testorg-json"}'
        org = Org._from_json(json.loads(data))


        self.assertIsInstance(org, Org)
        self.assertEqual(org.get_json(), data)
Пример #9
0
 def test_006_delete_network(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     n1 = Network('net1', testpartition)
     n1.segmentId = 333
     n1.vlanId = n1.segmentId
     n1.set_gateway('10.10.10.2/24')
     n1.vlanId = '124'
     n1.segmentId = '124'
     n1.segmentId = '124'
     resp = n1.delete(self.session)
Пример #10
0
def delete_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org

    org = Org(data['name'])

    # create partitions
    for partition in data['partitions']:

        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Deleting Network %s' % network['name']
            num = network['segment']
            vni = '{0}{0}'.format(num)
            n = Network('net{}'.format(num), part)
            n.segmentId = vni
            n.delete(session)
        print 'Deleting paritition %s' % partition['name']
        part.delete(session)
    print 'Deleting org %s' % data['name']
    org.delete(session)
Пример #11
0
def delete_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org

    org = Org(data['name'])

    # create partitions
    for partition in data['partitions']:

        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Deleting Network %s' % network['name']
            num = network['segment']
            vni = '{0}{0}'.format(num)
            n = Network('net{}'.format(num), part)
            n.segmentId = vni
            n.delete(session)
        print 'Deleting paritition %s' % partition['name']
        part.delete(session)
    print 'Deleting org %s' % data['name']
    org.delete(session)
Пример #12
0
 def test_get_orgs(self):
     orgs = Org.get(self.session())
     self.assertIsInstance(orgs, list)
Пример #13
0
 def test_001_create_org(self):
     testorg = Org('unittesting')
     resp = testorg.save(self.session)
     self.assertTrue(resp.ok)
Пример #14
0
 def test_create_valid_partition(self):
     org = Org(name='testorg')
     part = Partition('test-partition', org)
     self.assertIsInstance(part, Partition)
Пример #15
0
 def test_008_delete_org(self):
     testorg = Org('unittesting')
     resp = testorg.delete(self.session)
     self.assertTrue(resp.ok)
Пример #16
0
 def test_008_delete_org(self):
     testorg = Org('unittesting')
     resp = testorg.delete(self.session)
     self.assertTrue(resp.ok)
Пример #17
0
 def test_007_delete_partition(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     resp = testpartition.delete(self.session)
     self.assertTrue(resp.ok)
Пример #18
0
 def test_get_orgs(self):
     orgs = Org.get(self.session())
     self.assertIsInstance(orgs, list)
Пример #19
0
 def test_005_get_networks(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     nets = Network.get(self.session, testpartition)
     self.assertIsInstance(nets, list)
Пример #20
0
 def test_004_get_partitions(self):
     testorg = Org('unittesting')
     partitions = Partition.get(self.session, testorg)
     self.assertIsInstance(partitions, list)
Пример #21
0
 def test_001_create_org(self):
     testorg = Org('unittesting')
     resp = testorg.save(self.session)
     self.assertTrue(resp.ok)