Update server stack details dumping.
Change-Id: I98ef2bb4550f8184860cee220e8ba368e784805a
This commit is contained in:
parent
1be0c10a97
commit
b06ce3ae6f
@ -19,6 +19,7 @@ import itertools
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import testtools
|
import testtools
|
||||||
from testtools import content
|
from testtools import content
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
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,
|
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
|
content_type = content_type or content.UTF8_TEXT
|
||||||
if get_bytes is None:
|
if get_bytes is None:
|
||||||
if get_text:
|
if get_text:
|
||||||
get_bytes = get_text_to_get_bytes(get_text=get_text)
|
get_bytes = get_text_to_get_bytes(get_text=get_text)
|
||||||
elif get_json:
|
elif get_json:
|
||||||
get_bytes = get_json_to_get_bytes(get_json=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:
|
else:
|
||||||
message = ("Any of get_bytes, get_text or get_json parameters has "
|
message = ("Any of get_bytes, get_text or get_json parameters has "
|
||||||
"been specified")
|
"been specified")
|
||||||
@ -101,6 +104,16 @@ def get_json_to_get_bytes(get_json):
|
|||||||
return get_text
|
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):
|
def get_details_content_id(content_object):
|
||||||
try:
|
try:
|
||||||
return content_object.content_id
|
return content_object.content_id
|
||||||
|
@ -177,14 +177,21 @@ class ServerStackFixture(heat.HeatStackFixture):
|
|||||||
|
|
||||||
def getDetails(self):
|
def getDetails(self):
|
||||||
details = super(ServerStackFixture, self).getDetails()
|
details = super(ServerStackFixture, self).getDetails()
|
||||||
details[self.fixture_name] = tobiko.details_content(
|
details[self.fixture_name + '.server'] = self._get_server_content()
|
||||||
content_id=self.fixture_name, get_json=self._get_server_details)
|
details[self.fixture_name + '.console_output'] = (
|
||||||
|
self._get_console_output_content())
|
||||||
return details
|
return details
|
||||||
|
|
||||||
def _get_server_details(self):
|
def _get_server_content(self):
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
return {'server': self.server_details._info,
|
return tobiko.details_content(
|
||||||
'console_output': self.console_output}
|
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
|
@property
|
||||||
def console_output(self):
|
def console_output(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user