Beispiel #1
0
    def check_growth(self, **growth):
        if int(self.level) in (0, 10):
            raise storage2.StorageError("Raid%s doesn't support growth" %
                                        self.level)

        disk_growth = growth.get('disks')
        change_disks = False

        if disk_growth:
            for disk_cfg_or_obj in self.disks:
                disk = storage2.volume(disk_cfg_or_obj)
                try:
                    disk.check_growth(**disk_growth)
                    change_disks = True
                except storage2.NoOpError:
                    pass

        new_len = growth.get('disks_count')
        current_len = len(self.disks)
        change_size = new_len and int(new_len) != current_len

        if not change_size and not change_disks:
            raise storage2.NoOpError('Configurations are equal. Nothing to do')

        if change_size and int(new_len) < current_len:
            raise storage2.StorageError('Disk count can only be increased.')

        if change_size and int(self.level) in (0, 10):
            raise storage2.StorageError("Can't add disks to raid level %s" %
                                        self.level)
Beispiel #2
0
    def check_growth(self, **growth):
        size = growth.get('size')
        target_size = int(size or self.size)

        ebs_type = growth.get('volume_type')
        target_type = ebs_type or self.volume_type

        iops = growth.get('iops')
        target_iops = iops or self.iops

        change_type = ebs_type and ebs_type != self.volume_type
        change_size = size and size != self.size
        change_iops = iops and iops != self.iops

        if not (change_size or change_type or change_iops):
            raise storage2.NoOpError('New ebs volume configuration is equal'
                                     ' to present. Nothing to do.')

        if target_iops and (target_type != 'io1'):
            raise storage2.StorageError('EBS iops can only be used with '
                                        'io1 volume type')

        if 'io1' == target_type and not target_iops:
            raise storage2.StorageError('Iops parameter must be specified '
                                        'for io1 volumes')

        if size and int(size) < self.size:
            raise storage2.StorageError('New size is smaller than old.')