componentName)
class MachineParameters (Engines.MachineParameters):
- def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='',
- mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='',
- mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0):
- Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS,
- mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir,
- mode, policy, parallelLib, nb_component_nodes)
+ def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='',
+ mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='',
+ mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0):
+ Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS,
+ mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir,
+ mode, policy, parallelLib, nb_component_nodes)
+
+class ContainerParameters (Engines.ContainerParameters):
+ def __init__(self, container_name='', mode='start', workingdir='', nb_proc=0, isMPI=False, parallelLib='',resource_params=None):
+ if resource_params is None:resource_params=ResourceParameters()
+ Engines.ContainerParameters.__init__(self,container_name, mode, workingdir, nb_proc, isMPI, parallelLib,resource_params)
class ResourceParameters (Engines.ResourceParameters):
def __init__(self, name="", hostname="", OS="", componentList=[],
def test0(self):
""""""
- p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="start",
- policy="best",componentList=["PYHELLO"])
- co=cm.StartContainer( p )
- print "Container:",co,co.getHostName(), co.getPID(),co._get_name()
+ rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
+ p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="start",resource_params=rp)
+ co=cm.GiveContainer( p )
self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer")
- co=cm.StartContainer( p )
+ co=cm.GiveContainer( p )
self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer")
def test1(self):
""""""
- p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="get",
- policy="best",componentList=["PYHELLO"])
- co=cm.StartContainer( p )
- print "Container:",co,co.getHostName(), co.getPID(),co._get_name()
+ rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
+ p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="get",resource_params=rp)
+ co=cm.GiveContainer( p )
self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer")
- co=cm.StartContainer( p )
+ co=cm.GiveContainer( p )
self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer")
def test2(self):
""""""
- p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="getorstart",
- policy="best",componentList=["PYHELLO"])
- co=cm.StartContainer( p )
- print "Container:",co,co.getHostName(), co.getPID(),co._get_name()
+ rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
+ p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="getorstart",resource_params=rp)
+ co=cm.GiveContainer( p )
self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer")
- co=cm.StartContainer( p )
+ co=cm.GiveContainer( p )
self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer")
if __name__ == '__main__':
- unittest.main()
+ suite = unittest.TestLoader().loadTestsFromTestCase(TestContainerManager)
+ unittest.TextTestRunner().run(suite)
import unittest
import salome
import LifeCycleCORBA
+import SALOME
salome.salome_init()
cm= salome.lcc.getContainerManager()
rm= salome.lcc.getResourcesManager()
def test0(self):
"""host required"""
- params=LifeCycleCORBA.MachineParameters(hostname="m3")
+ params=LifeCycleCORBA.ResourceParameters(hostname="m3")
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ["m3"])
def test1(self):
"""OS required"""
- params=LifeCycleCORBA.MachineParameters(OS="Linux")
- machineList=rm.GetFittingResources(params)
- self.assertEqual(machineList, [])
+ params=LifeCycleCORBA.ResourceParameters(OS="Linux")
+ self.assertRaises(SALOME.SALOME_Exception,rm.GetFittingResources,params)
def test2(self):
"""component add required"""
- params=LifeCycleCORBA.MachineParameters(componentList=["add"])
+ params=LifeCycleCORBA.ResourceParameters(componentList=["add"])
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['claui2c6', 'm1', 'm2'])
def test3(self):
"""component tutu required"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tutu"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["tutu"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['m1', 'm2', 'm3'])
def test4(self):
"""component tata required"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tata"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["tata"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['m1', 'm2'])
def test5(self):
"""component titi required"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["titi"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["titi"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['m1', 'm2'])
def test6(self):
"""component toto required"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["toto"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["toto"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['claui2c6', 'm1', 'm2'])
def test7(self):
"""components add and toto required"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['claui2c6', 'm1', 'm2'])
def test8(self):
"""components add and toto required"""
- machineDef=rm.GetMachineParameters('claui2c6')
+ machineDef=rm.GetResourceDefinition('claui2c6')
self.assertEqual(machineDef.componentList, ['toto', 'add'])
def test10(self):
"""policy altcycl"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(rm.Find('altcycl',machineList), "claui2c6")
self.assertEqual(rm.Find('altcycl',machineList), "m1")
self.assertEqual(rm.Find('altcycl',machineList), "m2")
def test11(self):
"""policy cycl"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(rm.Find('cycl',machineList), "claui2c6")
self.assertEqual(rm.Find('cycl',machineList), "m1")
self.assertEqual(rm.Find('cycl',machineList), "m2")
def test12(self):
"""policy first"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(rm.Find('first',machineList), "claui2c6")
self.assertEqual(rm.Find('first',machineList), "claui2c6")
def test13(self):
"""policy best"""
- machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"]))
+ params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"])
+ machineList=rm.GetFittingResources(params)
self.assertEqual(rm.Find('best',machineList), "claui2c6")
self.assertEqual(rm.Find('best',machineList), "m1")
self.assertEqual(rm.Find('best',machineList), "m2")
self.assertEqual(rm.Find('best',machineList), "m2")
if __name__ == '__main__':
- unittest.main()
+ suite = unittest.TestLoader().loadTestsFromTestCase(TestResourceManager)
+ unittest.TextTestRunner().run(suite)