コード例 #1
0
ファイル: cluster.py プロジェクト: gdubroeucq/Clustershell_GG
def check_depend(clustershell_IHM, service, name, j):
    if (service[j].dependance != ""):
        serv = str(service[j].dependance)
        serv_split = serv.split(",")
        taske = task_self()
        nodes = str(service[j].noeuds)
        result = []
        error_nodes = []
        for m in range(0, len(serv_split)):
            out = ""
            output = ""
            cli = "service %s start" % serv_split[m]
            taske.shell(cli, nodes=nodes)
            taske.run()
            for output, nodelist in taske.iter_buffers():
                result.append(serv_split[m])
                print(
                    "/!\ Avortement /!\ %s: le service %s n'est pas activé ou installé"
                    % (NodeSet.fromlist(nodelist), serv_split[m]))
                clustershell_IHM.listWidget.addItem(
                    u"Avortement %s: le service %s n'est pas activé ou installé"
                    % (NodeSet.fromlist(nodelist), serv_split[m]))
                dep = "Avortement %s: le service %s n'est pas activé ou installé" % (
                    NodeSet.fromlist(nodelist), serv_split[m])
                clustershell_IHM.list_recap.append(
                    recap_cluster(serv, serv_split[m],
                                  NodeSet.fromlist(nodelist), 0, 1, dep))

    else:
        return (True, 0)
    if (len(result) == 0):
        return (True, 0)
    else:
        return (False, result)
コード例 #2
0
ファイル: cluster.py プロジェクト: gdubroeucq/Clustershell_GG
def check_etat_noeud2(etatnoeud_IHM, nodeset):

    etatnoeud_IHM.listWidget.clear()
    etatnoeud_IHM.listWidget_2.clear()
    etatnoeud_IHM.listWidget_3.clear()

    i = 1

    print nodeset
    for node in nodeset:
        cli = "echo Hello"
        taske = task_self()
        taske.shell(cli, nodes=node)
        taske.run()

        for output, nodelist in task_self().iter_buffers():
            if (output == "Hello"):

                etatnoeud_IHM.listWidget.insertItem(
                    i, "%s" % (NodeSet.fromlist(nodelist)))
                i = i + 1

            else:
                etatnoeud_IHM.listWidget_2.insertItem(
                    i, "%s" % (NodeSet.fromlist(nodelist)))
                i = i + 1
                etatnoeud_IHM.sortie.append(output)
                print "output: %s" % output
コード例 #3
0
ファイル: script.py プロジェクト: gdubroeucq/Clustershell_GG
def main():
    if len(sys.argv) <= 3:
        print "Veuillez entrer des paramètres (./script.py node[1-3] cron stop)"
    else:
        if ((len(sys.argv) % 2) == 0):
            try:  # vérifie les erreurs de syntaxe pour les nodes
                nodeset = NodeSet(sys.argv[1])
            except:
                print("Erreur: Problème avec la syntaxe \"%s\"" % sys.argv[1])
                return
            for i in range(2, len(sys.argv)):
                if i % 2 == 0:  # pour chaque chiffre pair
                    if (sys.argv[i + 1] == 'start' or 'stop' or 'status'
                            or 'restart' or 'reload'):
                        task = task_self()
                        cli = "service %s %s" % (sys.argv[i], sys.argv[i + 1])
                        task.shell(cli, nodes=sys.argv[1])
                        task.run()
                        for output, nodelist in task.iter_buffers():
                            print ''
                            print '%s: %s' % (NodeSet.fromlist(nodelist),
                                              output)
                    else:
                        print(
                            "Erreur: Veuillez vérifier que la commande soit compris dans [start,stop,status,restart,reload]"
                        )
        else:
            print("Erreur: Veuillez vérifier le nombre de paramètres")
コード例 #4
0
def run_task(cmd):
        task = task_self()
        for node in NodeSet('@pbsadmin'):
                task.run(cmd, nodes=node, timeout=60)
                for output, nodelist in task.iter_buffers():
                        if str(NodeSet.fromlist(nodelist)) == node:
                                return str(output)
                return None
