mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Merge branch 'master' of github.com:pcbsd/sysadm
This commit is contained in:
@@ -37,7 +37,7 @@ ssl_keygen()
|
||||
sysadm_restserver_stop()
|
||||
{
|
||||
if [ -e "/var/run/sysadm-rest.pid" ] ; then
|
||||
pkill -9 -F /var/run/sysadm-rest.pid
|
||||
pkill -9 -F /var/run/sysadm-rest.pid >/dev/null 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ ssl_keygen()
|
||||
sysadm_websocket_stop()
|
||||
{
|
||||
if [ -e "/var/run/sysadm-websocket.pid" ] ; then
|
||||
pkill -9 -F /var/run/sysadm-websocket.pid
|
||||
pkill -9 -F /var/run/sysadm-websocket.pid >/dev/null 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
//sysadm library interface classes
|
||||
#include "library/sysadm-general.h"
|
||||
#include "library/sysadm-iocage.h"
|
||||
#include "library/sysadm-iohyve.h"
|
||||
#include "library/sysadm-lifepreserver.h"
|
||||
#include "library/sysadm-network.h"
|
||||
#include "library/sysadm-systeminfo.h"
|
||||
@@ -52,6 +53,11 @@ RestOutputStruct::ExitCode WebSocket::AvailableSubsystems(bool allaccess, QJsonO
|
||||
out->insert("sysadm/iocage", "read/write");
|
||||
}
|
||||
|
||||
// - iohyve
|
||||
if(QFile::exists("/usr/local/sbin/iohyve")){
|
||||
out->insert("sysadm/iohyve", "read/write");
|
||||
}
|
||||
|
||||
// - Generic system information
|
||||
out->insert("sysadm/systeminfo","read/write");
|
||||
|
||||
@@ -86,6 +92,8 @@ RestOutputStruct::ExitCode WebSocket::EvaluateBackendRequest(const RestInputStru
|
||||
return EvaluateDispatcherRequest(IN.fullaccess, IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="iocage"){
|
||||
return EvaluateSysadmIocageRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="iohyve"){
|
||||
return EvaluateSysadmIohyveRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="lifepreserver"){
|
||||
return EvaluateSysadmLifePreserverRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="network"){
|
||||
@@ -387,3 +395,27 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIocageRequest(const QJsonVal
|
||||
}
|
||||
return RestOutputStruct::OK;
|
||||
}
|
||||
|
||||
//==== SYSADM -- iohyve ====
|
||||
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIohyveRequest(const QJsonValue in_args, QJsonObject *out){
|
||||
if(in_args.isObject()){
|
||||
QStringList keys = in_args.toObject().keys();
|
||||
bool ok = false;
|
||||
if(keys.contains("action")){
|
||||
QString act = JsonValueToString(in_args.toObject().value("action"));
|
||||
if(act=="listvms"){
|
||||
ok = true;
|
||||
out->insert("listvms", sysadm::Iohyve::listVMs());
|
||||
}
|
||||
|
||||
} //end of "action" key usage
|
||||
|
||||
//If nothing done - return the proper code
|
||||
if(!ok){
|
||||
return RestOutputStruct::BADREQUEST;
|
||||
}
|
||||
}else{ // if(in_args.isArray()){
|
||||
return RestOutputStruct::BADREQUEST;
|
||||
}
|
||||
return RestOutputStruct::OK;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ private:
|
||||
RestOutputStruct::ExitCode EvaluateDispatcherRequest(bool allaccess, const QJsonValue in_args, QJsonObject *out);
|
||||
// -- sysadm iocage API
|
||||
RestOutputStruct::ExitCode EvaluateSysadmIocageRequest(const QJsonValue in_args, QJsonObject *out);
|
||||
// -- sysadm iohyve API
|
||||
RestOutputStruct::ExitCode EvaluateSysadmIohyveRequest(const QJsonValue in_args, QJsonObject *out);
|
||||
// -- sysadm Network API
|
||||
RestOutputStruct::ExitCode EvaluateSysadmNetworkRequest(const QJsonValue in_args, QJsonObject *out);
|
||||
// -- sysadm LifePreserver API
|
||||
|
||||
@@ -4,6 +4,7 @@ CONFIG += c++11
|
||||
HEADERS += $${PWD}/sysadm-global.h \
|
||||
$${PWD}/sysadm-general.h \
|
||||
$${PWD}/sysadm-iocage.h \
|
||||
$${PWD}/sysadm-iohyve.h \
|
||||
$${PWD}/sysadm-lifepreserver.h \
|
||||
$${PWD}/sysadm-network.h \
|
||||
$${PWD}/sysadm-firewall.h \
|
||||
@@ -15,6 +16,7 @@ HEADERS += $${PWD}/sysadm-global.h \
|
||||
SOURCES += $${PWD}/NetDevice.cpp \
|
||||
$${PWD}/sysadm-general.cpp \
|
||||
$${PWD}/sysadm-iocage.cpp \
|
||||
$${PWD}/sysadm-iohyve.cpp \
|
||||
$${PWD}/sysadm-lifepreserver.cpp \
|
||||
$${PWD}/sysadm-network.cpp \
|
||||
$${PWD}/sysadm-firewall.cpp \
|
||||
|
||||
42
src/server/library/sysadm-iohyve.cpp
Normal file
42
src/server/library/sysadm-iohyve.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
//===========================================
|
||||
// PC-BSD source code
|
||||
// Copyright (c) 2016, PC-BSD Software/iXsystems
|
||||
// Available under the 3-clause BSD license
|
||||
// See the LICENSE file for full details
|
||||
//===========================================
|
||||
#include "sysadm-general.h"
|
||||
#include "sysadm-iohyve.h"
|
||||
#include "sysadm-global.h"
|
||||
|
||||
using namespace sysadm;
|
||||
|
||||
//PLEASE: Keep the functions in the same order as listed in pcbsd-general.h
|
||||
|
||||
// List the VMs on the box
|
||||
QJsonObject Iohyve::listVMs() {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList output = General::RunCommand("iohyve list").split("\n");
|
||||
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
if ( output.at(i).indexOf("VMM") != -1 )
|
||||
continue;
|
||||
|
||||
if ( output.at(i).isEmpty() )
|
||||
break;
|
||||
|
||||
QJsonObject vm;
|
||||
QString line = output.at(i).simplified();
|
||||
QString guest = line.section(" ", 0, 0);
|
||||
|
||||
vm.insert("vmm", line.section(" ", 1, 1));
|
||||
vm.insert("running", line.section(" ", 2, 2));
|
||||
vm.insert("rcboot", line.section(" ", 3, 3));
|
||||
vm.insert("description", line.section(" ", 4, -1));
|
||||
|
||||
retObject.insert(guest, vm);
|
||||
}
|
||||
|
||||
return retObject;
|
||||
}
|
||||
22
src/server/library/sysadm-iohyve.h
Normal file
22
src/server/library/sysadm-iohyve.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//===========================================
|
||||
// PC-BSD source code
|
||||
// Copyright (c) 2016, PC-BSD Software/iXsystems
|
||||
// Available under the 3-clause BSD license
|
||||
// See the LICENSE file for full details
|
||||
//===========================================
|
||||
#ifndef __PCBSD_LIB_UTILS_IOHYVE_H
|
||||
#define __PCBSD_LIB_UTILS_IOHYVE_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include "sysadm-global.h"
|
||||
|
||||
namespace sysadm{
|
||||
|
||||
class Iohyve{
|
||||
public:
|
||||
static QJsonObject listVMs();
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
TEMPLATE = app
|
||||
LANGUAGE = C++
|
||||
|
||||
CONFIG += qt warn_on release
|
||||
CONFIG += qt warn_off release
|
||||
QT = core network websockets concurrent
|
||||
|
||||
HEADERS += globals.h globals-qt.h \
|
||||
|
||||
Reference in New Issue
Block a user