You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

63 lines
1.7 KiB

import getpass
import libcloud.security
from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider
auth_username = 'fdai109'
auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
project_name = 'ai-netlab-pro'
region_name = 'RegionOne'
domain_name = "hsfulda"
ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
def main():
print(auth_username)
auth_password = getpass.getpass("Enter your OpenStack password:")
# libcloud.security.VERIFY_SSL_CERT = False
provider = get_driver(Provider.OPENSTACK)
conn = provider(auth_username,
auth_password,
ex_force_auth_url=auth_url,
ex_force_auth_version='3.x_password',
ex_tenant_name=project_name,
ex_force_service_region=region_name,
ex_domain_name=domain_name)
images = conn.list_images()
image = ''
for img in images:
if img.name == ubuntu_image_name:
image = img
print(img)
flavors = conn.list_sizes()
for flavor in flavors:
print(flavor)
flavor_id = '2'
flavor = conn.ex_get_size(flavor_id)
print(flavor)
networks = conn.ex_list_networks()
network = ''
for net in networks:
if net.name == "ai-netlab-pro-net":
network = net
instance_name = 'testing'
testing_instance = conn.create_node(name=instance_name, image=image, size=flavor, networks={network})
print(testing_instance)
instances = conn.list_nodes()
for instance in instances:
print(instance)
conn.destroy_node(testing_instance)
if __name__ == '__main__':
main()