コード例 #5
0
ファイル: IHM.py プロジェクト: gdubroeucq/Clustershell_GG
    def check_etat_noeud():
        etatnoeud_IHM.listWidget.clear()
        etatnoeud_IHM.listWidget_2.clear()
        etatnoeud_IHM.listWidget_3.clear()

        i = 1
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Warning)
        msg.setWindowTitle("Erreur")
        noeuds = etatnoeud_IHM.lineEdit.text()
        print "noeuds %s" % noeuds
        if (noeuds != ""):
            try:
                nodeset = NodeSet(str(noeuds))
                print nodeset
                for node in nodeset:
                    cli = "echo Hello"
                    taske = task_self()
                    taske.shell(cli, nodes=node)
                    taske.run()

                    for output, nodelist in task_self().iter_buffers():
                        if (output == "Hello"):

                            etatnoeud_IHM.listWidget.insertItem(
                                i, u"%s" % (NodeSet.fromlist(nodelist)))
                            i = i + 1

                        else:
                            etatnoeud_IHM.listWidget_2.insertItem(
                                i, u"%s" % (NodeSet.fromlist(nodelist)))
                            i = i + 1
                            etatnoeud_IHM.sortie.append(output)
                            print "output: %s" % output

            except:
                msg.setText("Oups ! Probleme")
                msg.exec_()

        else:
            msg.setText("Veuillez rentrer un ou plusieur noeuds")
            msg.setDetailedText(
                "node1,node2\nnode[1-5]\nnode1,node[5-6]\netc...")
            msg.exec_()
コード例 #6
0
ファイル: cluster.py プロジェクト: gdubroeucq/Clustershell_GG
def clustershell(clustershell_IHM, service, i):
    task = task_self()
    name = str(service[i].nom)
    name_split = name.split(",")
    state = str(service[i].action)
    nodes = str(service[i].noeuds)
    test_depend, result = check_depend(clustershell_IHM, service, name, i)
    if (test_depend == True):
        for n in range(0, len(name_split)):
            out = ""
            output = ""
            cli = "service %s %s" % (name_split[n], state)
            task.shell(cli, nodes=nodes)
            task.run()
            nodeset = NodeSet(nodes)
            for output, nodelist in task.iter_buffers():
                print("FAIL %s: %s %s" %
                      (name_split[n], NodeSet.fromlist(nodelist), output))
                clustershell_IHM.listWidget.addItem(
                    u"FAIL %s: %s %s" %
                    (name_split[n], NodeSet.fromlist(nodelist), output))
                nodeset.remove(NodeSet.fromlist(nodelist))
                clustershell_IHM.list_recap.append(
                    recap_cluster(name, name_split[n],
                                  NodeSet.fromlist(nodelist), 0, 2, output))
            if (str(nodeset) != nodes):
                if (len(nodeset) > 0):
                    print("OK %s: %s" % (name_split[n], nodeset))
                    clustershell_IHM.listWidget.addItem(
                        u"OK %s: %s" % (name_split[n], nodeset))
                    clustershell_IHM.list_recap.append(
                        recap_cluster(name, name_split[n], nodeset, 1))
            if (str(nodeset) == nodes):
                print("OK %s: %s" % (name_split[n], nodes))
                clustershell_IHM.listWidget.addItem(u"OK %s: %s" %
                                                    (name_split[n], nodes))
                clustershell_IHM.list_recap.append(
                    recap_cluster(name, name_split[n], nodes, 1))
コード例 #7
0
def clustershell(doc, service):  # Commandes distribuées
    recap = []
    for i in range(0, len(service)):
        task = task_self()
        name = service[i]
        name_split = service[i].split(",")
        state = doc[i].get(name).get("state")
        nodes = doc[i].get(name).get("nodes")
        x, y = getTerminalSize()
        string = "TASK: [%s]" % name
        star = '*' * (x - len(string))
        print("%s %s" % (string, star))
        test_depend, result, error_nodes = check_depend(doc, name, i)
        if (test_depend == True):
            for n in range(0, len(name_split)):
                out = ""
                output = ""
                cli = "service %s %s" % (name_split[n], state)
                task.shell(cli, nodes=nodes)
                task.run()
                space = ' ' * (15 - len(name_split[n]))
                printout(
                    "%s%s:  state=%s     nodes=%s\n" %
                    (name_split[n], space, state, nodes), YELLOW)
                for output, nodelist in task.iter_buffers():
                    printout(
                        'Error: %s: %s\n' %
                        (NodeSet.fromlist(nodelist), output), RED)
                    recap.append(0)
                if (out == output):
                    printout("OK\n", GREEN)
                    recap.append(1)
                print("")
        else:
            space = ' ' * (15 - len(name))
            printout(
                "%s%s:  state=%s    nodes=%s\n" % (name, space, state, nodes),
                YELLOW)
            printout(
                "Error depend %s: le(s) service(s) %s n'est(sont) pas activé(s) ou installé(s)\n"
                % (error_nodes, result), RED)
            print("")
            for yop in range(0, len(name_split)):
                recap.append(0)
    return recap
