Beispiel #1
0
def action(live=False):
    base = {
        Optional("namespace"):
        All(str, NotIn(["common"], msg="'common' is reserved")),
        Optional("connection-namespace"):
        str,
        Optional("protocols"):
        object,
        Optional("role"): [str],
        Optional("timeout"):
        timeout(),
        Optional("repeat"):
        Range(min=1),  # TODO: where to put it?
        Optional("failure_retry"):
        Range(min=1),  # TODO: where to put it?
    }

    if not live:
        return base
    return {
        **base,
        Optional("lava-lxc"): object,
        Optional("lava-multinode"): {
            Optional("timeout"): timeout(),
            Optional("roles"): dict,
        },
        Optional("lava-vland"): object,
        Optional("lava-xnbd"): object,
        Optional("repeat-count"): Range(min=0),
    }
Beispiel #2
0
def action():
    return {
        Optional("namespace"): All(str, NotIn(["common"], msg="'common' is reserved")),
        Optional("connection-namespace"): str,
        Optional("protocols"): object,
        Optional("role"): [str],
        Optional("timeout"): timeout(),
        Optional("repeat"): Range(min=1),  # TODO: where to put it?
        Optional("failure_retry"): Range(min=1),  # TODO: where to put it?
    }
Beispiel #3
0
def test_not_in():
    """Verify that NotIn works."""
    schema = Schema({"color": NotIn(frozenset(["blue", "red", "yellow"]))})
    schema({"color": "orange"})
    try:
        schema({"color": "blue"})
    except Invalid as e:
        assert_equal(str(e), "value is not allowed for dictionary value @ data['color']")
    else:
        assert False, "Did not raise NotInInvalid"
Beispiel #4
0
def Positive(thetype):
    """Demand a positive number type"""
    if thetype == int:
        return All(thetype, Range(1, float('inf')))
    else:
        return All(thetype, Range(0, float('inf')), NotIn([0]))
Beispiel #5
0
 # the label for this task
 Required("label"): str,
 # description of the task (for metadata)
 Required("description"): str,
 # attributes for this task
 Optional("attributes"): {str: object},
 # relative path (from config.path) to the file task was defined in
 Optional("job-from"): str,
 # dependencies of this task, keyed by name; these are passed through
 # verbatim and subject to the interpretation of the Task's get_dependencies
 # method.
 Optional("dependencies"): {
     All(
         str,
         NotIn(
             ["self", "decision"],
             "Can't use 'self` or 'decision' as depdency names.",
         ),
     ): object,
 },
 # Soft dependencies of this task, as a list of tasks labels
 Optional("soft-dependencies"): [str],
 Optional("requires"): Any("all-completed", "all-resolved"),
 # expiration and deadline times, relative to task creation, with units
 # (e.g., "14 days").  Defaults are set based on the project.
 Optional("expires-after"): str,
 Optional("deadline-after"): str,
 # custom routes for this task; the default treeherder routes will be added
 # automatically
 Optional("routes"): [str],
 # custom scopes for this task; any scopes required for the worker will be
 # added automatically. The following parameters will be substituted in each