Ejemplo n.º 1
0
def processmenu(menu, parent=None):
    optioncount = len(menu['options'])
    exitmenu = False
    pm = PropertyManager("Domains/domains.properties")

    jbossHome = pm.getValue("jboss.home")
    controller = pm.getValue("controller")
    user = pm.getValue("user")
    password = pm.getValue("password")
    while not exitmenu: #Loop until the user exits the menu
        getin = runmenu(menu, parent)
        if getin == optioncount:
            exitmenu = True
        elif menu['options'][getin]['type'] == COMMAND:
            curses.def_prog_mode()    # save curent curses environment
            os.system('reset')
            screen.clear() #clears previous screen
            command = menu['options'][getin]['command'] # run the command
            command.execute(jbossHome,controller,user,password)
            screen.clear() #clears previous screen on key press and updates display based on pos
            curses.reset_prog_mode()   # reset to 'current' curses environment
            curses.curs_set(1)         # reset doesn't do this right
            curses.curs_set(0)
        elif menu['options'][getin]['type'] == MENU:
            screen.clear() #clears previous screen on key press and updates display based on pos
            processmenu(menu['options'][getin], menu) # display the submenu
            screen.clear() #clears previous screen on key press and updates display based on pos
        elif menu['options'][getin]['type'] == EXITMENU:
            exitmenu = True
Ejemplo n.º 2
0
    def sendCommand(self, jbossHome, controller, user, password, cluster, sbgroup, domain, profile):
        self.fillParameters(jbossHome, controller, user, password)
        startCommand =  self._clisg+cluster+":add(profile="+profile+",socket-binding-group="+sbgroup+")"

        print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand)

        subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd, startCommand])
        pm = PropertyManager("Domains/"+domain+".properties")
        old_clusters = pm.getValue("clusters")
        if(old_clusters == None):
            new_clusters = cluster
        else:
            new_clusters = ValueUtils.addToValues(cluster, old_clusters, ',')
        pm.updateValue("Domains/"+domain+".properties", "clusters", new_clusters)
Ejemplo n.º 3
0
    def getDomain(basefile):
        domprops = PropertyManager("Domains/"+basefile+".properties")
        domains = domprops.getValue("domains").split(',')
        for i in range(len(domains)):
            print(str(i)+") "+domains[i])

        try:
            dom = int(raw_input("numero corrispondente al dominio >"))
        except ValueError:
            raise EapManagerException("ERRORE: Inserire un numero")

        if(dom>len(domains)):
            raise EapManagerException("ERRORE: Inserire un numero che sia compreso in quelli indicati")
        else:
            return domains[dom]
Ejemplo n.º 4
0
    def getCluster(domain):
        singleprops = PropertyManager("Domains/"+domain+".properties")
        clusters = singleprops.getValue("clusters").split(",")
        for i in range(len(clusters)):
            print(str(i)+") "+clusters[i])

        try:
            clus = int(raw_input("numero corrispondente al cluster >"))
        except ValueError:
            raise EapManagerException("ERRORE: Inserire un numero")

        if(clus>len(clusters)):
            raise EapManagerException("ERRORE: Inserire un numero che sia compreso in quelli indicati")
        else:
            return clusters[clus]
Ejemplo n.º 5
0
    def getInstance(domain,cluster):
        singleprops = PropertyManager("Domains/"+domain+".properties")
        instances = singleprops.getValue("cluster."+cluster+".instances").split(",")

        for i in range(len(instances)):
            print(str(i)+") "+instances[i])

        try:
            insts = int(raw_input("numero corrispondente all'istanza >"))
        except ValueError:
            raise EapManagerException("ERRORE: Inserire un numero")

        if(insts>len(instances)):
            raise EapManagerException("ERRORE: Inserire un numero che sia compreso in quelli indicati")
        else:
            hostPrefix = singleprops.getValue("host.prefix")
            hostNumb = int(singleprops.getValue("host.number"))
            hostsuffix = singleprops.getValue("host.suffix")

            for i in range(hostNumb):
                propKey="cluster."+cluster+"."+(hostPrefix if hostPrefix != None else "")+str(i+1)+(hostsuffix if hostsuffix != None else "")+"."+"instances"
                if (str(singleprops.getValue(propKey)) == instances[insts]):
                    host = (hostPrefix if hostPrefix != None else "")+str(i+1)+(hostsuffix if hostsuffix != None else "")
                    print(host)
                    return (instances[insts],host)

            raise EapManagerException("ERRORE istanza non deifinita nella configurazione")
