def init_args(self, home, config, framework, cluster, node, **kwargs): self._init_flags(**kwargs) if home is not None: self.home = home if self.config is None or config is not None: if config is not None: self.config_file = config else: usr_conf_file = self.home + '/.config/riak-mesos/config.json' sys_conf_file = '/etc/riak-mesos/config.json' usr_home = expanduser("~") usr_home_conf_file = \ usr_home + '/.config/riak-mesos/config.json' if os.path.isfile(usr_conf_file): self.config_file = usr_conf_file elif os.path.isfile(usr_home_conf_file): self.config_file = usr_home_conf_file elif os.path.isfile(sys_conf_file): self.config_file = sys_conf_file else: self.config_file = None if self.config_file is not None: self.vlog('Using config file: ' + self.config_file) else: self.vlog('Couldn\'t find config file') self.config = RiakMesosConfig(self.config_file) if cluster is not None: self.cluster = cluster if node is not None: self.node = node if framework is not None: self.framework = framework _framework = self.config.get('framework-name') if framework is None and _framework != '': self.framework = _framework if 'timeout' in kwargs and kwargs['timeout'] is not None: self.timeout = kwargs['timeout']
def __init__(self, cli_args): self.args = {} def_conf = '/etc/riak-mesos/config.json' cli_args, config_file = extract_option(cli_args, '--config', def_conf) cli_args, self.args['riak_file'] = extract_option( cli_args, '--file', '') cli_args, self.args['lines'] = extract_option(cli_args, '--lines', '1000') cli_args, self.args['force_flag'] = extract_flag(cli_args, '--force') cli_args, self.args['json_flag'] = extract_flag(cli_args, '--json') cli_args, self.args['help_flag'] = extract_flag(cli_args, '--help') cli_args, self.args['debug_flag'] = extract_flag(cli_args, '--debug') cli_args, self.args['cluster'] = extract_option( cli_args, '--cluster', 'default') cli_args, self.args['node'] = extract_option(cli_args, '--node', '') cli_args, self.args['bucket_type'] = extract_option( cli_args, '--bucket-type', 'default') cli_args, self.args['props'] = extract_option(cli_args, '--props', '') cli_args, timeout = extract_option(cli_args, '--timeout', '60', 'integer') self.args['timeout'] = int(timeout) cli_args, num_nodes = extract_option(cli_args, '--nodes', '1', 'integer') self.args['num_nodes'] = int(num_nodes) self.cmd = ' '.join(cli_args) util.debug(self.args['debug_flag'], 'Cluster: ' + self.args['cluster']) util.debug(self.args['debug_flag'], 'Node: ' + self.args['node']) util.debug(self.args['debug_flag'], 'Nodes: ' + str(self.args['num_nodes'])) util.debug(self.args['debug_flag'], 'Command: ' + self.cmd) config = None if os.path.isfile(config_file): config = RiakMesosConfig(config_file) self.cfg = config