Пример #1
0
 def callAlgorithmToAllInstances(algorithm):
     result = []
     try:
         manually_started_instances = ZorpHandler.findManullyStartedInstances(
         )
         for manually_started_instance in manually_started_instances:
             result.extend(
                 InstanceHandler.executeAlgorithmOnInstanceProcesses(
                     manually_started_instance, algorithm))
         for instance in InstancesConf():
             result.extend(
                 InstanceHandler.executeAlgorithmOnInstanceProcesses(
                     instance, algorithm))
         return result
     except Exception as e:
         return [CommandResultFailure(e.message)]
Пример #2
0
 def test_instance_generation(self):
     try:
         instancesconf = InstancesConf()
         instancesconf.instances_conf_path = self.filename
         for instance in instancesconf:
             self.assertEquals(instance.name, self.instance_name)
             self.assertEquals(instance.number_of_processes,
                               self.zorpctl_argv["num_of_processes"])
             self.assertEquals(instance.auto_restart,
                               self.zorpctl_argv["auto_restart"])
             self.assertEquals(instance.auto_start,
                               self.zorpctl_argv["auto_start"])
     except IOError as e:
         self.assertFalse(
             "Something went wrong while initializing InstancesConf object: %s"
             % e.message)
Пример #3
0
 def findManullyStartedInstances():
     import glob, os, re, subprocess
     paths = glob.glob("/var/run/zorp/zorp-*.pid")
     instance_names = []
     for path in paths:
         path_splitted = re.split('[-\.]', os.path.basename(path))
         instance_names.append(path_splitted[1])
     for zorpctl_instances in InstancesConf():
         regex = re.compile(
             zorpctl_instances.process_name.split('#')[0] + r'#[0-9]*')
         instance_names = filter(lambda i: not regex.search(i),
                                 instance_names)
     instances = []
     for instance_name in instance_names:
         instances.append(
             Instance(name=instance_name,
                      process_name=instance_name,
                      number_of_processes=1,
                      manually_started=True))
     return instances
Пример #4
0
 def searchInstance(instance_name):
     instances = []
     try:
         manually_started_instances = ZorpHandler.findManullyStartedInstances(
         )
         for manually_started_instance in manually_started_instances:
             if manually_started_instance.name == instance_name:
                 instances.append(manually_started_instance)
         for instance in InstancesConf():
             if instance.name == instance_name:
                 instances.append(instance)
         if instances:
             return instances
         else:
             return [
                 CommandResultFailure(
                     "Instance {0} not found!".format(instance_name),
                     instance_name)
             ]
     except IOError as e:
         return [CommandResultFailure(e.message)]
Пример #5
0
 def __init__(self):
     self.instancesconf = InstancesConf()