Beispiel #1
0
 def do_sigar(self, line):
     """Run a sigar command. See help for details"""
     if line.strip() != '':
         sigar_jar = gd.getGlobalData(gd.SIGAR_JAR)
         if not os.path.isfile(sigar_jar):
             if gd.getGlobalData(gd.INSTALLATION_TYPE) == hq_utils.DEV:
                 print "Could not find sigar JAR file - Please build the project before using this command"
             else:
                 print "Could not find sigar JAR file in. Expected location is %s" % sigar_jar
             return
         run_java_jar(sigar_jar, line)
     else:
         print "sigar command parameters are missing. Use 'sigar help' for details"
Beispiel #2
0
 def do_sigar(self,line):
     """Run a sigar command. See help for details"""
     if line.strip() != '':
         sigar_jar = gd.getGlobalData(gd.SIGAR_JAR)
         if not os.path.isfile(sigar_jar):
             if gd.getGlobalData(gd.INSTALLATION_TYPE) == hq_utils.DEV:
                 print "Could not find sigar JAR file - Please build the project before using this command"
             else:
                 print "Could not find sigar JAR file in. Expected location is %s"  % sigar_jar
             return
         run_java_jar(sigar_jar,line)
     else:
         print "sigar command parameters are missing. Use 'sigar help' for details"
Beispiel #3
0
#       Run "support-package.sh -l" for a complete list of all variables and their explanation.
#       See data/support-commands.common for detailed explanation.

keep_detail_folder = False
try:
    try:
        # Detect the architecture
        arch = detectArchitecture()
        addGlobalData(gd.ARCH,arch)
        # Find the path of the script
        scripts_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
        addGlobalData(gd.SCRIPTS_PATH,os.path.abspath(scripts_path))
        # Detect HQ related information
        # NOTE: Assumption is that script is in $HQ_HOME/support/scripts/
        detectHQInformation(os.path.abspath(os.path.join(scripts_path,'..','..')))
        arch = gd.getGlobalData(gd.ARCH)

        # Save java executable location as a variable
        addGlobalData(gd.JAVA_EXECUTABLE,os.path.join(gd.getGlobalData(gd.JRE),'bin','java'))
        java_executable = gd.getGlobalData(gd.JAVA_EXECUTABLE)
        # Save lib folder as a variable
        lib_folder = os.path.join(scripts_path,'..','lib')
        addGlobalData(gd.LIB_FOLDER,lib_folder)
        # Save jython JAR location as a variable
        jython_jar_location = os.path.join(lib_folder,'jython.jar')
        addGlobalData(gd.JYTHON_JAR_LOCATION,jython_jar_location)
        # Save the command line to run jython as a variable
        run_jython = '%(java_executable)s -jar %(jython_jar_location)s ' % vars()
        addGlobalData(gd.RUN_JYTHON,run_jython)
        # Save the command line to run a platform-independent tar as a variable
        simple_tar_path = os.path.join(scripts_path,'common','simpletar.py')
Beispiel #4
0
 def help_sigar(self):
     print "Run a sigar command\n"
     sigar_jar = gd.getGlobalData(gd.SIGAR_JAR)
     run_java_jar(sigar_jar, 'help')
Beispiel #5
0
def run_java_jar(jar_path, arg_str):
    java_executable = gd.getGlobalData(gd.JAVA_EXECUTABLE)
    s = "%s -jar %s %s" % (java_executable, jar_path, arg_str)
    subprocess.call(s, shell=True)
Beispiel #6
0
def run_with_jython(script_name, arg_str):
    run_jython = gd.getGlobalData(gd.RUN_JYTHON)
    s = "%s %s %s" % (run_jython, script_name, arg_str)
    subprocess.call(s, shell=True)
Beispiel #7
0
    def postloop(self):
        print

    def emptyline(self):
        pass


detectArchitecture()
# Find the path of the script
scripts_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
# NOTE: Assumption is that script is in $HQ_HOME/support/scripts/
hq_utils.detectHQInformation(
    os.path.abspath(os.path.join(scripts_path, '..', '..')))

s = SupportCmd(scripts_path)
s.prompt = "hq>"