Ejemplo n.º 6
0
    def execute(self, jbossHome, controller, user, password):
        print chr(27) + "[2J"
        console.flush()
        print("hai chiamato deploy")

        try:
            domain = FindUtils.getDomain("domains")
            cluster = FindUtils.getCluster(domain)
            pathTuple = FindUtils.findPath()

            print("Avvio cluster: "+cluster)
            self.sendCommand(jbossHome, controller, user, password, pathTuple[0], cluster, pathTuple[1])

            key="application."+domain+"."+cluster+".name"
            fname = "Domains/"+domain+".properties"
            pm = PropertyManager()
            pm.writeValue(fname,key,pathTuple[1].strip())
            raw_input("premere un tasto per continuare...")

        except (CalledProcessError, EapManagerException) as e:
            print(e.message)
            pass
    def sendCommand(self, jbossHome, controller, user, password, domain, cluster, host, instance, offset):
        self.fillParameters(jbossHome, controller, user, password)
        startCommand =  "/host="+host+"/server-config="+instance+":add(group="+cluster+",socket-binding-port-offset="+offset+",auto-start=false)"

        print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand)

        subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,startCommand])
        pm = PropertyManager("Domains/"+domain+".properties")
        oldInstances = pm.getValue("cluster."+cluster+".instances")
        if(oldInstances == None):
            newInstances = instance
        else:
            newInstances = ValueUtils.addToValues(instance, oldInstances, ',')
        pm.updateValue("Domains/"+domain+".properties", "cluster."+cluster+".instances", newInstances)

        oldHostInstances = pm.getValue("cluster."+cluster+"."+host+".instances")
        if(oldHostInstances == None):
            newHostInstances = instance
        else:
            newHostInstances = ValueUtils.addToValues(instance, oldHostInstances, ',')
        pm.updateValue("Domains/"+domain+".properties", "cluster."+cluster+"."+host+".instances", newHostInstances)
Ejemplo n.º 8
0
 def getHostPrefix(domain):
     singleprops = PropertyManager("Domains/"+domain+".properties")
     return singleprops.getValue("host.prefix")
Ejemplo n.º 9
0
#!/usr/bin/python
import sys

from utils.PropertyManager import PropertyManager
from activecmd import DeployCommand


__author__ = "Samuele Dell'Angelo (Red Hat)"

pm = PropertyManager("""Domains/domains.properties""")

jbossHome = pm.getValue("jboss.home")
controller = pm.getValue("controller")
user = pm.getValue("user")
password = pm.getValue("password")
cluster = path = name = ""
for arg in sys.argv:
    if(str(arg).find("-path") != -1):
        path = str(arg).split("=")[1]
    if(str(arg).find("-cluster") != -1):
        cluster = str(arg).split("=")[1]
    if(str(arg).find("-name") != -1):
        name = str(arg).split("=")[1]
    if(str(arg).find("-help") != -1):
        print("USAGE: deployBatch -path=<application-path> -cluster=<cluster> -name=<application-name>")
        exit(1)

if (path == "") or (cluster == "") or (name == ""):
    print("USAGE: deployBatch -path=<application-path> -cluster=<cluster> -name=<application-name>")
    exit(1)
