-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestmultisite.html
274 lines (214 loc) · 7.96 KB
/
testmultisite.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-EM21HD2PGW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-EM21HD2PGW');
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>State Machine Interface</title>
<script src="js/network.js"></script>
<script src="js/fa.js"></script>
<script src="js/site.js"></script>
<script src="js/vmware.js"></script>
<script src="js/ac.js"></script>
<script src="js/cvis.js"></script>
<script src="https://unpkg.com/[email protected]/dist/cytoscape.min.js"></script>
<style>
#output {
margin-top: 20px;
border: 1px solid #ccc;
padding: 10px;
}
.tooltip {
display: none;
position: absolute;
z-index: 1000;
padding: 8px;
background-color: white;
border: 1px solid black;
border-radius: 5px;
font-size: 16px;
}
.content-container {
display: flex; /* This will align the children side by side */
border-left: thick solid rgb(240, 83, 35); /* Left border */
border-right: thick solid rgb(240, 83, 35);; /* Right border */
border-bottom: thick solid rgb(240, 83, 35);; /* Right border */
border-top: thick solid rgb(240, 83, 35);; /* Right border */
border-width: 10x;
margin-bottom: 20px; /* Space at the bottom for scrolling */
}
#cy {
flex: 0 1 60%; /* Do not grow, can shrink, start with 70% of the space */
margin: 10px;
height: 650px;
overflow-y: auto;
box-sizing: border-box;
border-right: thick solid rgb(240, 83, 35);
}
#logWindow {
flex: 0 1 40%; /* Do not grow, can shrink, start with 30% of the space */
box-sizing: border-box;
overflow-y: auto;
margin: 10px;
height: 650px;
white-space: pre-wrap;
/*white-space: nowrap;*/
}
.json-table {
border-collapse: collapse;
}
.json-table th,
.json-table td {
border: 1px solid #FFD2A0; /* Light orange border */
padding: 8px;
text-align: left;
}
.json-table th {
background-color: #FFA500; /* Vibrant orange for table headers */
color: white; /* White text for better contrast */
}
.json-table tr:nth-child(even) {
background-color: #FFE5CC; /* Lighter orange for alternate rows */
}
.column-container {
display: flex;
justify-content: space-between;
}
.column {
flex: 1; /* Each column takes up equal space */
margin-right: 20px; /* Space between columns */
}
/* If you want the last column to not have margin on the right */
.column:last-child {
margin-right: 0;
}
@media (max-width: 768px) {
.content-container {
flex-direction: column; /* Stack the children on smaller screens */
}
#logWindow, #cy {
flex-basis: auto; /* Reset to auto on smaller screens */
}
}
</style>
</head>
<body>
<div id="tooltip" class="tooltip"></div>
<h1>Active Cluster Simulator</h1>
<p><a href="https://github.com/sile16/ActiveClusterVis">Documentation</a>, report issues <a href="https://github.com/sile16/ActiveClusterVis/issues">here</a>. Reload Page to start over.</p>
<label for="wanlatency">WAN Latency RTT (ms):</label>
<input oninput="site.setWANLatency(this.value)" type="text" id="wanlatency" name="wanlatency" value="3">
<!-- disable buttons after clicking -->
<button onclick="site.addEthAC();step();this.disabled=true;">Add Eth WAN Cables & Eth Replication</button>
<button onclick="site.addFCWan();step();this.disabled=true;">Add FC WAN Cables</button>
<button onclick="site.addFCReplication();step();">Add FC Replication </button>
<button onclick="site.addFCUniformHostEntries();step();">Add Uniform Host Entires</button>
<button onclick="site.setPreferredArray();step()">Set Preferred Array in Host Entry</button>
<button onclick="site.enableAPDPDL();">Enable VMWare APD/PDL</button>
<p>AC Pod Failover Preference:
<select id="podfailover" onchange="site.setPodFailoverPreference(this.value); step()">
<option value="none">None</option>
<option value="site1fa1">site1fa1</option>
<option value="site2fa1">site2fa1</option>
</select>
</p>
<label for="events">Mouse Click Event:</label>
<select id="events">
<!-- Common events can remain hardcoded or be dynamically generated as well -->
<option value="fail">Fail</option>
<option value="recover">Recover</option>
<option value="promote">Promote (FA Controllers Only)</option>
<option value="power_on">Power On (VM Only)</option>
<option value="power_off">Power Off (VM Only)</option>
<option value="vmotion_to_other_site">vMotion to other Site (VM Only)</option>
<option value="reboot">Reboot (VM Only)</option>
</select> add step after click <input type="checkbox" id="clickstep" name="step" value="step" checked>
<button onclick="step()">Step Forward In Time</button>
<br><br>
<div class="content-container">
<div id="cy"></div>
<div id="logWindow"></div>
</div>
<div class="column-container">
<div class="column">
<p>Pods:</p>
<div id="pods_table"></div>
<p>Pod States:</p>
<div id="podstates_table"></div>
<p>FlashArrays:</p>
<div id="fas_table"></div>
<p>FA Host Entries:</p>
<div id="fahosts_table"></div>
</div>
<div class="column">
<p>VMS:</p>
<div id="vms_table"></div>
<p>VMHosts</p>
<div id="vmhosts_table"></div>
<p>Datastore Paths</p>
<div id="vmhost_paths_table"></div>
</div>
</div>
<script>
let site;
function log(message) {
const logWindow = document.getElementById('logWindow');
logWindow.innerHTML += message + '\n';
logWindow.scrollTop = logWindow.scrollHeight;
}
function initializeSite() {
site = new MultiSite("Test Site", document.getElementById('wanlatency').value);
updateVisualization(site); // Add this line
//do 1 step to initialize the site
step();
step();
//log("site initialized");
//updateOutput("Site Initialized");
}
function step() {
site.fullStep();
updateVisualization(site); // Add this line
let currentjsonState = site.jsonStatus();
//content.json = currentjsonState;
for (let x of ['vms', 'pods', 'podstates', 'fas', 'fahosts', 'vmhosts', 'vmhost_paths']) {
createTableFromJson(x + '_table', currentjsonState[x]);
}
log("--------------------------------------------------------------------------------------------------------");
}
function createTableFromJson(divId, jsonList) {
// Find unique keys (attributes) from all objects in the list
const keys = [...new Set(jsonList.flatMap(Object.keys))];
// Start building the HTML for the table
let tableHtml = "<table class='json-table'>";
// Add headers
tableHtml += "<tr>";
keys.forEach(key => {
tableHtml += `<th>${key}</th>`;
});
tableHtml += "</tr>";
// Add rows
jsonList.forEach(obj => {
tableHtml += "<tr>";
keys.forEach(key => {
const cellValue = obj[key] !== undefined && obj[key] !== null ? obj[key] : '';
tableHtml += `<td>${cellValue}</td>`;
});
tableHtml += "</tr>";
});
tableHtml += "</table>";
// Insert the table into the specified div
document.getElementById(divId).innerHTML = tableHtml;
}
document.addEventListener('DOMContentLoaded', function() {
initializeSite();
});
</script>
</body>
</html>