try:
    if len(sys.argv) > 1:
        s.onecmd(" ".join(sys.argv[1:]))
    else:
        print "Hyperic HQ Support Frontend. Enter help to see available commands."
        print "HQ installation type is %s" % gd.getGlobalData(
            gd.INSTALLATION_TYPE)
        print "JRE folder %s" % os.path.abspath(gd.getGlobalData(gd.JRE))
        print "Jython JAR location: %s" % os.path.abspath(
            gd.getGlobalData(gd.JYTHON_JAR_LOCATION))
        s.cmdloop()
except KeyboardInterrupt, e:
    pass
Beispiel #8
0
def detectHQInformation(hq_home):
    # Add hq home as a a variable
    addGlobalData(gd.HQ_HOME,hq_home)

    # Detect the HQ installation type
    installation_type = getInstallationType(hq_home)
    addGlobalData(gd.INSTALLATION_TYPE,installation_type)
    # If it's a server installation,
    if installation_type == SERVER:
        addGlobalData(gd.SERVER_HOME,hq_home)
        expected_jre_location = os.path.join(hq_home,"jre")
        if os.path.exists(expected_jre_location):
            addGlobalData(gd.SERVER_JRE,expected_jre_location)
            addGlobalData(gd.JRE,expected_jre_location)
        else:
            # Add JAVA_HOME as the JRE path
            if 'JAVA_HOME' in os.environ.keys():
                addGlobalData(gd.JRE,os.environ['JAVA_HOME'])
        addGlobalData(gd.SUPPORT_BASE,os.path.join(hq_home,'support'))
    else:
        # If it's an agent installation
        if installation_type == AGENT:
            addGlobalData(gd.AGENT_HOME,hq_home)
            expected_jre_location = os.path.join(hq_home,"jre")
            if os.path.exists(expected_jre_location):
                addGlobalData(gd.AGENT_JRE,expected_jre_location)
                addGlobalData(gd.JRE,expected_jre_location)
            else:
                # add JAVA_HOME as the JRE path
                if 'JAVA_HOME' in os.environ.keys():
                    addGlobalData(gd.JRE,os.environ['JAVA_HOME'])
            addGlobalData(gd.SUPPORT_BASE,os.path.join(hq_home,'support'))
        else:
            # If it's a dev machine
            if installation_type == DEV:
                # Then add JAVA_HOME as the JRE path if it exists
                if 'JAVA_HOME' in os.environ.keys():
                    addGlobalData(gd.JRE,os.environ['JAVA_HOME'])
                addGlobalData(gd.SUPPORT_BASE,os.path.join(hq_home,'resources'))
                # Save the location of the support source-code project
                addGlobalData(gd.SUPPORT_PROJECT_BASE,os.path.join(hq_home,'..','..'))
            else:
                raise Exception("Unknown installation type")

    # Save lib folder as a variable
    lib_folder = os.path.join(gd.getGlobalData(gd.SUPPORT_BASE),'lib')
    addGlobalData(gd.LIB_FOLDER,lib_folder)

    # Save java executable location as a variable
    addGlobalData(gd.JAVA_EXECUTABLE,os.path.join(gd.getGlobalData(gd.JRE),'bin','java'))
    java_executable = gd.getGlobalData(gd.JAVA_EXECUTABLE)
    # Save jython JAR location as a variable
    jython_jar_location = os.path.join(gd.getGlobalData(gd.LIB_FOLDER),'jython.jar')
    addGlobalData(gd.JYTHON_JAR_LOCATION,jython_jar_location)
    # Save the command line to run jython as a variable
    run_jython = '%(java_executable)s -jar %(jython_jar_location)s ' % vars()
    addGlobalData(gd.RUN_JYTHON,run_jython)
    # Save the command line to run a platform-independent tar as a variable
    simple_tar_path = os.path.join(gd.getGlobalData(gd.SUPPORT_BASE),'scripts','common','simpletar.py')
    simple_tar_command = '%(run_jython)s %(simple_tar_path)s' % vars()
    addGlobalData(gd.SIMPLE_TAR,simple_tar_command)

    if installation_type == SERVER or installation_type == AGENT:
        # TODO Get sigar version automatically
        sigar_jar = os.path.abspath(os.path.join(gd.getGlobalData(gd.SUPPORT_BASE),'lib','sigar','sigar-1.6.6.jar'))
    else:
        # On dev machines, we need to take the sigar jar from the target folder
        sigar_jar = os.path.abspath(os.path.join(gd.getGlobalData(gd.SUPPORT_PROJECT_BASE),'target','generated-resources','lib-sigar','sigar-1.6.6.jar'))
    addGlobalData(gd.SIGAR_JAR,sigar_jar)

    addGlobalData(gd.RUN_SIGAR,'%(java_executable)s -jar %(sigar_jar)s' % vars())