コード例 #8
0
def run_task(cmd):
    """ run task on pbs server node """

    task = task_self()

    for node in NodeSet('@pbsadmin'):
        """ run on pbs nodes until it works """
        #print (cmd, node)
        task.run(cmd, nodes=node, timeout=60)

        #print 'node: %s error: %s' % (node, task.node_error(node))
        vlog(
            4, '%s timeouts:%s Error=%s' %
            (node, task.num_timeout(), task.node_error(node)))

        for output, nodelist in task.iter_buffers():
            #print 'nodelist:%s' % NodeSet.fromlist(nodelist)
            if str(NodeSet.fromlist(nodelist)) == node:
                return str(output)
            #print '%s: %s' % (NodeSet.fromlist(nodelist), output)

    return None
コード例 #9
0
def check_depend(doc, name, i):
    if (doc[i].get(name).get("depend") != None):
        serv = doc[i].get(name).get("depend")
        serv_split = serv.split(",")
        taske = task_self()
        nodes = doc[i].get(name).get("nodes")
        # out=""
        # output=""
        result = []
        for m in range(0, len(serv_split)):
            out = ""
            output = ""
            cli = "service %s start" % serv_split[m]
            taske.shell(cli, nodes=nodes)
            taske.run()
            for output, nodelist in taske.iter_buffers():
                result.append(serv_split[m])
                error_nodes = NodeSet.fromlist(nodelist)
    else:
        return (True, 0, 0)
    if (len(result) == 0):
        return (True, 0, 0)
    else:
        return (False, result, error_nodes)
コード例 #10
0
ファイル: Server.py プロジェクト: bullxpfs/lustre-shine
 def nodeset(self):
     """Return a NodeSet from server hostnames."""
     return NodeSet.fromlist((srv.hostname for srv in self))
コード例 #11
0
	def display(self, task) :
		self.clearnodes()
		for output, nodeset in task.iter_buffers() :
			self.nodes['text'] += str(NodeSet.fromlist(nodeset)) + ' ' + str(output) + '\n'
コード例 #12
0
ファイル: Server.py プロジェクト: gauthierdelerce/shine
 def nodeset(self):
     """Return a NodeSet from server hostnames."""
     return NodeSet.fromlist((srv.hostname for srv in self))
コード例 #13
0
	def display(self, task) :
		self.clearnodes()
		for output, nodeset in task.iter_buffers() :
			self.nodes['text'] += str(NodeSet.fromlist(nodeset)) + ' ' + str(output) + '\n'
		service = self.services.get(self.services.curselection()[0])
		self.enableactions(self.application.config['services'][service]['actions'])
コード例 #14
0
if len(sys.argv) == 4 :
	action = sys.argv[2]
	nodes = [(sys.argv[1], 'service ', sys.argv[1], sys.argv[3])]
elif len(sys.argv) == 3 :
	config.load()

	action = sys.argv[2]
	nodes = config.fetchNodes(sys.argv[1], action)
	
	if len(nodes) == 0 :
		print 'Service ' + sys.argv[1] + ' not found'
		exit(2)

else :
	print 'Usage : ' + sys.argv[0] + ' <service> <action> <nodeset>'
	exit(1)

task = task_self()

for service, daemon, manager, node in nodes:
	if config.checkAction(service, action) :
		task.shell(manager + daemon + ' ' + action, nodes=node)

	else :
		print 'Action "' + action + '" is not supported by ' + service
		print 'Actions supported : ' + config.listActions(service)
task.run()

for output, nodeset in task.iter_buffers():
	print NodeSet.fromlist(nodeset), output
コード例 #15
0
	def addnode(self, nodelist) :
		self.nodes.insert(END, unicode(NodeSet.fromlist(map(str, nodelist))))
		self.edited()