Also moved all of the Host C++ code to C APIs.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
bootstrap.conf | 3 +
configure.ac | 2 +-
src/Makefile.am | 8 +-
src/host.c | 384 ++++++++++++++++++++++++++++++++++++++++++++++++
src/host.cpp | 123 ---------------
src/host.h | 45 ++++---
src/linux_platform.cpp | 174 ----------------------
src/linux_platform.h | 34 -----
src/main.cpp | 20 ++-
src/platform.cpp | 36 -----
src/platform.h | 77 ----------
src/qmf/hostagent.cpp | 7 +-
src/qmf/hostagent.h | 3 +-
src/tests/.gitignore | 1 +
14 files changed, 439 insertions(+), 478 deletions(-)
create mode 100644 src/host.c
delete mode 100644 src/host.cpp
delete mode 100644 src/linux_platform.cpp
delete mode 100644 src/linux_platform.h
delete mode 100644 src/platform.cpp
delete mode 100644 src/platform.h
diff --git a/bootstrap.conf b/bootstrap.conf
index 8d602c1..9157db4 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -18,6 +18,9 @@
# gnulib modules used by this package.
gnulib_modules="
maintainer-makefile
+malloc
+stdbool
+strcspn
strdup-posix
"
diff --git a/configure.ac b/configure.ac
index 9fda954..1dfdd80 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ dnl ---------------------------------------------------------------------
AC_PREREQ([2.65])
AC_INIT([Matahari], [0.1.0], [matahari(a)lists.fedorahosted.org])
-AC_CONFIG_SRCDIR([src/linux_platform.cpp])
+AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_MACRO_DIR([m4])
diff --git a/src/Makefile.am b/src/Makefile.am
index 20532b0..d9c277f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,14 +17,12 @@ generated_file_list = \
nodist_matahari_SOURCES = $(generated_file_list) $(first)
matahari_SOURCES = \
- host.cpp \
+ host.c \
host.h \
hostlistener.h \
- linux_platform.cpp \
- linux_platform.h \
main.cpp \
- platform.cpp \
- platform.h \
+ utils.c \
+ utils.h \
qmf/hostagent.cpp \
qmf/hostagent.h \
virtio/multiplexer.cpp \
diff --git a/src/host.c b/src/host.c
new file mode 100644
index 0000000..9fe9b09
--- /dev/null
+++ b/src/host.c
@@ -0,0 +1,384 @@
+/* host.c - Copyright (C) 2009 Red Hat, Inc.
+ * Written by Darryl L. Pierce <dpierce(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA. A copy of the GNU General Public License is
+ * also available at
http://www.gnu.org/copyleft/gpl.html.
+ */
+
+#include <config.h>
+#include "host.h"
+#include <libudev.h>
+
+#ifdef HAVE_LIBVIRT
+#include <libvirt/libvirt.h>
+#endif
+
+#include <pcre.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/sysinfo.h>
+#include <sys/utsname.h>
+#include "utils.h"
+
+#define MAX_UUID_LENGTH 128
+
+typedef struct _heartbeat_listener
+{
+ host_heartbeat_callback_t listener;
+ struct _heartbeat_listener* next;
+} heartbeat_listener_t;
+
+typedef struct _update_listener
+{
+ host_update_callback_t listener;
+ struct _update_listener* next;
+} update_listener_t;
+
+heartbeat_listener_t* _heartbeat_listeners = NULL;
+update_listener_t* _update_listeners = NULL;
+unsigned int _heartbeat_sequence = 0;
+char* _cpu_model = NULL;
+
+void
+host_register_heartbeat_listener(host_heartbeat_callback_t listener)
+{
+ heartbeat_listener_t* current =
+ (heartbeat_listener_t*)malloc(sizeof(heartbeat_listener_t));
+
+ current->listener = listener;
+ current->next = NULL;
+
+ if(_heartbeat_listeners)
+ {
+ heartbeat_listener_t* tail = _heartbeat_listeners;
+ while(tail->next) tail = tail->next;
+ tail->next = current;
+ }
+ else
+ {
+ _heartbeat_listeners = current;
+ }
+}
+
+void
+host_remove_heartbeat_listener(host_heartbeat_callback_t listener)
+{
+ heartbeat_listener_t* current = _heartbeat_listeners;
+ heartbeat_listener_t* last = NULL;
+
+ while(current)
+ {
+ if (current->listener == listener)
+ {
+ if(current == _heartbeat_listeners)
+ {
+ _heartbeat_listeners = current->next;
+ }
+ else
+ {
+ last->next = current->next;
+ current->next = NULL;
+ }
+
+ free(current);
+ current = NULL;
+ }
+ else
+ {
+ last = current;
+ current = current->next;
+ }
+ }
+}
+
+void
+host_register_update_listener(host_update_callback_t listener)
+{
+ update_listener_t* current =
+ (update_listener_t*)malloc(sizeof(update_listener_t));
+
+ current->listener = listener;
+ current->next = NULL;
+
+ if(_update_listeners)
+ {
+ update_listener_t* tail = _update_listeners;
+ while(tail->next) tail = tail->next;
+ tail->next = current;
+ }
+ else
+ {
+ _update_listeners = current;
+ }
+}
+
+void
+host_remove_update_listener(host_update_callback_t listener)
+{
+ update_listener_t* current = _update_listeners;
+ update_listener_t* last = NULL;
+
+ while(current)
+ {
+ if (current->listener == listener)
+ {
+ if(current == _update_listeners)
+ {
+ _update_listeners = current->next;
+ }
+ else
+ {
+ last->next = current->next;
+ current->next = NULL;
+ }
+
+ free(current);
+ current = NULL;
+ }
+ else
+ {
+ last = current;
+ current = current->next;
+ }
+ }
+}
+
+void
+host_update_event(void)
+{
+ time_t __time;
+ time(&__time);
+
+ heartbeat_listener_t* _heartbeat_current = _heartbeat_listeners;
+
+ while(_heartbeat_current)
+ {
+ _heartbeat_current->listener((unsigned long)time, _heartbeat_sequence);
+ _heartbeat_current = _heartbeat_current->next;
+ }
+
+ update_listener_t* _update_current= _update_listeners;
+
+ while(_update_current)
+ {
+ _update_current->listener();
+ _update_current = _update_current->next;
+ }
+}
+
+char*
+host_get_uuid(void)
+{
+ static char* _uuid = NULL;
+
+ if(_uuid == NULL)
+ {
+ _uuid = (char*)malloc(MAX_UUID_LENGTH);
+#ifdef __linux__
+ FILE* input;
+
+ if( (input = fopen("/var/lib/dbus/machine-id", "r")) != NULL)
+ {
+ fscanf(input, "%s", _uuid);
+ fclose(input);
+ }
+#else
+ return "UNDEFINED";
+#endif
+ }
+
+ return _uuid;
+}
+
+char*
+host_get_hostname(void)
+{
+ char* result = NULL;
+
+#ifdef __linux__
+ struct utsname details;
+
+ if(!uname(&details))
+ {
+ result = (char*)malloc(strlen(details.nodename) + 1);
+ strcpy(result, details.nodename);
+ }
+#else
+
+#endif
+
+ return result;
+}
+
+char*
+host_get_hypervisor(void)
+{
+ static char* _hypervisor = NULL;
+
+ if(_hypervisor == NULL)
+ {
+#ifdef HAVE_LIBVIRT
+ virConnectPtr lvconn = virConnectOpenReadOnly(NULL);
+
+ if(lvconn)
+ {
+ const char* __hv = virConnectGetType(lvconn);
+ _hypervisor = (char*)malloc(strlen(__hv) + 1);
+ strcpy(_hypervisor, __hv);
+ virConnectClose(lvconn);
+ }
+#endif
+ }
+
+ return _hypervisor;
+}
+
+char*
+host_get_architecture(void)
+{
+ static char* _arch = NULL;
+
+ if(_arch == NULL)
+ {
+#ifdef __linux__
+ struct utsname details;
+
+ if(!uname(&details))
+ {
+ _arch = (char*)malloc(strlen(details.machine) + 1);
+ strcpy(_arch, details.machine);
+ }
+#else
+#endif
+ }
+
+ return _arch;
+}
+
+unsigned int
+host_get_memory(void)
+{
+ static int _memory = 0;
+
+ if(!_memory)
+ {
+#ifdef __linux__
+
+ struct sysinfo sysinf;
+ if(!sysinfo(&sysinf))
+ {
+ _memory = sysinf.totalram / 1024L;
+ }
+
+#else
+
+#endif
+ }
+
+ return _memory;
+}
+
+bool
+_found_cpu_model(char* line, int offset, int* matches)
+{
+ char* value;
+
+ value = line + matches[1];
+ _cpu_model = (char*)malloc(strlen(value) + 1);
+ strcpy(_cpu_model, value);
+
+ return true;
+}
+
+char*
+host_get_cpu_model(void)
+{
+ if(_cpu_model == NULL)
+ {
+#ifdef __linux__
+
+ search_file("/proc/cpuinfo", "model name.*:\\w*(\\S*)",
+ _found_cpu_model);
+
+#else
+
+#endif
+ }
+ return _cpu_model;
+}
+
+unsigned int
+host_get_number_of_cpu_cores(void)
+{
+ static unsigned int _cores = 0;
+
+ if(_cores == 0)
+ {
+#ifdef __linux__
+
+ struct udev* udev = udev_new();
+ struct udev_enumerate* enumerator = udev_enumerate_new(udev);
+
+ udev_enumerate_add_match_property(enumerator, "DRIVER",
"processor");
+ if(!udev_enumerate_scan_devices(enumerator))
+ {
+ struct udev_list_entry* entries =
+ udev_enumerate_get_list_entry(enumerator);
+ struct udev_list_entry* entry;
+
+ udev_list_entry_foreach(entry, entries)
+ {
+ _cores++;
+ }
+ }
+
+ udev_enumerate_unref(enumerator);
+ udev_unref(udev);
+
+#else
+
+#endif
+ }
+
+ return _cores;
+}
+
+double
+host_get_load_average(void)
+{
+ double result = 0.0;
+
+#ifdef __linux__
+
+ getloadavg(&result, 1);
+
+#else
+
+#endif
+
+ return result;
+}
+
+void
+host_reboot(void)
+{
+}
+
+void
+host_shutdown(void)
+{
+}
diff --git a/src/host.cpp b/src/host.cpp
deleted file mode 100644
index dfb83f5..0000000
--- a/src/host.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/* host.cpp - Copyright (C) 2009 Red Hat, Inc.
- * Written by Arjun Roy <arroy(a)redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at
http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include <config.h>
-#include "host.h"
-
-#include "platform.h"
-#include <set>
-
-using namespace std;
-
-set<HostListener*> _listeners;
-unsigned int _heartbeat_sequence;
-
-void
-host_register_listener(HostListener* listener)
-{
- _listeners.insert(listener);
-}
-
-void
-host_remove_listener(HostListener* listener)
-{
- _listeners.erase(listener);
-}
-
-void
-host_update_event()
-{
- _heartbeat_sequence++;
-
- time_t __time;
- time(&__time);
-
- for(set<HostListener*>::iterator iter = _listeners.begin();
- iter != _listeners.end();
- iter++)
- {
- (*iter)->heartbeat((unsigned long)__time,
- _heartbeat_sequence);
- }
-
- for(set<HostListener*>::iterator iter = _listeners.begin();
- iter != _listeners.end();
- iter++)
- {
- (*iter)->updated();
- }
-}
-
-string
-host_get_uuid()
-{
- return Platform::instance()->getUUID();
-}
-
-string
-host_get_hostname()
-{
- return Platform::instance()->getHostname();
-}
-
-string
-host_get_hypervisor()
-{
- return Platform::instance()->getHypervisor();
-}
-
-string
-host_get_architecture()
-{
- return Platform::instance()->getArchitecture();
-}
-
-unsigned int
-host_get_memory()
-{
- return Platform::instance()->getMemory();
-}
-
-string
-host_get_cpu_model()
-{
- return Platform::instance()->getCPUModel();
-}
-
-unsigned int
-host_get_number_of_cpu_cores()
-{
- return Platform::instance()->getNumberOfCPUCores();
-}
-
-double
-host_get_load_average()
-{
- return Platform::instance()->getLoadAverage();
-}
-
-void
-host_reboot()
-{
-}
-
-void
-host_shutdown()
-{
-}
diff --git a/src/host.h b/src/host.h
index dab88ad..f860a76 100644
--- a/src/host.h
+++ b/src/host.h
@@ -20,39 +20,48 @@
* also available at
http://www.gnu.org/copyleft/gpl.html.
*/
-#include <string>
-#include <set>
+#ifdef __cplusplus
+extern "C"
+{
+#endif
-#include "hostlistener.h"
+ typedef void(*host_heartbeat_callback_t)(unsigned long, unsigned int);
+ typedef void(*host_update_callback_t)(void);
-using namespace std;
+ void host_register_heartbeat_listener(host_heartbeat_callback_t listener);
-void host_register_listener(HostListener* listener);
+ void host_remove_heartbeat_listener(host_heartbeat_callback_t listener);
-void host_remove_istener(HostListener* listener);
+ void host_register_update_listener(host_update_callback_t listener);
-void host_update_event();
+ void host_remove_update_listener(host_update_callback_t listener);
-string host_get_uuid();
+ void host_update_event(void);
-string host_get_hostname();
+ char* host_get_uuid(void);
-string host_get_hypervisor();
+ char* host_get_hostname(void);
-string host_get_architecture();
+ char* host_get_hypervisor(void);
-unsigned int host_get_memory();
+ char* host_get_architecture(void);
-string host_get_cpu_model();
+ unsigned int host_get_memory(void);
-unsigned int host_get_number_of_cpu_cores();
+ char* host_get_cpu_model(void);
-double host_get_load_average();
+ unsigned int host_get_number_of_cpu_cores(void);
-void host_identify(const unsigned int iterations);
+ double host_get_load_average(void);
-void host_shutdown();
+ void host_identify(const unsigned int iterations);
-void host_reboot();
+ void host_shutdown(void);
+
+ void host_reboot(void);
+
+#ifdef __cplusplus
+}
+#endif
#endif // __HOST_H
diff --git a/src/linux_platform.cpp b/src/linux_platform.cpp
deleted file mode 100644
index 8b70f37..0000000
--- a/src/linux_platform.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/* linux_platform.cpp - Copyright (C) 2010 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce(a)redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at
http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include <config.h>
-#include <fstream>
-#include <iomanip>
-#include <iostream>
-#include <dirent.h>
-#include <libvirt/libvirt.h>
-#include <net/if.h>
-#include <pcre.h>
-#include <stdexcept>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/sysinfo.h>
-#include <sys/utsname.h>
-
-using namespace std;
-
-// TODO remove this wrapper once rhbz#583747 is fixed
-extern "C" {
-#include <libudev.h>
-}
-
-#include "linux_platform.h"
-
-using namespace std;
-
-LinuxPlatform::LinuxPlatform()
-{
- struct utsname details;
- ifstream *input;
-
- input = new ifstream("/var/lib/dbus/machine-id");
-
- if(input->is_open())
- {
- string uuid;
-
- getline(*input, uuid);
- input->close();
- delete input;
- this->setUUID(uuid);
- }
-
- if(!uname(&details))
- {
- this->setHostname(string(details.nodename));
- this->setArchitecture(string(details.machine));
- }
- else
- {
- throw runtime_error("Unable to retrieve system details");
- }
-
- virConnectPtr lvconn = virConnectOpenReadOnly(NULL);
-
- if(lvconn)
- {
- this->setHypervisor(string(virConnectGetType(lvconn)));
- virConnectClose(lvconn);
- }
-
- struct sysinfo sysinf;
- if(!sysinfo(&sysinf))
- {
- this->setMemory(sysinf.totalram / 1024L);
- }
- else
- {
- throw runtime_error("Unable to retrieve system memory details.");
- }
-
- int cpu_count = 0;
-
- struct udev* udev = udev_new();
- struct udev_enumerate* enumerator = udev_enumerate_new(udev);
-
- udev_enumerate_add_match_property(enumerator, "DRIVER",
"processor");
- if(!udev_enumerate_scan_devices(enumerator))
- {
- struct udev_list_entry* entries = udev_enumerate_get_list_entry(enumerator);
- struct udev_list_entry* entry;
-
- udev_list_entry_foreach(entry, entries)
- {
- cpu_count++;
- }
- setNumberOfCPUCores(cpu_count);
- }
-
- udev_enumerate_unref(enumerator);
- udev_unref(udev);
-
- input = new ifstream("/proc/cpuinfo");
-
- if(input->is_open())
- {
- string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)";
- int expected = 3;
- int found[expected * 3];
- const char* pcre_error;
- int pcre_error_offset;
- pcre* regex;
- bool done = false;
- bool started = false;
-
- regex = pcre_compile(regexstr.c_str(), 0, &pcre_error, &pcre_error_offset,
NULL);
- if(!regex) { throw runtime_error("Unable to compile regular
expression."); }
-
- while(!input->eof() && !done)
- {
- string line;
-
- getline(*input, line);
- int match = pcre_exec(regex, NULL, line.c_str(), line.length(),
- 0, PCRE_NOTEMPTY,found, expected * 3);
-
- if(match == expected)
- {
- string name = line.substr(found[2], found[3] - found[2]);
- string value = line.substr(found[4], found[5] - found[4]);
-
- // if we're at a second processor and we've already started, then
we're done
- if (name == "processor")
- {
- if (started)
- {
- done = true;
- }
- else
- {
- started = true;
- }
- }
- else
- {
- if(name == "model name") setCPUModel(value);
- }
- }
- }
- input->close();
- delete input;
- }
-}
-
-double
-LinuxPlatform::getLoadAverage() const
-{
- double load_average;
- ifstream input;
-
- input.open("/proc/loadavg", ios::in);
- input >> load_average;
- input.close();
-
- return load_average;
-}
diff --git a/src/linux_platform.h b/src/linux_platform.h
deleted file mode 100644
index de9664a..0000000
--- a/src/linux_platform.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __LINUX_PLATFORM_H
-#define __LINUX_PLATFORM_H
-
-/* linux_platform.h - Copyright (C) 2010 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce(a)redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at
http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include "platform.h"
-
-class LinuxPlatform : public Platform
-{
- public:
- LinuxPlatform();
- virtual ~LinuxPlatform() {}
-
- virtual double getLoadAverage() const;
-};
-
-#endif
diff --git a/src/main.cpp b/src/main.cpp
index 27b2434..1748e12 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,6 +43,8 @@ using namespace qpid::client;
using namespace std;
namespace _qmf = qmf::com::redhat::matahari;
+HostAgent _hostAgent;
+
// Global Variables
ManagementAgent::Singleton* singleton;
@@ -52,6 +54,17 @@ shutdown(int /*signal*/)
exit(0);
}
+void
+send_host_heartbeat_via_qmf(unsigned long time, unsigned int sequence)
+{
+ _hostAgent.heartbeat(time, sequence);
+}
+
+void send_host_update_via_qmf(void)
+{
+ _hostAgent.updated();
+}
+
static void
print_usage()
{
@@ -80,7 +93,6 @@ main(int argc, char **argv)
ConnectionSettings settings;
ManagementAgent *agent;
- HostAgent hostAgent;
struct option opt[] = {
{"help", no_argument, NULL, 'h'},
@@ -181,8 +193,10 @@ main(int argc, char **argv)
agent->init(settings, 5, false, ".magentdata");
- // Get the info and post it to the broker
- hostAgent.setup(agent);
+ // setup the host agent
+ host_register_heartbeat_listener(send_host_heartbeat_via_qmf);
+ host_register_update_listener(send_host_update_via_qmf);
+ _hostAgent.setup(agent);
while(1)
{
diff --git a/src/platform.cpp b/src/platform.cpp
deleted file mode 100644
index 087cf2a..0000000
--- a/src/platform.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/* platform.cpp - Copyright (C) 2010 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce(a)redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at
http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include <config.h>
-#include "platform.h"
-#include "linux_platform.h"
-
-Platform* Platform::_instance = 0;
-
-Platform*
-Platform::instance()
-{
- // TODO this is where we decide which implementation to use
- if(!_instance)
- {
- _instance = new LinuxPlatform;
- }
-
- return _instance;
-}
diff --git a/src/platform.h b/src/platform.h
deleted file mode 100644
index 7c0eb91..0000000
--- a/src/platform.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef __PLATFORM_H
-#define __PLATFORM_H
-
-/* platform.h - Copyright (C) 2010 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce(a)redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at
http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include <string>
-#include <vector>
-
-using namespace std;
-
-/*
- * Platform defines a type that provides platform-specific details.
- *
- * Implementations provide the specific details needed by the
- * various agents at runtime.
- */
-class Platform
-{
- private:
- static Platform* _instance;
-
- string _uuid;
- string _hostname;
- string _hypervisor;
- string _architecture;
- unsigned int _memory;
-
- string _cpu_model;
- unsigned int _cpu_cores;
-
- protected:
- Platform() {}
- virtual~ Platform() {}
-
- void setUUID(const string uuid) { _uuid = uuid; }
- void setHostname(const string hostname) { _hostname = hostname; }
- void setHypervisor(const string hypervisor) { _hypervisor = hypervisor; }
- void setArchitecture(const string arch) { _architecture = arch; }
- void setMemory(unsigned int memory) { _memory = memory; }
-
- void setCPUModel(const string model) { _cpu_model = model; }
- void setNumberOfCPUCores(const int cores) { _cpu_cores = cores; }
-
- public:
- // the singleton instance
- static Platform* instance();
-
- string getUUID() const { return _uuid; }
- string getHostname() const { return _hostname; }
- string getHypervisor() const { return _hypervisor; }
- string getArchitecture() const { return _architecture; }
- unsigned int getMemory() const { return _memory; }
-
- string getCPUModel() const { return _cpu_model; }
- unsigned int getNumberOfCPUCores() const { return _cpu_cores; }
-
- virtual double getLoadAverage() const = 0;
-};
-
-#endif
diff --git a/src/qmf/hostagent.cpp b/src/qmf/hostagent.cpp
index 94004d5..0e9a2a3 100644
--- a/src/qmf/hostagent.cpp
+++ b/src/qmf/hostagent.cpp
@@ -24,13 +24,10 @@
#include "qmf/com/redhat/matahari/EventHeartbeat.h"
HostAgent::HostAgent()
-{
- host_register_listener(this);
-}
+{}
HostAgent::~HostAgent()
-{
-}
+{}
void
HostAgent::setup(ManagementAgent* agent)
diff --git a/src/qmf/hostagent.h b/src/qmf/hostagent.h
index 7f7bbaa..6744400 100644
--- a/src/qmf/hostagent.h
+++ b/src/qmf/hostagent.h
@@ -24,7 +24,6 @@
#include <string>
#include "host.h"
-#include "hostlistener.h"
#include "qmf/com/redhat/matahari/Host.h"
@@ -33,7 +32,7 @@ using namespace std;
namespace _qmf = qmf::com::redhat::matahari;
-class HostAgent : public Manageable, public HostListener
+class HostAgent : public Manageable
{
private:
_qmf::Host* _management_object;
diff --git a/src/tests/.gitignore b/src/tests/.gitignore
index 6d437f4..456f85d 100644
--- a/src/tests/.gitignore
+++ b/src/tests/.gitignore
@@ -1,2 +1,3 @@
+testdatahandler
testhostapis
testmultiplexer
--
1.7.0.1