---
matahari.spec | 4 +-
src/CMakeLists.txt | 59 ++++++++++---
src/matahari-host.cpp | 209 ------------------------------------------------
src/matahari-hostd.cpp | 209 ++++++++++++++++++++++++++++++++++++++++++++++++
src/matahari-netd.cpp | 199 +++++++++++++++++++++++++++++++++++++++++++++
src/net.c | 39 +++++++++
src/net.h | 31 +++++++
src/qmf/netagent.cpp | 54 ++++++++++++
src/qmf/netagent.h | 50 ++++++++++++
src/schema-net.xml | 27 ------
10 files changed, 629 insertions(+), 252 deletions(-)
delete mode 100644 src/matahari-host.cpp
create mode 100644 src/matahari-hostd.cpp
create mode 100644 src/matahari-netd.cpp
create mode 100644 src/net.c
create mode 100644 src/net.h
create mode 100644 src/qmf/netagent.cpp
create mode 100644 src/qmf/netagent.h
diff --git a/matahari.spec b/matahari.spec
index 6155f59..4cbfcc4 100644
--- a/matahari.spec
+++ b/matahari.spec
@@ -19,7 +19,7 @@ BuildRoot:
%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: dbus >= 1.2.12
Requires: hal >= 0.5.12
-Requires: qpidc >= 0.5.819819
+Requires: qpid-cpp-client >= 0.7.946106
Requires: qmf >= 0.5.819819
Requires: libvirt >= 0.6.2
Requires: pcre >= 7.8
@@ -29,7 +29,7 @@ BuildRequires: libudev-devel
BuildRequires: gcc-c++ >= 4.4.0
BuildRequires: dbus-devel >= 1.2.12
BuildRequires: hal-devel >= 0.5.12
-BuildRequires: qpidc-devel >= 0.5.819819
+BuildRequires: qpid-cpp-client-devel >= 0.7.946106
BuildRequires: qmf-devel >= 0.5.819819
BuildRequires: libvirt-devel >= 0.6.2
BuildRequires: pcre-devel >= 7.8
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8cf9813..9e22c97 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -25,7 +25,7 @@ install(FILES ${SCHEMAS} DESTINATION share/matahari)
# Main function plus QMF models
set(HOST_SOURCES
- matahari-host.cpp
+ matahari-hostd.cpp
qmf/hostagent.cpp
qmf/processoragent.cpp)
@@ -50,7 +50,25 @@ set(GENERATED_SCHEMA_SOURCES
add_executable(${M_HOST} ${HOST_SOURCES} ${HOST_LIBRARY} ${GENERATED_SCHEMA_SOURCES})
+set(NET_SOURCES
+ matahari-netd.cpp
+ qmf/netagent.cpp)
+
+set(NET_LIBRARY
+ net.c)
+
+set(GENERATED_NET_SCHEMA_SOURCES
+ qmf/com/redhat/matahari/net/ArgsInterfaceStart.h
+ qmf/com/redhat/matahari/net/ArgsInterfaceStop.h
+ qmf/com/redhat/matahari/net/Package.cpp
+ qmf/com/redhat/matahari/net/Package.h
+ qmf/com/redhat/matahari/net/Interface.cpp
+ qmf/com/redhat/matahari/net/Interface.h)
+
+add_executable(${M_NET} ${NET_SOURCES} ${NET_LIBRARY} ${GENERATED_NET_SCHEMA_SOURCES})
+
pkg_check_modules(pcre REQUIRED libpcre)
+pkg_check_modules(netcf REQUIRED netcf)
if(NOT PKG_CONFIG_FOUND)
message("pkg-config not found")
@@ -109,6 +127,13 @@ else(pcre_FOUND)
message(FATAL_ERROR "PCRE header/library not found.")
endif(pcre_FOUND)
+if(netcf_FOUND)
+ target_link_libraries(${M_NET} ${netcf_LIBRARIES})
+ include_directories(${netcf_INCLUDE_DIRS})
+else(netcf_FOUND)
+ message(FATAL_ERROR "NETCF header/library not found.")
+endif(netcf_FOUND)
+
set(simple_libs check libvirt udev_new)
foreach(lib ${simple_libs})
find_library(${lib}_LIBRARIES ${lib})
@@ -124,22 +149,26 @@ if(QMFGEN-NOTFOUND)
message(FATAL_ERROR Missing QMF schema processor.)
endif(QMFGEN-NOTFOUND)
-set(regen_schema OFF)
-message(STATUS "Regenerating QMF schemas")
-foreach (schema_file ${SCHEMAS} ${QMFGEN})
- foreach (file ${GENERATED_SCHEMA_SOURCES})
- if (${schema_file} IS_NEWER_THAN ${file})
- set(regen_schema ON)
- message("${schema_file} is newer than ${file}")
- endif (${schema_file} IS_NEWER_THAN ${file})
- endforeach (file ${GENERATED_SCHEMA_SOURCES})
-endforeach (schema_file ${SCHEMAS})
+set(regen_schema ON)
+#
+#message(STATUS "Regenerating QMF schemas")
+#foreach (schema_file ${SCHEMAS} ${QMFGEN})
+# foreach (file ${GENERATED_SCHEMA_SOURCES} ${GENERATED_NET_SCHEMA_SOURCES})
+# if (${schema_file} IS_NEWER_THAN ${file})
+# set(regen_schema ON)
+# message("${schema_file} is newer than ${file}")
+# endif (${schema_file} IS_NEWER_THAN ${file})
+# endforeach (file ${GENERATED_SCHEMA_SOURCES})
+#endforeach (schema_file ${SCHEMAS})
if (regen_schema)
# Regenerate everything
- execute_process(COMMAND rm -f ${GENERATED_SCHEMA_SOURCES})
- execute_process(COMMAND ${QMFGEN} -o ./qmf ${SCHEMAS}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ execute_process(COMMAND rm -rf "${CMAKE_CURRENT_SOURCE_DIR}/qmf/com")
+ foreach (schema_file ${SCHEMAS})
+ message("regen: ${schema_file}")
+ execute_process(COMMAND ${QMFGEN} -o ./qmf ${schema_file}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ endforeach(schema_file ${SCHEMAS})
else (regen_schema)
message(STATUS "No need to generate QMF schema")
endif (regen_schema)
@@ -174,6 +203,8 @@ set( CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
#configure_file(autorun.in arun )
install(TARGETS ${M_HOST} DESTINATION sbin)
+install(TARGETS ${M_NET} DESTINATION sbin)
+
if(WIN32)
# Find qpid files needed by matahari
file(GLOB_RECURSE QPID_EXE ${MINGW_ROOT}/*/qpidd.exe)
diff --git a/src/matahari-host.cpp b/src/matahari-host.cpp
deleted file mode 100644
index 790277d..0000000
--- a/src/matahari-host.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/* main.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.
- */
-
-#ifndef WIN32
-#include <config.h>
-#include <getopt.h>
-#endif
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include <qpid/agent/ManagementAgent.h>
-#include <qpid/client/ConnectionSettings.h>
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <vector>
-#include <exception>
-
-#include <signal.h>
-#include <cstdlib>
-
-#include "host.h"
-
-#include "qmf/hostagent.h"
-#include "qmf/processoragent.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::host;
-
-// Global Variables
-ManagementAgent::Singleton* singleton;
-
-void
-shutdown(int /*signal*/)
-{
- exit(0);
-}
-
-#ifdef __linux__
-static void
-print_usage()
-{
- printf("Usage:\tmatahari <options>\n");
- printf("\t-d | --daemon run as a daemon.\n");
- printf("\t-h | --help print this help message.\n");
- printf("\t-b | --broker specify broker host name..\n");
- printf("\t-g | --gssapi force GSSAPI authentication.\n");
- printf("\t-u | --username username to use for authentication
purproses.\n");
- printf("\t-s | --service service name to use for authentication
purproses.\n");
- printf("\t-p | --port specify broker port.\n");
-}
-#endif
-
-int
-main(int argc, char **argv)
-{
-#ifdef __linux__
- int arg;
- int idx = 0;
- bool verbose = false;
- bool daemonize = false;
-#endif
- bool gssapi = false;
- char *servername = NULL;
- char *username = NULL;
- char *service = NULL;
- int serverport = 5672;
-
- ConnectionSettings settings;
- ManagementAgent *agent;
- HostAgent hostAgent;
- ProcessorAgent processorAgent;
-
-#ifdef __linux__
- struct option opt[] = {
- {"help", no_argument, NULL, 'h'},
- {"daemon", no_argument, NULL, 'd'},
- {"broker", required_argument, NULL, 'b'},
- {"gssapi", no_argument, NULL, 'g'},
- {"username", required_argument, NULL, 'u'},
- {"service", required_argument, NULL, 's'},
- {"port", required_argument, NULL, 'p'},
- {0, 0, 0, 0}
- };
-
- // Get args
- while ((arg = getopt_long(argc, argv, "hdb:gu:s:p:", opt, &idx)) != -1)
{
- switch (arg) {
- case 'h':
- case '?':
- print_usage();
- exit(0);
- break;
- case 'd':
- daemonize = true;
- break;
- case 'v':
- verbose = true;
- break;
- case 's':
- if (optarg) {
- service = strdup(optarg);
- } else {
- print_usage();
- exit(1);
- }
- break;
- case 'u':
- if (optarg) {
- username = strdup(optarg);
- } else {
- print_usage();
- exit(1);
- }
- break;
- case 'g':
- gssapi = true;
- break;
- case 'p':
- if (optarg) {
- serverport = atoi(optarg);
- } else {
- print_usage();
- exit(1);
- }
- break;
- case 'b':
- if (optarg) {
- servername = strdup(optarg);
- } else {
- print_usage();
- exit(1);
- }
- break;
- default:
- fprintf(stderr, "unsupported option '-%c'. See --help.\n", arg);
- print_usage();
- exit(0);
- break;
- }
- }
-
- if (daemonize == true) {
- if (daemon(0, 0) < 0) {
- fprintf(stderr, "Error daemonizing: %s\n", strerror(errno));
- exit(1);
- }
- }
-#endif
-
- // Get our management agent
- singleton = new ManagementAgent::Singleton();
- agent = singleton->getInstance();
- _qmf::Package packageInit(agent);
-
- // Set up the cleanup handler for sigint
- signal(SIGINT, shutdown);
-
- // Connect to the broker
- settings.host = servername ? servername : "127.0.0.1";
- settings.port = serverport;
-
- if (username != NULL) {
- settings.username = username;
- }
- if (service != NULL) {
- settings.service = service;
- }
- if (gssapi == true) {
- settings.mechanism = "GSSAPI";
- }
-
- agent->init(settings, 5, false, ".magentdata");
-
- // Get the info and post it to the broker
- hostAgent.setup(agent);
- processorAgent.setup(agent, hostAgent);
-
- while(1)
- {
- host_update_event();
- qpid::sys::sleep(5);
- }
-
- return 0;
-}
diff --git a/src/matahari-hostd.cpp b/src/matahari-hostd.cpp
new file mode 100644
index 0000000..7317628
--- /dev/null
+++ b/src/matahari-hostd.cpp
@@ -0,0 +1,209 @@
+/* matahari-hostd.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.
+ */
+
+#ifndef WIN32
+#include <config.h>
+#include <getopt.h>
+#endif
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include <qpid/agent/ManagementAgent.h>
+#include <qpid/client/ConnectionSettings.h>
+#include <qpid/sys/Time.h>
+
+#include <iostream>
+#include <fstream>
+#include <string.h>
+#include <errno.h>
+#include <vector>
+#include <exception>
+
+#include <signal.h>
+#include <cstdlib>
+
+#include "host.h"
+
+#include "qmf/hostagent.h"
+#include "qmf/processoragent.h"
+
+#include "qmf/com/redhat/matahari/host/Package.h"
+
+using namespace std;
+namespace _qmf = qmf::com::redhat::matahari::host;
+
+// Global Variables
+ManagementAgent::Singleton* singleton;
+
+void
+shutdown(int /*signal*/)
+{
+ exit(0);
+}
+
+#ifdef __linux__
+static void
+print_usage()
+{
+ printf("Usage:\tmatahari-hostd <options>\n");
+ printf("\t-d | --daemon run as a daemon.\n");
+ printf("\t-h | --help print this help message.\n");
+ printf("\t-b | --broker specify broker host name..\n");
+ printf("\t-g | --gssapi force GSSAPI authentication.\n");
+ printf("\t-u | --username username to use for authentication
purproses.\n");
+ printf("\t-s | --service service name to use for authentication
purproses.\n");
+ printf("\t-p | --port specify broker port.\n");
+}
+#endif
+
+int
+main(int argc, char **argv)
+{
+#ifdef __linux__
+ int arg;
+ int idx = 0;
+ bool verbose = false;
+ bool daemonize = false;
+#endif
+ bool gssapi = false;
+ char *servername = NULL;
+ char *username = NULL;
+ char *service = NULL;
+ int serverport = 5672;
+
+ ConnectionSettings settings;
+ ManagementAgent *agent;
+ HostAgent hostAgent;
+ ProcessorAgent processorAgent;
+
+#ifdef __linux__
+ struct option opt[] = {
+ {"help", no_argument, NULL, 'h'},
+ {"daemon", no_argument, NULL, 'd'},
+ {"broker", required_argument, NULL, 'b'},
+ {"gssapi", no_argument, NULL, 'g'},
+ {"username", required_argument, NULL, 'u'},
+ {"service", required_argument, NULL, 's'},
+ {"port", required_argument, NULL, 'p'},
+ {0, 0, 0, 0}
+ };
+
+ // Get args
+ while ((arg = getopt_long(argc, argv, "hdb:gu:s:p:", opt, &idx)) != -1)
{
+ switch (arg) {
+ case 'h':
+ case '?':
+ print_usage();
+ exit(0);
+ break;
+ case 'd':
+ daemonize = true;
+ break;
+ case 'v':
+ verbose = true;
+ break;
+ case 's':
+ if (optarg) {
+ service = strdup(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ case 'u':
+ if (optarg) {
+ username = strdup(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ case 'g':
+ gssapi = true;
+ break;
+ case 'p':
+ if (optarg) {
+ serverport = atoi(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ case 'b':
+ if (optarg) {
+ servername = strdup(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ default:
+ fprintf(stderr, "unsupported option '-%c'. See --help.\n", arg);
+ print_usage();
+ exit(0);
+ break;
+ }
+ }
+
+ if (daemonize == true) {
+ if (daemon(0, 0) < 0) {
+ fprintf(stderr, "Error daemonizing: %s\n", strerror(errno));
+ exit(1);
+ }
+ }
+#endif
+
+ // Get our management agent
+ singleton = new ManagementAgent::Singleton();
+ agent = singleton->getInstance();
+ _qmf::Package packageInit(agent);
+
+ // Set up the cleanup handler for sigint
+ signal(SIGINT, shutdown);
+
+ // Connect to the broker
+ settings.host = servername ? servername : "127.0.0.1";
+ settings.port = serverport;
+
+ if (username != NULL) {
+ settings.username = username;
+ }
+ if (service != NULL) {
+ settings.service = service;
+ }
+ if (gssapi == true) {
+ settings.mechanism = "GSSAPI";
+ }
+
+ agent->init(settings, 5, false, ".magentdata");
+
+ // Get the info and post it to the broker
+ hostAgent.setup(agent);
+ processorAgent.setup(agent, hostAgent);
+
+ while(1)
+ {
+ host_update_event();
+ qpid::sys::sleep(5);
+ }
+
+ return 0;
+}
diff --git a/src/matahari-netd.cpp b/src/matahari-netd.cpp
new file mode 100644
index 0000000..9c2f920
--- /dev/null
+++ b/src/matahari-netd.cpp
@@ -0,0 +1,199 @@
+/* matahari-netd.cpp - Copyright (C) 2010 Red Hat, Inc.
+ * Written by Adam Stokes <astokes(a)fedoraproject.org>
+ *
+ * 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.
+ */
+
+#ifndef WIN32
+#include <config.h>
+#include <getopt.h>
+#endif
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include <qpid/agent/ManagementAgent.h>
+#include <qpid/client/ConnectionSettings.h>
+
+#include <iostream>
+#include <fstream>
+#include <string.h>
+#include <errno.h>
+#include <vector>
+#include <exception>
+
+#include <signal.h>
+#include <cstdlib>
+
+#include "net.h"
+
+#include "qmf/netagent.h"
+
+#include "qmf/com/redhat/matahari/net/Package.h"
+
+using namespace std;
+namespace _qmf = qmf::com::redhat::matahari::net;
+
+// Global Variables
+ManagementAgent::Singleton* singleton;
+
+void
+shutdown(int /*signal*/)
+{
+ exit(0);
+}
+
+#ifdef __linux__
+static void
+print_usage()
+{
+ printf("Usage:\tmatahari-netd <options>\n");
+ printf("\t-d | --daemon run as a daemon.\n");
+ printf("\t-h | --help print this help message.\n");
+ printf("\t-b | --broker specify broker host name..\n");
+ printf("\t-g | --gssapi force GSSAPI authentication.\n");
+ printf("\t-u | --username username to use for authentication
purproses.\n");
+ printf("\t-s | --service service name to use for authentication
purproses.\n");
+ printf("\t-p | --port specify broker port.\n");
+}
+#endif
+
+int
+main(int argc, char **argv)
+{
+#ifdef __linux__
+ int arg;
+ int idx = 0;
+ bool verbose = false;
+ bool daemonize = false;
+#endif
+ bool gssapi = false;
+ char *servername = NULL;
+ char *username = NULL;
+ char *service = NULL;
+ int serverport = 5672;
+
+ ConnectionSettings settings;
+ ManagementAgent *agent;
+ NetAgent netAgent;
+
+#ifdef __linux__
+ struct option opt[] = {
+ {"help", no_argument, NULL, 'h'},
+ {"daemon", no_argument, NULL, 'd'},
+ {"broker", required_argument, NULL, 'b'},
+ {"gssapi", no_argument, NULL, 'g'},
+ {"username", required_argument, NULL, 'u'},
+ {"service", required_argument, NULL, 's'},
+ {"port", required_argument, NULL, 'p'},
+ {0, 0, 0, 0}
+ };
+
+ // Get args
+ while ((arg = getopt_long(argc, argv, "hdb:gu:s:p:", opt, &idx)) != -1)
{
+ switch (arg) {
+ case 'h':
+ case '?':
+ print_usage();
+ exit(0);
+ break;
+ case 'd':
+ daemonize = true;
+ break;
+ case 'v':
+ verbose = true;
+ break;
+ case 's':
+ if (optarg) {
+ service = strdup(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ case 'u':
+ if (optarg) {
+ username = strdup(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ case 'g':
+ gssapi = true;
+ break;
+ case 'p':
+ if (optarg) {
+ serverport = atoi(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ case 'b':
+ if (optarg) {
+ servername = strdup(optarg);
+ } else {
+ print_usage();
+ exit(1);
+ }
+ break;
+ default:
+ fprintf(stderr, "unsupported option '-%c'. See --help.\n", arg);
+ print_usage();
+ exit(0);
+ break;
+ }
+ }
+
+ if (daemonize == true) {
+ if (daemon(0, 0) < 0) {
+ fprintf(stderr, "Error daemonizing: %s\n", strerror(errno));
+ exit(1);
+ }
+ }
+#endif
+
+ // Get our management agent
+ singleton = new ManagementAgent::Singleton();
+ agent = singleton->getInstance();
+ _qmf::Package packageInit(agent);
+
+ // Set up the cleanup handler for sigint
+ signal(SIGINT, shutdown);
+
+ // Connect to the broker
+ settings.host = servername ? servername : "127.0.0.1";
+ settings.port = serverport;
+
+ if (username != NULL) {
+ settings.username = username;
+ }
+ if (service != NULL) {
+ settings.service = service;
+ }
+ if (gssapi == true) {
+ settings.mechanism = "GSSAPI";
+ }
+
+ agent->init(settings, 5, false, ".magentdata");
+
+ // Get the info and post it to the broker
+ netAgent.setup(agent);
+
+ return 0;
+}
diff --git a/src/net.c b/src/net.c
new file mode 100644
index 0000000..6e078da
--- /dev/null
+++ b/src/net.c
@@ -0,0 +1,39 @@
+/* net.c - Copyright (C) 2010 Red Hat, Inc.
+ * Written by Adam Stokes <astokes(a)fedoraproject.org>
+ *
+ * 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 "net.h"
+#include <netcf.h>
+
+struct netcf *ncf;
+
+int
+net_start(struct netcf_if *nif)
+{
+ if (ncf_init(&ncf, NULL) < 0)
+ return NETCF_EINTERNAL;
+ return ncf_if_up(nif);
+}
+
+int
+net_stop(struct netcf_if *nif)
+{
+ if (ncf_init(&ncf, NULL) < 0)
+ return NETCF_EINTERNAL;
+ return ncf_if_down(nif);
+}
diff --git a/src/net.h b/src/net.h
new file mode 100644
index 0000000..3b26e96
--- /dev/null
+++ b/src/net.h
@@ -0,0 +1,31 @@
+/* net.h - Copyright (C) 2010 Red Hat, Inc.
+ * Written by Adam Stokes <astokes(a)fedoraproject.org>
+ *
+ * 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.
+ */
+
+#ifndef __NET_H
+#define __NET_H
+
+#include <netcf.h>
+
+/* Start an interface */
+int net_start(struct netcf_if *);
+
+/* Stop interface */
+int net_stop(struct netcf_if *);
+
+#endif // __NET_H
diff --git a/src/qmf/netagent.cpp b/src/qmf/netagent.cpp
new file mode 100644
index 0000000..5ac7328
--- /dev/null
+++ b/src/qmf/netagent.cpp
@@ -0,0 +1,54 @@
+/* netagent.cpp - Copyright (C) 2010 Red Hat, Inc.
+ * Written by Adam Stokes <astokes(a)fedoraproject.org>
+ *
+ * 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.
+ */
+
+#ifndef WIN32
+#include "config.h"
+#endif
+
+#include "netagent.h"
+#include <qpid/agent/ManagementAgent.h>
+
+NetAgent::NetAgent()
+{ }
+
+NetAgent::~NetAgent()
+{ }
+
+void
+NetAgent::setup(ManagementAgent* agent)
+{
+ this->_agent = agent;
+ this->_management_object = new _qmf::Interface(agent, this);
+ agent->addObject(this->_management_object);
+}
+
+Manageable::status_t
+NetAgent::ManagementMethod(uint32_t method, Args& arguments, string& text)
+{
+ switch(method)
+ {
+ case _qmf::Interface::METHOD_START:
+ net_start(this->nif);
+ return Manageable::STATUS_OK;
+ case _qmf::Interface::METHOD_STOP:
+ net_stop(this->nif);
+ return Manageable::STATUS_OK;
+ }
+ return Manageable::STATUS_NOT_IMPLEMENTED;
+}
diff --git a/src/qmf/netagent.h b/src/qmf/netagent.h
new file mode 100644
index 0000000..1d3a86b
--- /dev/null
+++ b/src/qmf/netagent.h
@@ -0,0 +1,50 @@
+/* netagent.cpp - Copyright (C) 2010 Red Hat, Inc.
+ * Written by Adam Stokes <astokes(a)fedoraproject.org>
+ *
+ * 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.
+ */
+
+#ifndef __NETAGENT_H
+#define __NETAGENT_H
+
+#include <qpid/management/Manageable.h>
+#include <string>
+
+#include "net.h"
+#include "qmf/com/redhat/matahari/net/Interface.h"
+
+using namespace qpid::management;
+using namespace std;
+
+namespace _qmf = qmf::com:redhat::matahari::net;
+
+class NetAgent : public Manageable
+{
+ private:
+ _qmf::Interface* _management_object;
+ ManagementAgent* _agent;
+ struct netcf_if *nif;
+
+ public:
+ NetAgent();
+ virtual ~NetAgent();
+
+ void setup(ManagementAgent* agent);
+ ManagementObject* GetManagementObject() const { return _management_object; }
+ status_t ManagementMethod(uint32_t method, Args& arguments, string& text);
+};
+
+#endif // __NETAGENT_H
diff --git a/src/schema-net.xml b/src/schema-net.xml
index 42bb637..32eb53f 100644
--- a/src/schema-net.xml
+++ b/src/schema-net.xml
@@ -1,37 +1,10 @@
<schema package="com.redhat.matahari.net">
<class name="Interface">
- <!-- properties -->
- <property name="name" type="sstr"
access="RO" desc="Interface name" />
- <property name="mac_address" type="sstr"
access="RO" desc="Physical hardware address" />
-
<!-- APIs -->
- <method name="identify" desc="Tell network device to
blink light">
- <arg name="intf" dir="IO" type="sstr" />
- </method>
- <method name="add_address" desc="Applies new IP address
to device">
- <arg name="address" dir="IO" type="uint32" />
- <arg name="netmask" dir="IO" type="uint32" />
- <arg name="intf" dir="IO" type="sstr" />
- </method>
- <method name="remove_address" desc="Remove IP
address">
- <arg name="intf" dir="IO" type="sstr" />
- </method>
- <method name="list_addresses" desc="List IP
addresses">
- <arg name="intf" dir="IO" type="sstr" />
- </method>
- <method name="list_dns_servers" desc="List of DNS
servers">
- <arg name="intf" dir="IO" type="sstr" />
- </method>
- <method name="destroy" desc="Remove network
interface">
- <arg name="intf" dir="IO" type="sstr" />
- </method>
<method name="start" desc="Starts network
interface">
<arg name="intf" dir="IO" type="sstr" />
</method>
- <method name="restart" desc="Restarts network
interface">
- <arg name="intf" dir="IO" type="sstr" />
- </method>
<method name="stop" desc="Stops network
interface">
<arg name="intf" dir="IO" type="sstr" />
</method>
--
1.7.2.3