예제 #1
0
    def _retrieve_properties(self,
                             managed_object_type,
                             props=[],
                             collector=None,
                             root=None,
                             recurse=True):
        if not collector:
            collector = self.service_content.propertyCollector
        if not root:
            root = self.service_content.rootFolder

        property_spec = vim.PropertySpec(type=managed_object_type,
                                         pathSet=props)
        selection_specs = list(self._build_full_traversal()) if recurse else []
        object_spec = vim.ObjectSpec(obj=root, selectSet=selection_specs)

        spec = vim.PropertyFilterSpec(propSet=[property_spec],
                                      objectSet=[object_spec])
        options = vim.RetrieveOptions()
        objects = []
        retrieve_result = collector.RetrievePropertiesEx(specSet=[spec],
                                                         options=options)
        while retrieve_result is not None and retrieve_result.token:
            objects.extend(retrieve_result.objects)
            retrieve_result = collector.ContinueRetrievePropertiesEx(
                retrieve_result.token)
        if retrieve_result is not None:
            objects.extend(retrieve_result.objects)
        return objects
예제 #2
0
def CollectMultiple(content, objects, parameters, handleNotFound=True):
    if len(objects) == 0:
        return {}
    result = None
    pc = content.propertyCollector
    propSet = [vim.PropertySpec(type=objects[0].__class__, pathSet=parameters)]

    while result == None and len(objects) > 0:
        try:
            objectSet = []
            for obj in objects:
                objectSet.append(vim.ObjectSpec(obj=obj))
            specSet = [
                vim.PropertyFilterSpec(objectSet=objectSet, propSet=propSet)
            ]
            result = pc.RetrieveProperties(specSet=specSet)
        except vim.ManagedObjectNotFound as ex:
            objects.remove(ex.obj)
            result = None

    out = {}
    for x in result:
        out[x.obj] = {}
        for y in x.propSet:
            out[x.obj][y.name] = y.val
    return out
예제 #3
0
 def _get_object_set(self):
     return [vim.ObjectSpec(obj=self._get_container_view(), selectSet=self._get_select_set())]
예제 #4
0
 def _get_object_set(self):
     return [vim.ObjectSpec(obj=task) for task in self.tasks]