Re: [Matahari] [cloud-apis] matahari apis for virt
by Perry Myers
cross-posting to matahari list, since this discussion is more about
matahari implementation rather than the apis themselves.
On 07/22/2010 10:01 AM, Perry Myers wrote:
> On 07/22/2010 03:25 AM, Andrew Beekhof wrote:
>>
>> ----- "Daniel P. Berrange"<berrange(a)redhat.com> wrote:
>>
>>> On Wed, Jul 21, 2010 at 03:20:30PM -0400, Darryl L. Pierce wrote:
>>>> (respond long time coming)
>>>>
>>>> On Wed, Jun 16, 2010 at 09:16:10AM +0100, Daniel P. Berrange wrote:
>>>>> As I mention above though, the single daemon model is really bad
>>> when
>>>>> you come to write SELinux policy, because it makes it near
>>> impossible
>>>>> to lock down its access. I know we have this model with libvirtd
>>> already
>>>>> and this is one of its core flaws. One day libvirtd is going to
>>> have to
>>>>> be split into libvirtd-hypervisor, libvirtd-network,
>>> libvirtd-storage,
>>>>> etc, so that we can actually write a usable SELinux policy for
>>> it.
>>>>
>>>> I exchanged emails with Dan Walsh on this and we can have one
>>> daemon
>>>> spawn multiple processes, each running in a separate SELinux
>>> context
>>>> with the appropriate restrictions on each. So don't need to have
>>>> multiple Matahari daemons running to have proper access control.
>>>
>>> I don't see any difference from what I described, besides the
>>> change in terminology s/daemon/process/ ? Once you're spawning
>>> processes, rather than just creating threads you're in the model
>>> I proposed[1].
>>>
>>> Regards,
>>> Daniel
>>>
>>> [1] Ok in theory you can fork, but not then execve a new binary but
>>> that way is a rather hairy approach because you end up with
>>> many of the disadvantages of both the threads& processes models.
>>
>> Agreed.
>> Fork without exec would mean we're still using a single selinux context
>> for everything.
>>
>> I think the main alternatives here are:
>>
>> a) Matahari fork+exec's one short-lived child per job, possibly passing
>> job details via the command line or environment.
>>
>> b) A Matahari daemon that fork+exec's N long-lived children at startup
>> and gives them jobs via ipc
>>
>> c) The Matahari init script kicks of N long-lived daemons at startup and
>> they receive jobs via qpid
>>
>>
>> 'a' is not particularly performance friendly (and can have security
>> implications) and 'b' is re-implementing a stripped down qpid broker.
>>
>> So on balance, I think c) is probably the most preferrable approach and
>> if I understood correctly, pretty much what Daniel was proposing.
>
> Ack on using option C, though if we're doing this then having 'n' init
> scripts does make more sense (as danpb indicated). I had written up an
> email in parallel coming up with the same analysis, but you beat me to it. :)
>
> What this means is that we have the follow architecture:
>
> * On Linux:
> * matahari is an SRPM that has several binary RPM subpackages:
> matahari-net, matahari-host, matahari-pkg, matahari-services, etc
> * The matahari binary RPM might just be common libraries that are
> shared between the various other RPMs/daemons
> * Each other RPM has it's own:
> * daemon that connects to QMF bus as an agent
> * init script to start stop that particular daemon
> * selinux policy specific to what that portion of matahari needs to do
> * On Windows:
> * init script == Windows Service, so one Windows Service for each of
> matahari-net, matahari-host, etc
> * Each of these Windows Services is an independent QMF agent
> * We don't want 'n' Windows installers, since they don't have nice RPM
> and yum functionality. So where Linux will have matahari-* for each
> service, we'll have a single 'matahari installer' for Windows that
> installs all of the services. Admin can deactivate services they
> don't want to use
>
> Questions:
> Do we have each Agent connect to a single qpid broker installed on the
> guest, and then all we need to do is connect that broker to an external
> broker outside of the guest? This would make configuration much easier,
> all of the various matahari daemons/services could connect to a static
> configuration for the local broker, and then the only place with custom
> config would be chaining the local broker to the other external brokers?
>
> Can the single guest broker that we have connect to both an external
> network broker and also connect over virtio-serial to the host broker? Or
> do we need two guest brokers, one to handle network based QMF and one to
> handle virtio-serial based QMF?
>
> Perry
>
> _______________________________________________
> cloud-apis mailing list
> cloud-apis(a)redhat.com
> https://www.redhat.com/mailman/listinfo/cloud-apis
13 years, 10 months
Status of mingw32 cross-compile
by Ryan O'Hara
I've been working on building Matahari for Windows using the mingw32
cross-compiler. Here is the a detailed description of the current
status.
First, I've skipped trying to build the libcheck dependency under
mingw32. This is not critical for a functional matahari agent, so for
now we'll ignore it.
The first major hurdle is getting libvirt built under mingw32. This
requires the mingw32-portablexdr package, which is now built and
pending review. You can find the srpm and spec file here:
http://people.redhat.com/~rohara/mingw32/portablexdr/mingw32-portablexdr-...
http://people.redhat.com/~rohara/mingw32/portablexdr/mingw32-portablexdr....
One potential pitfall to be aware of is that you may need to manually
run the mingw32 ranlib against the results dll:
% i686-pc-mingw32-ranlib
/usr/i686-pc-mingw32/sys-root/mingw/lib/libportablexdr.dll.a
There is a bug related to this problem which can be found here:
https://bugzilla.redhat.com/show_bug.cgi?id=595006
With this installed, we can now attempt to build libvirt for
mingw32. Daniel Berrange has posted the srpm and spec file here:
http://berrange.fedorapeople.org/review/mingw32-libvirt/mingw32-libvirt-0...
http://berrange.fedorapeople.org/review/mingw32-libvirt/mingw32-libvirt.spec
Daniel was able to build the mingw32-libvirt rpm on F12. I was unable
to build the same package (from the same srpm) on F13, so I reverted
to F12 to verify that the build would indeed work. It did not. I am
seeing the same problems on F12 as I saw on F13. Specifically:
+ /usr/lib/rpm/brp-strip-static-archive
strip:/root/rpmbuild/BUILDROOT/mingw32-libvirt-0.8.2-3.fc13.x86_64/usr/i686-pc-mingw32/sys-root/mingw/lib/libvirt.dll.a(d000892.o):
Unable to recognise the format of file: File format not recognized
strip:/root/rpmbuild/BUILDROOT/mingw32-libvirt-0.8.2-3.fc13.x86_64/usr/i686-pc-mingw32/sys-root/mingw/lib/libvirt.dll.a(d000009.o):
Unable to recognise the format of file: File format not recognized
...
I see several of these messages until the rpm build ultimately fails
with:
Processing files: mingw32-libvirt-debuginfo-0.8.2-3.fc12.noarch
error: Could not open %files file
/root/rpmbuild/BUILD/libvirt-0.8.2/debugfiles.list: No such file or directory
RPM build errors:
Could not open %files file
/root/rpmbuild/BUILD/libvirt-0.8.2/debugfiles.list: No such file or directory
Ryan
13 years, 10 months
Re: [Matahari] [PATCH] Repackaged Host into com.redhat.matahari.host.
by Andrew Beekhof
Opps, I forgot to do reply all.
On Wed, Jul 14, 2010 at 2:41 PM, Darryl L. Pierce <dpierce(a)redhat.com> wrote:
> On Wed, Jul 14, 2010 at 01:29:53PM +0200, Andrew Beekhof wrote:
>> > + <property name="cpu_model" type="lstr" access="RO" desc="The process model description." />
>> > + <property name="cpu_cores" type="uint8" access="RO" desc="The number of processor cores." />
>>
>> Number of cpus?
>> Should we assume all CPUs are the same?
>
> That's a good question. My experience has been with systems where the
> CPUs are all the same model. Is it possible for a system to have
> multiple different physical processors? If so, should we have a
> "list_processors" API and a Processor agent to represent it.
Unless anyone knows different, I'd vote for assuming they're all the
same and adding: cpu_count
>> > +
>> > + <!-- statistics -->
>> > + <statistic name="last_updated" type="absTime" desc="The last time a heartbeat occurred." />
>>
>> Not sure last_updated is useful.
>> If the system is up sufficiently to give us this (or any) value, then
>> its also up sufficiently to update it.
>> Though perhaps I'm misunderstanding the distinction between property
>> and statistic.
>
> A property is a fixed value, while a statistic is one that changes.
>
> In this case, with the last_updated timestamp, the Qpid broker will
> cache for an indeterminate period of time, the vaues from an agent. The
> agent can actually die and the value will still be in the broker. So
> this gives a way of seeing how long it's been since the last time the
> agent sent a heartbeat and infer from that if the agent is dead.
Ah. Ok, sounds good.
>> > + <statistic name="load_average" type="double" desc="The current processing load average." />
>>
>> You'll probably want to go with the standard and make the 1,5, and 15
>> minute load averages available.
>
> Okay, that's cool. I'll update the wiki and schema to have
> "load_average_1", "load_average_5" and "load_average_15". Does that
> naming seem reasonable?
Sure.
>> > + <eventArguments>
>> > + <arg name="timestamp" type="absTime" />
>> > + <arg name="sequence" type="uint32" />
>> > + </eventArguments>
>> > +
>> > + <event name="heartbeat" args="timestamp,sequence" />
>>
>> Strange syntax there. Does this mean all events must contain the same
>> arguments?
>
> No. It just defines the "timestamp" and "sequence" argument types, and
> then declares heartbeat as sending out those two types during its event.
Ah, I see how it works now.
13 years, 10 months
[PATCH] Repackaged Host into com.redhat.matahari.host.
by Darryl L. Pierce
Also included all of the new APIs, but did not provide the backing
implementation. Those will be included in followup patches.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
src/Makefile.am | 16 ++++++------
src/main.cpp | 4 +-
src/qmf/hostagent.cpp | 3 +-
src/qmf/hostagent.h | 4 +-
src/schema.xml | 62 ++++++++++++++++++++++++++-----------------------
5 files changed, 46 insertions(+), 43 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 6182fb1..daddf9d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,12 +10,12 @@ AM_CXXFLAGS = $(INCLUDES)
sbin_PROGRAMS = matahari
generated_file_list = \
- qmf/com/redhat/matahari/EventHeartbeat.cpp \
- qmf/com/redhat/matahari/EventHeartbeat.h \
- qmf/com/redhat/matahari/Host.cpp \
- qmf/com/redhat/matahari/Host.h \
- qmf/com/redhat/matahari/Package.cpp \
- qmf/com/redhat/matahari/Package.h
+ qmf/com/redhat/matahari/host/EventHeartbeat.cpp \
+ qmf/com/redhat/matahari/host/EventHeartbeat.h \
+ qmf/com/redhat/matahari/host/Host.cpp \
+ qmf/com/redhat/matahari/host/Host.h \
+ qmf/com/redhat/matahari/host/Package.cpp \
+ qmf/com/redhat/matahari/host/Package.h
nodist_matahari_SOURCES = $(generated_file_list) config.h
@@ -30,8 +30,8 @@ matahari_SOURCES = \
$(generated_file_list): schema.xml
qmf-gen -o ./qmf ./schema.xml
-BUILT_SOURCES = $(generated_file_list) $(first)
-CLEANFILES = $(generated_file_list) $(first)
+BUILT_SOURCES = $(generated_file_list)
+CLEANFILES = $(generated_file_list)
matahari_CPPFLAGS = -fno-strict-aliasing
matahari_LDADD = -lpcre -lqmf -lqpidclient -lqpidcommon -ludev -lvirt
diff --git a/src/main.cpp b/src/main.cpp
index 27b2434..f7d6329 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -36,12 +36,12 @@
#include "qmf/hostagent.h"
-#include "qmf/com/redhat/matahari/Package.h"
+#include "qmf/com/redhat/matahari/host/Package.h"
using namespace qpid::management;
using namespace qpid::client;
using namespace std;
-namespace _qmf = qmf::com::redhat::matahari;
+namespace _qmf = qmf::com::redhat::matahari::host;
// Global Variables
ManagementAgent::Singleton* singleton;
diff --git a/src/qmf/hostagent.cpp b/src/qmf/hostagent.cpp
index 94004d5..b28c5c5 100644
--- a/src/qmf/hostagent.cpp
+++ b/src/qmf/hostagent.cpp
@@ -21,7 +21,7 @@
#include "hostagent.h"
#include <qpid/agent/ManagementAgent.h>
-#include "qmf/com/redhat/matahari/EventHeartbeat.h"
+#include "qmf/com/redhat/matahari/host/EventHeartbeat.h"
HostAgent::HostAgent()
{
@@ -45,7 +45,6 @@ HostAgent::setup(ManagementAgent* agent)
_management_object->set_hypervisor(host_get_hypervisor());
_management_object->set_arch(host_get_architecture());
_management_object->set_memory(host_get_memory());
- _management_object->set_beeping(false);
_management_object->set_cpu_model(host_get_cpu_model());
_management_object->set_cpu_cores(host_get_number_of_cpu_cores());
diff --git a/src/qmf/hostagent.h b/src/qmf/hostagent.h
index 7f7bbaa..d1f3bc1 100644
--- a/src/qmf/hostagent.h
+++ b/src/qmf/hostagent.h
@@ -26,12 +26,12 @@
#include "host.h"
#include "hostlistener.h"
-#include "qmf/com/redhat/matahari/Host.h"
+#include "qmf/com/redhat/matahari/host/Host.h"
using namespace qpid::management;
using namespace std;
-namespace _qmf = qmf::com::redhat::matahari;
+namespace _qmf = qmf::com::redhat::matahari::host;
class HostAgent : public Manageable, public HostListener
{
diff --git a/src/schema.xml b/src/schema.xml
index 20fd9bc..76e1371 100644
--- a/src/schema.xml
+++ b/src/schema.xml
@@ -1,31 +1,35 @@
-<schema package="com.redhat.matahari">
-
- <class name="Host">
-
- <!-- general properties -->
- <property name="uuid" type="sstr" access="RO" desc="Host UUID" index="y"/>
- <property name="hostname" type="sstr" access="RO" desc="Hostname"/>
- <property name="memory" type="int64" access="RO" desc="Amount of primary memory for host (kb)" unit="kb"/>
- <property name="hypervisor" type="sstr" access="RO" desc="Hypervisor used by host"/>
- <property name="arch" type="sstr" access="RO" desc="Architecture of host"/>
- <property name="beeping" type="bool" access="RW" desc="speaker beep loop active? (used to identify host)"/>
-
- <!-- CPU properties -->
- <property name="cpu_model" type="lstr" access="RO" desc="The process model description." />
- <property name="cpu_cores" type="uint8" access="RO" desc="The number of processor cores." />
- <statistic name="load_average" type="double" desc="The current processing load average." />
-
- <!-- APIs -->
- <method name="shutdown" desc="Shutdown node" />
- <method name="reboot" desc="Reboot node" />
-
- </class>
-
- <eventArguments>
- <arg name="timestamp" type="absTime" />
- <arg name="sequence" type="uint32" />
- </eventArguments>
-
- <event name="heartbeat" args="timestamp,sequence" />
+<schema package="com.redhat.matahari.host">
+
+ <class name="Host">
+ <!-- properties -->
+ <property name="uuid" type="sstr" access="RO" desc="Host UUID" index="y" />
+ <property name="hostname" type="sstr" access="RO" desc="Hostname" />
+ <property name="is_virtual" type="bool" access="RO" desc="Is this machine virtual?" />
+ <property name="operating_system" type="sstr" access="RO" desc="The installed operating system." />
+ <property name="memory" type="int64" access="RO" desc="Amount of primary memory for host (kb)" unit="kb" />
+ <property name="arch" type="sstr" access="RO" desc="Architecture of host" />
+ <property name="hypervisor" type="sstr" access="RO" desc="Hypervisor used by host" />
+ <property name="platform" type="sstr" access="RO" desc="The wordsize for the host." />
+ <property name="cpu_model" type="lstr" access="RO" desc="The process model description." />
+ <property name="cpu_cores" type="uint8" access="RO" desc="The number of processor cores." />
+
+ <!-- statistics -->
+ <statistic name="last_updated" type="absTime" desc="The last time a heartbeat occurred." />
+ <statistic name="load_average" type="double" desc="The current processing load average." />
+
+ <!-- APIs -->
+ <method name="list_network_interfaces" desc="Returns the list of all network interfaces." />
+ <method name="identify" desc="Tells the host to beep its pc speaker." />
+ <method name="shutdown" desc="Shutdown node" />
+ <method name="reboot" desc="Reboot node" />
+
+ </class>
+
+ <eventArguments>
+ <arg name="timestamp" type="absTime" />
+ <arg name="sequence" type="uint32" />
+ </eventArguments>
+
+ <event name="heartbeat" args="timestamp,sequence" />
</schema>
--
1.7.1.1
13 years, 10 months
[PATCH matahari] Removed the multiplexer.
by Darryl L. Pierce
Since it's no longer going to be used, this patch removes it from the
repository.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
.gitignore | 1 +
src/Makefile.am | 19 +++----
src/tests/.gitignore | 1 -
src/tests/Makefile.am | 13 +-----
src/tests/testmultiplexer.cpp | 110 -----------------------------------------
src/tests/testmultiplexer.h | 46 -----------------
src/virtio/multiplexer.cpp | 62 -----------------------
src/virtio/multiplexer.h | 48 ------------------
8 files changed, 11 insertions(+), 289 deletions(-)
delete mode 100644 src/tests/testmultiplexer.cpp
delete mode 100644 src/tests/testmultiplexer.h
delete mode 100644 src/virtio/multiplexer.cpp
delete mode 100644 src/virtio/multiplexer.h
diff --git a/.gitignore b/.gitignore
index e4935e0..5e5bdc5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@ config.log
config.status
configure
depcomp
+INSTALL
install-sh
lib
m4
diff --git a/src/Makefile.am b/src/Makefile.am
index 20532b0..f95ae01 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,20 +1,23 @@
-NCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/src/qmf/com/redhat/matahari $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) $(UDEV_CFLAGS)
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src/qmf/com/redhat/matahari \
+ $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) $(UDEV_CFLAGS)
AM_CFLAGS = $(INCLUDES)
AM_CXXFLAGS = $(INCLUDES)
sbin_PROGRAMS = matahari
-first = qmf/com/redhat/matahari/Host.cpp
-
generated_file_list = \
qmf/com/redhat/matahari/EventHeartbeat.cpp \
qmf/com/redhat/matahari/EventHeartbeat.h \
+ qmf/com/redhat/matahari/Host.cpp \
qmf/com/redhat/matahari/Host.h \
qmf/com/redhat/matahari/Package.cpp \
qmf/com/redhat/matahari/Package.h
-nodist_matahari_SOURCES = $(generated_file_list) $(first)
+nodist_matahari_SOURCES = $(generated_file_list) config.h
matahari_SOURCES = \
host.cpp \
@@ -26,13 +29,9 @@ matahari_SOURCES = \
platform.cpp \
platform.h \
qmf/hostagent.cpp \
- qmf/hostagent.h \
- virtio/multiplexer.cpp \
- virtio/multiplexer.h
-
-$(generated_file_list): $(generated_file_list)
+ qmf/hostagent.h
-$(first): schema.xml $(generated_file_list)
+$(generated_file_list): schema.xml
qmf-gen -o ./qmf ./schema.xml
BUILT_SOURCES = $(generated_file_list) $(first)
diff --git a/src/tests/.gitignore b/src/tests/.gitignore
index 6d437f4..68400ae 100644
--- a/src/tests/.gitignore
+++ b/src/tests/.gitignore
@@ -1,2 +1 @@
testhostapis
-testmultiplexer
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 13fea3d..f8c9973 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -1,23 +1,12 @@
bin_PROGRAMS = \
- testhostapis \
- testmultiplexer
+ testhostapis
INCLUDES = \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/src
-
-testmultiplexer_SOURCES = \
- $(top_srcdir)/src/virtio/multiplexer.cpp \
- $(top_srcdir)/src/virtio/multiplexer.h \
- testmultiplexer.cpp \
- testmultiplexer.h
-
-testmultiplexer_LDADD = -lcppunit
-testmultiplexer_LDADD += ../../lib/libgnu.a
-
testhostapis_SOURCES = \
$(top_srcdir)/src/host.cpp \
$(top_srcdir)/src/host.h \
diff --git a/src/tests/testmultiplexer.cpp b/src/tests/testmultiplexer.cpp
deleted file mode 100644
index 6208cc2..0000000
--- a/src/tests/testmultiplexer.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/* testmultiplexer.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 "testmultiplexer.h"
-
-#include "virtio/multiplexer.h"
-
-#include <cppunit/TestAssert.h>
-#include <cppunit/TestCaller.h>
-#include <cppunit/TestResult.h>
-#include <cppunit/TestSuite.h>
-#include <cppunit/ui/text/TestRunner.h>
-
-const string APINAME("testapifunction");
-
-const char*
-test_callback_function(const char* input)
-{
- return input;
-}
-
-TestMultiplexer::TestMultiplexer()
- :TestCase("TestMultiplexer")
-{}
-
-TestSuite*
-TestMultiplexer::suite()
-{
- CppUnit::TestSuite *result = new CppUnit::TestSuite("TestMultiplexer");
-
- result->addTest(new CppUnit::TestCaller<TestMultiplexer>
- ("testBadAPINameGetsNull",
- &TestMultiplexer::testUnregisteredAPIIsNull));
- result->addTest(new CppUnit::TestCaller<TestMultiplexer>
- ("testRegisterAPIMethod",
- &TestMultiplexer::testRegisterAPIMethod));
- result->addTest(new CppUnit::TestCaller<TestMultiplexer>
- ("testEnsureCallingAnUnregisteredAPIFails",
- &TestMultiplexer::testEnsureCallingAnUnregisteredAPIFails));
- result->addTest(new CppUnit::TestCaller<TestMultiplexer>
- ("testEnsureAPIIsCalled",
- &TestMultiplexer::testEnsureAPIIsCalled));
-
- return result;
-}
-
-void
-TestMultiplexer::setUp()
-{
- Multiplexer::instance()->registerAPI(APINAME, test_callback_function);
-}
-
-void
-TestMultiplexer::testUnregisteredAPIIsNull()
-{
- CPPUNIT_ASSERT(NULL == Multiplexer::instance()->getAPI(APINAME + "!"));
-}
-
-void
-TestMultiplexer::testRegisterAPIMethod()
-{
- t_apifunction apifunction = test_callback_function;
-
- CPPUNIT_ASSERT(apifunction == Multiplexer::instance()->getAPI(APINAME));
-}
-
-void
-TestMultiplexer::testEnsureCallingAnUnregisteredAPIFails()
-{
- string input = string("This is some input");
- string result = Multiplexer::instance()->invokeAPI(APINAME + "!", input);
-
- CPPUNIT_ASSERT(string("") == result);
-}
-
-void TestMultiplexer::testEnsureAPIIsCalled()
-{
- string expected = "This is what I expected";
- string result = Multiplexer::instance()->invokeAPI(APINAME, expected);
-
- CPPUNIT_ASSERT(expected == result);
-}
-
-int
-main(int argc, char** argv)
-{
- CppUnit::TextUi::TestRunner runner;
-
- runner.addTest(TestMultiplexer::suite());
- runner.run();
-
- return 0;
-}
diff --git a/src/tests/testmultiplexer.h b/src/tests/testmultiplexer.h
deleted file mode 100644
index 04cb9e5..0000000
--- a/src/tests/testmultiplexer.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef __TESTMULTIPLEXER_H
-#define __TESTMULTIPLEXER_H
-
-/* testmultiplexer.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 "virtio/multiplexer.h"
-
-#include <cppunit/TestCase.h>
-#include <cppunit/TestSuite.h>
-
-using namespace CppUnit;
-using namespace std;
-
-class TestMultiplexer : public CppUnit::TestCase
-{
- public:
- TestMultiplexer();
-
- static TestSuite* suite();
-
- void setUp();
-
- void testUnregisteredAPIIsNull();
- void testRegisterAPIMethod();
- void testEnsureCallingAnUnregisteredAPIFails();
- void testEnsureAPIIsCalled();
-};
-
-#endif
diff --git a/src/virtio/multiplexer.cpp b/src/virtio/multiplexer.cpp
deleted file mode 100644
index 8f72ddc..0000000
--- a/src/virtio/multiplexer.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/* multiplexer.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 "multiplexer.h"
-
-// the singleton
-Multiplexer* Multiplexer::_instance = new Multiplexer();
-
-typedef map<string, t_apifunction> APIMAP;
-
-Multiplexer::Multiplexer()
-{}
-
-Multiplexer*
-Multiplexer::instance()
-{
- return _instance;
-}
-
-void
-Multiplexer::registerAPI(string name, t_apifunction apifunction)
-{
- _apis.insert(APIMAP::value_type(string(name), apifunction));
-}
-
-t_apifunction
-Multiplexer::getAPI(string name)
-{
- return (*_apis.find(name)).second;
-}
-
-string
-Multiplexer::invokeAPI(string name, string input)
-{
- string result = string("");
- t_apifunction funcptr = (*_apis.find(name)).second;
-
- if(funcptr)
- {
- result = funcptr(input.c_str());
- }
-
- return result;
-}
-
diff --git a/src/virtio/multiplexer.h b/src/virtio/multiplexer.h
deleted file mode 100644
index 26a288c..0000000
--- a/src/virtio/multiplexer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __MULTIPLEXER_H
-#define __MULTIPLEXER_H
-
-/* multiplexer.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 <map>
-#include <string>
-
-using namespace std;
-
-typedef const char*(*t_apifunction)(const char*);
-
-// Multiplexer processes the content received from a remote system.
-class Multiplexer
-{
- private:
- Multiplexer();
-
- static Multiplexer* _instance;
-
- map<string, t_apifunction> _apis;
-
- public:
- static Multiplexer* instance();
-
- void registerAPI(string apiname, t_apifunction apifunction);
- t_apifunction getAPI(string apiname);
- string invokeAPI(string apiname, string input);
-};
-
-#endif
--
1.7.1.1
13 years, 10 months
[PATCH matahari] Removed the platform-specific Platform class.
by Darryl L. Pierce
Deleted the files linux_platform.{cpp,h} and platform.{cpp,h}. All of
that functionality was moved into the host.cpp file into conditionally
compiled sections.
No Windows code was added, just the Linux code relocated.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
configure.ac | 2 +-
src/Makefile.am | 4 -
src/host.cpp | 220 +++++++++++++++++++++++++++++++++++++++++---
src/linux_platform.cpp | 174 ----------------------------------
src/linux_platform.h | 34 -------
src/platform.cpp | 36 -------
src/platform.h | 77 ---------------
src/tests/Makefile.am | 17 +---
src/tests/testhostapis.cpp | 130 --------------------------
src/tests/testhostapis.h | 54 -----------
10 files changed, 208 insertions(+), 540 deletions(-)
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
delete mode 100644 src/tests/testhostapis.cpp
delete mode 100644 src/tests/testhostapis.h
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..947367d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,11 +20,7 @@ matahari_SOURCES = \
host.cpp \
host.h \
hostlistener.h \
- linux_platform.cpp \
- linux_platform.h \
main.cpp \
- platform.cpp \
- platform.h \
qmf/hostagent.cpp \
qmf/hostagent.h \
virtio/multiplexer.cpp \
diff --git a/src/host.cpp b/src/host.cpp
index dfb83f5..0b991fc 100644
--- a/src/host.cpp
+++ b/src/host.cpp
@@ -1,5 +1,5 @@
-/* host.cpp - Copyright (C) 2009 Red Hat, Inc.
- * Written by Arjun Roy <arroy(a)redhat.com>
+/* host.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
@@ -18,14 +18,25 @@
*/
#include <config.h>
+#include <cstdlib>
+#include <fstream>
#include "host.h"
-
-#include "platform.h"
+#include <libvirt/libvirt.h>
+#include <pcre.h>
#include <set>
+#include <stdexcept>
+#include <string>
+#include <sys/sysinfo.h>
+#include <sys/utsname.h>
+
+// TODO remove this wrapper once rhbz#583747 is fixed
+extern "C" {
+#include <libudev.h>
+}
using namespace std;
-set<HostListener*> _listeners;
+set<HostListener*> _listeners;
unsigned int _heartbeat_sequence;
void
@@ -53,7 +64,7 @@ host_update_event()
iter++)
{
(*iter)->heartbeat((unsigned long)__time,
- _heartbeat_sequence);
+ _heartbeat_sequence);
}
for(set<HostListener*>::iterator iter = _listeners.begin();
@@ -67,49 +78,230 @@ host_update_event()
string
host_get_uuid()
{
- return Platform::instance()->getUUID();
+ static string uuid;
+
+ if(uuid.empty())
+ {
+
+#ifdef __linux__
+ ifstream input("/var/lib/dbus/machine-id");
+
+ if(input.is_open())
+ {
+ getline(input, uuid);
+ input.close();
+ }
+#endif
+
+ }
+
+ return uuid;
}
string
host_get_hostname()
{
- return Platform::instance()->getHostname();
+ static string hostname;
+
+ if(hostname.empty())
+ {
+
+#ifdef __linux__
+ struct utsname details;
+
+ if(!uname(&details))
+ {
+ hostname = string(details.nodename);
+ }
+ #endif
+
+ }
+
+ return hostname;
}
string
host_get_hypervisor()
{
- return Platform::instance()->getHypervisor();
+ static string hypervisor;
+
+ if(hypervisor.empty())
+ {
+
+#ifdef HAVE_LIBVIRT
+ virConnectPtr lvconn = virConnectOpenReadOnly(NULL);
+
+ if(lvconn)
+ {
+ hypervisor = string(virConnectGetType(lvconn));
+ virConnectClose(lvconn);
+ }
+#endif
+
+ }
+
+ return hypervisor;
}
string
host_get_architecture()
{
- return Platform::instance()->getArchitecture();
+ static string architecture;
+
+ if(architecture.empty())
+ {
+
+#ifdef __linux__
+ struct utsname details;
+
+ if(!uname(&details))
+ {
+ architecture = string(details.machine);
+ }
+#endif
+
+ }
+
+ return architecture;
}
unsigned int
host_get_memory()
{
- return Platform::instance()->getMemory();
+ static unsigned int memory = 0;
+
+ if(!memory)
+ {
+
+#ifdef __linux__
+ struct sysinfo sysinf;
+ if(!sysinfo(&sysinf))
+ {
+ memory = sysinf.totalram / 1024L;
+ }
+#endif
+
+ }
+
+ return memory;
}
string
host_get_cpu_model()
{
- return Platform::instance()->getCPUModel();
+ static string model;
+
+ if(model.empty())
+ {
+
+#ifdef __linux__
+ ifstream* 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") model = value;
+ }
+ }
+ }
+ input->close();
+ delete input;
+ }
+#endif
+
+ }
+
+ return model;
}
unsigned int
host_get_number_of_cpu_cores()
{
- return Platform::instance()->getNumberOfCPUCores();
+ unsigned int cores = 0;
+
+ if(!cores)
+ {
+
+#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);
+#endif
+
+ }
+
+ return cores;
}
double
host_get_load_average()
{
- return Platform::instance()->getLoadAverage();
+ double result = 0.0;
+
+#ifdef __linux__
+ double load_average;
+ ifstream input;
+
+ input.open("/proc/loadavg", ios::in);
+ input >> result;
+ input.close();
+#endif
+
+ return result;
}
void
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/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/tests/Makefile.am b/src/tests/Makefile.am
index 13fea3d..49df0c0 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -1,6 +1,5 @@
bin_PROGRAMS = \
- testhostapis \
testmultiplexer
INCLUDES = \
@@ -16,18 +15,4 @@ testmultiplexer_SOURCES = \
testmultiplexer.h
testmultiplexer_LDADD = -lcppunit
-testmultiplexer_LDADD += ../../lib/libgnu.a
-
-testhostapis_SOURCES = \
- $(top_srcdir)/src/host.cpp \
- $(top_srcdir)/src/host.h \
- $(top_srcdir)/src/linux_platform.cpp \
- $(top_srcdir)/src/linux_platform.h \
- $(top_srcdir)/src/platform.cpp \
- $(top_srcdir)/src/platform.h \
- testhostapis.cpp \
- testhostapis.h
-
-testhostapis_LDFLAGS = -L/usr/local/lib
-testhostapis_LDADD = -lcppunit $(LIBVIRT_LIBS) $(PCRE_LIBS) $(UDEV_LIBS)
-testhostapis_LDADD += ../../lib/libmatahari.a
+testmultiplexer_LDADD += ../../lib/libmatahari.a
diff --git a/src/tests/testhostapis.cpp b/src/tests/testhostapis.cpp
deleted file mode 100644
index 9710700..0000000
--- a/src/tests/testhostapis.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/* testhostapis.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 <config.h>
-#include "testhostapis.h"
-
-#include "host.h"
-#include <cppunit/TestCaller.h>
-#include <cppunit/ui/text/TestRunner.h>
-
-TestHostApis::TestHostApis()
- :TestCase("TestHostApis")
-{}
-
-TestHostApis::~TestHostApis()
-{}
-
-TestSuite*
-TestHostApis::suite()
-{
- TestSuite* result = new TestSuite("Host APIs");
-
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetUUID",
- &TestHostApis::testHostGetUUID));
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetHostname",
- &TestHostApis::testHostGetHostname));
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetHypervisor",
- &TestHostApis::testHostGetHypervisor));
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetArchitecture",
- &TestHostApis::testHostGetArchitecture));
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetMemory",
- &TestHostApis::testHostGetMemory));
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetCpuModel",
- &TestHostApis::testHostGetCpuModel));
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetNumberOfCpuCores",
- &TestHostApis::testHostGetNumberOfCpuCores));
- result->addTest(new TestCaller<TestHostApis>
- ("testHostGetLoadAverage",
- &TestHostApis::testHostGetLoadAverage));
-
- return result;
-}
-
-void
-TestHostApis::setUp()
-{
- this->platform = Platform::instance();
-}
-
-void
-TestHostApis::testHostGetUUID()
-{
- CPPUNIT_ASSERT(platform->getUUID() == host_get_uuid());
-}
-
-void
-TestHostApis::testHostGetHostname()
-{
- CPPUNIT_ASSERT(platform->getHostname() == host_get_hostname());
-}
-
-void
-TestHostApis::testHostGetHypervisor()
-{
- CPPUNIT_ASSERT(platform->getHypervisor() == host_get_hypervisor());
-}
-
-void
-TestHostApis::testHostGetArchitecture()
-{
- CPPUNIT_ASSERT(platform->getArchitecture() == host_get_architecture());
-}
-
-void
-TestHostApis::testHostGetMemory()
-{
- CPPUNIT_ASSERT(platform->getMemory() == host_get_memory());
-}
-
-void
-TestHostApis::testHostGetCpuModel()
-{
- CPPUNIT_ASSERT(platform->getCPUModel() == host_get_cpu_model());
-}
-
-void
-TestHostApis::testHostGetNumberOfCpuCores()
-{
- CPPUNIT_ASSERT(platform->getNumberOfCPUCores() == host_get_number_of_cpu_cores());
-}
-
-void
-TestHostApis::testHostGetLoadAverage()
-{
- CPPUNIT_ASSERT(platform->getLoadAverage() == host_get_load_average());
-}
-
-int
-main(int argc, char** argv)
-{
- TextUi::TestRunner runner;
-
- runner.addTest(TestHostApis::suite());
- runner.run();
-
- return 0;
-}
diff --git a/src/tests/testhostapis.h b/src/tests/testhostapis.h
deleted file mode 100644
index faebb22..0000000
--- a/src/tests/testhostapis.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef __TESTHOSTAPIS_H
-#define __TESTHOSTAPIS_H
-
-/* testhostapis.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 <cppunit/TestCase.h>
-#include <cppunit/TestSuite.h>
-
-#include "platform.h"
-
-using namespace CppUnit;
-
-class TestHostApis : public TestCase
-{
- private:
- Platform* platform;
-
- public:
- TestHostApis();
- virtual ~TestHostApis();
-
- static TestSuite* suite();
-
- void setUp();
-
- void testHostGetUUID();
- void testHostGetHostname();
- void testHostGetHypervisor();
- void testHostGetArchitecture();
- void testHostGetMemory();
- void testHostGetCpuModel();
- void testHostGetNumberOfCpuCores();
- void testHostGetLoadAverage();
- void testHostIsBeeping();
-};
-
-#endif
--
1.7.0.1
13 years, 10 months