Kaitlin Rupert wrote:
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1211403918 25200
# Node ID 1a4f0bc12b84af40d1ebef71ea3d6d30b300af05
# Parent 00ed91b75fd62cdcdcfb51c403646118edb91c54
[TEST] Update create_netpool_conf() to support new pool creation.
This includes the following changes:
-Updated create_netpool_conf() so that caller can specify whether to use an existing
pool or create a new pool.
-Added destroy_netpool() / destroy_vnet()
-Updated CIM_NetResourceAllocationSettingData to set the PoolID
-Added xml_get_net_network().
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Jun 10 20:04:06 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed May 21 14:05:18 2008 -0700
@@ -22,6 +22,7 @@
#
import os
import pywbem
+import random
from distutils.file_util import move_file
from XenKvmLib.test_xml import *
from XenKvmLib.test_doms import *
@@ -331,19 +332,22 @@
return status, diskid
-def create_netpool_conf(server, virt):
+def create_netpool_conf(server, virt, use_existing=True):
status = PASS
test_network = None
try:
- vir_network = net_list(server, virt)
- if len(vir_network) > 0:
- test_network = vir_network[0]
- else:
- netxml = NetXML(server, virt=virt)
+ if use_existing == True:
+ vir_network = net_list(server, virt)
+ if len(vir_network) > 0:
+ test_network = vir_network[0]
+
+ if test_network == None:
+ net_name = "default-net" + str(random.randint(1, 100))
+ netxml = NetXML(server, virt=virt, networkname=net_name)
ret = netxml.create_vnet()
if not ret:
logger.error("Failed to create Virtual Network '%s'",
- test_network)
+ net_name)
status = FAIL
else:
test_network = netxml.xml_get_netpool_name()
@@ -351,3 +355,17 @@
logger.error("Exception: In fn create_netpool_conf(): %s", detail)
status=FAIL
return status, test_network
This is a good addition.
+
+def destroy_netpool(server, virt, net_name):
+ if net_name == None:
+ return FAIL
+
+ netxml = NetXML(server, virt=virt, networkname=net_name)
+ ret = netxml.destroy_vnet()
+ if not ret:
+ logger.error("Failed to destroy Virtual Network '%s'",
+ net_name)
+ return FAIL
+
+ return PASS
+
diff -r 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/vsms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Jun 10 20:04:06 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed May 21 14:05:18 2008 -0700
@@ -151,13 +151,16 @@
pass
class CIM_NetResourceAllocationSettingData(CIMClassMOF):
- def __init__(self, type, mac, name):
+ def __init__(self, type, mac, name, virt_net=None):
self.Address = mac
self.NetworkType = type
if type == 'ethernet' or type == 'bridge' :
self.ResourceType = RASD_TYPE_NET_ETHER
else:
self.ResourceType = RASD_TYPE_NET_OTHER
I think the "network" type interface should also be considered as
RASD_TYPE_NET_EHTER ?
+
+ if virt_net != None :
+ self.PoolID = "NetworkPool/%s" % virt_net
if mac != None:
self.InstanceID = '%s/%s' % (name, mac)
diff -r 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Jun 10 20:04:06 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed May 21 14:05:18 2008 -0700
@@ -215,6 +215,9 @@
def create_vnet(self):
return self.run(self.server, 'net-create', self.xml_string)
+ def destroy_vnet(self):
+ return self.run(self.server, 'net-destroy', self.net_name)
+
def xml_get_netpool_name(self):
npoolname = self.get_value_xpath('/network/name')
return npoolname
@@ -403,7 +406,12 @@
bridgeStr = self.get_value_xpath(
'/domain/devices/interface/source/@bridge')
return bridgeStr
-
+
+ def xml_get_net_network(self):
+ networkStr = self.get_value_xpath(
+ '/domain/devices/interface/source/@network')
+ return networkStr
+
def dumpxml(self, ip):
cmd = 'virsh -c %s dumpxml %s' % (self.vuri, self.dname)
s, o = utils.run_remote(ip, cmd)
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim