Merge lp:~newell-jensen/maas/xml-to-yaml-commissioning-result into lp:~maas-committers/maas/trunk

Proposed by Newell Jensen
Status: Merged
Approved by: Newell Jensen
Approved revision: no longer in the source branch.
Merged at revision: 2965
Proposed branch: lp:~newell-jensen/maas/xml-to-yaml-commissioning-result
Merge into: lp:~maas-committers/maas/trunk
Prerequisite: lp:~newell-jensen/maas/xml-to-yaml-node-view
Diff against target: 112 lines (+55/-3)
3 files modified
src/maasserver/templates/metadataserver/nodecommissionresult.html (+28/-3)
src/metadataserver/models/noderesult.py (+12/-0)
src/metadataserver/models/tests/test_nodecommissionresult.py (+15/-0)
To merge this branch: bzr merge lp:~newell-jensen/maas/xml-to-yaml-commissioning-result
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+234016@code.launchpad.net

Commit message

Edited commissioningresult.html and model to have tabbed xml and yaml (default) output, if required.

Description of the change

This branch is the third and final of three, which together allow the user to view the xml output in the ui as either yaml (default tab) or xml.

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :
Download full text (5.7 KiB)

Attached is a screen shot of the UI for this branch.

On Tue, Sep 9, 2014 at 2:37 PM, Newell Jensen <email address hidden>
wrote:

> Newell Jensen has proposed merging
> lp:~newell-jensen/maas/xml-to-yaml-commissioning-result into lp:maas with
> lp:~newell-jensen/maas/xml-to-yaml-node-view as a prerequisite.
>
> Commit message:
> Edited commissioningresult.html and model to have tabbed xml and yaml
> (default) output, if required.
>
>
> Requested reviews:
> MAAS Maintainers (maas-maintainers)
> Related bugs:
> Bug #1358859 in MAAS: "Commissioning output xml is hard to understand,
> would be nice to have yaml as an output option."
> https://bugs.launchpad.net/maas/+bug/1358859
>
> For more details, see:
>
> https://code.launchpad.net/~newell-jensen/maas/xml-to-yaml-commissioning-result/+merge/234016
>
> This branch is the third and final of three, which together allow the user
> to view the xml output in the ui as either yaml (default tab) or xml.
> --
>
> https://code.launchpad.net/~newell-jensen/maas/xml-to-yaml-commissioning-result/+merge/234016
> You are the owner of
> lp:~newell-jensen/maas/xml-to-yaml-commissioning-result.
>
> === modified file
> 'src/maasserver/templates/metadataserver/nodecommissionresult.html'
> --- src/maasserver/templates/metadataserver/nodecommissionresult.html
> 2014-08-18 17:23:04 +0000
> +++ src/maasserver/templates/metadataserver/nodecommissionresult.html
> 2014-09-09 21:35:02 +0000
> @@ -5,6 +5,14 @@
> {% block page-title %}Commissioning result for node: {{
> object.node.hostname }}{% endblock %}
>
> {% block content %}
> + <script type="text/javascript">
> + <!--
> + YUI().use('history', 'tabview', function (Y) {
> + var tabview = new Y.TabView({srcNode: '#tags'});
> + tabview.render();
> + });
> + // -->
> + </script>
> <ul class="data-list">
> <li class="block size7 first" id="name">
> <h4>Output file</h4>
> @@ -30,9 +38,26 @@
> <li class="block first separate" id="output">
> {% if object.data %}
> <h2>Output</h2>
> -<pre>
> -{{ object.get_data_as_html }}
> -</pre>
> + {% if object.name == "99-maas-02-capture-lldp.out" or object.name
> == "00-maas-01-lshw.out" %}
> + <div class="block first" id="tags">
> + <ul class="list size2 no-background normal">
> + <li><a href="#yaml">DiscYAML</a></li>
> + <li><a href="#xml">Discovery XML</a></li>
> + </ul>
> + <div class="last size12 no-background normal">
> + <div id="yaml">
> + <pre>{{ object.get_data_as_yaml_html }}</pre>
> + </div>
> + <div id="xml">
> + <pre>{{ object.get_data_as_html }}</pre>
> + </div>
> + </div>
> + </div>
> + {% else %}
> + <pre>
> + {{ object.get_data_as_html }}
> + </pre>
> + {% endif %}
> {% endif %}
> </li>
> </ul>
>
> === modified file 'src/metadataserver/models/noderesult.py'
> --- src/metadataserver/models/noderesult.py 2014-08-13 21:49:35 +0000
> +++ src/metadataserver/models/noderesult.py 2014-09-09 21:35:02 +0000
> @@ -27,6 +27,7 @@
> from django.utils.html ...

Read more...

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Hi Newell,

Can you please attach it to the bug report?

Revision history for this message
Newell Jensen (newell-jensen) wrote :

Yes,

Here is the screenshot for this branch:

https://bugs.launchpad.net/maas/+bug/1358859/+attachment/4199993/+files/commissioning-result-tabs.png

On Tue, Sep 9, 2014 at 2:54 PM, Andres Rodriguez <email address hidden>
wrote:

> Hi Newell,
>
> Can you please attach it to the bug report?
> --
>
> https://code.launchpad.net/~newell-jensen/maas/xml-to-yaml-commissioning-result/+merge/234016
> You are the owner of
> lp:~newell-jensen/maas/xml-to-yaml-commissioning-result.
>

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Why is the text for YAML "DiscYAML" and not "Discovery YAML"?

review: Needs Information
Revision history for this message
Newell Jensen (newell-jensen) wrote :

> Why is the text for YAML "DiscYAML" and not "Discovery YAML"?

Because that was a keystroke "delete" typo, fixing now.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good now! Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/templates/metadataserver/nodecommissionresult.html'
2--- src/maasserver/templates/metadataserver/nodecommissionresult.html 2014-08-18 17:23:04 +0000
3+++ src/maasserver/templates/metadataserver/nodecommissionresult.html 2014-09-11 18:20:32 +0000
4@@ -5,6 +5,14 @@
5 {% block page-title %}Commissioning result for node: {{ object.node.hostname }}{% endblock %}
6
7 {% block content %}
8+ <script type="text/javascript">
9+ <!--
10+ YUI().use('tabview', function (Y) {
11+ var tabview = new Y.TabView({srcNode: '#tags'});
12+ tabview.render();
13+ });
14+ // -->
15+ </script>
16 <ul class="data-list">
17 <li class="block size7 first" id="name">
18 <h4>Output file</h4>
19@@ -30,9 +38,26 @@
20 <li class="block first separate" id="output">
21 {% if object.data %}
22 <h2>Output</h2>
23-<pre>
24-{{ object.get_data_as_html }}
25-</pre>
26+ {% if object.name == "99-maas-02-capture-lldp.out" or object.name == "00-maas-01-lshw.out" %}
27+ <div class="block first" id="tags">
28+ <ul class="list size2 no-background normal">
29+ <li><a href="#yaml">YAML</a></li>
30+ <li><a href="#xml">XML</a></li>
31+ </ul>
32+ <div class="last size12 no-background normal">
33+ <div id="yaml">
34+ <pre>{{ object.get_data_as_yaml_html }}</pre>
35+ </div>
36+ <div id="xml">
37+ <pre>{{ object.get_data_as_html }}</pre>
38+ </div>
39+ </div>
40+ </div>
41+ {% else %}
42+ <pre>
43+ {{ object.get_data_as_html }}
44+ </pre>
45+ {% endif %}
46 {% endif %}
47 </li>
48 </ul>
49
50=== modified file 'src/metadataserver/models/noderesult.py'
51--- src/metadataserver/models/noderesult.py 2014-08-13 21:49:35 +0000
52+++ src/metadataserver/models/noderesult.py 2014-09-11 18:20:32 +0000
53@@ -27,6 +27,7 @@
54 from django.utils.html import escape
55 from maasserver.models.cleansave import CleanSave
56 from maasserver.models.timestampedmodel import TimestampedModel
57+from maasserver.utils.converters import XMLToYAML
58 from metadataserver import DefaultMeta
59 from metadataserver.enum import (
60 RESULT_TYPE,
61@@ -121,3 +122,14 @@
62 def get_data_as_html(self):
63 """More-or-less human-readable HTML representation of the output."""
64 return escape(self.data.decode('utf-8', 'replace'))
65+
66+ def get_data_as_yaml_html(self):
67+ """More-or-less human-readable Yaml HTML representation
68+ of the output.
69+ """
70+ from metadataserver.models.commissioningscript import (
71+ LLDP_OUTPUT_NAME,
72+ LSHW_OUTPUT_NAME,
73+ )
74+ if self.name in (LLDP_OUTPUT_NAME, LSHW_OUTPUT_NAME):
75+ return escape(XMLToYAML(self.data).convert())
76
77=== modified file 'src/metadataserver/models/tests/test_nodecommissionresult.py'
78--- src/metadataserver/models/tests/test_nodecommissionresult.py 2014-09-05 11:25:28 +0000
79+++ src/metadataserver/models/tests/test_nodecommissionresult.py 2014-09-11 18:20:32 +0000
80@@ -19,10 +19,15 @@
81 from django.core.exceptions import ValidationError
82 from django.http import Http404
83 from maasserver.testing.factory import factory
84+from maasserver.utils.converters import XMLToYAML
85 from maastesting.djangotestcase import DjangoTestCase
86 from metadataserver.enum import RESULT_TYPE
87 from metadataserver.fields import Bin
88 from metadataserver.models import NodeResult
89+from metadataserver.models.commissioningscript import (
90+ LLDP_OUTPUT_NAME,
91+ LSHW_OUTPUT_NAME,
92+ )
93
94
95 class TestNodeResult(DjangoTestCase):
96@@ -68,6 +73,16 @@
97 data=output.encode('ascii'))
98 self.assertEqual(output, result.get_data_as_html())
99
100+ def test_get_data_as_yaml_html_returns_output(self):
101+ data = "<data>bar</data>".encode("utf-8")
102+ expected = XMLToYAML(data).convert()
103+ lshw_result = factory.make_NodeResult_for_commissioning(
104+ name=LSHW_OUTPUT_NAME, script_result=0, data=data)
105+ lldp_result = factory.make_NodeResult_for_commissioning(
106+ name=LLDP_OUTPUT_NAME, script_result=0, data=data)
107+ self.assertEqual(expected, lshw_result.get_data_as_yaml_html())
108+ self.assertEqual(expected, lldp_result.get_data_as_yaml_html())
109+
110 def test_get_data_as_html_escapes_binary(self):
111 output = b'\x00\xff'
112 result = factory.make_NodeResult_for_commissioning(data=output)