Exemplo n.º 1
0
    def _get_pool_usage(self, pool, host, timestamp):
        total = pool["total_capacity_gb"]
        free = pool["free_capacity_gb"]

        unknowns = ["unknown", "infinite", None]
        if (total in unknowns) or (free in unknowns):
            return {}

        allocated = pool["allocated_capacity_gb"]
        provisioned = pool["provisioned_capacity_gb"]
        reserved = pool["reserved_percentage"]
        ratio = pool["max_over_subscription_ratio"]
        support = pool["thin_provisioning_support"]

        virtual_free = utils.calculate_virtual_free_capacity(
            total,
            free,
            provisioned,
            support,
            ratio,
            reserved,
            support)

        pool_usage = dict(
            type='pool',
            name_to_id='#'.join([host, pool['pool_name']]),
            total=float(total),
            free=float(free),
            allocated=float(allocated),
            provisioned=float(provisioned),
            virtual_free=float(virtual_free),
            reported_at=timestamp)

        return pool_usage
Exemplo n.º 2
0
    def _weigh_object(self, host_state, weight_properties):
        """Higher weights win.  We want spreading to be the default."""
        free_space = host_state.free_capacity_gb
        total_space = host_state.total_capacity_gb
        if (free_space == 'infinite' or free_space == 'unknown' or
                total_space == 'infinite' or total_space == 'unknown'):
            # (zhiteng) 'infinite' and 'unknown' are treated the same
            # here, for sorting purpose.

            # As a partial fix for bug #1350638, 'infinite' and 'unknown' are
            # given the lowest weight to discourage driver from report such
            # capacity anymore.
            free = -1 if CONF.capacity_weight_multiplier > 0 else float('inf')
        else:
            # NOTE(xyang): If 'provisioning:type' is 'thick' in extra_specs,
            # we will not use max_over_subscription_ratio and
            # provisioned_capacity_gb to determine whether a volume can be
            # provisioned. Instead free capacity will be used to evaluate.
            thin = True
            vol_type = weight_properties.get('volume_type', {}) or {}
            provision_type = vol_type.get('extra_specs', {}).get(
                'provisioning:type')
            if provision_type == 'thick':
                thin = False

            free = utils.calculate_virtual_free_capacity(
                total_space,
                free_space,
                host_state.provisioned_capacity_gb,
                host_state.thin_provisioning_support,
                host_state.max_over_subscription_ratio,
                host_state.reserved_percentage,
                thin)

        return free
Exemplo n.º 3
0
    def _get_pool_usage(self, pool, host, timestamp):
        total = pool["total_capacity_gb"]
        free = pool["free_capacity_gb"]

        unknowns = ["unknown", "infinite", None]
        if (total in unknowns) or (free in unknowns):
            return {}

        allocated = pool["allocated_capacity_gb"]
        provisioned = pool["provisioned_capacity_gb"]
        reserved = pool["reserved_percentage"]
        ratio = pool["max_over_subscription_ratio"]
        support = pool["thin_provisioning_support"]

        virtual_free = utils.calculate_virtual_free_capacity(
            total,
            free,
            provisioned,
            support,
            ratio,
            reserved,
            support)

        pool_usage = dict(
            type='pool',
            name_to_id='#'.join([host, pool['pool_name']]),
            total=float(total),
            free=float(free),
            allocated=float(allocated),
            provisioned=float(provisioned),
            virtual_free=float(virtual_free),
            reported_at=timestamp)

        return pool_usage
Exemplo n.º 4
0
    def _weigh_object(self, host_state, weight_properties):
        """Higher weights win.  We want spreading to be the default."""
        free_space = host_state.free_capacity_gb
        total_space = host_state.total_capacity_gb
        if (free_space == 'infinite' or free_space == 'unknown'
                or total_space == 'infinite' or total_space == 'unknown'):
            # (zhiteng) 'infinite' and 'unknown' are treated the same
            # here, for sorting purpose.

            # As a partial fix for bug #1350638, 'infinite' and 'unknown' are
            # given the lowest weight to discourage driver from report such
            # capacity anymore.
            free = -1 if CONF.capacity_weight_multiplier > 0 else float('inf')
        else:
            free = utils.calculate_virtual_free_capacity(
                total_space, free_space, host_state.provisioned_capacity_gb,
                host_state.thin_provisioning_support,
                host_state.max_over_subscription_ratio,
                host_state.reserved_percentage)

        return free
Exemplo n.º 5
0
    def _weigh_object(self, host_state, weight_properties):
        """Higher weights win.  We want spreading to be the default."""
        free_space = host_state.free_capacity_gb
        total_space = host_state.total_capacity_gb
        if (free_space == 'infinite' or free_space == 'unknown' or
                total_space == 'infinite' or total_space == 'unknown'):
            # (zhiteng) 'infinite' and 'unknown' are treated the same
            # here, for sorting purpose.

            # As a partial fix for bug #1350638, 'infinite' and 'unknown' are
            # given the lowest weight to discourage driver from report such
            # capacity anymore.
            free = -1 if CONF.capacity_weight_multiplier > 0 else float('inf')
        else:
            free = utils.calculate_virtual_free_capacity(
                total_space,
                free_space,
                host_state.provisioned_capacity_gb,
                host_state.thin_provisioning_support,
                host_state.max_over_subscription_ratio,
                host_state.reserved_percentage)

        return free