示例#1
0
def getTasksInfo(clusterName):
    strs =  str(clusterName) + "_tasks"
    tasksInfo = []
    message = Globals.mc.get(strs)
    print message
    if message is not None:
        return message
    tasks_sum = 0
    tasks_commit = 0
    task_info = db.select('task_info ,operation_info',where='task_info.operation_id=operation_info.id and task_info.cluster_name=$clusterName ',what = "task_info.id as taskID,description,reference,operation_id,operation_info.id,operation_type,commitSupported,pauseSupported,stopSupported,percentageSupported",vars=locals())
    tasks_sum = len(task_info)
    if tasks_sum > 0:
        for task in task_info:
            if task.operation_id == 2:
                migrate = taskService.Migrate_operation()
                (code, reval) = migrate.get_migrate_info(task.reference)
                (code,message) = taskService.getMigrateStatus(reval)
                if code == 0:
                    tasks_commit = tasks_commit + 1
            elif task.operation_id == 1:
                disk = taskService.Disk_operation()
                (code, reval) = disk.get_disk_info(task.reference)
                messages = reval.split('\n')
                message = messages[len(messages) - 1].strip()[:-1]
                code, message = taskService.getInitialStatus(reval)
                if code == 0:
                    tasks_commit = tasks_commit + 1
            else:
                rebal = taskService.Rebalance_operation()
                (code, reval) = rebal.get_rebalance_info(task.reference)
                if code == 0:
                    tasks_commit = tasks_commit + 1
        tasksInfo = tasks_commit,tasks_sum
    return tasksInfo
示例#2
0
 def run(self):
     while not self.thread_stop:
         status,local_IP = Utils.getLocal_IP()
         localIP =  local_IP.strip()
         commandWithArgs = self.operation + "status"
         status,message = Utils.executeOnServer(localIP,commandWithArgs)
         code,message = taskService.getMigrateStatus(message)
         if code == "6":
             commandWithArgs = self.operation + "commit"
             status,message = Utils.executeOnServer(localIP, commandWithArgs)
             self.thread_stop = True
         sleep(self.interval)
示例#3
0
 def run(self):
     while not self.thread_stop:
         tasks_sum = 0
         tasks_commit = 0
         serversInfo = []
         totalSpace = Decimal("0.0")
         usedSpace = Decimal("0.0")
         cluster_info = Globals.db.select('cluster_info')
         if len(cluster_info) != 0:
             for cluster in cluster_info:
                 clusterName = cluster.name
                 task_info = Globals.db.select('task_info ,operation_info',where='task_info.operation_id=operation_info.id and task_info.cluster_name=$clusterName ',what = "task_info.id as taskID,description,reference,operation_id,operation_info.id,operation_type,commitSupported,pauseSupported,stopSupported,percentageSupported",vars=locals())
                 tasks_sum = len(task_info)
                 if tasks_sum > 0:
                     for task in task_info:
                         if task.operation_id == 2:
                             migrate = taskService.Migrate_operation()
                             (code, reval) = migrate.get_migrate_info(task.reference)
                             (code,message) = taskService.getMigrateStatus(reval)
                             if code == 0:
                                 tasks_commit = tasks_commit + 1
                         elif task.operation_id == 1:
                             disk = taskService.Disk_operation()
                             (code, reval) = disk.get_disk_info(task.reference)
                             messages = reval.split('\n')
                             message = messages[len(messages) - 1].strip()[:-1]
                             code, message = taskService.getInitialStatus(reval)
                             if code == 0:
                                 tasks_commit = tasks_commit + 1
                         else:
                             rebal = taskService.Rebalance_operation()
                             (code, reval) = rebal.get_rebalance_info(task.reference)
                             if code == 0:
                                 tasks_commit = tasks_commit + 1
                     strs =  str(clusterName) + "_tasks"
                     tasksInfo = tasks_commit,tasks_sum
                     Globals.mc.set(strs,tasksInfo)
         sleep(self.interval)