コード例 #1
0
ファイル: utils.py プロジェクト: alcuma/keedio-stacks
def execute_sudo_krb(cmd,
                     user=None,
                     principal=None,
                     keytab=None,
                     keytab_cache=None,
                     input=None):
    import params

    secure = params.security_enabled
    user = user or params.hdfs_user
    principal = principal or params.hdfs_principal_name
    keytab = keytab or params.hdfs_user_keytab
    keytab_cache = keytab_cache or params.kerberos_cache_file

    auth_token = None

    if secure:
        import kerberosWrapper
        auth_token = kerberosWrapper.krb_wrapper(params.hdfs_principal_name,
                                                 params.hdfs_user_keytab,
                                                 params.kerberos_cache_file)
        os.environ['KRB5CCNAME'] = params.kerberos_cache_file
    else:
        cmd_aux = ["su", "-s", "/bin/bash", params.hdfs_user, "-c"]
        cmd_aux.append(' '.join(cmd))
        cmd = cmd_aux
    Logger.info("Executing %s" % str(cmd))
    executed = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    out, err = executed.communicate(input=input)
    if secure and auth_token:
        auth_token.destroy()

    return out, err, executed.returncode
コード例 #2
0
ファイル: utils.py プロジェクト: keedio/keedio-stacks
def execute_sudo_krb(cmd,user=None,principal=None,keytab=None,keytab_cache=None,input=None):
  import params
  
  secure = params.security_enabled
  user = user or params.hdfs_user
  principal = principal or params.hdfs_principal_name
  keytab = keytab or params.hdfs_user_keytab
  keytab_cache = keytab_cache or params.kerberos_cache_file
  
  auth_token=None
  
  if secure:
    import kerberosWrapper
    auth_token = kerberosWrapper.krb_wrapper(principal,keytab,keytab_cache)
    os.environ['KRB5CCNAME'] = keytab_cache
  else:
    cmd_aux = ["su","-s","/bin/bash",user,"-c"]
    cmd_aux.append(' '.join(cmd))
    cmd = cmd_aux
  Logger.info("Executing %s" % str(cmd)) 
  executed=Popen(cmd,stdin=PIPE,stdout=PIPE,stderr=PIPE)
  out,err=executed.communicate(input=input)
  if secure and auth_token:
    auth_token.destroy()

  return out,err,executed.returncode
コード例 #3
0
 def __init__(self,args):
     html_auth = None
     if args.secure:
         html_auth=HTTPKerberosAuth()
         auth_token = kerberosWrapper.krb_wrapper(args.principal,args.keytab,args.cache_file)
         os.environ['KRB5CCNAME'] = args.cache_file
     self.qjm=[{'host':journal.split(':')[0], 'journalState':Journalnode(html_auth,journal.split(':')[0],journal.split(':')[1])} for journal in args.qjm.split(',')]
     if args.secure and auth_token: auth_token.destroy() 
コード例 #4
0
 def __init__(self,args):
     self.html_auth = None
     if args.secure:
         self.html_auth=HTTPKerberosAuth()
         auth_token = kerberosWrapper.krb_wrapper(args.principal,args.keytab,args.cache_file)
         os.environ['KRB5CCNAME'] = args.cache_file
     if args.historyserver == 'localhost':
         self.historyserver = socket.getfqdn()
     else:
         self.historyserver = args.historyserver
     self.hs_port = args.hs_port
     self.hs_status = dict()
     self.status()
     if args.secure and auth_token: auth_token.destroy() 
コード例 #5
0
    def __init__(self,args):
        if args.secure:
            auth_token = kerberosWrapper.krb_wrapper(args.principal, args.keytab,args.cache_file)
            os.environ['KRB5CCNAME'] = args.cache_file
        self.zkserver = args.hosts
        self.zk_client = args.zk_client
        self.test = args.test
        self.hdfs_cluster_name=args.hdfs_cluster_name
        self.tests = {'hdfs' : self.check_hdfs,
                'hbase' : self.check_hbase,
                'kafka' : self.check_kafka
        }
        self.check_topics=args.check_topics
        self.topic=args.topic
	if args.secure and auth_token: auth_token.destroy()
