mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 18:20:23 +00:00
[API CHANGE] Add a new action for sysadm/network class:
"action" = "list-settings"
List all the settings for network devices that are saved in /etc/rc.conf
-----------------
REST Request (example):
-------------------------------
PUT /sysadm/network
{
"action" : "list-settings"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"namespace" : "sysadm",
"args" : {
"action" : "list-settings"
},
"name" : "network"
}
Response:
-------------------------------
{
"args": {
"lo0": {
"associated_device": "",
"device": "lo0",
"static_gateway": "",
"static_ipv4": "",
"static_ipv6": "",
"static_netmask": "",
"use_dhcp": "false"
},
"re0": {
"associated_device": "",
"device": "re0",
"static_gateway": "",
"static_ipv4": "",
"static_ipv6": "",
"static_netmask": "",
"use_dhcp": "true"
},
"ue0": {
"associated_device": "",
"device": "ue0",
"static_gateway": "",
"static_ipv4": "",
"static_ipv6": "",
"static_netmask": "",
"use_dhcp": "true"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -409,9 +409,9 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmNetworkRequest(const QJsonVa
|
||||
bool ok = false;
|
||||
if(keys.contains("action")){
|
||||
QString act = JsonValueToString(in_args.toObject().value("action"));
|
||||
QStringList devs = sysadm::NetDevice::listNetDevices();
|
||||
if(act=="list-devices"){
|
||||
ok = true;
|
||||
QStringList devs = sysadm::NetDevice::listNetDevices();
|
||||
for(int i=0; i<devs.length(); i++){
|
||||
sysadm::NetDevice D(devs[i]);
|
||||
QJsonObject obj;
|
||||
@@ -428,6 +428,30 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmNetworkRequest(const QJsonVa
|
||||
//Add this device info to the main output structure
|
||||
out->insert(devs[i], obj);
|
||||
}
|
||||
|
||||
}else if(act=="list-settings"){
|
||||
ok = true;
|
||||
for(int i=0; i<devs.length(); i++){
|
||||
sysadm::NetDevSettings D = sysadm::Network::deviceRCSettings(devs[i]);
|
||||
QJsonObject obj;
|
||||
//assemble the information about this device into an output object
|
||||
obj.insert("device", D.device);
|
||||
obj.insert("associated_device", D.asDevice);
|
||||
obj.insert("use_dhcp", D.useDHCP ? "true" : "false" );
|
||||
obj.insert("static_ipv4", D.staticIPv4);
|
||||
obj.insert("static_ipv6", D.staticIPv6);
|
||||
obj.insert("static_netmask", D.staticNetmask);
|
||||
obj.insert("static_gateway", D.staticGateway);
|
||||
if(D.wifihost){
|
||||
obj.insert("wifi_country", D.wifiCountry);
|
||||
obj.insert("wifi_ssid", D.wifiSSID);
|
||||
obj.insert("wifi_bssid", D.wifiBSSID);
|
||||
obj.insert("wifi_channel", D.wifiChannel);
|
||||
obj.insert("wifi_secure_only", D.wifisecurity ? "true" : "false");
|
||||
}
|
||||
//Add this device info to the main output structure
|
||||
out->insert(devs[i], obj);
|
||||
}
|
||||
}
|
||||
|
||||
} //end of "action" key usage
|
||||
|
||||
Reference in New Issue
Block a user