def __init__(self): from comoonics.cluster import getClusterRepository, getClusterInfo self.clusterRepositories = [] self.clusterInfos = [] self.clusterRepositories.append(getClusterRepository(os.path.join(testpath, "cluster.conf"))) self.clusterInfos.append(getClusterInfo(self.clusterRepositories[0])) self.clusterRepositories.append(None) self.clusterInfos.append(None) self.clusterRepositories.append(getClusterRepository(maxnodeidnum=3)) self.clusterInfos.append(getClusterInfo(self.clusterRepositories[2]))
def testClusterRepositoryEXT3(self): from comoonics import XmlTools result="""<cluster config_version="1" name="testcluster"> <clusternodes> <clusternode name="name0" nodeid="1" votes="1"> <com_info> <eth master="bond0" name="eth0" slave="yes"/> <eth master="bond0" name="eth1" slave="yes"/> <eth bondingopts="miimon=100,mode=passive" name="bond0"/> <eth gateway="10.0.0.2" ip="10.0.0.1" name="bond0.100" netmask="255.255.255.0"/> <rootvolume fstype="ext3" name="/dev/vg_testcluster_sr/lv_sharedroot"/> </com_info> <fence> <method name="1"/> </fence> </clusternode> </clusternodes> <fencedevices/> <cman expected_votes="1" two_node="0"/> <rm> <resources/> <failoverdomains/> </rm> </cluster> """ self.numnodes=1 osrcluster=OSRCluster(self.clustername, self.numnodes) for i in range(self.numnodes): _node=OSRClusterNode(osrcluster, "name%u" %i, self.rootvolume) _node.rootvol=self.rootvolume _node.rootfstype="ext3" _netdev=OSRClusterNodeNetdev(_node, "eth0") _netdev.master="bond0" _netdev.slave="yes" _node.addNetdev(_netdev) _netdev=OSRClusterNodeNetdev(_node, "eth1") _netdev.master="bond0" _netdev.slave="yes" _node.addNetdev(_netdev) _netdev=OSRClusterNodeNetdev(_node, "bond0") _netdev.bondingopts="miimon=100,mode=passive" _node.addNetdev(_netdev) _netdev=OSRClusterNodeNetdev(_node, "bond0.100") _netdev.ip="10.0.0.1" _netdev.netmask="255.255.255.0" _netdev.gateway="10.0.0.2" _node.addNetdev(_netdev) osrcluster.addNode(_node) log.debug("Cluster: %s" %osrcluster) log.debug("Cluster as hash: %s" %osrcluster.toHash()) from comoonics.cluster import getClusterRepository hash=osrcluster.toHash() tmp=getClusterRepository(None,None,hash,self.defaults) print XmlTools.toPrettyXML(tmp.getElement()) tmp=XmlTools.toPrettyXML(tmp.getElement()) self.assertEquals(result.replace(" ", "").replace("\n", ""), tmp.replace("\t", "").replace(" ", "").replace("\n", ""))
def init(self): import os.path ComSystem.setExecMode(ComSystem.SIMULATE) super(test_ClusterNodeNic, self).init() #create comclusterRepository Object self.clusterRepository = getClusterRepository(os.path.join(self._testpath, "cluster2.conf")) #create comclusterinfo object self.clusterInfo = getClusterInfo(self.clusterRepository) # setup the cashes for clustat for redhat cluster self.clusterInfo.helper.setSimOutput()
def __init__(self, query): from comoonics.cluster import getClusterRepository, getClusterInfo, clusterconf ClusterAssistantHelper.__init__(self, query) self.error=False # create Reader object try: clusterRepository = getClusterRepository(clusterconf) #create comclusterinfo object self.clusterInfo = getClusterInfo(clusterRepository) except Exception, e: ComLog.getLogger(__logStrLevel__).error("Error parsing cluster.conf %s" %e) ComLog.errorTraceLog() self.error=True
def init(self): import os.path ComSystem.setExecMode(ComSystem.SIMULATE) super(test_ClusterNode, self).init() #create comclusterRepository Object self.clusterRepository = getClusterRepository(os.path.join(self._testpath, "cluster2.conf")) #create comclusterinfo object self.clusterInfo = getClusterInfo(self.clusterRepository) # setup the cashes for clustat for redhat cluster self.clusterInfo.helper.setSimOutput() self.nics=list() for node in self.clusterInfo.getNodes(): node.helper.output=self.clusterInfo.helper.output for nic in node.getNics(): self.nics.append(nic)
def testClusterRepositoryGFS(self): from comoonics import XmlTools self.numnodes=5 result="""<cluster config_version="1" name="testcluster"> <clusternodes> <clusternode name="name0" nodeid="1" votes="1"> <com_info> <eth ip="dhcp" mac="00:00:00:xx:00" name="eth0"/> <rootvolume fstype="gfs" name="/dev/vg_testcluster_sr/lv_sharedroot"/> <filesystems> <filesystem dest="/var/run" fstype="bind" mountopts="defaults" source="/.cluster/cdsl/%(param0)s/var/run"/> </filesystems> </com_info> <fence> <method name="1"/> </fence> </clusternode> <clusternode name="name1" nodeid="2" votes="1"> <com_info> <eth ip="dhcp" mac="00:00:00:xx:01" name="eth0"/> <rootvolume fstype="gfs" name="/dev/vg_testcluster_sr/lv_sharedroot"/> <filesystems> <filesystem dest="/var/run" fstype="bind" mountopts="defaults" source="/.cluster/cdsl/%(param0)s/var/run"/> </filesystems> </com_info> <fence> <method name="1"/> </fence> </clusternode> <clusternode name="name2" nodeid="3" votes="1"> <com_info> <eth ip="dhcp" mac="00:00:00:xx:02" name="eth0"/> <rootvolume fstype="gfs" name="/dev/vg_testcluster_sr/lv_sharedroot"/> <filesystems> <filesystem dest="/var/run" fstype="bind" mountopts="defaults" source="/.cluster/cdsl/%(param0)s/var/run"/> </filesystems> </com_info> <fence> <method name="1"/> </fence> </clusternode> <clusternode name="name3" nodeid="4" votes="1"> <com_info> <eth ip="dhcp" mac="00:00:00:xx:03" name="eth0"/> <rootvolume fstype="gfs" name="/dev/vg_testcluster_sr/lv_sharedroot"/> <filesystems> <filesystem dest="/var/run" fstype="bind" mountopts="defaults" source="/.cluster/cdsl/%(param0)s/var/run"/> </filesystems> </com_info> <fence> <method name="1"/> </fence> </clusternode> <clusternode name="name4" nodeid="5" votes="1"> <com_info> <eth ip="dhcp" mac="00:00:00:xx:04" name="eth0"/> <rootvolume fstype="gfs" name="/dev/vg_testcluster_sr/lv_sharedroot"/> <filesystems> <filesystem dest="/var/run" fstype="bind" mountopts="defaults" source="/.cluster/cdsl/%(param0)s/var/run"/> </filesystems> </com_info> <fence> <method name="1"/> </fence> </clusternode> </clusternodes> <fencedevices/> <cman expected_votes="1" two_node="0"/> <rm> <resources/> <failoverdomains/> </rm> </cluster> """ log.debug("Setting up cluster %s" %self.clustername) osrcluster=OSRCluster(self.clustername, self.numnodes) for i in range(self.numnodes): _node=OSRClusterNode(osrcluster, "name%u" %i, self.rootvolume) _node.rootvol=self.rootvolume _node.rootfstype="gfs" _node.addNetdev(OSRClusterNodeNetdev(_node, self.netdev)) _node.getNetdev(self.netdev).mac="00:00:00:xx:0%u" %i _node.getNetdev(self.netdev).ip="dhcp" _node.addFilesystem(OSRClusterNodeFilesystem(_node, "bind", "/.cluster/cdsl/%(param0)s/var/run", "/var/run")) osrcluster.addNode(_node) log.debug("Cluster: %s" %osrcluster) log.debug("Cluster as hash: %s" %osrcluster.toHash()) from comoonics.cluster import getClusterRepository tmp=getClusterRepository(None,None,osrcluster.toHash(),self.defaults) print XmlTools.toPrettyXML(tmp.getElement()) tmp=XmlTools.toPrettyXML(tmp.getElement()) self.assertEquals(result.replace(" ", "").replace("\n", ""), tmp.replace("\t", "").replace(" ", "").replace("\n", ""))