<s> import errno <EOL> import logging <EOL> import os . path <EOL> from hadoop import confparse <EOL> from desktop . lib . security_util import get_components <EOL> from hbase . conf import HBASE_CONF_DIR , USE_DOAS <EOL> LOG = logging . getLogger ( __name__ ) <EOL> SITE_PATH = None <EOL> SITE_DICT = None <EOL> _CNF_HBASE_THRIFT_KERBEROS_PRINCIPAL = '<STR_LIT>' <EOL> _CNF_HBASE_AUTHENTICATION = '<STR_LIT>' <EOL> _CNF_HBASE_IMPERSONATION_ENABLED = '<STR_LIT>' <EOL> _CNF_HBASE_USE_THRIFT_HTTP = '<STR_LIT>' <EOL> _CNF_HBASE_USE_THRIFT_SSL = '<STR_LIT>' <EOL> def reset ( ) : <EOL> global SITE_DICT <EOL> SITE_DICT = None <EOL> def get_conf ( ) : <EOL> if SITE_DICT is None : <EOL> _parse_site ( ) <EOL> return SITE_DICT <EOL> def get_server_principal ( ) : <EOL> principal = get_conf ( ) . get ( _CNF_HBASE_THRIFT_KERBEROS_PRINCIPAL , None ) <EOL> components = get_components ( principal ) <EOL> if components is not None : <EOL> return components [ <NUM_LIT:0> ] <EOL> def get_server_authentication ( ) : <EOL> return get_conf ( ) . get ( _CNF_HBASE_AUTHENTICATION , '<STR_LIT>' ) . upper ( ) <EOL> def is_impersonation_enabled ( ) : <EOL> return get_conf ( ) . get ( _CNF_HBASE_IMPERSONATION_ENABLED , '<STR_LIT>' ) . upper ( ) == '<STR_LIT>' or USE_DOAS . get ( ) <EOL> def is_using_thrift_http ( ) : <EOL> return get_conf ( ) . get ( _CNF_HBASE_USE_THRIFT_HTTP , '<STR_LIT>' ) . upper ( ) == '<STR_LIT>' or USE_DOAS . get ( ) <EOL> def is_using_thrift_ssl ( ) : <EOL> return get_conf ( ) . get ( _CNF_HBASE_USE_THRIFT_SSL , '<STR_LIT>' ) . upper ( ) == '<STR_LIT>' <EOL> def _parse_site ( ) : <EOL> global SITE_DICT <EOL> global SITE_PATH <EOL> SITE_PATH = os . path . join ( HBASE_CONF_DIR . get ( ) , '<STR_LIT>' ) <EOL> try : <EOL> data = file ( SITE_PATH , '<STR_LIT:r>' ) . read ( ) <EOL> except IOError , err : <EOL> if err . errno != errno . ENOENT : <EOL> LOG . error ( '<STR_LIT>' % ( SITE_PATH , err ) ) <EOL> return <EOL> data = "<STR_LIT>" <EOL> SITE_DICT = confparse . ConfParse ( data ) </s>
