Exemple #1
0
def validate_hbase_column_qualifier(arg, name=''):
    if name:
        name += ' '
    if not arg:
        raise InvalidOptionException(
            '%(name)shbase column qualifier not defined' % locals())
    if isHBaseColumnQualifier(arg):
        log_option('%(name)shbase column' % locals(), arg)
        return True
    raise InvalidOptionException(
        "invalid %(name)shbase column '%(arg)s' defined" % locals())
Exemple #2
0
def validate_hbase_table(arg, name=''):
    if name:
        name += ' '
    if not arg:
        raise InvalidOptionException('%(name)shbase table not defined' %
                                     locals())
    if isHBaseTable(arg):
        log_option('%(name)shbase table' % locals(), arg)
        return True
    raise InvalidOptionException(
        "invalid %(name)shbase table '%(arg)s' defined" % locals())
Exemple #3
0
def validate_hbase_rowkey(arg, name=''):
    if name:
        name += ' '
    if not arg:
        raise InvalidOptionException('%(name)shbase row key not defined' %
                                     locals())
    if isHBaseRowKey(arg):
        log_option('%(name)shbase row key' % locals(), arg)
        return True
    raise InvalidOptionException(
        "invalid %(name)shbase row key '%(arg)s' defined" % locals())
Exemple #4
0
 def connection(self, host, port, user, password, ssl=False, **kwargs):
     # must set X-Requested-By in newer versions of Ambari
     self.x_requested_by = user
     if user == 'admin':
         self.x_requested_by = os.getenv('USER', user)
     #log.info("contacting Ambari as '%s'" % self.user)
     if not isHost(host) or not isPort(port) or not isUser(user) or not password:
         raise InvalidOptionException('invalid options passed to AmbariBlueprint()')
     proto = 'http' # pylint: disable=unused-variable
     if ssl:
         proto = 'https'
     self.host = host
     self.port = port
     self.user = user
     self.password = password
     # if kwargs.has_key('strip_config') and kwargs['strip_config']:
     if 'strip_config' in kwargs and kwargs['strip_config']:
         self.strip_config = True
     self.url_base = '%(proto)s://%(host)s:%(port)s/api/v1' % locals()
     if 'dir' in kwargs and kwargs['dir']:
         self.blueprint_dir = kwargs['dir']
     if not isDirname(self.blueprint_dir):
         qquit('UNKNOWN', 'invalid dir arg passed to AmbariBlueprintTool')
     try:
         if not self.blueprint_dir or not os.path.exists(self.blueprint_dir):
             log.info("creating blueprint data dir '%s'" % self.blueprint_dir)
             os.mkdir(self.blueprint_dir)
         if not os.path.isdir(self.blueprint_dir):
             raise IOError("blueprint dir '%s'already taken and is not a directory" % self.blueprint_dir)
     except IOError as _:
         die("'failed to create dir '%s': %s" % (self.blueprint_dir, _))
Exemple #5
0
 def raise_invalidoptionexception():
     raise InvalidOptionException('test')