pdu: list, create, show, delete
Change-Id: I1d184eba4fef6cd55719ef5b0e51a29b05c34b96
Signed-off-by: lombardofr <lombardo@everyup.it>
diff --git a/instancehandler/template/instance_list.html b/instancehandler/template/instance_list.html
index bc94e5f..39d9b3c 100644
--- a/instancehandler/template/instance_list.html
+++ b/instancehandler/template/instance_list.html
@@ -40,12 +40,15 @@
{% include 'instance_list_ns.html' %}
{% elif type == 'vnf' %}
{% include 'instance_list_vnf.html' %}
+ {% elif type == 'pdu' %}
+ {% include 'instance_list_pdu.html' %}
{% endif %}
</div>
</div>
{% include 'modal/instance_create.html' %}
+ {% include 'modal/instance_create_pdu.html' %}
{% include 'modal/instance_show.html' %}
{% include 'modal/instance_new_action.html' %}
{% include 'modal/instance_new_alarm.html' %}
@@ -75,6 +78,7 @@
<script src="/static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script>
+ var table;
var instance_type = '{{ type }}';
var row_builder = {
'ns': [
@@ -184,7 +188,8 @@
},
],
- 'vnf': [ {
+ 'vnf': [
+ {
"render": function (data, type, row) {
return row["_id"];
},
@@ -226,10 +231,58 @@
},
"targets": 5
},
+ ],
+ 'pdu': [
+ {
+ "render": function (data, type, row) {
+ return row["_id"];
+ },
+ "targets": 0
+ },
+ {
+ "render": function (data, type, row) {
+ return row["name"];
+ },
+ "targets": 1
+ },
+ {
+ "render": function (data, type, row) {
+ return row["type"];
+ },
+ "targets": 2
+ },
+ {
+ "render": function (data, type, row) {
+ return row['_admin']['usageState'];
+ },
+ "targets": 3
+ },
+ {
+ "render": function (data, type, row) {
+ return moment.unix(row['_admin']['created']).format('YYYY-MM-DD hh:mm:ss a');
+ },
+ "targets": 4
+ },
+ {
+ "render": function (data, type, row) {
+ return '<div class="btn-group">' +
+ ' <button type="button" class="btn btn-default"' +
+ ' onclick="javascript:showInstanceDetails(\''+instance_type+'\', \''+row["_id"]+'\')"' +
+ ' data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info">' +
+ ' <i class="fa fa-info"></i>' +
+ ' </button>' +
+ '<button type="button" class="btn btn-default"' +
+ ' onclick="javascript:deletePDU(\''+ row["name"] +'\', \''+row["_id"]+'\')"' +
+ ' data-toggle="tooltip" data-placement="top" data-container="body" title="Delete"><i' +
+ ' class="far fa-trash-alt"></i></button>'+
+ ' </div>';
+ },
+ "targets": 5
+ }
]
};
$(document).ready(function () {
- var table = $('#instances_table').DataTable({
+ table = $('#instances_table').DataTable({
responsive: true,
"ajax": {
"url": "/instances/" + instance_type + "/list/",
@@ -254,6 +307,8 @@
setInterval(function () {
table.ajax.reload();
}, 10000);
+
+
});
</script>
diff --git a/instancehandler/template/instance_list_pdu.html b/instancehandler/template/instance_list_pdu.html
new file mode 100644
index 0000000..3eab3fc
--- /dev/null
+++ b/instancehandler/template/instance_list_pdu.html
@@ -0,0 +1,33 @@
+{% load get %}
+{% load date_tag %}
+<div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ type|upper }}</h3>
+
+ <div class="box-tools">
+ <button type="button" class="btn btn-default" data-container="body"
+ data-toggle="tooltip" data-placement="top" title="New PDU"
+ onclick="javascript:openModalCreatePDU({ 'project_id':'{{ project_id }}','vim_list_url': '{% url "vims:list" %}'})">
+ <i class="fa fa-plus"></i> <span> New PDU</span>
+ </button>
+ </div>
+
+ </div>
+ <div class="box-body">
+ <table id="instances_table" class="table table-bordered table-striped responsive" style="width:100%">
+ <thead>
+ <tr>
+ <th>Identifier</th>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Usage State</th>
+ <th>Created At</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+
+ </tbody>
+ </table>
+ </div>
+</div>
\ No newline at end of file
diff --git a/instancehandler/template/instance_list_vnf.html b/instancehandler/template/instance_list_vnf.html
index d290ad1..ae82675 100644
--- a/instancehandler/template/instance_list_vnf.html
+++ b/instancehandler/template/instance_list_vnf.html
@@ -1,14 +1,11 @@
{% load get %}
{% load date_tag %}
-
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ type|upper }} Instances</h3>
<div class="box-tools">
-
-
</div>
</div>
diff --git a/instancehandler/template/modal/instance_create.html b/instancehandler/template/modal/instance_create.html
index 7544919..8b4d40c 100644
--- a/instancehandler/template/modal/instance_create.html
+++ b/instancehandler/template/modal/instance_create.html
@@ -6,7 +6,7 @@
<span aria-hidden="true">×</span></button>
<h4 class="modal-title">New Instance</h4>
</div>
- <form id="formCreateNS" action='{% url "instances:create" %}'
+ <form id="formCreateNS" action='{% url "instances:create" type='ns' %}'
class="form-horizontal"
method="post" enctype="multipart/form-data">
{% csrf_token %}
diff --git a/instancehandler/template/modal/instance_create_pdu.html b/instancehandler/template/modal/instance_create_pdu.html
new file mode 100644
index 0000000..444bd7e
--- /dev/null
+++ b/instancehandler/template/modal/instance_create_pdu.html
@@ -0,0 +1,87 @@
+<div class="modal" id="modal_new_pdu" xmlns="http://www.w3.org/1999/html">
+ <div class="modal-dialog modal-lg">
+ <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">New PDU</h4>
+ </div>
+ <form id="formCreatePDU" action='{% url "instances:create" type='pdu' %}'
+ class="form-horizontal"
+ method="post" enctype="multipart/form-data">
+ {% csrf_token %}
+ <div class="modal-body" id="modal_new_pdu_body">
+ <div id="pdu_base_div">
+
+ <div class="form-group">
+
+ <label for="pdu_name" class="col-sm-2">Name *</label>
+ <div class="col-sm-3">
+ <input class="form-control" id="pdu_name" name="name" placeholder="Name" required>
+ </div>
+
+ <label for="pdu_type" class="col-sm-2">PDU type *</label>
+ <div class="col-sm-3">
+ <input class="form-control" id="pdu_type" name="pdu_type" placeholder="Type" required>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="pdu_vim_accounts" class="col-sm-2">Vim Accounts *</label>
+ <div class="col-sm-6">
+ <select required id="pdu_vim_accounts" class="js-example-basic-multiple form-control" name="pdu_vim_accounts"
+ multiple="multiple">
+ </select>
+ </div>
+ </div>
+
+ </div>
+ <div class="row">
+ <h4 class="col-sm-4">Interfaces:</h4>
+ </div>
+ <div id="interfaces_div">
+
+ <div class="interface-group">
+ <button type="button" class="btn btn-success btn-add btn-sm pull-right">+</button>
+ <div class="form-group">
+ <label for="interfaces_name" class="col-sm-2">Name</label>
+ <div class="col-sm-3">
+ <input name="interfaces_name" class="form-control input-sm" required>
+ </div>
+ <label for="interfaces_name" class="col-sm-2">IP</label>
+ <div class="col-sm-3">
+ <input name="interfaces_ip" class="form-control input-sm" required>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="interfaces_mgmt" class="col-sm-2">Mgmt</label>
+ <div class="col-sm-3">
+ <select name="interfaces_mgmt" id="interfaces_mgmt" class="form-control">
+ <option value="false">False</option>
+ <option value="true">True</option>
+ </select>
+ </div>
+ <label for="interfaces_vimnetname" class="col-sm-2">Net name</label>
+ <div class="col-sm-3">
+ <input id="interfaces_vimnetname" name="interfaces_vimnetname" class="form-control input-sm" required>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
+ <button class="btn btn-primary"
+ data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Creating..."
+ id="create_new_pdu">Create
+ </button>
+
+ </div>
+ </form>
+ </div>
+ <!-- /.modal-content -->
+ </div>
+ <!-- /.modal-dialog -->
+</div>
+
+
+
diff --git a/instancehandler/template/modal/instance_new_action.html b/instancehandler/template/modal/instance_new_action.html
index 6cf3059..1aa1c24 100644
--- a/instancehandler/template/modal/instance_new_action.html
+++ b/instancehandler/template/modal/instance_new_action.html
@@ -24,11 +24,9 @@
<div class="row">
<h5 class="col-sm-4">Primitive parameters :</h5>
-
</div>
- <div id="primitive_params_div">
-
+ <div id="primitive_params_div" class="primitive-group">
<div class="form-group">
<label class="col-sm-2">Name: </label>
<div class="col-sm-3">
@@ -42,7 +40,6 @@
</div>
</div>
-
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>