<ul class="dropdown-menu">
<li><a href="#" onclick="javascript:performAction('{% url 'projects:instances:action' instance_id=i|get:'_id' project_id=project_id type=type %}')">
<i class="fa fa-magic"></i>Exec NS Primitive</a></li>
- <li><a href="#"> <i class="fa fa-list"></i>Active operations</a></li>
+ <li><a href="{% url 'projects:instances:ns_operations' project_id=project_id type=type instance_id=i|get:'_id'%}"> <i class="fa fa-list"></i>Active operations</a></li>
</ul>
--- /dev/null
+{% extends "base.html" %}
+{% load get %}
+{% load date_tag %}
+{% load staticfiles %}
+
+
+
+{% block head_block %}
+ {{ block.super }}
+ <!-- Codemirror core CSS -->
+ <link rel="stylesheet" href="/static/bower_components/codemirror/lib/codemirror.css">
+ <link rel="stylesheet" href="/static/bower_components/codemirror/addon/fold/foldgutter.css" />
+ <link rel="stylesheet" href="/static/bower_components/codemirror/theme/neat.css">
+ <link rel="stylesheet" href="/static/bower_components/codemirror/addon/dialog/dialog.css">
+ <link rel="stylesheet" href="/static/bower_components/codemirror/addon/display/fullscreen.css">
+ <link rel="stylesheet" href="/static/bower_components/select2/dist/css/select2.min.css">
+{% endblock %}
+{% block title_header_big %}
+ {{ block.super }}
+{% endblock %}
+{% block left_sidebar %}
+ {% include 'osm/osm_project_left_sidebar.html' %}
+{% endblock %}
+
+
+{% block breadcrumb_body %}
+ {{ block.super }}
+ <li><a href="{% url 'projects:instances:list' project_id=project_id type=type %}">Instances</a></li>
+{% endblock %}
+
+{% block content_body %}
+ {{ block.super }}
+ {% include 'modal/instance_create.html' %}
+ {% csrf_token %}
+ <div class="row">
+ <div class="col-md-12">
+
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">Active operations</h3>
+
+ </div>
+ <div class="box-body">
+ <table id="instances_table" class="table table-bordered table-striped">
+ <thead>
+ <tr>
+ <th>Id</th>
+ <th>Type</th>
+ <th>Operation State</th>
+ <th>Start Time</th>
+ <th>Status Entered Time</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for i in operations %}
+ <tr>
+
+ <td>{{ i|get:"_id" }}</td>
+ <td>{{ i|get:"lcmOperationType" }}</td>
+
+ {% if i|get:"operationState" == 'FAILED' %}
+ <td><span class="label label-danger">{{ i|get:"operationState" }}</span> </td>
+ {% elif i|get:"operationState" == 'PROCESSING' %}
+ <td><span class="label label-warning">{{ i|get:"operationState" }}</span> </td>
+ {% elif i|get:"operationState" == 'COMPLETED' %}
+ <td><span class="label label-success">{{ i|get:"operationState" }}</span> </td>
+ {% else %}
+ <td>{{ i|get:"operationState" }}</td>
+ {% endif %}
+
+ <td >{{ i.startTime|get_date }}</td>
+ <td >{{ i.statusEnteredTime|get_date }}</td>
+ <td>
+ <div class="btn-group">
+ <button type="button" class="btn btn-default"
+ onclick="javascript:showOperationDetails('{% url 'projects:instances:ns_operation' op_id=i|get:'_id' instance_id=i|get:'nsInstanceId' project_id=project_id type=type %}')"
+ data-toggle="tooltip" data-placement="top" data-container="body" title="More Info"><i
+ class="fa fa-info"></i>
+ </button>
+
+
+ </div>
+
+ </td>
+
+
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ {% include 'modal/operation_show.html' %}
+{% endblock %}
+
+{% block resource_block %}
+ {{ block.super }}
+ <!-- Utility JS -->
+ <script src="/static/bower_components/select2/dist/js/select2.js"></script>
+ <script src="/static/bower_components/codemirror/lib/codemirror.js"></script>
+ <script src="/static/bower_components/codemirror/addon/fold/foldcode.js"></script>
+ <script src="/static/bower_components/codemirror/addon/fold/foldgutter.js"></script>
+ <script src="/static/bower_components/codemirror/addon/fold/brace-fold.js"></script>
+ <script src="/static/bower_components/codemirror/mode/javascript/javascript.js"></script>
+ <script src="/static/bower_components/codemirror/addon/search/searchcursor.js"></script>
+ <script src="/static/bower_components/codemirror/addon/search/search.js"></script>
+ <script src="/static/bower_components/codemirror/addon/dialog/dialog.js"></script>
+ <script src="/static/bower_components/codemirror/addon/display/autorefresh.js"></script>
+ <script src="/static/bower_components/codemirror/addon/edit/matchbrackets.js"></script>
+ <script src="/static/bower_components/codemirror/addon/edit/closebrackets.js"></script>
+ <script src="/static/bower_components/codemirror/addon/display/fullscreen.js"></script>
+ <script src="/static/bower_components/codemirror/keymap/sublime.js"></script>
+ <script src="/static/src/instancehandler/instance_operations_list.js"></script>
+
+{% endblock %}
+
+{% block footer %}
+ {% include "footer.html" %}
+{% endblock %}
--- /dev/null
+<div class="modal" id="modal_show_operation" xmlns="http://www.w3.org/1999/html">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">×</span></button>
+ <h4 class="modal-title" >Instance details</h4>
+ </div>
+
+ <div class="modal-body" id="modal_show_operation_body" >
+ <textarea id="operation_view_json">
+ </textarea>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
+
+ </div>
+
+ </div>
+ <!-- /.modal-content -->
+ </div>
+ <!-- /.modal-dialog -->
+</div>
url(r'^(?P<type>[ns|vnf]+)/list/', views.list, name='list'),
url(r'^create/', views.create, name='create'),
url(r'^(?P<type>[ns|vnf]+)/(?P<instance_id>[0-9a-z-]+)/delete$', views.delete, name='delete'),
- url(r'^(?P<type>[ns|vnf]+)/(?P<instance_id>[0-9a-z-]+)/action', views.action, name='action'),
+ url(r'^(?P<type>[ns|vnf]+)/(?P<instance_id>[0-9a-z-]+)/action$', views.action, name='action'),
+ url(r'^(?P<type>[ns|vnf]+)/(?P<instance_id>[0-9a-z-]+)/operation$', views.ns_operations, name='ns_operations'),
+ url(r'^(?P<type>[ns|vnf]+)/(?P<instance_id>[0-9a-z-]+)/operation/(?P<op_id>[0-9a-z-]+)', views.ns_operation, name='ns_operation'),
url(r'^(?P<type>[ns|vnf]+)/(?P<instance_id>[0-9a-z-]+)', views.show, name='show'),
]
result = client.ns_create(ns_data)
return __response_handler(request, result, 'projects:instances:list', to_redirect=True, type='ns', project_id=project_id)
+@login_required
+def ns_operations(request, project_id=None, instance_id=None, type=None):
+ client = Client()
+ result = client.ns_op_list(instance_id)
+ return __response_handler(request, {'operations': result, 'type': 'ns', 'project_id': project_id}, 'instance_operations_list.html')
+
+@login_required
+def ns_operation(request, op_id, project_id=None, instance_id=None, type=None):
+ client = Client()
+ result = client.ns_op(op_id)
+ return __response_handler(request, result)
@login_required
def action(request, project_id=None, instance_id=None, type=None):
json=action_payload)
return None
+ def ns_op_list(self, id):
+ token = self.get_token()
+ headers = {}
+ if token:
+ headers['Authorization'] = 'Bearer {}'.format(token)
+ headers['Content-Type'] = 'application/json'
+ headers['accept'] = 'application/json'
+
+ _url = "{0}/nslcm/v1/ns_lcm_op_occs/?nsInstanceId={1}".format(self._base_path, id)
+ return self._send_get(_url, headers=headers)
+ return None
+
+ def ns_op(self, id):
+ token = self.get_token()
+ headers = {}
+ if token:
+ headers['Authorization'] = 'Bearer {}'.format(token)
+ headers['Content-Type'] = 'application/json'
+ headers['accept'] = 'application/json'
+
+ _url = "{0}/nslcm/v1/ns_lcm_op_occs/{1}".format(self._base_path, id)
+ return self._send_get(_url, headers=headers)
+ return None
+
def vnfd_list(self):
token = self.get_token()
if token:
],
'libraries':{
'get': 'sf_t3d.templatetags.get',
-
+ 'date_tag': 'sf_t3d.templatetags.datetag',
}
},
},
--- /dev/null
+#
+# Copyright 2018 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from django import template
+import time
+register = template.Library()
+
+
+'''
+ Custom template filter handle timestamp
+'''
+
+
+# TODO add configurable date format
+@register.filter
+def get_date(timestamp):
+ if isinstance(timestamp, float):
+ return time.strftime("%d-%m-%Y %H:%M:%S", time.gmtime(timestamp))
+ return '-'
+
// load vim account list
select2_groups = $('#vimAccountId').select2({
placeholder: 'Select VIM',
+ width: '100%',
ajax: {
url: args.vim_list_url,
dataType: 'json',
--- /dev/null
+/*
+ Copyright 2018 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+
+function showOperationDetails(url_info) {
+ var dialog = bootbox.dialog({
+ message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
+ closeButton: true
+ });
+ $.ajax({
+ url: url_info,
+ type: 'GET',
+ dataType: "json",
+ contentType: "application/json;charset=utf-8",
+ success: function (result) {
+ editorJSON.setValue(JSON.stringify(result, null, "\t"));
+ editorJSON.setOption("autoRefresh", true);
+ dialog.modal('hide');
+ $('#modal_show_operation').modal('show');
+ },
+ error: function (result) {
+ dialog.modal('hide');
+ bootbox.alert("An error occurred while retrieving the information for the NS");
+ }
+ });
+}
+
+var editorJSON;
+
+$(document).ready(function () {
+ var json_editor_settings = {
+ mode: "javascript",
+ showCursorWhenSelecting: true,
+ autofocus: true,
+ lineNumbers: true,
+ lineWrapping: true,
+ foldGutter: true,
+ gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
+ autoCloseBrackets: true,
+ matchBrackets: true,
+ extraKeys: {
+ "F11": function (cm) {
+ cm.setOption("fullScreen", !cm.getOption("fullScreen"));
+ },
+ "Esc": function (cm) {
+ if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
+ },
+ "Ctrl-Q": function (cm) {
+ cm.foldCode(cm.getCursor());
+ }
+ },
+ theme: "neat",
+ keyMap: "sublime"
+ };
+ var myJsonTextArea = document.getElementById("operation_view_json");
+ editorJSON = CodeMirror(function (elt) {
+ myJsonTextArea.parentNode.replaceChild(elt, myJsonTextArea);
+ }, json_editor_settings);
+
+
+});
\ No newline at end of file