# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1219444183 25200
# Node ID b445b3731ab95f0a00b0e9076f3be6adbb426562
# Parent 6fe50a81ce144056f1223f6af5f10804e915af37
[TEST] Add network pool name arg to create_netpool_conf()
Also, add a check to see if the network pool name supplied is one of the pools currently
defined (if any are defined).
Change default_network_pool to be a name that isn't likely to be in use (or at least,
commonly used).
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 6fe50a81ce14 -r b445b3731ab9 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Aug 20 14:28:01 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Fri Aug 22 15:29:43 2008 -0700
@@ -39,6 +39,8 @@
from VirtLib.live import diskpool_list, virsh_version, net_list, domain_list
from XenKvmLib.vxml import PoolXML, NetXML
from XenKvmLib.enumclass import getInstance
+from VirtLib import utils
+from XenKvmLib import const
test_dpath = "foo"
disk_file = '/etc/libvirt/diskpool.conf'
@@ -373,7 +375,8 @@
return status, diskid
-def create_netpool_conf(server, virt, use_existing=False):
+def create_netpool_conf(server, virt, use_existing=False,
+ net_name=const.default_network_name):
status = PASS
test_network = None
try:
@@ -383,7 +386,14 @@
test_network = vir_network[0]
if test_network == None:
- net_name = "default-net" + str(random.randint(1, 100))
+ cmd = "virsh -c %s net-list --all | grep %s" % \
+ (utils.virt2uri(virt), net_name)
+ ret, out = utils.run_remote(server, cmd)
+ if out != "":
+ logger.error("Network pool with name '%s' already
exists",
+ net_name)
+ return FAIL, "Unknown"
+
netxml = NetXML(server, virt=virt, networkname=net_name)
ret = netxml.create_vnet()
if not ret:
diff -r 6fe50a81ce14 -r b445b3731ab9 suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Aug 20 14:28:01 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Fri Aug 22 15:29:43 2008 -0700
@@ -27,7 +27,7 @@
# vxml.NetXML
default_bridge_name = 'testbridge'
-default_network_name = 'default-net'
+default_network_name = 'cimtest-networkpool'
default_net_type = 'network'
#vxml.PoolXML