예제 #1
0
    def _check_target_flavor(self, instance, flavor, block_device_info):
        ephemerals = driver.block_device_info_get_ephemerals(block_device_info)
        eph_size = (block_device.get_bdm_ephemeral_disk_size(ephemerals) or
                    instance.flavor.ephemeral_gb)

        new_root_gb = flavor.root_gb
        curr_root_gb = instance.flavor.root_gb
        new_eph_size = flavor.ephemeral_gb

        root_down = new_root_gb < curr_root_gb
        ephemeral_down = new_eph_size < eph_size
        booted_from_volume = self._block_dev_man.is_boot_from_volume(
            block_device_info)

        if root_down and not booted_from_volume:
            raise exception.InstanceFaultRollback(
                exception.CannotResizeDisk(
                    reason=_("Cannot resize the root disk to a smaller size. "
                             "Current size: %(curr_root_gb)s GB. Requested "
                             "size: %(new_root_gb)s GB.") % {
                                 'curr_root_gb': curr_root_gb,
                                 'new_root_gb': new_root_gb}))
        # We allow having a new flavor with no ephemeral storage, in which
        # case we'll just remove all the ephemeral disks.
        elif ephemeral_down and new_eph_size:
            reason = (_("The new flavor ephemeral size (%(flavor_eph)s) is "
                       "smaller than the current total ephemeral disk size: "
                       "%(current_eph)s.") %
                      dict(flavor_eph=flavor.ephemeral_gb,
                           current_eph=eph_size))
            raise exception.InstanceFaultRollback(
                exception.CannotResizeDisk(reason=reason))
예제 #2
0
 def test_get_bdm_ephemeral_disk_size(self):
     size = block_device.get_bdm_ephemeral_disk_size(self.new_mapping)
     self.assertEqual(10, size)
예제 #3
0
 def test_get_bdm_ephemeral_disk_size(self):
     size = block_device.get_bdm_ephemeral_disk_size(self.new_mapping)
     self.assertEqual(10, size)