Return images from selected folders only in vSphere SOAP driver
@@ -232,12 +232,20 @@ class VSphereNodeDriver(NodeDriver):
"""
return []
- def list_images(self, location=None):
+ def list_images(self, location=None, folder_ids=[]):
"""
- Lists VM templates as images
+ Lists VM templates as images.
+ If folder is given then it will list images contained
+ in that folder only.
"""
images = []
+ if folder_ids:
+ vms = []
+ for folder_id in folder_ids:
+ folder_object = self._get_item_by_moid('Folder', folder_id)
+ vms.extend(folder_object.childEntity)
+ else:
content = self.connection.RetrieveContent()
vms = content.viewManager.CreateContainerView(
content.rootFolder,
@@ -1644,7 +1652,7 @@ class VSphere_6_7_NodeDriver(NodeDriver):
raise
return result
- def list_images(self):
+ def list_images(self, **kwargs):
libraries = self.ex_list_content_libraries()
item_ids = []
if libraries:
