Exemple #1
0
class test_ClusterRepository(baseClusterTestClass):
    """
    Methods from RedhatClusterRepository
    """
    def setUp(self):
        import os.path
        from comoonics.cluster.ComClusterRepository import ClusterRepository
        super(test_ClusterRepository, self).setUp()
        #create comclusterRepository Object
        self.clusterRepository = ClusterRepository(
            os.path.join(self._testpath, "cluster2.conf"))

    def testGetnodename(self):
        # except first nic because it does not have an mac-address
        _tmp = self.nicValues[1:]
        for i in range(len(_tmp)):
            self.assertEqual(
                _tmp[i]["nodename"],
                str(self.clusterRepository.getNodeName(_tmp[i]["mac"])))
        self.assertRaises(ClusterMacNotFoundException,
                          self.clusterRepository.getNodeName, "murks")

    def testGetnodeid(self):
        # except first nic because it does not have an mac-address
        _tmp = self.nicValues[1:]
        for i in range(len(_tmp)):
            self.assertEqual(
                _tmp[i]["nodeid"],
                str(self.clusterRepository.getNodeId(_tmp[i]["mac"])))
        self.assertRaises(ClusterMacNotFoundException,
                          self.clusterRepository.getNodeId, "murks")
def test(clustername="testcluster", numnodes=5, usehostnames=False, rootvolume="/dev/vg_testcluster_sr/lv_sharedroot", netdev="eth0"):
    logging.basicConfig()
    from xml.dom.ext import PrettyPrint
    defaults = {"cluster":{"config_version":"1", "name":"clurcent5",
                                "cman":{"expected_votes":"1", "two_node":"0"},
                                "clusternodes":
                                         {"clusternode":[
                                                 {"nodeid":"N", "name":"gfs-nodeN", "votes":"1",
                                                  "com_info":{
                                                      "rootvolume":{"name":"/dev/VG_SHAREDROOT/LV_SHAREDROOT"},
                                                      "eth":[{"ip":"10.0.0.0", "name":"eth0"}],
                                                      "fenceackserver":{"passwd":"XXX", "user":"******"}},
                                                  "fence":{"method":{"name":"1"}}}]},
                                "fencedevices":{},
                                "rm":{"failoverdomains":{},"resources":{}}}}
    log.setLevel(logging.DEBUG)
    log.debug("Setting up cluster %s" %clustername)
    osrcluster=OSRCluster(clustername, usehostnames, numnodes)
    for i in range(1, 6):
        _node=OSRClusterNode(osrcluster, "name%u" %i, rootvolume)
        _node.rootvol=rootvolume
        _node.addNetdev(OSRClusterNodeNetdev(_node, netdev))
        _node.getNetdev(netdev).mac="00:00:00:xx:0%u" %i
        _node.getNetdev(netdev).ip="dhcp"
        osrcluster.addNode(_node)
    log.debug("Cluster: %s" %osrcluster)
    log.debug("Cluster as hash: %s" %osrcluster.toHash())
    from comoonics.cluster.ComClusterRepository import ClusterRepository
    _tmp=ClusterRepository(None,None,osrcluster.toHash(),defaults)
    
    log.debug("To cluster.conf: ")
    PrettyPrint(_tmp.getDocument())
Exemple #3
0
 def setUp(self):
     import os.path
     from comoonics.cluster.ComClusterRepository import ClusterRepository
     super(test_ClusterRepository, self).setUp()
     #create comclusterRepository Object
     self.clusterRepository = ClusterRepository(
         os.path.join(self._testpath, "cluster2.conf"))
Exemple #4
0
 def __init__(self):
     import comoonics.cluster
     from comoonics.cluster.ComClusterRepository import ClusterRepository
     from comoonics.cluster.ComClusterInfo import ClusterInfo
     doc=comoonics.cluster.parseClusterConf(os.path.join(testpath, "cluster.conf"))
 
     self.clusterRepository = ClusterRepository(doc.documentElement,doc)
     self.clusterinfo = ClusterInfo(self.clusterRepository)
class test_ClusterRepository(baseClusterTestClass):      
    """
    Methods from RedhatClusterRepository
    """                    
    def setUp(self):
        import os.path
        from comoonics.cluster.ComClusterRepository import ClusterRepository
        super(test_ClusterRepository, self).setUp()
        #create comclusterRepository Object
        self.clusterRepository = ClusterRepository(os.path.join(self._testpath, "cluster2.conf"))

    def testGetnodename(self):
        # except first nic because it does not have an mac-address
        _tmp = self.nicValues[1:]
        for i in range(len(_tmp)):
            self.assertEqual(_tmp[i]["nodename"], str(self.clusterRepository.getNodeName(_tmp[i]["mac"])))
        self.assertRaises(ClusterMacNotFoundException, self.clusterRepository.getNodeName,"murks")
        
    def testGetnodeid(self):
        # except first nic because it does not have an mac-address
        _tmp = self.nicValues[1:]
        for i in range(len(_tmp)):
            self.assertEqual(_tmp[i]["nodeid"], str(self.clusterRepository.getNodeId(_tmp[i]["mac"])))
        self.assertRaises(ClusterMacNotFoundException, self.clusterRepository.getNodeId,"murks")
 def __init__(self, query):
     from xml.dom.ext.reader import Sax2
     from comoonics.cluster.ComClusterRepository import ClusterRepository
     from comoonics.cluster.ComClusterInfo import ClusterInfo
     ClusterAssistantHelper.__init__(self, query)
     self.error=False
     # create Reader object
     try:
         reader = Sax2.Reader()
         _file = open("/etc/cluster/cluster.conf", "r")
         reader = Sax2.Reader()
         doc = reader.fromStream(_file)
         #create comclusterRepository Object
         clusterRepository = ClusterRepository(doc.documentElement, doc)
         #create comclusterinfo object
         self.clusterInfo = ClusterInfo(clusterRepository)
     except Exception, e:
         ComLog.getLogger(__logStrLevel__).error("Error parsing cluster.conf %s" %e)
         ComLog.errorTraceLog()       
         self.error=True
Exemple #7
0
    def init(self):
        import os.path
        from comoonics.cluster.ComClusterRepository import ClusterRepository
        from comoonics.cluster.ComClusterInfo import ClusterInfo
        from comoonics import ComSystem
        ComSystem.setExecMode(ComSystem.SIMULATE)
        super(test_ClusterNode, self).init()
        #create comclusterRepository Object
        self.clusterRepository = ClusterRepository(
            os.path.join(self._testpath, "cluster2.conf"))

        #create comclusterinfo object
        self.clusterInfo = ClusterInfo(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 test(clustername="testcluster",
         numnodes=5,
         usehostnames=False,
         rootvolume="/dev/vg_testcluster_sr/lv_sharedroot",
         netdev="eth0"):
    logging.basicConfig()
    from xml.dom.ext import PrettyPrint
    defaults = {
        "cluster": {
            "config_version": "1",
            "name": "clurcent5",
            "cman": {
                "expected_votes": "1",
                "two_node": "0"
            },
            "clusternodes": {
                "clusternode": [{
                    "nodeid": "N",
                    "name": "gfs-nodeN",
                    "votes": "1",
                    "com_info": {
                        "rootvolume": {
                            "name": "/dev/VG_SHAREDROOT/LV_SHAREDROOT"
                        },
                        "eth": [{
                            "ip": "10.0.0.0",
                            "name": "eth0"
                        }],
                        "fenceackserver": {
                            "passwd": "XXX",
                            "user": "******"
                        }
                    },
                    "fence": {
                        "method": {
                            "name": "1"
                        }
                    }
                }]
            },
            "fencedevices": {},
            "rm": {
                "failoverdomains": {},
                "resources": {}
            }
        }
    }
    log.setLevel(logging.DEBUG)
    log.debug("Setting up cluster %s" % clustername)
    osrcluster = OSRCluster(clustername, usehostnames, numnodes)
    for i in range(1, 6):
        _node = OSRClusterNode(osrcluster, "name%u" % i, rootvolume)
        _node.rootvol = rootvolume
        _node.addNetdev(OSRClusterNodeNetdev(_node, netdev))
        _node.getNetdev(netdev).mac = "00:00:00:xx:0%u" % i
        _node.getNetdev(netdev).ip = "dhcp"
        osrcluster.addNode(_node)
    log.debug("Cluster: %s" % osrcluster)
    log.debug("Cluster as hash: %s" % osrcluster.toHash())
    from comoonics.cluster.ComClusterRepository import ClusterRepository
    _tmp = ClusterRepository(None, None, osrcluster.toHash(), defaults)

    log.debug("To cluster.conf: ")
    PrettyPrint(_tmp.getDocument())
 def setUp(self):
     import os.path
     from comoonics.cluster.ComClusterRepository import ClusterRepository
     super(test_ClusterRepository, self).setUp()
     #create comclusterRepository Object
     self.clusterRepository = ClusterRepository(os.path.join(self._testpath, "cluster2.conf"))