-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmanager.php
96 lines (84 loc) · 2.42 KB
/
manager.php
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
<!--
Coded By:
Shreshth Tuli
-->
<html>
<head><title>EdgeLens - Manager (Master)</title>
</head>
<body>
<?php
{
// Read IPs from config.txt
$file = fopen("config.txt", "r");
$content = "";
$line = fgets($file);
$localIP = getHostByName(getHostName());
while(($line = fgets($file)) !== false){
$content=$content.$line;
}
if(isset($_POST['config'])){echo "All Workers Configured<br/>";}
fclose($file);
// Alter first line of config.txt as per Enable master or aneka set or not
if(isset($_POST['enableMaster'])){
if(isset($_POST['enableAneka'])){
file_put_contents("config.txt", "EnableMaster EnableAneka".PHP_EOL.$content);
}
else{
file_put_contents("config.txt", "EnableMaster DisableAneka".PHP_EOL.$content);
}
}
else{
if(isset($_POST['enableAneka'])){
file_put_contents("config.txt", "DisableMaster EnableAneka".PHP_EOL.$content);
}
else{
file_put_contents("config.txt", "DisableMaster DisableAneka".PHP_EOL.$content);
}
}
// If new IP added, add to config.txt
if(isset($_POST['ip']) && $_POST['ip']!=""){
$file = fopen("config.txt", "a");
$k = $_POST['ip']."\n";
echo "Worker IP added : ".$_POST['ip']."<br/>";
fwrite($file, $k);
fclose($file);
}
{
// Display IPs already set
echo "Set Worker IPs here <br/>";
$file = fopen("config.txt", "r");
$line = fgets($file);
while(($line = fgets($file)) !== false){
echo "Worker IP : ".$line."<br/>";
if(isset($_POST['sync'])){
$ip = preg_replace('/\s+/', '', $line);
$tmp = file_get_contents("http://".$ip."/HealthFog/manager.php/?sync=sync");
}
}
fclose($file);
echo "<br/>"."Add Worker IP<br/>";
echo "
<form id='ipinfo' method='post'>
<input type='checkbox' name='enableMaster' value='Yes' checked />Enable Master as Worker <br/>
<input type='checkbox' name='enableAneka' value='Yes' checked />Enable Aneka<br/>
<input type='text' name='ip' id='ip' maxlength=\"500\" /> <br/>
<input type='submit' name='add' value='Add Worker' /> <br/>
<input type='submit' name='config' value='Configure Workers' />
<br/><br/>
<input type='submit' name='remove' value='Remove all workers' />
<input type='submit' name='sync' value='Sync Jar file' />
</form>";
}
}
$localIP = getHostByName(getHostName());
echo "Master IP address : ".$localIP;
?>
<?php
// Remove all worker nodes
if(isset($_POST['remove'])){
file_put_contents("config.txt", "EnableMaster EnableAneka".PHP_EOL);
echo "All Workers removed<br/>";
}
?>
</body>
</html>