blob: 6394c44d8b70bd3333e8e8fcb493e0e9f2878811 [file] [log] [blame]
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -05001<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <% include ../partials/head %>
7 <% include ../partials/header %>
8 <script type="text/javascript" src="/javascripts/admportal.js" async></script>
9 <title>SDN-C AdminPortal</title>
10<script class="init">
11 $(document).ready(function() {
12 $('#vm_networks').DataTable( {
13 "order": [[ 0, "asc" ]]
14 } );
15} );
16</script>
17
18</head>
19<body>
20
21<div class="well well-sm">
22<h3>VM Networks </h3>
23</div>
24
25<% if ( typeof result != 'undefined' ) {
26 if (result.code.length > 0) {
27 if ( result.code == 'success' ) { %>
28 <div class='alert alert-success' role='alert'>
29 <%
30 for ( x in result.msg ){ %>
31 <div><%= result.msg[x] %></div>
32 <% } %>
33 </div>
34 <% } else { %>
35 <div class='alert alert-danger' role='danger'>
36 <%
37 for ( x in result.msg ){ %>
38 <div><%= result.msg[x] %></div>
39 <% } %>
40 </div>
41 <% } %>
42 <% } %>
43<% } %>
44
45<% if( typeof privilege != 'undefined'){
46 var priv = privilege.privilege;
47} else {
48 var priv = 'A';
49} %>
50
51
52<div class="container-fluid">
53
54 <% if (priv == 'A'){ %>
55 <div class="actions" style="padding:15px 0px;">
56 <button class="btn btn-primary btn-md" data-toggle="modal" data-target="#add_vm_network">
57 Add VM Network
58 </button>
59 </div>
60 <% } %>
61
62 <table id="vm_networks" class="table table-hover table-condensed">
63 <thead>
64 <tr>
65 <th>*VNF_TYPE</th>
66 <th>*VM_TYPE</th>
67 <th>*NETWORK_ROLE</th>
68 <th>IP_COUNT</th>
69 <th>ASSIGN_IPS</th>
70 <th>ASSIGN_MACS</th>
71 <th>ASSIGN_FLOATING_IP</th>
72 <% if(priv == 'A'){ %>
73 <th>Action</th>
74 <% } %>
75 </tr>
76 </thead>
77 <tbody>
78 <% rows.forEach( function(row) { %>
79 <tr>
80 <td><%= row.vnf_type %></td>
81 <td><%= row.vm_type %></td>
82 <td><%= row.network_role %></td>
83 <td><%= row.ip_count %></td>
84 <td><%= (row.assign_ips == '1') ? 'true' : 'false' %></td>
85 <td><%= (row.assign_macs == '1') ? 'true' : 'false' %></td>
86 <td><%= (row.assign_floating_ip == '1') ? 'true' : 'false' %></td>
87 <% if(priv == 'A' ) { %>
88 <td>
89 <button type="button" class="btn btn-default btn-xs"
90 onclick="deleteVmNetwork('<%= row.vnf_type %>', '<%= row.vm_type %>', '<%= row.network_role %>');">Delete</button>
91 </td>
92 <% } %>
93 </tr>
94 <% }); %>
95 </tbody>
96 </table>
97
98 <% if(priv == 'A'){ %>
99 <div class="actions" style="padding:0px 25px;">
100 <form method="POST" action="/mobility/uploadVmNetworks" enctype="multipart/form-data">
101 <div class="form-group">
102 <label for="dest">File input</label>
103 <input name="filename" type="file" id="dest">
104 <p class="help-block">Choose a file to upload.</p>
105 </div>
106 <button type="button" class="btn btn-default"
107 onclick="uploadFile(this.form);">Upload File</button>
108 </form>
109 </div>
110 <% } %>
111</div>
112
113<% include ../partials/vm_networks %>
114<footer>
115 <% include ../partials/footer %>
116</footer>
117
118<script type="text/javascript">
119
120function addVmNetwork(form)
121{
122 var errorMsg='';
123 var vnf_type='';
124 var vm_type='';
125 var network_role='';
126 var ip_count = '';
127 var assign_ips='';
128 var assign_macs='';
129 var assign_floating_ip='';
130
131 if ( form.name == 'addForm' )
132 {
133 vnf_type = form.nf_vnf_type;
134 vm_type = form.nf_vm_type;
135 network_role = form.nf_network_role;
136 ip_count = form.nf_ip_count;
137 assign_ips = form.nf_assign_ips;
138 assign_macs = form.nf_assign_macs;
139 assign_floating_ip = form.nf_assign_floating_ip;
140 }
141
142 if ( (vnf_type.value == null) || (vnf_type.value == "") || isblank(vnf_type.value) )
143 {
144 errorMsg += 'VNF Type is required.<br>';
145 }
146 if ( (vm_type.value == null) || (vm_type.value == "") || isblank(vm_type.value) )
147 {
148 errorMsg += 'VM Type is required.<br>';
149 }
150 if ( (network_role.value == null) || (network_role.value == "") || isblank(network_role.value) ){
151 errorMsg += 'Network Role is required.<br>';
152 }
153 if( errorMsg.length > 0 ) {
154 bootbox.alert(errorMsg);
155 return;
156 }
157 if (ip_count.value.length >0 && !isDigit(ip_count.value) )
158 {
159 bootbox.alert('VM Count must be a number.');
160 return;
161 }
162 if (assign_ips.value == 'true' && ip_count.value.length == 0)
163 {
164 bootbox.alert("If ASSIGN IPS equals 'true', IP COUNT must be populated with a number.");
165 return;
166 }
167
168 form.submit();
169}
170
171function deleteVmNetwork(vnf_type,vm_type,network_role) {
172
173 bootbox.confirm({
174 message: "Are you sure you want to delete VM_NETWORK [" + vnf_type + "]" + "[" + vm_type + "][" + network_role + "]",
175 callback: function(result) {
176 if ( result )
177 {
178 location.assign("/mobility/deleteVmNetwork?vnf_type=" + vnf_type + "&vm_type=" + vm_type + "&network_role=" + network_role);
179
180 }
181 return;
182 },
183 buttons: {
184 cancel: {
185 label: "Cancel"
186 },
187 confirm: {
188 label: "Yes"
189 }
190 }
191 });
192}
193
194</script>
195
196</body>
197</html>
198