summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/stacks/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/dashboards/project/stacks/api.py')
-rw-r--r--openstack_dashboard/dashboards/project/stacks/api.py83
1 files changed, 0 insertions, 83 deletions
diff --git a/openstack_dashboard/dashboards/project/stacks/api.py b/openstack_dashboard/dashboards/project/stacks/api.py
deleted file mode 100644
index ce5affd..0000000
--- a/openstack_dashboard/dashboards/project/stacks/api.py
+++ /dev/null
@@ -1,83 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13import json
14
15from openstack_dashboard.api import heat
16
17from openstack_dashboard.dashboards.project.stacks import mappings
18from openstack_dashboard.dashboards.project.stacks import sro
19
20
21class Stack(object):
22 pass
23
24
25def d3_data(request, stack_id=''):
26 try:
27 stack = heat.stack_get(request, stack_id)
28 except Exception:
29 stack = Stack()
30 stack.id = stack_id
31 stack.stack_name = request.session.get('stack_name', '')
32 stack.stack_status = 'DELETE_COMPLETE'
33 stack.stack_status_reason = 'DELETE_COMPLETE'
34
35 try:
36 resources = heat.resources_list(request, stack.stack_name)
37 except Exception:
38 resources = []
39
40 d3_data = {"nodes": [], "stack": {}}
41 if stack:
42 stack_image = mappings.get_resource_image(stack.stack_status, 'stack')
43 stack_node = {
44 'stack_id': stack.id,
45 'name': stack.stack_name,
46 'status': stack.stack_status,
47 'image': stack_image,
48 'image_size': 60,
49 'image_x': -30,
50 'image_y': -30,
51 'text_x': 40,
52 'text_y': ".35em",
53 'in_progress': (stack.status == 'IN_PROGRESS'),
54 'info_box': sro.stack_info(stack, stack_image)
55 }
56 d3_data['stack'] = stack_node
57
58 if resources:
59 for resource in resources:
60 resource_image = mappings.get_resource_image(
61 resource.resource_status,
62 resource.resource_type)
63 resource_status = mappings.get_resource_status(
64 resource.resource_status)
65 if resource_status in ('IN_PROGRESS', 'INIT'):
66 in_progress = True
67 else:
68 in_progress = False
69 resource_node = {
70 'name': resource.resource_name,
71 'status': resource.resource_status,
72 'image': resource_image,
73 'required_by': resource.required_by,
74 'image_size': 50,
75 'image_x': -25,
76 'image_y': -25,
77 'text_x': 35,
78 'text_y': ".35em",
79 'in_progress': in_progress,
80 'info_box': sro.resource_info(resource)
81 }
82 d3_data['nodes'].append(resource_node)
83 return json.dumps(d3_data)