def image_size(self, image_id):
        # TODO(mmutsuzaki) We should iterate over all the image datastores
        # until we find one that has the image.
        image_ds = list(self._ds_manager.image_datastores())[0]
        image_path = os_vmdk_flat_path(image_ds, image_id, IMAGE_FOLDER_NAME)

        return os.path.getsize(image_path)
    def image_size(self, image_id):
        # TODO(mmutsuzaki) We should iterate over all the image datastores
        # until we find one that has the image.
        image_ds = list(self._ds_manager.image_datastores())[0]
        image_path = os_vmdk_flat_path(image_ds, image_id, IMAGE_FOLDER_NAME)

        return os.path.getsize(image_path)
 def _lock_data_disk(self, datastore_id, image_id):
     """
     Lock the data disks associated with the VMs in the provided ref file.
     Return True if locking was successful false otherwise.
     """
     data_disk = os_vmdk_flat_path(datastore_id, image_id)
     try:
         # Its ok to delete the data disk as a subsequent power on will
         # fail if the data disk is not there.
         os.remove(data_disk)
     except OSError:
         # Remove failed so disk is locked.
         self._logger.debug("Disk %s on datastore %s is already locked" % (data_disk, datastore_id))
         return False
     return True
 def _lock_data_disk(self, datastore_id, image_id):
     """
     Lock the data disks associated with the VMs in the provided ref file.
     Return True if locking was successful false otherwise.
     """
     data_disk = os_vmdk_flat_path(datastore_id, image_id)
     try:
         # Its ok to delete the data disk as a subsequent power on will
         # fail if the data disk is not there.
         os.remove(data_disk)
     except OSError:
         # Remove failed so disk is locked.
         self._logger.debug("Disk %s on datastore %s is already locked" %
                            (data_disk, datastore_id))
         return False
     return True
Beispiel #5
0
    def image_size(self, image_id):
        for image_ds in self._ds_manager.image_datastores():
            try:
                image_path = os_vmdk_flat_path(image_ds, image_id,
                                               IMAGE_FOLDER_NAME_PREFIX)
                return os.path.getsize(image_path)
            except os.error:
                self._logger.info("Image %s not found in DataStore %s" %
                                  (image_id, image_ds))

        self._logger.warning("Failed to get image size:",
                             exc_info=True)
        # Failed to access shared image.
        raise NoSuchResourceException(
            ResourceType.IMAGE,
            "Image does not exist.")
    def image_size(self, image_id):
        for image_ds in self._ds_manager.image_datastores():
            try:
                image_path = os_vmdk_flat_path(image_ds, image_id,
                                               IMAGE_FOLDER_NAME_PREFIX)
                return os.path.getsize(image_path)
            except os.error:
                self._logger.info("Image %s not found in DataStore %s" %
                                  (image_id, image_ds))

        self._logger.warning("Failed to get image size:",
                             exc_info=True)
        # Failed to access shared image.
        raise NoSuchResourceException(
            ResourceType.IMAGE,
            "Image does not exist.")