'Sets up a resource provider that shares DISK_GB inventory via an
aggregate, a couple resource providers representing "local disk"
compute nodes and ensures the _get_providers_sharing_capacity()
function finds that provider and not providers of "local disk".'

def test_shared_provider_capacity(self):

    cn1_uuid = uuidsentinel.cn1
    cn1 = objects.ResourceProvider(self.ctx, name='cn1', uuid=cn1_uuid)
    cn1.create()
    cn2_uuid = uuidsentinel.cn2
    cn2 = objects.ResourceProvider(self.ctx, name='cn2', uuid=cn2_uuid)
    cn2.create()
    for cn in (cn1, cn2):
        vcpu = objects.Inventory(resource_provider=cn, resource_class=fields.ResourceClass.VCPU, total=24, reserved=0, min_unit=1, max_unit=24, step_size=1, allocation_ratio=16.0)
        memory_mb = objects.Inventory(resource_provider=cn, resource_class=fields.ResourceClass.MEMORY_MB, total=32768, reserved=0, min_unit=64, max_unit=32768, step_size=64, allocation_ratio=1.5)
        inv_list = objects.InventoryList(objects=[vcpu, memory_mb])
        cn.set_inventory(inv_list)
    ss_uuid = uuidsentinel.ss
    ss = objects.ResourceProvider(self.ctx, name='shared    storage', uuid=ss_uuid)
    ss.create()
    disk_gb = objects.Inventory(resource_provider=ss, resource_class=fields.ResourceClass.DISK_GB, total=2000, reserved=0, min_unit=10, max_unit=100, step_size=10, allocation_ratio=1.0)
    disk_gb.obj_set_defaults()
    inv_list = objects.InventoryList(objects=[disk_gb])
    ss.set_inventory(inv_list)
    t = objects.Trait.get_by_name(self.ctx, 'MISC_SHARES_VIA_AGGREGATE')
    ss.set_traits(objects.TraitList(objects=[t]))
    got_ids = rp_obj._get_providers_with_shared_capacity(self.ctx, fields.ResourceClass.STANDARD.index(fields.ResourceClass.DISK_GB), 100)
    self.assertEqual([ss.id], got_ids)
