Skip to content

Instantly share code, notes, and snippets.

@donbowman
Created June 30, 2016 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donbowman/76b9dbb81cd2e01e8abe9a5fbf42e713 to your computer and use it in GitHub Desktop.
Save donbowman/76b9dbb81cd2e01e8abe9a5fbf42e713 to your computer and use it in GitHub Desktop.
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