Exemplo n.º 1
0
def _fullCompactIndex(params):
    bg_slices = _get_bg_slices(params)
    #if the build-group parameter is not specified runs compaction for all build groups
    if params['build-group']:
        bg = params['build-group']
        if bg not in bg_slices:
            common.print_usage("Invalid build group {}".format(bg))
        bg_slices = {bg: bg_slices[bg]}

    url = "http://{}:{}/mami/indexing/soap".format(params['master'] , params['master-port'])
    wsdl_url = "{}?wsdl".format(url)
    imp = Import('exa:exa.bee', "{}?xsd=2".format(url))
    client = Client(wsdl_url, plugins=[ImportDoctor(imp)])
    for bg in bg_slices:
        nb_slices = int(bg_slices[bg])
        slices = ','.join(str(i) for i in xrange(nb_slices))
        print "Compacting slices ({}) for build group ({})".format(slices, bg)
        client.options.plugins = [common._AttributePlugin(buildGroup=bg, indexSlices=slices)]
        client.service.fullCompactIndex()
        client.options.plugins = []
        _wait_compaction_complete(client, params, bg)
Exemplo n.º 2
0
def main():
	valid_commands = ['slave', 'probe', 'indexing']
	usage = "Usage: cvcli command action parameters"
	usage_command = usage + "\nValid commands: {}".format(' '.join(valid_commands))
	if len(sys.argv) < 3:
		common.print_usage(usage_command)
	command = sys.argv[1]
	action = sys.argv[2]
	app_args = [] if len(sys.argv) == 3 else sys.argv[3:]
	try:
		module = importlib.import_module('cvcli.' + command)
	except ImportError:
		common.print_usage("Invalid command\n" + usage_command)	
	try:
		valid_actions = module.valid_actions()
		if action in ['help', '-h', '--help'] :
			common.print_usage(usage, quit=False, show_common_args=True)
			for a in valid_actions:
				ops = module.valid_options(a)
				common.print_usage("\ncvcli {} {}".format(command, a), ops=ops, quit=False)
			sys.exit(0)
		if not action in valid_actions:
			common.print_usage("\nInvalid action\n" + usage)
		options = module.valid_options(action)
		params = common.parse_args(app_args, usage, options)
		if params['help']:
			common.print_usage('', options)

		return getattr(module, action)(params)
	except AttributeError, e:
		print e
		common.print_usage("Invalid action\n" + usage)
Exemplo n.º 3
0
		common.print_usage(usage_command)
	command = sys.argv[1]
	action = sys.argv[2]
	app_args = [] if len(sys.argv) == 3 else sys.argv[3:]
	try:
		module = importlib.import_module('cvcli.' + command)
	except ImportError:
		common.print_usage("Invalid command\n" + usage_command)	
	try:
		valid_actions = module.valid_actions()
		if action in ['help', '-h', '--help'] :
			common.print_usage(usage, quit=False, show_common_args=True)
			for a in valid_actions:
				ops = module.valid_options(a)
				common.print_usage("\ncvcli {} {}".format(command, a), ops=ops, quit=False)
			sys.exit(0)
		if not action in valid_actions:
			common.print_usage("\nInvalid action\n" + usage)
		options = module.valid_options(action)
		params = common.parse_args(app_args, usage, options)
		if params['help']:
			common.print_usage('', options)

		return getattr(module, action)(params)
	except AttributeError, e:
		print e
		common.print_usage("Invalid action\n" + usage)
	except TypeError, e:
		print e
		common.print_usage("Invalid action\n" + usage)