Beispiel #9
0
def detectHQInformation(hq_home):
    # Add hq home as a a variable
    addGlobalData(gd.HQ_HOME, hq_home)

    # Detect the HQ installation type
    installation_type = getInstallationType(hq_home)
    addGlobalData(gd.INSTALLATION_TYPE, installation_type)
    # If it's a server installation,
    if installation_type == SERVER:
        addGlobalData(gd.SERVER_HOME, hq_home)
        expected_jre_location = os.path.join(hq_home, "jre")
        if os.path.exists(expected_jre_location):
            addGlobalData(gd.SERVER_JRE, expected_jre_location)
            addGlobalData(gd.JRE, expected_jre_location)
        else:
            # Add JAVA_HOME as the JRE path
            if 'JAVA_HOME' in os.environ.keys():
                addGlobalData(gd.JRE, os.environ['JAVA_HOME'])
        addGlobalData(gd.SUPPORT_BASE, os.path.join(hq_home, 'support'))
    else:
        # If it's an agent installation
        if installation_type == AGENT:
            addGlobalData(gd.AGENT_HOME, hq_home)
            expected_jre_location = os.path.join(hq_home, "jre")
            if os.path.exists(expected_jre_location):
                addGlobalData(gd.AGENT_JRE, expected_jre_location)
                addGlobalData(gd.JRE, expected_jre_location)
            else:
                # add JAVA_HOME as the JRE path
                if 'JAVA_HOME' in os.environ.keys():
                    addGlobalData(gd.JRE, os.environ['JAVA_HOME'])
            addGlobalData(gd.SUPPORT_BASE, os.path.join(hq_home, 'support'))
        else:
            # If it's a dev machine
            if installation_type == DEV:
                # Then add JAVA_HOME as the JRE path if it exists
                if 'JAVA_HOME' in os.environ.keys():
                    addGlobalData(gd.JRE, os.environ['JAVA_HOME'])
                addGlobalData(gd.SUPPORT_BASE,
                              os.path.join(hq_home, 'resources'))
                # Save the location of the support source-code project
                addGlobalData(gd.SUPPORT_PROJECT_BASE,
                              os.path.join(hq_home, '..', '..'))
            else:
                raise Exception("Unknown installation type")

    # Save lib folder as a variable
    lib_folder = os.path.join(gd.getGlobalData(gd.SUPPORT_BASE), 'lib')
    addGlobalData(gd.LIB_FOLDER, lib_folder)

    # Save java executable location as a variable
    addGlobalData(gd.JAVA_EXECUTABLE,
                  os.path.join(gd.getGlobalData(gd.JRE), 'bin', 'java'))
    java_executable = gd.getGlobalData(gd.JAVA_EXECUTABLE)
    # Save jython JAR location as a variable
    jython_jar_location = os.path.join(gd.getGlobalData(gd.LIB_FOLDER),
                                       'jython.jar')
    addGlobalData(gd.JYTHON_JAR_LOCATION, jython_jar_location)
    # Save the command line to run jython as a variable
    run_jython = '%(java_executable)s -jar %(jython_jar_location)s ' % vars()
    addGlobalData(gd.RUN_JYTHON, run_jython)
    # Save the command line to run a platform-independent tar as a variable
    simple_tar_path = os.path.join(gd.getGlobalData(gd.SUPPORT_BASE),
                                   'scripts', 'common', 'simpletar.py')
    simple_tar_command = '%(run_jython)s %(simple_tar_path)s' % vars()
    addGlobalData(gd.SIMPLE_TAR, simple_tar_command)

    if installation_type == SERVER or installation_type == AGENT:
        # TODO Get sigar version automatically
        sigar_jar = os.path.abspath(
            os.path.join(gd.getGlobalData(gd.SUPPORT_BASE), 'lib', 'sigar',
                         'sigar-1.6.6.jar'))
    else:
        # On dev machines, we need to take the sigar jar from the target folder
        sigar_jar = os.path.abspath(
            os.path.join(gd.getGlobalData(gd.SUPPORT_PROJECT_BASE), 'target',
                         'generated-resources', 'lib-sigar',
                         'sigar-1.6.6.jar'))
    addGlobalData(gd.SIGAR_JAR, sigar_jar)

    addGlobalData(gd.RUN_SIGAR,
                  '%(java_executable)s -jar %(sigar_jar)s' % vars())
