parent
9c40400d26
commit
427aab95ea
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"unordered_set": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,10 @@
|
|||||||
#ifndef JSON_UTILS_H
|
#ifndef JSON_UTILS_H
|
||||||
#define JSON_UTILS_H
|
#define JSON_UTILS_H
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
#include <json/retrieve.h>
|
||||||
JsonObject getNode(String name, JsonArray nodes);
|
//JsonObject getNode(String name, JsonArray nodes);
|
||||||
JsonObject getContainer(int id, JsonArray containers);
|
Node getNode(String name);
|
||||||
|
Container getContainer(int id, String node);
|
||||||
|
VM getVM(int id, String node);
|
||||||
|
|
||||||
#endif /* JSON_UTILS_H */
|
#endif /* JSON_UTILS_H */
|
||||||
|
|||||||
@ -1,27 +1,52 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
#include <json/utils.h>
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
/**
|
Node getNode(String name)
|
||||||
Get a specific node from an array of nodes
|
{
|
||||||
*/
|
int numNodes;
|
||||||
JsonObject getNode(String name, JsonArray nodes) {
|
|
||||||
for (JsonObject node : nodes) {
|
Node *nodes = getNodeInfo(&numNodes);
|
||||||
if (node["node"] == name) {
|
for (int i = 0; i < numNodes; i++)
|
||||||
return node;
|
{
|
||||||
|
if (nodes[i].name == name)
|
||||||
|
{
|
||||||
|
return nodes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::runtime_error("Can't find the requested node in the array");
|
||||||
|
}
|
||||||
|
|
||||||
|
Container getContainer(int id, String node)
|
||||||
|
{
|
||||||
|
|
||||||
|
int numContainers;
|
||||||
|
Container *containers = getContainerInfo(&numContainers, node);
|
||||||
|
for (int i = 0; i < numContainers; i++)
|
||||||
|
{
|
||||||
|
if (containers[i].id == id)
|
||||||
|
{
|
||||||
|
return containers[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayError("Node not found!");
|
|
||||||
|
|
||||||
|
throw std::runtime_error("Can't find the requested container in the array");
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject getContainer(int id, JsonArray containers) {
|
VM getVM(int id, String node)
|
||||||
for (JsonObject container : containers) {
|
{
|
||||||
Serial.println(id);
|
int numVMs;
|
||||||
Serial.println(container["vmid"].as<int>());
|
|
||||||
if (container["vmid"].as<int>() == id) {
|
VM *vms = getVMInfo(&numVMs, node);
|
||||||
return container;
|
for (int i = 0; i < numVMs; i++)
|
||||||
|
{
|
||||||
|
if (vms[i].id == id)
|
||||||
|
{
|
||||||
|
return vms[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayError("Machine not found!");
|
|
||||||
|
|
||||||
|
throw std::runtime_error("Can't find the requested vm in the array");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue