Esempio n. 1
0
 def runas(cls, user, cmd, env=None, logoutput=True, runKinit=True):
     if Ambari.is_cluster_secure() and runKinit:
         if user is None:
             user = Config.getEnv('USER')
         kerbTicket = Machine.getKerberosTicket(user=user, rmIfExists=True)
         if not env:
             env = {}
         env['KRB5CCNAME'] = kerbTicket
         user = None
     return Machine.runas(user, cmd, env=env, logoutput=logoutput)
Esempio n. 2
0
    def run(
            cls,
            cmd,
            cwd=None,
            env=None,
            mavenOpts=None,
            logoutput=True,
            user=None,
            version=_version,
            mvn_url=_maven_download_url
    ):

        # Overriding this function with run2
        # Thre reason being that newer HW products may or may not include Hadoop as a part of the package
        # Having import of Hadoop module crashes the run because the Hadoop configurations are not being found.
        # In order to overcome that we set the krb5ccname in run and pass the same to the run2 function
        # which then executes the maven command

        # if running a secure cluster get a kerb ticket
        krb5ccname = None
        #Notifying that java tests are being executed.
        pytest.java_tests_wrapped = True
        from beaver.component.ambari import Ambari
        if Ambari.is_cluster_secure():
            krb5ccname = Machine.getKerberosTicket(user)

        exit_code, stdout = cls.run2(
            cmd,
            cwd=cwd,
            env=env,
            mavenOpts=mavenOpts,
            logoutput=logoutput,
            user=user,
            version=version,
            mvn_url=mvn_url,
            krb5ccname=krb5ccname
        )
        return exit_code, stdout
Esempio n. 3
0
ZOO_CFG_FILE = os.path.join(ZOOKEEPER_CONF_DIR, 'zoo.cfg')
ZOOKEEPER_ENV_FILE = os.path.join(ZOOKEEPER_CONF_DIR, 'zookeeper-env.sh')
HADOOPQA_USER = Config.get('hadoop', 'HADOOPQA_USER')

if Machine.type() == 'Windows':
    ZK_CLI_CMD = os.path.join(ZK_HOME, 'bin', 'zkCli.cmd')
    NETCAT_CMD = Config.get('zookeeper', 'ZOOKEEPER_NETCAT_HOME')
    ZK_SERVER_CMD = os.path.join(ZK_HOME.replace("client", "server"), 'bin',
                                 'zkServer.cmd')
else:
    ZK_CLI_CMD = os.path.join(ZK_HOME, 'bin', 'zkCli.sh')
    NETCAT_CMD = "nc"
    ZK_SERVER_CMD = os.path.join(ZK_HOME.replace("client", "server"), 'bin',
                                 'zkServer.sh')

if Ambari.is_cluster_secure():
    keytabFile = Machine.getHeadlessUserKeytab(HADOOPQA_USER)
    _kinitloc = Machine.which("kinit", "root")
    _cmd = "%s  -k -t %s %s" % (_kinitloc, keytabFile,
                                Machine.get_user_principal(HADOOPQA_USER))
    exit_code, output = Machine.run(_cmd)


class Zookeeper(object):
    _zkHosts = None
    _version = None
    _zkPort = None

    @classmethod
    def run(cls, cmd, env=None, logoutput=True, runKinit=True):
        return cls.runas(user=None,