
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1237338803 25200 # Node ID 177ae29d2ae5c1f9fe37e8cffb000bfeb2dc28af # Parent e810ca0c3e585a0b58b1da2e280fb69232a20be1 Add basic support for creating network pools. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r e810ca0c3e58 -r 177ae29d2ae5 libxkutil/Makefile.am --- a/libxkutil/Makefile.am Fri Mar 20 16:26:02 2009 -0700 +++ b/libxkutil/Makefile.am Tue Mar 17 18:13:23 2009 -0700 @@ -4,14 +4,15 @@ CFLAGS += $(CFLAGS_STRICT) -noinst_HEADERS = cs_util.h misc_util.h device_parsing.h xmlgen.h infostore.h +noinst_HEADERS = cs_util.h misc_util.h device_parsing.h xmlgen.h infostore.h \ + pool_parsing.h lib_LTLIBRARIES = libxkutil.la AM_LDFLAGS = -lvirt -luuid libxkutil_la_SOURCES = cs_util_instance.c misc_util.c device_parsing.c \ - xmlgen.c infostore.c + xmlgen.c infostore.c pool_parsing.c noinst_PROGRAMS = xml_parse_test diff -r e810ca0c3e58 -r 177ae29d2ae5 libxkutil/pool_parsing.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libxkutil/pool_parsing.c Tue Mar 17 18:13:23 2009 -0700 @@ -0,0 +1,70 @@ +/* + * Copyright IBM Corp. 2009 + * + * Authors: + * Kaitlin Rupert <karupert@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdbool.h> +#include <inttypes.h> +#include <sys/stat.h> +#include <libxml/tree.h> +#include <libxml/parser.h> +#include <libxml/xpath.h> + +#include <libcmpiutil/libcmpiutil.h> + +#include "pool_parsing.h" +#include "../src/svpc_types.h" + +int define_pool(virConnectPtr conn, const char *xml, int res_type) +{ + int ret = 1; + + if (res_type == CIM_RES_TYPE_NET) { + virNetworkPtr ptr = virNetworkDefineXML(conn, xml); + if (ptr == NULL) { + CU_DEBUG("Unable to define virtual network"); + return 0; + } + + if (virNetworkCreate(ptr) != 0) { + CU_DEBUG("Unable to start virtual network"); + ret = 0; + + if (virNetworkUndefine(ptr) != 0) + CU_DEBUG("Unable to undefine virtual network"); + } + + virNetworkFree(ptr); + } + + return ret; +} + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ + diff -r e810ca0c3e58 -r 177ae29d2ae5 libxkutil/pool_parsing.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libxkutil/pool_parsing.h Tue Mar 17 18:13:23 2009 -0700 @@ -0,0 +1,60 @@ +/* + * Copyright IBM Corp. 2009 + * + * Authors: + * Kaitlin Rupert <karupert@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __RES_POOLS_H_ +#define __RES_POOLS_H + +#include <stdint.h> +#include <stdbool.h> +#include <libvirt/libvirt.h> + +#include "../src/svpc_types.h" + +struct net_pool { + char *addr; + char *netmask; + char *ip_start; + char *ip_end; + char *forward_mode; + char *forward_dev; +}; + +struct virt_pool { + uint16_t type; + union { + struct net_pool net; + } pool_info; + char *id; +}; + +int define_pool(virConnectPtr conn, const char *xml, int res_type); + + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */