def stonith_create(lib, argv, modifiers): if modifiers["before"] and modifiers["after"]: raise error("you cannot specify both --before and --after{0}".format( "" if modifiers["group"] else " and you have to specify --group" )) if not modifiers["group"]: if modifiers["before"]: raise error("you cannot use --before without --group") elif modifiers["after"]: raise error("you cannot use --after without --group") if len(argv) < 2: usage.stonith(["create"]) sys.exit(1) stonith_id = argv[0] stonith_type = argv[1] parts = parse_create_args(argv[2:]) settings = dict( allow_absent_agent=modifiers["force"], allow_invalid_operation=modifiers["force"], allow_invalid_instance_attributes=modifiers["force"], ensure_disabled=modifiers["disabled"], use_default_operations=not modifiers["no-default-ops"], wait=modifiers["wait"], ) if not modifiers["group"]: lib.stonith.create( stonith_id, stonith_type, parts["op"], parts["meta"], parts["options"], **settings ) else: adjacent_resource_id = None put_after_adjacent = False if modifiers["after"]: adjacent_resource_id = modifiers["after"] put_after_adjacent = True if modifiers["before"]: adjacent_resource_id = modifiers["before"] put_after_adjacent = False lib.stonith.create_in_group( stonith_id, stonith_type, modifiers["group"], parts["op"], parts["meta"], parts["options"], adjacent_resource_id=adjacent_resource_id, put_after_adjacent=put_after_adjacent, **settings )
def stonith_create(lib, argv, modifiers): """ Options: * --before - specified resource inside a group before which new resource will be placed inside the group * --after - specified resource inside a group after which new resource will be placed inside the group * --group - specifies group in which resource will be created * --force - allow not existing agent, invalid operations or invalid instance attributes * --disabled - created reource will be disabled * --no-default-ops - do not add default operations * --wait * -f - CIB file """ modifiers.ensure_only_supported( "--before", "--after", "--group", "--force", "--disabled", "--no-default-ops", "--wait", "-f", ) if modifiers.is_specified("--before") and modifiers.is_specified( "--after"): raise error("you cannot specify both --before and --after{0}".format( "" if modifiers. is_specified("--group") else " and you have to specify --group")) if not modifiers.is_specified("--group"): if modifiers.is_specified("--before"): raise error("you cannot use --before without --group") elif modifiers.is_specified("--after"): raise error("you cannot use --after without --group") if len(argv) < 2: raise CmdLineInputError() stonith_id = argv[0] stonith_type = argv[1] parts = parse_create_args(argv[2:]) settings = dict( allow_absent_agent=modifiers.get("--force"), allow_invalid_operation=modifiers.get("--force"), allow_invalid_instance_attributes=modifiers.get("--force"), ensure_disabled=modifiers.get("--disabled"), use_default_operations=not modifiers.get("--no-default-ops"), wait=modifiers.get("--wait"), ) if not modifiers.get("--group"): lib.stonith.create(stonith_id, stonith_type, parts["op"], parts["meta"], parts["options"], **settings) else: adjacent_resource_id = None put_after_adjacent = False if modifiers.get("--after"): adjacent_resource_id = modifiers.get("--after") put_after_adjacent = True if modifiers.get("--before"): adjacent_resource_id = modifiers.get("--before") put_after_adjacent = False lib.stonith.create_in_group(stonith_id, stonith_type, modifiers.get("--group"), parts["op"], parts["meta"], parts["options"], adjacent_resource_id=adjacent_resource_id, put_after_adjacent=put_after_adjacent, **settings)
def stonith_create(lib, argv, modifiers): """ Options: * --before - specified resource inside a group before which new resource will be placed inside the group * --after - specified resource inside a group after which new resource will be placed inside the group * --group - specifies group in which resource will be created * --force - allow not existing agent, invalid operations or invalid instance attributes * --disabled - created reource will be disabled * --no-default-ops - do not add default operations * --wait * -f - CIB file """ modifiers.ensure_only_supported( "--before", "--after", "--group", "--force", "--disabled", "--no-default-ops", "--wait", "-f", ) if modifiers.is_specified("--before") and modifiers.is_specified("--after"): raise error("you cannot specify both --before and --after{0}".format( "" if modifiers.is_specified("--group") else " and you have to specify --group" )) if not modifiers.is_specified("--group"): if modifiers.is_specified("--before"): raise error("you cannot use --before without --group") if modifiers.is_specified("--after"): raise error("you cannot use --after without --group") if len(argv) < 2: raise CmdLineInputError() stonith_id = argv[0] stonith_type = argv[1] parts = parse_create_args(argv[2:]) settings = dict( allow_absent_agent=modifiers.get("--force"), allow_invalid_operation=modifiers.get("--force"), allow_invalid_instance_attributes=modifiers.get("--force"), ensure_disabled=modifiers.get("--disabled"), use_default_operations=not modifiers.get("--no-default-ops"), wait=modifiers.get("--wait"), ) if not modifiers.get("--group"): lib.stonith.create( stonith_id, stonith_type, parts["op"], parts["meta"], parts["options"], **settings ) else: adjacent_resource_id = None put_after_adjacent = False if modifiers.get("--after"): adjacent_resource_id = modifiers.get("--after") put_after_adjacent = True if modifiers.get("--before"): adjacent_resource_id = modifiers.get("--before") put_after_adjacent = False lib.stonith.create_in_group( stonith_id, stonith_type, modifiers.get("--group"), parts["op"], parts["meta"], parts["options"], adjacent_resource_id=adjacent_resource_id, put_after_adjacent=put_after_adjacent, **settings )