summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tuskar_ui/api/node.py3
-rw-r--r--tuskar_ui/exceptions.py5
-rw-r--r--tuskar_ui/infrastructure/nodes/tests.py28
-rw-r--r--tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js25
-rw-r--r--tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html27
-rw-r--r--tuskar_ui/infrastructure/templates/infrastructure/_scripts.html1
-rw-r--r--tuskar_ui/test/api_tests/node_tests.py8
7 files changed, 69 insertions, 28 deletions
diff --git a/tuskar_ui/api/node.py b/tuskar_ui/api/node.py
index 5864c3f1..31e96775 100644
--- a/tuskar_ui/api/node.py
+++ b/tuskar_ui/api/node.py
@@ -229,7 +229,8 @@ class Node(base.APIResourceWrapper):
server = servers_dict.get(n.instance_uuid, None)
nodes_with_instance.append(cls(n, instance=server,
request=request))
- return nodes_with_instance
+ return [cls.get(request, node.uuid)
+ for node in nodes_with_instance]
return [cls.get(request, node.uuid) for node in nodes]
@classmethod
diff --git a/tuskar_ui/exceptions.py b/tuskar_ui/exceptions.py
index c733264c..0fd36788 100644
--- a/tuskar_ui/exceptions.py
+++ b/tuskar_ui/exceptions.py
@@ -11,9 +11,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from ironicclient import exceptions as ironic_exceptions
from openstack_dashboard import exceptions
from tuskarclient.openstack.common.apiclient import exceptions as tuskarclient
NOT_FOUND = exceptions.NOT_FOUND
-RECOVERABLE = exceptions.RECOVERABLE + (tuskarclient.ClientException,)
+RECOVERABLE = exceptions.RECOVERABLE + (
+ ironic_exceptions.Conflict, tuskarclient.ClientException,
+)
UNAUTHORIZED = exceptions.UNAUTHORIZED
diff --git a/tuskar_ui/infrastructure/nodes/tests.py b/tuskar_ui/infrastructure/nodes/tests.py
index adc14bc4..3be52c23 100644
--- a/tuskar_ui/infrastructure/nodes/tests.py
+++ b/tuskar_ui/infrastructure/nodes/tests.py
@@ -18,6 +18,7 @@ import json
from ceilometerclient.v2 import client as ceilometer_client
from django.core import urlresolvers
from horizon import exceptions as horizon_exceptions
+from ironicclient import exceptions as ironic_exceptions
import mock
from novaclient import exceptions as nova_exceptions
from openstack_dashboard.test.test_data import utils
@@ -54,6 +55,9 @@ class NodesTests(test.BaseAdminViewTests):
def _raise_horizon_exception_not_found(self, request, *args, **kwargs):
raise horizon_exceptions.NotFound
+ def _raise_ironic_exception(self, request, *args, **kwargs):
+ raise ironic_exceptions.Conflict
+
def stub_ceilometerclient(self):
if not hasattr(self, "ceilometerclient"):
self.mox.StubOutWithMock(ceilometer_client, 'Client')
@@ -556,3 +560,27 @@ class NodesTests(test.BaseAdminViewTests):
deployment_ramdisk='8',
),
])
+
+ def test_delete_deployed_on_servers(self):
+ all_nodes = [api.node.Node(node)
+ for node in self.ironicclient_nodes.list()]
+ node = all_nodes[6]
+ data = {'action': 'all_nodes_table__delete',
+ 'object_ids': [node.uuid]}
+
+ with contextlib.nested(
+ mock.patch('tuskar_ui.api.node.Node', **{
+ 'spec_set': [
+ 'list',
+ 'delete',
+ ],
+ 'list.return_value': [node],
+ 'delete.side_effect': self._raise_ironic_exception,
+ }),
+ mock.patch('openstack_dashboard.api.nova.server_list',
+ return_value=([], False)),
+ ):
+ res = self.client.post(INDEX_URL, data)
+ self.assertMessageCount(error=1, warning=0)
+ self.assertNoFormErrors(res)
+ self.assertRedirectsNoFollow(res, INDEX_URL)
diff --git a/tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js b/tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js
new file mode 100644
index 00000000..23658f10
--- /dev/null
+++ b/tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js
@@ -0,0 +1,25 @@
+tuskar.performance = (function () {
+ 'use strict';
+
+ var module = {};
+
+ module.show_hide_datepickers = function () {
+ var date_options = $("#date_options");
+ date_options.change(function(evt) {
+ if ($(this).find("option:selected").val() === "other"){
+ evt.stopPropagation();
+ $("#date_from, #date_to").val('');
+ $("#date_from_group, #date_to_group").show();
+ } else {
+ $("#date_from_group, #date_to_group").hide();
+ }
+ });
+ if (date_options.find("option:selected").val() === "other"){
+ $("#date_from_group, #date_to_group").show();
+ } else {
+ $("#date_from_group, #date_to_group").hide();
+ }
+ };
+
+ return module;
+} ());
diff --git a/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html b/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html
index 6c27e91e..1ad01607 100644
--- a/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html
+++ b/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html
@@ -52,31 +52,8 @@
</div>
<script type="text/javascript">
- if (typeof $ !== 'undefined') {
- show_hide_datepickers();
- } else {
- addHorizonLoadEvent(function() {
- show_hide_datepickers();
- });
- }
- // TODO(lsmola) Pull the common code into a js file.
- function show_hide_datepickers() {
- var date_options = $("#date_options");
- date_options.change(function(evt) {
- if ($(this).find("option:selected").val() === "other"){
- evt.stopPropagation();
- $("#date_from, #date_to").val('');
- $("#date_from_group, #date_to_group").show();
- } else {
- $("#date_from_group, #date_to_group").hide();
- }
- });
- if (date_options.find("option:selected").val() === "other"){
- $("#date_from_group, #date_to_group").show();
- } else {
- $("#date_from_group, #date_to_group").hide();
- }
- }
+ (window.$ || window.addHorizonLoadEvent)(
+ tuskar.performance.show_hide_datepickers);
</script>
<div id="node-charts" class="nodes row">
diff --git a/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html b/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html
index d1c9b77c..61d91811 100644
--- a/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html
+++ b/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html
@@ -9,6 +9,7 @@
<script src='{{ STATIC_URL }}infrastructure/js/tuskar.number_picker.js' type='text/javascript' charset='utf-8'></script>
<script src='{{ STATIC_URL }}infrastructure/js/tuskar.edit_plan.js' type='text/javascript' charset='utf-8'></script>
<script src='{{ STATIC_URL }}infrastructure/js/tuskar.deployment_progress.js' type='text/javascript' charset='utf-8'></script>
+ <script src='{{ STATIC_URL }}infrastructure/js/tuskar.performance.js' type='text/javascript' charset='utf-8'></script>
{% endblock %}
{% comment %} Tuskar-UI Client-side Templates (These should *not* be inside the "compress" tag.) {% endcomment %}
diff --git a/tuskar_ui/test/api_tests/node_tests.py b/tuskar_ui/test/api_tests/node_tests.py
index ea92b6a7..2589caab 100644
--- a/tuskar_ui/test/api_tests/node_tests.py
+++ b/tuskar_ui/test/api_tests/node_tests.py
@@ -97,9 +97,15 @@ class NodeAPITests(test.APITestCase):
node = self.ironicclient_nodes.first()
nodes = self.ironicclient_nodes.list()
- with mock_ironicclient(node=node, nodes=nodes), mock.patch(
+ with mock_ironicclient(
+ node=node,
+ nodes=nodes
+ ), mock.patch(
'openstack_dashboard.api.nova.server_list',
return_value=(instances, None),
+ ), mock.patch(
+ 'openstack_dashboard.api.nova.server_get',
+ return_value=instances[0],
):
ret_val = api.node.Node.list(self.request)