Remove nova.db call from baremetal PXE driver
Baremetal PXE driver was fetching instance_type from the nova db. Now that no-db-compute is done, that's not possible. Also, there's a more efficient way -- just call extract_instance_type(instance)! Baremetal unit tests should check for instance_types with swap = 0 and with swap > 0. This required changing test/utils to include a real copy of instance_types in instance['system_metadata']. Change-Id: I2a91e5c026782946f6b01e4189ec85d30ba87583
This commit is contained in:
@@ -69,7 +69,7 @@ class BareMetalPXETestCase(bm_db_base.BMDBTestCase):
|
|||||||
self.node_info = bm_db_utils.new_bm_node(
|
self.node_info = bm_db_utils.new_bm_node(
|
||||||
id=123,
|
id=123,
|
||||||
service_host='test_host',
|
service_host='test_host',
|
||||||
cpus=2,
|
cpus=4,
|
||||||
memory_mb=2048,
|
memory_mb=2048,
|
||||||
prov_mac_address='11:11:11:11:11:11',
|
prov_mac_address='11:11:11:11:11:11',
|
||||||
)
|
)
|
||||||
@@ -221,20 +221,21 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase):
|
|||||||
pxe.get_deploy_ari_id(self.instance), 'bbbb')
|
pxe.get_deploy_ari_id(self.instance), 'bbbb')
|
||||||
|
|
||||||
def test_get_partition_sizes(self):
|
def test_get_partition_sizes(self):
|
||||||
# m1.tiny: 10GB root, 0GB swap
|
# default "kinda.big" instance
|
||||||
self.instance['instance_type_id'] = 1
|
|
||||||
sizes = pxe.get_partition_sizes(self.instance)
|
|
||||||
self.assertEqual(sizes[0], 10240)
|
|
||||||
self.assertEqual(sizes[1], 1)
|
|
||||||
|
|
||||||
# kinda.big: 40GB root, 1GB swap
|
|
||||||
ref = utils.get_test_instance_type()
|
|
||||||
self.instance['instance_type_id'] = ref['id']
|
|
||||||
self.instance['root_gb'] = ref['root_gb']
|
|
||||||
sizes = pxe.get_partition_sizes(self.instance)
|
sizes = pxe.get_partition_sizes(self.instance)
|
||||||
self.assertEqual(sizes[0], 40960)
|
self.assertEqual(sizes[0], 40960)
|
||||||
self.assertEqual(sizes[1], 1024)
|
self.assertEqual(sizes[1], 1024)
|
||||||
|
|
||||||
|
def test_swap_not_zero(self):
|
||||||
|
# override swap to 0
|
||||||
|
instance_type = utils.get_test_instance_type(self.context)
|
||||||
|
instance_type['swap'] = 0
|
||||||
|
self.instance = utils.get_test_instance(self.context, instance_type)
|
||||||
|
|
||||||
|
sizes = pxe.get_partition_sizes(self.instance)
|
||||||
|
self.assertEqual(sizes[0], 40960)
|
||||||
|
self.assertEqual(sizes[1], 1)
|
||||||
|
|
||||||
def test_get_tftp_image_info(self):
|
def test_get_tftp_image_info(self):
|
||||||
# Raises an exception when options are neither specified
|
# Raises an exception when options are neither specified
|
||||||
# on the instance nor in configuration file
|
# on the instance nor in configuration file
|
||||||
|
|||||||
Reference in New Issue
Block a user