2015-06-24 15:19:40 +03:00
/* -------------------------------------------------------------------------- */
2015-09-23 16:03:22 +03:00
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
2015-06-24 15:19:40 +03:00
/* */
/* 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 <string.h>
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 ;
} ;
2015-07-09 15:02:28 +03:00
char remove_state ( )
2015-06-24 15:19:40 +03:00
{
string state_str ;
get ( " STATE " , state_str ) ;
2015-07-09 15:02:28 +03:00
erase ( " STATE " ) ;
2015-06-24 15:19:40 +03:00
if ( state_str . empty ( ) )
{
return ' - ' ;
}
return state_str [ 0 ] ;
} ;
} ;
# endif