Merge "Fix Deployable get_by_host"
This commit is contained in:
commit
07a273e70d
@ -102,6 +102,14 @@ placement_opts = [
|
||||
cfg.IntOpt('timeout',
|
||||
default=None,
|
||||
help=_('Timeout for inactive connections (in seconds)')),
|
||||
cfg.BoolOpt('split_loggers',
|
||||
default=False,
|
||||
help=_('Split the logging of requests across multiple loggers '
|
||||
'instead of just one. Defaults to False.')),
|
||||
cfg.IntOpt('collect_timing',
|
||||
default=False,
|
||||
help=_('Whether or not to collect per-method timing information'
|
||||
' for each API call. (optional,defaults to False')),
|
||||
]
|
||||
|
||||
|
||||
|
@ -97,11 +97,13 @@ class Deployable(base.CyborgObject, object_base.VersionedObjectDictCompat):
|
||||
def get_by_host(cls, context, host):
|
||||
"""Get a Deployable by host."""
|
||||
db_deps = cls.dbapi.deployable_get_by_host(context, host)
|
||||
query = {"deployable_id": db_deps.id}
|
||||
obj_dpl_list = cls._from_db_object_list(db_deps, context)
|
||||
for obj_dpl in obj_dpl_list:
|
||||
query = {"deployable_id": obj_dpl.id}
|
||||
attr_get_list = Attribute.get_by_filter(context,
|
||||
query)
|
||||
db_deps.attributes_list = attr_get_list
|
||||
return cls._from_db_object_list(db_deps, context)
|
||||
obj_dpl.attributes_list = attr_get_list
|
||||
return obj_dpl_list
|
||||
|
||||
@classmethod
|
||||
def list(cls, context):
|
||||
|
@ -278,6 +278,23 @@ class _TestDeployableObject(DbTestCase):
|
||||
self.assertEqual(len(dpl_get_list), 1)
|
||||
self.assertEqual(dpl_get_list[0].uuid, dpl2.uuid)
|
||||
|
||||
def test_get_by_host(self):
|
||||
dep1 = self.fake_deployable
|
||||
dep2 = self.fake_deployable2
|
||||
fake_hostname = 'host_name'
|
||||
dep_obj1 = objects.Deployable(context=self.context,
|
||||
**dep1)
|
||||
dep_obj2 = objects.Deployable(context=self.context,
|
||||
**dep2)
|
||||
dep_obj1.create(self.context)
|
||||
dep_obj2.create(self.context)
|
||||
|
||||
dep_obj1.save(self.context)
|
||||
dep_obj2.save(self.context)
|
||||
dep_objs = objects.Deployable.get_by_host(self.context, fake_hostname)
|
||||
self.assertEqual(dep_objs[0].host, fake_hostname)
|
||||
self.assertEqual(dep_objs[1].host, fake_hostname)
|
||||
|
||||
|
||||
class TestDeployableObject(test_objects._LocalTest,
|
||||
_TestDeployableObject):
|
||||
|
@ -42,6 +42,8 @@ class PlacementAPIClientTestCase(base.DietTestCase):
|
||||
load_auth_mock.assert_called_once_with(cfg.CONF, 'placement')
|
||||
ks_sess_mock.assert_called_once_with(auth=load_auth_mock.return_value,
|
||||
cert=None,
|
||||
collect_timing=False,
|
||||
split_loggers=False,
|
||||
timeout=None,
|
||||
verify=True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user