(self)
return obj_content_list
Traverse the whole vSphere infrastructure and returns the list of raw pyvmomi MOR objects with
        the required pre-fetched attributes.
Traverse the whole vSphere infrastructure and returns the list of raw pyvmomi MOR objects with
        the required pre-fetched attributes.
Traverse the whole vSphere infrastructure and returns the list of raw pyvmomi MOR objects with the required pre - fetched attributes .
def _get_raw_infrastructure(self):
        # type: () -> List[vmodl.query.PropertyCollector.ObjectContent]
        """Traverse the whole vSphere infrastructure and returns the list of raw pyvmomi MOR objects with
        the required pre-fetched attributes."""
        content = self._conn.content  # vim.ServiceInstanceContent reference from the connection

        property_specs = []
        # Specify which attributes we want to retrieve per object
        for resource in ALL_RESOURCES:
            property_spec = vmodl.query.PropertyCollector.PropertySpec()
            property_spec.type = resource
            property_spec.pathSet = ["name", "parent"]
            if self.config.should_collect_attributes:
                property_spec.pathSet.append("customValue")
            if resource == vim.VirtualMachine:
                property_spec.pathSet.append("runtime.powerState")
                property_spec.pathSet.append("runtime.host")
                property_spec.pathSet.append("guest.hostName")
            property_specs.append(property_spec)

        # Specify the attribute of the root object to traverse to obtain all the attributes
        traversal_spec = vmodl.query.PropertyCollector.TraversalSpec()
        traversal_spec.path = "view"
        traversal_spec.skip = False
        traversal_spec.type = vim.view.ContainerView

        retr_opts = vmodl.query.PropertyCollector.RetrieveOptions()
        # To limit the number of objects retrieved per call.
        # If batch_collector_size is 0, collect maximum number of objects.
        retr_opts.maxObjects = self.config.batch_collector_size

        # Specify the root object from where we collect the rest of the objects
        obj_spec = vmodl.query.PropertyCollector.ObjectSpec()
        obj_spec.skip = True
        obj_spec.selectSet = [traversal_spec]

        # Create our filter spec from the above specs
        filter_spec = vmodl.query.PropertyCollector.FilterSpec()
        filter_spec.propSet = property_specs

        view_ref = content.viewManager.CreateContainerView(content.rootFolder, ALL_RESOURCES, True)
        try:
            obj_spec.obj = view_ref
            filter_spec.objectSet = [obj_spec]

            # Collect the objects and their properties
            res = content.propertyCollector.RetrievePropertiesEx([filter_spec], retr_opts)
            obj_content_list = res.objects
            # Results can be paginated
            while res.token is not None:
                res = content.propertyCollector.ContinueRetrievePropertiesEx(res.token)
                obj_content_list.extend(res.objects)
        finally:
            view_ref.Destroy()

        return obj_content_list
def _get_raw_infrastructure ( self ) : # type: () -> List[vmodl.query.PropertyCollector.ObjectContent] content = self . _conn . content # vim.ServiceInstanceContent reference from the connection property_specs = [ ] # Specify which attributes we want to retrieve per object for resource in ALL_RESOURCES : property_spec = vmodl . query . PropertyCollector . PropertySpec ( ) property_spec . type = resource property_spec . pathSet = [ "name" , "parent" ] if self . config . should_collect_attributes : property_spec . pathSet . append ( "customValue" ) if resource == vim . VirtualMachine : property_spec . pathSet . append ( "runtime.powerState" ) property_spec . pathSet . append ( "runtime.host" ) property_spec . pathSet . append ( "guest.hostName" ) property_specs . append ( property_spec ) # Specify the attribute of the root object to traverse to obtain all the attributes traversal_spec = vmodl . query . PropertyCollector . TraversalSpec ( ) traversal_spec . path = "view" traversal_spec . skip = False traversal_spec . type = vim . view . ContainerView retr_opts = vmodl . query . PropertyCollector . RetrieveOptions ( ) # To limit the number of objects retrieved per call. # If batch_collector_size is 0, collect maximum number of objects. retr_opts . maxObjects = self . config . batch_collector_size # Specify the root object from where we collect the rest of the objects obj_spec = vmodl . query . PropertyCollector . ObjectSpec ( ) obj_spec . skip = True obj_spec . selectSet = [ traversal_spec ] # Create our filter spec from the above specs filter_spec = vmodl . query . PropertyCollector . FilterSpec ( ) filter_spec . propSet = property_specs view_ref = content . viewManager . CreateContainerView ( content . rootFolder , ALL_RESOURCES , True ) try : obj_spec . obj = view_ref filter_spec . objectSet = [ obj_spec ] # Collect the objects and their properties res = content . propertyCollector . RetrievePropertiesEx ( [ filter_spec ] , retr_opts ) obj_content_list = res . objects # Results can be paginated while res . token is not None : res = content . propertyCollector . ContinueRetrievePropertiesEx ( res . token ) obj_content_list . extend ( res . objects ) finally : view_ref . Destroy ( ) return obj_content_list