Example #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)
Example #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)
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())
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())
Example #5
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)
Example #6
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)
Example #7
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)
Example #8
0
 def test_create_valid_partition(self):
     org = Org(name='testorg')
     part = Partition('test-partition', org)
     self.assertIsInstance(part, Partition)
Example #9
0
 def test_007_delete_partition(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     resp = testpartition.delete(self.session)
     self.assertTrue(resp.ok)
Example #10
0
 def test_005_get_networks(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     nets = Network.get(self.session, testpartition)
     self.assertIsInstance(nets, list)
Example #11
0
 def test_004_get_partitions(self):
     testorg = Org('unittesting')
     partitions = Partition.get(self.session, testorg)
     self.assertIsInstance(partitions, list)
Example #12
0
 def test_007_delete_partition(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     resp = testpartition.delete(self.session)
     self.assertTrue(resp.ok)
Example #13
0
 def test_004_get_partitions(self):
     testorg = Org('unittesting')
     partitions = Partition.get(self.session, testorg)
     self.assertIsInstance(partitions, list)