Browse Source

changed image search for ubuntu image

master
Sebastian Rieger 7 years ago
parent
commit
01937c66ce
  1. 17
      demo1-getting-started.py

17
demo1-getting-started.py

@ -5,16 +5,18 @@ from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider from libcloud.compute.types import Provider
auth_username = 'fdai109' auth_username = 'fdai109'
auth_url = 'https://192.168.72.40:5000'
auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
project_name = 'ai-netlab-pro' project_name = 'ai-netlab-pro'
region_name = 'RegionOne' region_name = 'RegionOne'
domain_name = "hsfulda" domain_name = "hsfulda"
ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
def main(): def main():
print(auth_username) print(auth_username)
auth_password = getpass.getpass("Enter your OpenStack password:") auth_password = getpass.getpass("Enter your OpenStack password:")
libcloud.security.VERIFY_SSL_CERT = False
# libcloud.security.VERIFY_SSL_CERT = False
provider = get_driver(Provider.OPENSTACK) provider = get_driver(Provider.OPENSTACK)
conn = provider(auth_username, conn = provider(auth_username,
@ -26,17 +28,16 @@ def main():
ex_domain_name=domain_name) ex_domain_name=domain_name)
images = conn.list_images() images = conn.list_images()
for image in images:
print(image)
image = ''
for img in images:
if img.name == ubuntu_image_name:
image = img
print(img)
flavors = conn.list_sizes() flavors = conn.list_sizes()
for flavor in flavors: for flavor in flavors:
print(flavor) print(flavor)
image_id = '95718fad-2b33-469c-a256-15888f461f66'
image = conn.get_image(image_id)
print(image)
flavor_id = '2' flavor_id = '2'
flavor = conn.ex_get_size(flavor_id) flavor = conn.ex_get_size(flavor_id)
print(flavor) print(flavor)

Loading…
Cancel
Save