Beispiel #10
0
 def help_sigar(self):
     print "Run a sigar command\n"
     sigar_jar = gd.getGlobalData(gd.SIGAR_JAR)
     run_java_jar(sigar_jar,'help')
Beispiel #11
0
def run_java_jar(jar_path,arg_str):
    java_executable = gd.getGlobalData(gd.JAVA_EXECUTABLE)
    s = "%s -jar %s %s" % (java_executable,jar_path,arg_str)
    subprocess.call(s,shell=True)
Beispiel #12
0
def run_with_jython(script_name,arg_str):
    run_jython = gd.getGlobalData(gd.RUN_JYTHON)
    s = "%s %s %s" % (run_jython,script_name,arg_str)
    subprocess.call(s,shell=True)
Beispiel #13
0
        """quit - Quit the frontend"""
        return True

    def postloop(self):
        print

    def emptyline(self):
        pass


detectArchitecture()
# Find the path of the script
scripts_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
# NOTE: Assumption is that script is in $HQ_HOME/support/scripts/
hq_utils.detectHQInformation(os.path.abspath(os.path.join(scripts_path,'..','..')))

s = SupportCmd(scripts_path)
s.prompt = "hq>"

try:
    if len(sys.argv) > 1:
        s.onecmd(" ".join(sys.argv[1:]))
    else:
        print "Hyperic HQ Support Frontend. Enter help to see available commands."
        print "HQ installation type is %s" % gd.getGlobalData(gd.INSTALLATION_TYPE)
        print "JRE folder %s" % os.path.abspath(gd.getGlobalData(gd.JRE))
        print "Jython JAR location: %s" % os.path.abspath(gd.getGlobalData(gd.JYTHON_JAR_LOCATION))
        s.cmdloop()
except KeyboardInterrupt,e:
    pass
Beispiel #14
0
#       See data/support-commands.common for detailed explanation.

keep_detail_folder = False
try:
    try:
        # Detect the architecture
        arch = detectArchitecture()
        addGlobalData(gd.ARCH, arch)
        # Find the path of the script
        scripts_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
        addGlobalData(gd.SCRIPTS_PATH, os.path.abspath(scripts_path))
        # Detect HQ related information
        # NOTE: Assumption is that script is in $HQ_HOME/support/scripts/
        detectHQInformation(
            os.path.abspath(os.path.join(scripts_path, '..', '..')))
        arch = gd.getGlobalData(gd.ARCH)

        # Save java executable location as a variable
        addGlobalData(gd.JAVA_EXECUTABLE,
                      os.path.join(gd.getGlobalData(gd.JRE), 'bin', 'java'))
        java_executable = gd.getGlobalData(gd.JAVA_EXECUTABLE)
        # Save lib folder as a variable
        lib_folder = os.path.join(scripts_path, '..', 'lib')
        addGlobalData(gd.LIB_FOLDER, lib_folder)
        # Save jython JAR location as a variable
        jython_jar_location = os.path.join(lib_folder, 'jython.jar')
        addGlobalData(gd.JYTHON_JAR_LOCATION, jython_jar_location)
        # Save the command line to run jython as a variable
        run_jython = '%(java_executable)s -jar %(jython_jar_location)s ' % vars(
        )
        addGlobalData(gd.RUN_JYTHON, run_jython)