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())
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 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)
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)
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 test_005_get_networks(self): testorg = Org('unittesting') testpartition = Partition('p1', testorg) nets = Network.get(self.session, testpartition) self.assertIsInstance(nets, list)