else:
Ejemplo n.º 10
0
    def execute(self, jbossHome, controller, user, password):
        self.fillParameters(jbossHome, controller, user, password)
        print chr(27) + "[2J"
        console.flush()
        print("hai chiamato deploy drain mode")

        try:
            domain = FindUtils.getDomain("domains")
            print("server group passive...")
            clusterA = FindUtils.getCluster(domain)
            print("server group active...")
            clusterB = FindUtils.getCluster(domain)
            pathTuple = FindUtils.findPath()
            runtimeNameList = pathTuple[0].split('/')
            runtimeNameSingle = runtimeNameList[len(runtimeNameList)-1]
            runtimeName = self._clirname+runtimeNameSingle

            deployCommand =  'deploy'
            sgCompl=self._clisgs+clusterB
            nameCompl=self._cliname+pathTuple[1]

            pm = PropertyManager("Domains/"+domain+".properties")
            hostNumb = pm.getValue("host.number")
            hostPrefix = pm.getValue("host.prefix")
            hostSuffix = pm.getValue("host.suffix")

            appKey="application."+domain+"."+clusterB+".name"

            #appName = pm.getValue(appKey)
            appName=pathTuple[1]
            
            #UNDEPLOY FROM PASSIVE CLUSTER
            #list deployments in group
            listDeploymentsPassiveCommand='ls'+" "+ self._clisg + clusterA+'/deployment'
            print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+listDeploymentsPassiveCommand)
            output = subprocess.Popen([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,listDeploymentsPassiveCommand], stdout=subprocess.PIPE ).communicate()[0]
            deploymentList = ValueUtils.parseDeploymentList(output)

            if(appName in deploymentList):
                undeployCommand=self._clisg+clusterA+self._clidpmt+appName+":undeploy()"
                print(undeployCommand)
                subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,undeployCommand])
                removeSgCommand=self._clisg+clusterA+self._clidpmt+appName+":remove()"
                print(undeployCommand)
                subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,removeSgCommand])
        
        
            #list deployments in domain
            listDeploymentsCommandDomain='ls'+" "+ '/deployment'
            print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+listDeploymentsCommandDomain)
            output = subprocess.Popen([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,listDeploymentsCommandDomain], stdout=subprocess.PIPE ).communicate()[0]
            deploymentList = ValueUtils.parseDeploymentList(output)
            #undeploy
            if(appName in deploymentList):
                #list deployments in group
                listDeploymentsCommand='ls'+" "+ self._clisg + clusterB+'/deployment'
                print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+listDeploymentsCommand)
                output = subprocess.Popen([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,listDeploymentsCommand], stdout=subprocess.PIPE ).communicate()[0]
                deploymentList = ValueUtils.parseDeploymentList(output)

                if(appName in deploymentList):
                    undeployCommand=self._clisg+clusterB+self._clidpmt+appName+":undeploy()"
                    print(undeployCommand)
                    subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,undeployCommand])
                    removeSgCommand=self._clisg+clusterB+self._clidpmt+appName+":remove()"
                    print(undeployCommand)
                    subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,removeSgCommand])
                
                removeCommand=self._clidpmt+appName+":remove()"
                print(removeCommand)
                subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,removeCommand])

            #deploy
            print(self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+deployCommand+" "+pathTuple[0]+" "+sgCompl+" "+nameCompl+" "+runtimeName)
            subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,deployCommand+" "+pathTuple[0]+" "+sgCompl+" "+nameCompl+" "+runtimeName])

            #enable contexts
            for i in range(int(hostNumb)):
                instances = pm.getValue("cluster."+clusterB+"."+hostPrefix+str(i+1)+hostSuffix+".instances").split(',')
                for instance in instances:
                    enableCommand = "/host="+hostPrefix+str(i+1)+hostSuffix+"/server="+instance+"/subsystem=modcluster:enable()"
                    print(enableCommand)
                    subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,enableCommand])


            #disable contexts
            for i in range(int(hostNumb)):
                print("cluster."+clusterA+"."+hostPrefix+str(i+1)+".instances")
                instances = pm.getValue("cluster."+clusterA+"."+hostPrefix+str(i+1)+hostSuffix+".instances").split(',')
                for instance in instances:
                    disableCommand = "/host="+hostPrefix+str(i+1)+hostSuffix+"/server="+instance+"/subsystem=modcluster:disable()"
                    print(disableCommand)
                    subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,disableCommand])

            fname = "Domains/"+domain+".properties"
            pm = PropertyManager()
            pm.updateValue(fname,appKey,pathTuple[1].strip())




        except (CalledProcessError, EapManagerException) as e:
            print(e.message)
            pass


        raw_input("premere un tasto per continuare...")
Ejemplo n.º 11
0
#!/usr/bin/python
import datetime
import os
import sys

from utils.PropertyManager import PropertyManager


__author__ = "Samuele Dell'Angelo (Red Hat)"


import shutil
import glob

pm = PropertyManager("""Domains/domains.properties""")

base_dir = pm.getValue("host.controller.jboss.home")

def findAllFiles(instance,fileType):
    path = base_dir+"/domain/servers/"+instance+"/log/"
    return glob.glob(path+"*."+fileType+"*")


def generateDestDir(instance):
    path = base_dir+"/domain/servers/"+instance+"/log/"
    now = datetime.datetime.now()
    month = str(now.month) if len(str(now.month)) == 2 else "0"+str(now.month)
    day = str(now.day) if len(str(now.day)) == 2 else "0"+str(now.day)
    hour = str(now.hour) if len(str(now.hour)) == 2 else "0"+str(now.hour)
    minute = str(now.minute) if len(str(now.minute)) == 2 else "0"+str(now.minute)
    destDir = path+"StoreLog_dd"+str(now.year)+month+day+"."+hour+minute+"/"