Update server stack details dumping.

Change-Id: I98ef2bb4550f8184860cee220e8ba368e784805a
This commit is contained in:
Federico Ressi 2019-08-28 14:19:17 +02:00
parent 1be0c10a97
commit b06ce3ae6f
2 changed files with 26 additions and 6 deletions

View File

@ -19,6 +19,7 @@ import itertools
from oslo_log import log
import testtools
from testtools import content
import yaml
LOG = log.getLogger(__name__)
@ -64,13 +65,15 @@ def copy_details_content(content_object, content_id):
def details_content(content_id, content_type=None, get_bytes=None,
get_text=None, get_json=None):
get_text=None, get_json=None, get_yaml=None):
content_type = content_type or content.UTF8_TEXT
if get_bytes is None:
if get_text:
get_bytes = get_text_to_get_bytes(get_text=get_text)
elif get_json:
get_bytes = get_json_to_get_bytes(get_json=get_json)
elif get_yaml:
get_bytes = get_yaml_to_get_bytes(get_yaml=get_yaml)
else:
message = ("Any of get_bytes, get_text or get_json parameters has "
"been specified")
@ -101,6 +104,16 @@ def get_json_to_get_bytes(get_json):
return get_text
def get_yaml_to_get_bytes(get_yaml):
assert callable(get_yaml)
def get_text():
obj = get_yaml()
yield yaml.dump(obj).encode(errors='ignore')
return get_text
def get_details_content_id(content_object):
try:
return content_object.content_id

View File

@ -177,14 +177,21 @@ class ServerStackFixture(heat.HeatStackFixture):
def getDetails(self):
details = super(ServerStackFixture, self).getDetails()
details[self.fixture_name] = tobiko.details_content(
content_id=self.fixture_name, get_json=self._get_server_details)
details[self.fixture_name + '.server'] = self._get_server_content()
details[self.fixture_name + '.console_output'] = (
self._get_console_output_content())
return details
def _get_server_details(self):
def _get_server_content(self):
# pylint: disable=protected-access
return {'server': self.server_details._info,
'console_output': self.console_output}
return tobiko.details_content(
content_id=self.fixture_name,
get_yaml=lambda: self.server_details._info)
def _get_console_output_content(self):
return tobiko.details_content(
content_id=self.fixture_name,
get_text=lambda: self.console_output)
@property
def console_output(self):