- logger.info("Private Neutron network created successfully.")
- return True
-
-def get_network_id(neutron, network_name):
- networks = neutron.list_networks()['networks']
- id = ''
- for n in networks:
- if n['name'] == network_name:
- id = n['id']
- break
- return id
-
-def check_neutron_net(neutron, net_name):
- for network in neutron.list_networks()['networks']:
- if network['name'] == net_name :
- for subnet in network['subnets']:
- return True
- return False
-
-def delete_neutron_net(neutron):
- #TODO: remove router, ports
- try:
- #https://github.com/isginf/openstack_tools/blob/master/openstack_remove_tenant.py
- for network in neutron.list_networks()['networks']:
- if network['name'] == NEUTRON_PRIVATE_NET_NAME :
- for subnet in network['subnets']:
- print "Deleting subnet " + subnet
- neutron.delete_subnet(subnet)
- print "Deleting network " + network['name']
- neutron.delete_neutron_net(network['id'])
- finally:
- return True
- return False
-
-
-
-
-
-def create_glance_image(path,name,disk_format):
- """
- Create a glance image given the absolute path of the image, its name and the disk format
- """
- cmd = "glance image-create --name "+name+" --is-public true --disk-format "+disk_format+" --container-format bare --file "+path
- execute_command(cmd)
- return True
-
-
-
-
-
-def download_url(url, dest_path):
- """
- Download a file to a destination path given a URL
- """
- name = url.rsplit('/')[-1]
- dest = dest_path + name
- try:
- response = urllib2.urlopen(url)
- except (urllib2.HTTPError, urllib2.URLError):
- logger.error("Error in fetching %s" %url)