예제 #1
0
    def validate_vpool_extendable(self):
        """
        Perform some validations on the specified StorageRouter to verify whether a vPool can be created or extended on it
        :return: None
        :rtype: NoneType
        """
        if self.partition_info is None:
            raise RuntimeError(
                'Partition information has not been retrieved yet')

        # Validate RDMA capabilities
        if self.sd_installer.rdma_enabled is True and self.storagerouter.rdma_capable is False:
            raise RuntimeError(
                'DTL transport over RDMA is not supported by StorageRouter with IP {0}'
                .format(self.storagerouter.ip))

        # Validate block cache is allowed to be used
        if self.storagerouter.features is None:
            raise RuntimeError('Could not load available features')
        self.block_cache_supported = 'block-cache' in self.storagerouter.features.get(
            'alba', {}).get('features', [])
        if self.block_cache_supported is False and (
                self.sd_installer.block_cache_on_read is True
                or self.sd_installer.block_cache_on_write is True):
            raise RuntimeError('Block cache is not a supported feature')

        # Validate mount point for the vPool to be created does not exist yet
        if StorageRouterController.mountpoint_exists(
                name=self.vp_installer.name,
                storagerouter_guid=self.storagerouter.guid):
            raise RuntimeError(
                'The mount point for vPool {0} already exists'.format(
                    self.vp_installer.name))

        # Validate SCRUB role available on any StorageRouter
        if StorageRouterController.check_scrub_partition_present() is False:
            raise RuntimeError(
                'At least 1 StorageRouter must have a partition with a {0} role'
                .format(DiskPartition.ROLES.SCRUB))

        # Validate required roles present
        for required_role in [
                DiskPartition.ROLES.DB, DiskPartition.ROLES.DTL,
                DiskPartition.ROLES.WRITE
        ]:
            if required_role not in self.partition_info:
                raise RuntimeError(
                    'Missing required partition with a {0} role'.format(
                        required_role))
            elif len(self.partition_info[required_role]) == 0:
                raise RuntimeError(
                    'At least 1 partition with a {0} role is required per StorageRouter'
                    .format(required_role))
            elif required_role in [
                    DiskPartition.ROLES.DB, DiskPartition.ROLES.DTL
            ]:
                if len(self.partition_info[required_role]) > 1:
                    raise RuntimeError(
                        'Only 1 partition with a {0} role is allowed per StorageRouter'
                        .format(required_role))
            else:
                total_available = [
                    part['available']
                    for part in self.partition_info[required_role]
                ]
                if total_available == 0:
                    raise RuntimeError(
                        'Not enough available space for {0}'.format(
                            required_role))

        # Validate mount points are mounted
        for role, part_info in self.partition_info.iteritems():
            if role not in [
                    DiskPartition.ROLES.DB, DiskPartition.ROLES.DTL,
                    DiskPartition.ROLES.WRITE, DiskPartition.ROLES.SCRUB
            ]:
                continue

            for part in part_info:
                mount_point = part['mountpoint']
                if mount_point == DiskPartition.VIRTUAL_STORAGE_LOCATION:
                    continue
                if self.root_client.is_mounted(path=mount_point) is False:
                    raise RuntimeError(
                        'Mount point {0} is not mounted'.format(mount_point))