from xml.etree import ElementTree as ET
+import sys
from pyvcloud import Http
import logging
# view vapp action
if action == 'vapp' or namespace.action == 'vapp':
- print namespace.vapp_name
if namespace.vapp_name is not None and namespace.uuid:
logger.debug("Requesting vapp {} for vdc {}".format(namespace.vapp_name, namespace.vcdvdc))
vapp_dict = {}
print("Can't find vapp by given name {}".format(namespace.vapp_name))
return
- vapp_dict = vim.get_vapp(vdc_name=namespace.vcdvdc, vapp_name=vapp_uuid, isuuid=True)
- if vapp_dict is not None:
+ print " namespace {}".format(namespace)
+ if vapp_dict is not None and namespace.osm:
+ vm_info_dict = vim.get_vminstance(vim_vm_uuid=vapp_uuid)
+ print vm_info_dict
+ if vapp_dict is not None and namespace.osm != True:
+ vapp_dict = vim.get_vapp(vdc_name=namespace.vcdvdc, vapp_name=vapp_uuid, isuuid=True)
print_vapp(vapp_dict=vapp_dict)
# view network
The return true if image uploaded correctly
"""
try:
- catalog_uuid = vim.get_image_id_from_path(path=image_file)
+ catalog_uuid = vim.get_image_id_from_path(path=image_file, progress=True)
if catalog_uuid is not None and validate_uuid4(catalog_uuid):
print("Image uploaded and uuid {}".format(catalog_uuid))
return True
- except:
+ except vimconn.vimconnException as upload_exception:
print("Failed uploaded {} image".format(image_file))
-
+ print("Error Reason: {}".format(upload_exception.message))
return False
The image name can be UUID of name.
Args:
- image_name - image identified by UUID or text string.
- vm_name
+ vim - vim connector
+ image_name - image identified by UUID or text string.
+ vm_name - vmname
+
Returns:
The return true if image uploaded correctly
if vim_catalog is None:
return None
+ print (" Booting {} image id {} ".format(vm_name, vim_catalog))
vm_uuid = vim.new_vminstance(name=vm_name, image_id=vim_catalog)
if vm_uuid is not None and validate_uuid4(vm_uuid):
print("Image booted and vm uuid {}".format(vm_uuid))
if vapp_dict is not None:
print_vapp(vapp_dict=vapp_dict)
return True
+ except vimconn.vimconnNotFoundException as notFound:
+ print("Failed boot {} image".format(image_name))
+ print(notFound.message)
+ except vimconn.vimconnException as vimconError:
+ print("Failed boot {} image".format(image_name))
+ print(vimconError.message)
except:
- print("Failed uploaded {} image".format(image_name))
+ print("Failed boot {} image".format(image_name))
+
+
+ return False
def image_action(vim=None, action=None, namespace=None):
log_level="DEBUG",
config={'admin_username': namespace.vcdamdin, 'admin_password': namespace.vcdadminpassword})
vim.vca = vim.connect()
+
except vimconn.vimconnConnectionException:
print("Failed connect to vcloud director. Please check credential and hostname.")
return
view_vapp_parser.add_argument('vapp_name', action='store',
help='- view vapp for specific vapp name in vcloud director')
view_vapp_parser.add_argument('-u', '--uuid', default=False, action='store_true', help='view vapp based on uuid')
+ view_vapp_parser.add_argument('-o', '--osm', default=False, action='store_true', help='provide view in OSM format')
# view network
view_network = view_sub_subparsers.add_parser('network')