Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def test_002_create_partition(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     resp = testpartition.save(self.session)
     self.assertTrue(resp.ok)
Ejemplo n.º 6
0
 def test_002_create_partition(self):
     testorg = Org('unittesting')
     testpartition = Partition('p1', testorg)
     resp = testpartition.save(self.session)
     self.assertTrue(resp.ok)