Goal: To determine by a each VM's UUID if it is managed by vCloud Director or vCenter. This is so I can know which API to send the commands too. I search each vm by UUID because the program is looping through a command_dictonary. Thus, it is not always looping through a very large amount of VM's.
Since I already have the VM object I'm trying to get to the object value config.extraConfig Inside this object value there is an array of values. This is also where the vCloud director UUID is stored. I need this UUID to make the REST URL needed to send commands to vCloud Director.
However I am having issues accessing the value. Basically I want iterate over the object array list until the .Key value is =='cloud.uuid' however, the code I'm using returns the error:
2014-12-01 15:41:00,278 ERROR ApplicationError
Traceback (most recent call last):
File "/home/grant/workspace/Portal/PortalModules/PortalBackendController.py", line 240, in vm_command_center
print option.Key, option.value
AttributeError: 'vim.option.OptionValue' object has no attribute 'Key'
This is the code I'm using:
for vcenter in list_of_vc_connections:
#call the current time to keep the connection alive.
list_of_vc_connections[vcenter].CurrentTime()
vm_uuid = command_dict[command]['vm_uuid']
search_index = list_of_vc_connections[vcenter].content.searchIndex
vm = search_index.FindByUuid(None, vm_uuid, True, True)
command_exec = command_dict[command]['command']
vcenter_uuid = uuid_dict[vcenter]
vm_mor = vm._moId
for option in vm.config.extraConfig:
print option
if option.Key == 'cloud.uuid':
print option.value
Goal: To determine by a each VM's UUID if it is managed by vCloud Director or vCenter. This is so I can know which API to send the commands too. I search each vm by UUID because the program is looping through a command_dictonary. Thus, it is not always looping through a very large amount of VM's.
Since I already have the VM object I'm trying to get to the object value config.extraConfig Inside this object value there is an array of values. This is also where the vCloud director UUID is stored. I need this UUID to make the REST URL needed to send commands to vCloud Director.
However I am having issues accessing the value. Basically I want iterate over the object array list until the .Key value is =='cloud.uuid' however, the code I'm using returns the error:
This is the code I'm using:
This is what it prints for option: