Skip to content

Commit fbff359

Browse files
v3.2.0
1 parent 426f632 commit fbff359

38 files changed

+3109
-545
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
# v3.2.0
2+
- added removal confirmation of remote hosts
3+
- added preference choices for logging and logs page
4+
- added preferences for custom page refresh rates
5+
- added preferences for custom API connection and operation timeout
6+
- improved CPU guage, changing from top to /proc/stat readings
7+
- improved handling connection to unresponsive remote hosts
8+
- fixed bug with adding hosts due to data type
9+
110
# v3.1.0
2-
- improved performace of page loads
11+
- improved performance of page loads
312
- updated instance backups to include a filesize of exported files
413
- updated exporting backup image to using a script to spawn it off into a background process
514
- updated remote host table header

lxd-dashboard/backend/aaa/accounting.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@
2525
//Require code from lxd-dashboard/backend/config/db.php
2626
require_once('../config/db.php');
2727

28-
function logEvent($action, $remote, $project, $object, $status_code, $message){
29-
//Will be used in future releases with remote database option
28+
function logEvent($action, $remote, $project, $object, $status_code, $message, $user_id = 0){
29+
$logs_enabled_value = retrievePreference("logs_enabled");
30+
31+
if ($logs_enabled_value == 'true'){
32+
$hostname = gethostname();
33+
34+
if ($user_id == 0){
35+
$user_id = (!empty($_SESSION['user_id'])) ? $_SESSION['user_id'] : 0;
36+
}
37+
38+
$event_added = addLogEvent($action, $remote, $project, $object, $status_code, $message, $hostname, $user_id);
39+
}
3040
}
3141
?>

lxd-dashboard/backend/aaa/authentication.php

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,69 @@
7272
//Store user's controls in a SESSION array
7373
$_SESSION['controls'] = $controls;
7474

75+
//Store preference values in SESSION array
76+
$preferences = retrieveTableRows("lxd_preferences");
77+
foreach ($preferences as $preference){
78+
//API Preferences
79+
if ($preference['name'] == "get_connection_timeout")
80+
$_SESSION['get_connection_timeout'] = $preference['value'];
81+
if ($preference['name'] == "get_operation_timeout")
82+
$_SESSION['get_operation_timeout'] = $preference['value'];
83+
if ($preference['name'] == "post_connection_timeout")
84+
$_SESSION['post_connection_timeout'] = $preference['value'];
85+
if ($preference['name'] == "post_operation_timeout")
86+
$_SESSION['post_operation_timeout'] = $preference['value'];
87+
if ($preference['name'] == "patch_connection_timeout")
88+
$_SESSION['patch_connection_timeout'] = $preference['value'];
89+
if ($preference['name'] == "patch_operation_timeout")
90+
$_SESSION['patch_operation_timeout'] = $preference['value'];
91+
if ($preference['name'] == "put_connection_timeout")
92+
$_SESSION['put_connection_timeout'] = $preference['value'];
93+
if ($preference['name'] == "put_operation_timeout")
94+
$_SESSION['put_operation_timeout'] = $preference['value'];
95+
if ($preference['name'] == "delete_connection_timeout")
96+
$_SESSION['delete_connection_timeout'] = $preference['value'];
97+
if ($preference['name'] == "delete_operation_timeout")
98+
$_SESSION['delete_operation_timeout'] = $preference['value'];
99+
//Page Refresh Preferences
100+
if ($preference['name'] == "certificates_page_rate")
101+
$_SESSION['certificates_page_rate'] = $preference['value'];
102+
if ($preference['name'] == "cluster_members_page_rate")
103+
$_SESSION['cluster_members_page_rate'] = $preference['value'];
104+
if ($preference['name'] == "containers_page_rate")
105+
$_SESSION['containers_page_rate'] = $preference['value'];
106+
if ($preference['name'] == "containers_single_page_rate")
107+
$_SESSION['containers_single_page_rate'] = $preference['value'];
108+
if ($preference['name'] == "images_page_rate")
109+
$_SESSION['images_page_rate'] = $preference['value'];
110+
if ($preference['name'] == "logs_page_rate")
111+
$_SESSION['logs_page_rate'] = $preference['value'];
112+
if ($preference['name'] == "network_acls_page_rate")
113+
$_SESSION['network_acls_page_rate'] = $preference['value'];
114+
if ($preference['name'] == "networks_page_rate")
115+
$_SESSION['networks_page_rate'] = $preference['value'];
116+
if ($preference['name'] == "operations_page_rate")
117+
$_SESSION['operations_page_rate'] = $preference['value'];
118+
if ($preference['name'] == "profiles_page_rate")
119+
$_SESSION['profiles_page_rate'] = $preference['value'];
120+
if ($preference['name'] == "projects_page_rate")
121+
$_SESSION['projects_page_rate'] = $preference['value'];
122+
if ($preference['name'] == "remotes_single_page_rate")
123+
$_SESSION['remotes_single_page_rate'] = $preference['value'];
124+
if ($preference['name'] == "remotes_page_rate")
125+
$_SESSION['remotes_page_rate'] = $preference['value'];
126+
if ($preference['name'] == "simplestreams_page_rate")
127+
$_SESSION['simplestreams_page_rate'] = $preference['value'];
128+
if ($preference['name'] == "storage_pools_page_rate")
129+
$_SESSION['storage_pools_page_rate'] = $preference['value'];
130+
if ($preference['name'] == "storage_volumes_page_rate")
131+
$_SESSION['storage_volumes_page_rate'] = $preference['value'];
132+
if ($preference['name'] == "virtual_machines_page_rate")
133+
$_SESSION['virtual_machines_page_rate'] = $preference['value'];
134+
if ($preference['name'] == "virtual_machines_single_page_rate")
135+
$_SESSION['virtual_machines_single_page_rate'] = $preference['value'];
136+
}
137+
75138
$results = '{"status": "Ok", "status_code": 200, "metadata": "{}"}';
76139
}
77140
else {
@@ -90,6 +153,7 @@
90153

91154
case "deauthenticateUser":
92155
$username = $_SESSION['username'];
156+
$user_id = $_SESSION['user_id'];
93157
//Clear the SESSION variables
94158
$_SESSION = array();
95159
if (session_destroy())
@@ -100,7 +164,7 @@
100164
//Send event to accounting
101165
$event = json_decode($results, true);
102166
$object = $username;
103-
logEvent($action, $remote, $project, $object, $event['status_code'], $event['status']);
167+
logEvent($action, $remote, $project, $object, $event['status_code'], $event['status'], $user_id);
104168

105169
break;
106170

lxd-dashboard/backend/aaa/authorization.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
-- listUsers
4646
-- removeGroupFromUser
4747
-- removeRoleFromGroup
48+
-- updateLogPreferences
49+
-- updateOutboundRequestPreferences
50+
-- updateRefreshRatePreferences
4851
4952
- /admin/backend/admin/user-profile.php
5053
-- retrieveUserId
@@ -197,6 +200,7 @@
197200
-- displayStorageInfo
198201
-- displaySysInfo
199202
-- displayVirtualMachineInfo
203+
-- validateRemoteConnection
200204
201205
- /admin/backend/lxd/remotes.php
202206
-- addRemote
@@ -478,15 +482,19 @@ function getControls($roles){
478482
"updateImage",
479483
"updateInstanceInformation",
480484
"updateInstanceUsingForm",
485+
"updateLogPreferences",
481486
"updateNetwork",
482487
"updateNetworkAcl",
488+
"updateOutboundRequestPreferences",
483489
"updateProfile",
484490
"updateProject",
491+
"updateRefreshRatePreferences",
485492
"updateRemote",
486493
"updateStoragePool",
487494
"updateStorageVolume",
488495
"updateUserAccount",
489496
"updateUserPassword",
497+
"validateRemoteConnection",
490498
"viewCertificate"
491499
);
492500
$controls = array_merge($controls, $admin_controls);
@@ -651,6 +659,7 @@ function getControls($roles){
651659
"updateRemote",
652660
"updateStoragePool",
653661
"updateStorageVolume",
662+
"validateRemoteConnection",
654663
"viewCertificate"
655664
);
656665
$controls = array_merge($controls, $operator_controls);
@@ -747,6 +756,7 @@ function getControls($roles){
747756
"stopInstance",
748757
"stopInstanceForcefully",
749758
"unfreezeInstance",
759+
"validateRemoteConnection",
750760
"viewCertificate"
751761
);
752762
$controls = array_merge($controls, $user_controls);
@@ -827,7 +837,8 @@ function getControls($roles){
827837
"retrieveHostAndPort",
828838
"retrieveInstanceState",
829839
"retrieveUserDetails",
830-
"retrieveUserId"
840+
"retrieveUserId",
841+
"validateRemoteConnection"
831842
);
832843
$controls = array_merge($controls, $auditor_controls);
833844
break;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/*
3+
LXDWARE LXD Dashboard - A web-based interface for managing LXD servers
4+
Copyright (C) 2020-2021 LXDWARE.COM
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License as
8+
published by the Free Software Foundation, either version 3 of the
9+
License, or (at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU Affero General Public License for more details.
15+
16+
You should have received a copy of the GNU Affero General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
//Start session if not already started
21+
if (!isset($_SESSION)) {
22+
session_start();
23+
}
24+
25+
//Declare and instantiate GET variables
26+
$action = (isset($_GET['action'])) ? filter_var(urldecode($_GET['action']), FILTER_SANITIZE_STRING) : "";
27+
28+
//Require code from lxd-dashboard/backend/config/db.php
29+
require_once('../config/db.php');
30+
31+
//Require code from lxd-dashboard/backend/aaa/accounting.php
32+
require_once('../aaa/accounting.php');
33+
34+
if (isset($_SESSION['username'])) {
35+
36+
require_once('../aaa/authorization.php');
37+
38+
//Run the matching action
39+
switch ($action) {
40+
41+
case "listLogEvents":
42+
$logs_retrieval = intval(retrievePreference("logs_retrieval"));
43+
if ($logs_retrieval < 1){
44+
$logs_retrieval = 100;
45+
}
46+
47+
$rows = retrieveTableRows('lxd_logs', $logs_retrieval);
48+
49+
$i = 0;
50+
echo '{ "data": [';
51+
52+
foreach ($rows as $row){
53+
54+
if ($i > 0){
55+
echo ",";
56+
}
57+
$i++;
58+
59+
echo "[ ";
60+
61+
echo '"';
62+
echo "<i class='fas fa-history fa-lg' style='color:#4e73df'></i>";
63+
echo '",';
64+
65+
echo '"' . htmlentities($row['id']) . '",';
66+
echo '"' . htmlentities($row['control']) . '",';
67+
echo '"' . htmlentities($row['remote_id']) . '",';
68+
echo '"' . htmlentities($row['project']) . '",';
69+
echo '"' . htmlentities($row['object']) . '",';
70+
echo '"' . htmlentities($row['status_code']) . '",';
71+
echo '"' . htmlentities($row['message']) . '",';
72+
echo '"' . htmlentities($row['hostname']) . '",';
73+
echo '"' . htmlentities($row['user_id']) . '",';
74+
echo '"' . htmlentities($row['date']) . '"';
75+
76+
echo " ]";
77+
}
78+
79+
echo " ]}";
80+
break;
81+
82+
}
83+
84+
}
85+
86+
?>

0 commit comments

Comments
 (0)