Created
June 30, 2016 20:55
-
-
Save donbowman/76b9dbb81cd2e01e8abe9a5fbf42e713 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from neutronclient.v2_0 import client | |
neutron = client.Client(username='don', | |
password='XXX', | |
tenant_name='don',auth_url='https://keystone.sandvine.rocks/v2.0') | |
ids = [] | |
sids = [] | |
for i in range(1,254): | |
network = {'name': 'pnet-%s' % i, 'admin_state_up': True} | |
n = neutron.create_network({'network':network}) | |
id = n['network']['id'] | |
ids.append(id) | |
srange="172.17.%u.9" % i | |
erange="172.17.%u.254" % i | |
cidr="172.17.%u.0/24" % i | |
name = "subnet-%u" % i | |
subnet = {'enable_dhcp': True, | |
'network_id': id, | |
'allocation_pools': [{'start': srange, 'end': erange}], | |
'ip_version': 4, | |
'cidr': cidr, | |
'name': name} | |
s = neutron.create_subnet({'subnet':subnet}) | |
sid = s['subnet']['id'] | |
sids.append(sid) | |
for i in sids: | |
neutron.delete_subnet({'subnet':{'id': i}}) | |
for i in ids: | |
neutron.delete_network({'network':{'id': i}}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment