Merge "Fix warning in logs that '' is not a valid UUID."
This commit is contained in:
commit
deed9c822e
cyborg
@ -93,7 +93,6 @@ class ExtARQ(base.CyborgObject, object_base.VersionedObjectDictCompat,
|
||||
@classmethod
|
||||
def get(cls, context, uuid, lock=False):
|
||||
"""Find a DB ExtARQ and return an Obj ExtARQ."""
|
||||
# TODO() Fix warnings that '' is not an UUID
|
||||
db_extarq = cls.dbapi.extarq_get(context, uuid)
|
||||
obj_arq = objects.ARQ(context)
|
||||
obj_extarq = cls(context)
|
||||
@ -242,8 +241,14 @@ class ExtARQ(base.CyborgObject, object_base.VersionedObjectDictCompat,
|
||||
resource='attach handle',
|
||||
msg='')
|
||||
|
||||
# TODO() Get the deployable_uuid
|
||||
db_extarq['deployable_uuid'] = ''
|
||||
if db_extarq['deployable_id']:
|
||||
dep = objects.Deployable.get_by_id(db_extarq['deployable_id'])
|
||||
db_extarq['deployable_uuid'] = dep.uuid
|
||||
else:
|
||||
LOG.debug('Setting deployable UUID to zeroes for db_extarq %s',
|
||||
db_extarq['uuid'])
|
||||
db_extarq['deployable_uuid'] = (
|
||||
'00000000-0000-0000-0000-000000000000')
|
||||
|
||||
# Get the device profile group
|
||||
obj_devprof = DeviceProfile.get_by_name(context, devprof['name'])
|
||||
|
@ -23,6 +23,7 @@ from cyborg.common import exception
|
||||
from cyborg import objects
|
||||
from cyborg.tests.unit.db import base
|
||||
from cyborg.tests.unit import fake_deployable
|
||||
from cyborg.tests.unit import fake_device_profile
|
||||
from cyborg.tests.unit import fake_extarq
|
||||
|
||||
|
||||
@ -371,3 +372,35 @@ class TestExtARQObject(base.DbTestCase):
|
||||
|
||||
self.assertRaises(exception.ARQBadState,
|
||||
objects.ExtARQ.get_arq_bind_statuses, arq_list)
|
||||
|
||||
@mock.patch('cyborg.objects.device_profile.DeviceProfile.get_by_name')
|
||||
@mock.patch('cyborg.objects.deployable.Deployable.get_by_id')
|
||||
@mock.patch('cyborg.db.sqlalchemy.api.Connection.'
|
||||
'attach_handle_get_by_id')
|
||||
@mock.patch('cyborg.db.sqlalchemy.api.Connection.'
|
||||
'device_profile_get_by_id')
|
||||
def test_fill_obj_extarq_fields(self, mock_get_devprof, mock_get_ah,
|
||||
mock_get_obj_dep, mock_obj_devprof):
|
||||
in_db_extarq = self.fake_db_extarqs[0]
|
||||
# Since state is not 'Bound', attach_handle_get_by_id is not called.
|
||||
in_db_extarq['state'] = 'Initial'
|
||||
in_db_extarq['deployable_id'] = None
|
||||
db_devprof = fake_device_profile.get_db_devprofs()[0]
|
||||
obj_devprof = fake_device_profile.get_obj_devprofs()[0]
|
||||
|
||||
mock_get_devprof.return_value = db_devprof
|
||||
mock_obj_devprof.return_value = obj_devprof
|
||||
|
||||
out_db_extarq = objects.ExtARQ._fill_obj_extarq_fields(
|
||||
self.context, in_db_extarq)
|
||||
|
||||
self.assertEqual(out_db_extarq['device_profile_name'],
|
||||
db_devprof['name'])
|
||||
self.assertEqual(out_db_extarq['attach_handle_type'], '')
|
||||
self.assertEqual(out_db_extarq['attach_handle_info'], '')
|
||||
self.assertEqual(
|
||||
out_db_extarq['deployable_uuid'],
|
||||
'00000000-0000-0000-0000-000000000000')
|
||||
devprof_group_id = out_db_extarq['device_profile_group_id']
|
||||
self.assertEqual(out_db_extarq['device_profile_group'],
|
||||
obj_devprof['groups'][devprof_group_id])
|
||||
|
Loading…
x
Reference in New Issue
Block a user