Use common functions in NonSharedStorageFixture

For code refactoring purpose in the placement NonSharedStorageFixture
setup, this patch substitutes common functions in test_base.py for
existing native setup functions for creating providers and setting
inventories.

Change-Id: I312333ed8ecd51b9f3f6b818c33b3ef54703f997
This commit is contained in:
Tetsuro Nakamura 2018-08-02 10:56:57 +09:00
parent d4dbb42593
commit e23237c375
1 changed files with 8 additions and 51 deletions

View File

@ -330,67 +330,24 @@ class NonSharedStorageFixture(APIFixture):
def start_fixture(self):
super(NonSharedStorageFixture, self).start_fixture()
cn1_uuid = uuidutils.generate_uuid()
cn2_uuid = uuidutils.generate_uuid()
aggA_uuid = uuidutils.generate_uuid()
aggB_uuid = uuidutils.generate_uuid()
aggC_uuid = uuidutils.generate_uuid()
os.environ['CN1_UUID'] = cn1_uuid
os.environ['CN2_UUID'] = cn2_uuid
os.environ['AGGA_UUID'] = aggA_uuid
os.environ['AGGB_UUID'] = aggB_uuid
os.environ['AGGC_UUID'] = aggC_uuid
cn1 = rp_obj.ResourceProvider(
self.context,
name='cn1',
uuid=cn1_uuid)
cn1.create()
cn1 = tb.create_provider(self.context, 'cn1')
cn2 = tb.create_provider(self.context, 'cn2')
cn2 = rp_obj.ResourceProvider(
self.context,
name='cn2',
uuid=cn2_uuid)
cn2.create()
os.environ['CN1_UUID'] = cn1.uuid
os.environ['CN2_UUID'] = cn2.uuid
# Populate compute node inventory for VCPU and RAM
# Populate compute node inventory for VCPU, RAM and DISK
for cn in (cn1, cn2):
vcpu_inv = rp_obj.Inventory(
self.context,
resource_provider=cn,
resource_class='VCPU',
total=24,
reserved=0,
max_unit=24,
min_unit=1,
step_size=1,
allocation_ratio=16.0)
vcpu_inv.obj_set_defaults()
ram_inv = rp_obj.Inventory(
self.context,
resource_provider=cn,
resource_class='MEMORY_MB',
total=128 * 1024,
reserved=0,
max_unit=128 * 1024,
min_unit=256,
step_size=256,
allocation_ratio=1.5)
ram_inv.obj_set_defaults()
disk_inv = rp_obj.Inventory(
self.context,
resource_provider=cn,
resource_class='DISK_GB',
total=2000,
reserved=100,
max_unit=2000,
min_unit=10,
step_size=10,
allocation_ratio=1.0)
disk_inv.obj_set_defaults()
inv_list = rp_obj.InventoryList(objects=[vcpu_inv, ram_inv,
disk_inv])
cn.set_inventory(inv_list)
tb.add_inventory(cn, 'VCPU', 24)
tb.add_inventory(cn, 'MEMORY_MB', 128 * 1024)
tb.add_inventory(cn, 'DISK_GB', 2000)
class CORSFixture(APIFixture):