Adding avail_images() so that --list-images can be used

This commit is contained in:
Nitin Madhok 2015-04-07 10:36:29 -04:00
parent 305ce35a09
commit 26317635c4

View File

@ -602,7 +602,7 @@ def list_networks(kwargs=None, call=None):
def list_nodes_min(kwargs=None, call=None):
'''
Return a list of the VMs that are on the provider, with no details
Return a list of all VMs and templates that are on the provider, with no details
CLI Example:
@ -627,7 +627,7 @@ def list_nodes_min(kwargs=None, call=None):
def list_nodes(kwargs=None, call=None):
'''
Return a list of the VMs that are on the provider, with basic fields
Return a list of all VMs and templates that are on the provider, with basic fields
CLI Example:
@ -660,6 +660,40 @@ def list_nodes(kwargs=None, call=None):
return ret
def avail_images():
'''
Return a list of all the templates present in this VMware environment with basic
details
CLI Example:
.. code-block:: bash
salt-cloud --list-images my-vmware-config
'''
templates = {}
vm_properties = [
"name",
"config.template",
"config.guestFullName",
"config.hardware.numCPU",
"config.hardware.memoryMB"
]
vm_list = _get_mors_with_properties(vim.VirtualMachine, vm_properties)
for vm in vm_list:
if vm["config.template"]:
templates[vm["name"]] = {
'name': vm["name"],
'guest_fullname': vm["config.guestFullName"],
'cpus': vm["config.hardware.numCPU"],
'ram': vm["config.hardware.memoryMB"]
}
return templates
def list_folders(kwargs=None, call=None):
'''
List all the folders for this VMware environment