From 83a4165fffc1b18765d67623f9b067bf80d37ef8 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 24 Jun 2015 14:19:40 +0200 Subject: [PATCH] feature #3718: Added missing include file --- include/VirtualMachineMonitorInfo.h | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 include/VirtualMachineMonitorInfo.h diff --git a/include/VirtualMachineMonitorInfo.h b/include/VirtualMachineMonitorInfo.h new file mode 100644 index 0000000000..464f99da04 --- /dev/null +++ b/include/VirtualMachineMonitorInfo.h @@ -0,0 +1,76 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +#ifndef VIRTUAL_MACHINE_MONITOR_INFO_H_ +#define VIRTUAL_MACHINE_MONITOR_INFO_H_ + +#include "Template.h" + +#include + +using namespace std; + +/** + * Virtual Machine Monitor class, stores the monitor data for the VM + */ +class VirtualMachineMonitorInfo : public Template +{ +public: + VirtualMachineMonitorInfo():Template(false,'=',"MONITORING"){}; + + ~VirtualMachineMonitorInfo(){}; + + /** + * Update the monitoring information with data from the probes + * @param monitor_data of the VM + * @param error description if any + * @return 0 on success + */ + int update(const string& monitor_data, string& error) + { + char * error_c = 0; + + clear(); + + int rc = parse(monitor_data, &error_c); + + if (rc != 0) + { + error = error_c; + + free(error_c); + } + + return rc; + }; + + char get_state() const + { + string state_str; + + get("STATE", state_str); + + if (state_str.empty()) + { + return '-'; + } + + return state_str[0]; + }; +}; + +#endif +