Exemple #1
0
 def validate_zpool(self, zpool):
     """Return NodeStorage object or raise ValidationError"""
     try:
         return self.vm.node.get_node_storage(self.vm.dc, zpool)
     except NodeStorage.DoesNotExist:
         msg = _('Storage with zpool=%(zpool)s does not exist on target node.')
         raise APIValidationError(msg % {'zpool': zpool})
Exemple #2
0
    def validate_storage_resources(self):
        """Validate node storage resources"""
        for zpool, size in self.vm.get_disks().items():
            ns = self._nss[zpool]

            if not ns.check_free_space(size):
                raise APIValidationError(_('Not enough free disk space on target storage with zpool=%s.') % zpool)
Exemple #3
0
 def change_zpool(cls, disk, zpool):
     """Switch zpool in zfs_filesystem attribute"""
     try:
         dataset = disk['zfs_filesystem']
     except KeyError:
         raise APIValidationError('Invalid disk configuration.')
     else:
         return cls._change_zpool(dataset, zpool)
Exemple #4
0
    def validate_node_resources(self, ignore_cpu_ram=False, ignore_disk=False):
        """Validate dc_node resources"""
        vm = self.vm
        node = vm.node
        dc_node = node.get_dc_node(vm.dc)
        vm_resources = vm.get_cpu_ram_disk(zpool=node.zpool, ram_overhead=True, ignore_cpu_ram=ignore_cpu_ram,
                                           ignore_disk=ignore_disk)

        if not dc_node.check_free_resources(*vm_resources):
            raise APIValidationError(_('Not enough free resources on target node.'))
Exemple #5
0
    def validate_node_resources(self, ignore_cpu_ram=False):
        """Validate dc_node resources"""
        vm = self.vm
        node = vm.node
        dc_node = node.get_dc_node(vm.dc)

        if ignore_cpu_ram:
            vm_resources = (0, 0, sum(vm.get_disks(zpool=node.zpool).values()))
        else:
            vm_resources = vm.get_cpu_ram_disk(zpool=node.zpool,
                                               ram_overhead=True)

        if not dc_node.check_free_resources(*vm_resources):
            raise APIValidationError(
                _('Not enough free resources on target node.'))
Exemple #6
0
 def get_zpool(disk):
     """Return zpool part from zfs_filesystem attribute"""
     try:
         return disk['zfs_filesystem'].split('/')[0]
     except (KeyError, IndexError):
         raise APIValidationError('Invalid disk configuration.')