Fix Deployable get_by_host
1.Fix get_by_host. 2.Add missing configs of placement. Change-Id: I4452371d02fface1adbc322cb75cc39e32062303
This commit is contained in:
parent
2f6f71849e
commit
0ac1227f69
@ -102,6 +102,14 @@ placement_opts = [
|
|||||||
cfg.IntOpt('timeout',
|
cfg.IntOpt('timeout',
|
||||||
default=None,
|
default=None,
|
||||||
help=_('Timeout for inactive connections (in seconds)')),
|
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):
|
def get_by_host(cls, context, host):
|
||||||
"""Get a Deployable by host."""
|
"""Get a Deployable by host."""
|
||||||
db_deps = cls.dbapi.deployable_get_by_host(context, 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)
|
||||||
attr_get_list = Attribute.get_by_filter(context,
|
for obj_dpl in obj_dpl_list:
|
||||||
query)
|
query = {"deployable_id": obj_dpl.id}
|
||||||
db_deps.attributes_list = attr_get_list
|
attr_get_list = Attribute.get_by_filter(context,
|
||||||
return cls._from_db_object_list(db_deps, context)
|
query)
|
||||||
|
obj_dpl.attributes_list = attr_get_list
|
||||||
|
return obj_dpl_list
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def list(cls, context):
|
def list(cls, context):
|
||||||
|
@ -278,6 +278,23 @@ class _TestDeployableObject(DbTestCase):
|
|||||||
self.assertEqual(len(dpl_get_list), 1)
|
self.assertEqual(len(dpl_get_list), 1)
|
||||||
self.assertEqual(dpl_get_list[0].uuid, dpl2.uuid)
|
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,
|
class TestDeployableObject(test_objects._LocalTest,
|
||||||
_TestDeployableObject):
|
_TestDeployableObject):
|
||||||
|
@ -42,6 +42,8 @@ class PlacementAPIClientTestCase(base.DietTestCase):
|
|||||||
load_auth_mock.assert_called_once_with(cfg.CONF, 'placement')
|
load_auth_mock.assert_called_once_with(cfg.CONF, 'placement')
|
||||||
ks_sess_mock.assert_called_once_with(auth=load_auth_mock.return_value,
|
ks_sess_mock.assert_called_once_with(auth=load_auth_mock.return_value,
|
||||||
cert=None,
|
cert=None,
|
||||||
|
collect_timing=False,
|
||||||
|
split_loggers=False,
|
||||||
timeout=None,
|
timeout=None,
|
||||||
verify=True)
|
verify=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user