From 34b388277d4135dd613b751310e482fe9ca8d95e Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 2 Aug 2017 11:14:38 -0400 Subject: [PATCH] [API CHANGE] Add a new "action" for sysadm/systemmanager "action"="deviceinfo" will return the full information about all devices attached to the system (via `pciconf -lv`) ------------------- REST Request (example): ------------------------------- PUT /sysadm/systemmanager { "action" : "deviceinfo" } WebSocket Request: ------------------------------- { "id" : "fooid", "name" : "systemmanager", "namespace" : "sysadm", "args" : { "action" : "deviceinfo" } } Response: ------------------------------- { "args": { "deviceinfo": { "ahci0": { "class": "mass storage", "device": "8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]", "subclass": "SATA", "vendor": "Intel Corporation" }, "ehci0": { "class": "serial bus", "device": "8 Series/C220 Series Chipset Family USB EHCI", "subclass": "USB", "vendor": "Intel Corporation" }, "ehci1": { "class": "serial bus", "device": "8 Series/C220 Series Chipset Family USB EHCI", "subclass": "USB", "vendor": "Intel Corporation" }, "hdac0": { "class": "multimedia", "subclass": "HDA", "vendor": "NVIDIA Corporation" }, "hdac1": { "class": "multimedia", "device": "8 Series/C220 Series Chipset High Definition Audio Controller", "subclass": "HDA", "vendor": "Intel Corporation" }, "hostb0": { "class": "bridge", "device": "4th Gen Core Processor DRAM Controller", "subclass": "HOST-PCI", "vendor": "Intel Corporation" }, "isab0": { "class": "bridge", "device": "B85 Express LPC Controller", "subclass": "PCI-ISA", "vendor": "Intel Corporation" }, "none0": { "class": "simple comms", "device": "8 Series/C220 Series Chipset Family MEI Controller", "vendor": "Intel Corporation" }, "none1": { "class": "serial bus", "device": "8 Series/C220 Series Chipset Family SMBus Controller", "subclass": "SMBus", "vendor": "Intel Corporation" }, "pcib1": { "class": "bridge", "device": "Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller", "subclass": "PCI-PCI", "vendor": "Intel Corporation" }, "pcib2": { "class": "bridge", "device": "8 Series/C220 Series Chipset Family PCI Express Root Port", "subclass": "PCI-PCI", "vendor": "Intel Corporation" }, "pcib3": { "class": "bridge", "device": "8 Series/C220 Series Chipset Family PCI Express Root Port", "subclass": "PCI-PCI", "vendor": "Intel Corporation" }, "pcib4": { "class": "bridge", "device": "8 Series/C220 Series Chipset Family PCI Express Root Port", "subclass": "PCI-PCI", "vendor": "Intel Corporation" }, "pcib5": { "class": "bridge", "device": "82801 PCI Bridge", "subclass": "PCI-PCI", "vendor": "Intel Corporation" }, "re0": { "class": "network", "device": "RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller", "subclass": "ethernet", "vendor": "Realtek Semiconductor Co., Ltd." }, "vgapci0": { "class": "display", "device": "GM206 [GeForce GTX 960]", "subclass": "VGA", "vendor": "NVIDIA Corporation" }, "xhci0": { "class": "serial bus", "device": "8 Series/C220 Series Chipset Family USB xHCI", "subclass": "USB", "vendor": "Intel Corporation" } } }, "id": "fooid", "name": "response", "namespace": "sysadm" } --- src/server/WebBackend.cpp | 26 ++++++++++++--------- src/server/library/sysadm-pkg.cpp | 10 ++++---- src/server/library/sysadm-systemmanager.cpp | 26 ++++++++++++++++++++- src/server/library/sysadm-systemmanager.h | 4 +++- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/server/WebBackend.cpp b/src/server/WebBackend.cpp index 98a4f10..8bcd889 100644 --- a/src/server/WebBackend.cpp +++ b/src/server/WebBackend.cpp @@ -529,50 +529,54 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmSystemMgmtRequest(const QJso ok = true; out->insert("batteryinfo", sysadm::SysMgmt::batteryInfo()); } - if(act=="cpupercentage"){ + else if(act=="cpupercentage"){ ok = true; out->insert("cpupercentage", sysadm::SysMgmt::cpuPercentage()); } - if(act=="cputemps"){ + else if(act=="cputemps"){ ok = true; out->insert("cputemps", sysadm::SysMgmt::cpuTemps()); } - if(act=="externalmounts"){ + else if(act=="externalmounts"){ ok = true; out->insert("externalmounts", sysadm::SysMgmt::externalDevicePaths()); } - if(act=="halt"){ + else if(act=="halt"){ ok = true; out->insert("halt", sysadm::SysMgmt::systemHalt()); } - if(act=="killproc"){ + else if(act=="killproc"){ ok = true; out->insert("killproc", sysadm::SysMgmt::killProc(in_args.toObject())); } - if(act=="memorystats"){ + else if(act=="memorystats"){ ok = true; out->insert("memorystats", sysadm::SysMgmt::memoryStats()); } - if(act=="procinfo"){ + else if(act=="procinfo"){ ok = true; out->insert("procinfo", sysadm::SysMgmt::procInfo()); } - if(act=="reboot"){ + else if(act=="reboot"){ ok = true; out->insert("reboot", sysadm::SysMgmt::systemReboot()); } - if(act=="setsysctl"){ + else if(act=="setsysctl"){ ok = true; out->insert("setsysctl", sysadm::SysMgmt::setSysctl(in_args.toObject())); } - if(act=="sysctllist"){ + else if(act=="sysctllist"){ ok = true; out->insert("sysctllist", sysadm::SysMgmt::sysctlList()); } - if(act=="systeminfo"){ + else if(act=="systeminfo"){ ok = true; out->insert("systeminfo", sysadm::SysMgmt::systemInfo()); } + else if(act=="deviceinfo"){ + ok = true; + out->insert("deviceinfo", sysadm::SysMgmt::systemDevices()); + } } //end of "action" key usage diff --git a/src/server/library/sysadm-pkg.cpp b/src/server/library/sysadm-pkg.cpp index 1333518..2536b61 100644 --- a/src/server/library/sysadm-pkg.cpp +++ b/src/server/library/sysadm-pkg.cpp @@ -385,8 +385,10 @@ QJsonArray PKG::list_repos(bool updated){ } QJsonObject PKG::evaluateInstall(QStringList origins, QString repo){ - qDebug() << "Verify Install:" << origins << repo; + //qDebug() << "Verify Install:" << origins << repo; QJsonObject out; + out.insert("install_origins", QJsonArray::fromStringList(origins) ); + out.insert("repo", repo); if(repo=="local" || origins.isEmpty()){ return out; } //nothing to do QString dbconn = openDB(repo); QString ldbconn = openDB("local"); @@ -418,14 +420,14 @@ QJsonObject PKG::evaluateInstall(QStringList origins, QString repo){ for(int i=0; i