コード例 #6
0
 def __init__(self,args):
     self.html_auth = None
     self.datanode_port=args.datanode_port
     if args.secure:
         self.html_auth=HTTPKerberosAuth()
         auth_token = kerberosWrapper.krb_wrapper(args.principal,args.keytab,args.cache_file)
         os.environ['KRB5CCNAME'] = args.cache_file
     status,self.hdfsreport = self.parser_hdfsreport()
     if status ==0:
         for datanode in self.hdfsreport.keys():
             if datanode != 'Total':
                 # port = self.hdfsreport[datanode]['Name'].split(':')[1]
                 self.hdfsreport[datanode]['blockscanner']=self.blockscanner(datanode,self.datanode_port)
         self.namenodes=self.getNamenodesRol(args.namenodes)
     if args.secure and auth_token: auth_token.destroy() 
コード例 #7
0
    def __init__(self,args):
	self.html_auth = None
        if args.secure:
            self.html_auth=HTTPKerberosAuth()
            auth_token = kerberosWrapper.krb_wrapper(args.principal,args.keytab,args.cache_file)
	    os.environ['KRB5CCNAME'] = args.cache_file
	if args.rm == 'localhost':
            self.rm=socket.getfqdn()
        else:
            self.rm=args.rm
        self.port=args.port
        
        self.clusterinfo=dict()
        self.clustermetrics=dict()
        self.clusternodes=[]
        self.status()
	if args.secure and auth_token: auth_token.destroy()
コード例 #8
0
 def __init__(self, args):
     html_auth = None
     if args.secure:
         html_auth = HTTPKerberosAuth()
         auth_token = kerberosWrapper.krb_wrapper(args.principal,
                                                  args.keytab,
                                                  args.cache_file)
         os.environ['KRB5CCNAME'] = args.cache_file
     self.qjm = [{
         'host':
         journal.split(':')[0],
         'journalState':
         Journalnode(html_auth,
                     journal.split(':')[0],
                     journal.split(':')[1])
     } for journal in args.qjm.split(',')]
     if args.secure and auth_token: auth_token.destroy()
コード例 #9
0
    def __init__(self,params):
	self.log_file = params.get('log_file','ganglia.') 	
	logging.basicConfig(filename='/var/log/' + self.log_file + 'oozie.log',level=logging.DEBUG)
        self.host = params.get('host','localhost')
        self.port = params.get('port','8080')
        self.secure = params.get('secure',False)
        self.html_auth=None
        self.query_size = params.get('query_size',50)

        if self.secure:
            self.principal = params.get('principal')
            self.keytab = params.get('keytab')
            self.cache_file = params.get('cache_file','/tmp/oozie_gmond.cc')
            self.html_auth=HTTPKerberosAuth()
            auth_token = kerberosWrapper.krb_wrapper(self.principal,self.keytab,self.cache_file)
            os.environ['KRB5CCNAME'] = self.cache_file
        self.coordinators = self.get_coordinators()
        if self.secure and auth_token: auth_token.destroy()
コード例 #10
0
    def __init__(self,args):
        self.html_auth = None
        if args.secure:
            self.html_auth=HTTPKerberosAuth()
            auth_token = kerberosWrapper.krb_wrapper(args.principal,args.keytab,args.cache_file)
            os.environ['KRB5CCNAME'] = args.cache_file
        self.namenode=args.namenode
        self.port=args.port
        self.path=args.path
        self.type=args.type
        self.owner=args.owner
        self.group=args.group
        self.permission=args.permission
        self.writable=args.writable
	self.admin=args.admin
        self.filescanner()
        if self.writable:
           self.checkWritable()
        if args.secure and auth_token: auth_token.destroy()
コード例 #11
0
    def __init__(self, args):
        self.html_auth = None
        if args.secure:
            self.html_auth = HTTPKerberosAuth()
            auth_token = kerberosWrapper.krb_wrapper(args.principal,
                                                     args.keytab,
                                                     args.cache_file)
            os.environ['KRB5CCNAME'] = args.cache_file
        if args.rm == 'localhost':
            self.rm = socket.getfqdn()
        else:
            self.rm = args.rm
        self.port = args.port

        self.clusterinfo = dict()
        self.clustermetrics = dict()
        self.clusternodes = []
        self.status()
        if args.secure and auth_token: auth_token.destroy()
コード例 #12
0
 def __init__(self, args):
     if args.secure:
         auth_token = kerberosWrapper.krb_wrapper(args.principal,
                                                  args.keytab,
                                                  args.cache_file)
         os.environ['KRB5CCNAME'] = args.cache_file
     self.zkserver = args.hosts
     self.zk_client = args.zk_client
     self.test = args.test
     self.hdfs_cluster_name = args.hdfs_cluster_name
     self.tests = {
         'hdfs': self.check_hdfs,
         'hbase': self.check_hbase,
         'kafka': self.check_kafka
     }
     self.check_topics = args.check_topics
     self.topic = args.topic
     if args.secure and auth_token: auth_token.destroy()
     self.zk = KazooClient(hosts=self.zkserver)
     self.zk.start()
コード例 #13
0
    def __init__(self, params):
        self.log_file = params.get('log_file', 'ganglia.')
        logging.basicConfig(filename='/var/log/' + self.log_file + 'oozie.log',
                            level=logging.DEBUG)
        self.host = params.get('host', 'localhost')
        self.port = params.get('port', '8080')
        self.secure = params.get('secure', False)
        self.html_auth = None
        self.query_size = params.get('query_size', 50)

        if self.secure:
            self.principal = params.get('principal')
            self.keytab = params.get('keytab')
            self.cache_file = params.get('cache_file', '/tmp/oozie_gmond.cc')
            self.html_auth = HTTPKerberosAuth()
            auth_token = kerberosWrapper.krb_wrapper(self.principal,
                                                     self.keytab,
                                                     self.cache_file)
            os.environ['KRB5CCNAME'] = self.cache_file
        self.coordinators = self.get_coordinators()
        if self.secure and auth_token: auth_token.destroy()
コード例 #14
0
 def __init__(self, args):
     self.html_auth = None
     if args.secure:
         self.html_auth = HTTPKerberosAuth()
         auth_token = kerberosWrapper.krb_wrapper(args.principal,
                                                  args.keytab,
                                                  args.cache_file)
         os.environ['KRB5CCNAME'] = args.cache_file
     self.namenode = args.namenode
     self.port = args.port
     self.path = args.path
     self.type = args.type
     self.owner = args.owner
     self.group = args.group
     self.permission = args.permission
     self.writable = args.writable
     self.admin = args.admin
     self.filescanner()
     if self.writable:
         self.checkWritable()
     if args.secure and auth_token: auth_token.destroy()
コード例 #15
0
 def __init__(self, args):
     self.html_auth = None
     self.datanode_port = args.datanode_port
     self.ha = args.ha
     if args.secure:
         self.html_auth = HTTPKerberosAuth()
         auth_token = kerberosWrapper.krb_wrapper(args.principal,
                                                  args.keytab,
                                                  args.cache_file)
         os.environ['KRB5CCNAME'] = args.cache_file
     status, self.hdfsreport = self.parser_hdfsreport()
     if status == 0:
         for datanode in self.hdfsreport.keys():
             if datanode != 'Total':
                 # port = self.hdfsreport[datanode]['Name'].split(':')[1]
                 self.hdfsreport[datanode][
                     'blockscanner'] = self.blockscanner(
                         datanode, self.datanode_port)
         if args.ha:
             self.namenodes = self.getNamenodesRol(args.namenodes)
     if args.secure and auth_token: auth_token.destroy()