Exemple #1
0
 def test_raises_when_invalid_resource_specification(self):
     self.assertRaises(
         CmdLineInputError,
         lambda: parse_args.parse_add(
             ["T", "master", "resource1", "something_else"]
         )
     )
Exemple #2
0
 def test_raises_when_resource_not_specified(self):
     self.assertRaises(
         CmdLineInputError,
         lambda: parse_args.parse_add(
             ["T", "loss-policy=fence"]
         )
     )
Exemple #3
0
def add(lib, argv, modifiers):
    """
    create ticket constraint
    object lib exposes library
    list argv see usage for "constraint colocation add"
    dict like object modifiers can contain
        "force" allows resource in clone/master and constraint duplicity

    Options:
      * --force - allow resource inside clone (or master), allow duplicate
        element
      * -f - CIB file
    """
    modifiers.ensure_only_supported("--force", "-f")
    ticket, resource_id, resource_role, options = parse_args.parse_add(argv)
    if "rsc-role" in options:
        raise CmdLineInputError(
            "Resource role must not be specified among options"
            +", specify it before resource id"
        )

    if resource_role:
        options["rsc-role"] = resource_role

    lib.constraint_ticket.add(
        ticket,
        resource_id,
        options,
        resource_in_clone_alowed=modifiers.get("--force"),
        duplication_alowed=modifiers.get("--force"),
    )
Exemple #4
0
def add(lib, argv, modifiers):
    """
    create ticket constraint
    object lib exposes library
    list argv see usage for "constraint colocation add"
    dict like object modifiers can contain
        "force" allows resource in clone/master and constraint duplicity
        "autocorrect" allows correct resource to its clone/master parent
    """
    ticket, resource_id, resource_role, options = parse_args.parse_add(argv)
    if "rsc-role" in options:
        raise CmdLineInputError(
            "Resource role must not be specified among options" +
            ", specify it before resource id")

    if resource_role:
        options["rsc-role"] = resource_role

    lib.constraint_ticket.add(
        ticket,
        resource_id,
        options,
        autocorrection_allowed=modifiers["autocorrect"],
        resource_in_clone_alowed=modifiers["force"],
        duplication_alowed=modifiers["force"],
    )
Exemple #5
0
def add(lib, argv, modificators):
    """
    create ticket constraint
    object lib exposes library
    list argv see usage for "constraint colocation add"
    dict like object modificators can contain
        "force" allows resource in clone/master and constraint duplicity
        "autocorrect" allows correct resource to its clone/master parent
    """
    ticket, resource_id, resource_role, options = parse_args.parse_add(argv)
    if "rsc-role" in options:
        raise CmdLineInputError(
            "Resource role must not be specified among options"
            +", specify it before resource id"
        )

    if resource_role:
        options["rsc-role"] = resource_role

    lib.constraint_ticket.add(
        ticket,
        resource_id,
        options,
        autocorrection_allowed=modificators["autocorrect"],
        resource_in_clone_alowed=modificators["force"],
        duplication_alowed=modificators["force"],
    )
Exemple #6
0
def add(lib, argv, modifiers):
    """
    create ticket constraint
    object lib exposes library
    list argv see usage for "constraint colocation add"
    dict like object modifiers can contain
        "force" allows resource in clone/master and constraint duplicity

    Options:
      * --force - allow resource inside clone (or master), allow duplicate
        element
      * -f - CIB file
    """
    modifiers.ensure_only_supported("--force", "-f")
    ticket, resource_id, resource_role, options = parse_args.parse_add(argv)
    if "rsc-role" in options:
        raise CmdLineInputError(
            "Resource role must not be specified among options"
            +", specify it before resource id"
        )

    if resource_role:
        options["rsc-role"] = resource_role

    lib.constraint_ticket.add(
        ticket,
        resource_id,
        options,
        resource_in_clone_alowed=modifiers.get("--force"),
        duplication_alowed=modifiers.get("--force"),
    )
Exemple #7
0
 def test_parse_add_args_with_resource_role(self):
     self.assertEqual(
         parse_args.parse_add(
             ["T", "master", "resource1", "ticket=T", "loss-policy=fence"]),
         ("T", "resource1", "master", {
             "ticket": "T",
             "loss-policy": "fence",
         }))
Exemple #8
0
 def test_parse_add_args(self):
     self.assertEqual(
         parse_args.parse_add(
             ["T", "resource1", "ticket=T", "loss-policy=fence"]),
         ("T", "resource1", "", {
             "ticket": "T",
             "loss-policy": "fence",
         }),
     )
Exemple #9
0
 def test_parse_add_args(self):
     self.assertEqual(
         parse_args.parse_add(
             ["T", "resource1", "ticket=T", "loss-policy=fence"]
         ),
         (
             "T",
             "resource1",
             "",
             {
                 "ticket": "T",
                 "loss-policy": "fence",
             }
         )
     )
Exemple #10
0
 def test_raises_when_resource_not_specified(self):
     self.assertRaises(
         CmdLineInputError,
         lambda: parse_args.parse_add(["T", "loss-policy=fence"]),
     )
Exemple #11
0
 def test_raises_when_invalid_resource_specification(self):
     self.assertRaises(
         CmdLineInputError,
         lambda: parse_args.parse_add(
             ["T", "master", "resource1", "something_else"]),
     )