コード例 #1
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "algorithm":  { "$ref": "#/pScheduler/Limit/String" },
            "as":         { "$ref": "#/pScheduler/Limit/Boolean" },
            "dest-port":  { "$ref": "#/pScheduler/Limit/Cardinal" },
            "dest":       { "$ref": "#/pScheduler/Limit/String" },
            "first-ttl":  { "$ref": "#/pScheduler/Limit/Cardinal" },
            "fragment":   { "$ref": "#/pScheduler/Limit/Boolean" },
            "hops":       { "$ref": "#/pScheduler/Limit/Cardinal" },
            "hostnames":  { "$ref": "#/pScheduler/Limit/Boolean" },
            "ip-version": { "$ref": "#/pScheduler/Limit/CardinalList" },
            "length":     { "$ref": "#/pScheduler/Limit/Cardinal" },
            "probe-type": { "$ref": "#/pScheduler/Limit/String" },
            "queries":    { "$ref": "#/pScheduler/Limit/Cardinal" },
            "sendwait":   { "$ref": "#/pScheduler/Limit/Duration" },
            "source":     { "$ref": "#/pScheduler/Limit/String" },
            "tos":        { "$ref": "#/pScheduler/Limit/CardinalZeroList" },
            "wait":       { "$ref": "#/pScheduler/Limit/Duration" }
        },
        "additionalProperties": False
        }

    return json_validate(json, schema)
コード例 #2
0
ファイル: validate.py プロジェクト: thom1555/pscheduler
def spec_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "duration": {
                "$ref": "#/pScheduler/Duration"
            },
            "host": {
                "$ref": "#/pScheduler/Host"
            },
            "host-node": {
                "$ref": "#/pScheduler/URLHostPort"
            },
            "interval": {
                "$ref": "#/pScheduler/Duration"
            },
            "parting-comment": {
                "$ref": "#/pScheduler/String"
            },
            "starting-comment": {
                "$ref": "#/pScheduler/String"
            },
        },
        "required": ["duration"]
    }
    return json_validate(json, schema)
コード例 #3
0
ファイル: validate.py プロジェクト: smritigambhir/pscheduler
def spec_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "dawdle": {
                "$ref": "#/pScheduler/Duration"
            },
            "fail": {
                "$ref": "#/pScheduler/Probability"
            },
            "dest": {
                "$ref": "#/pScheduler/Host"
            },
            "dest-node": {
                "$ref": "#/pScheduler/URLHostPort"
            },
            "source": {
                "$ref": "#/pScheduler/Host"
            },
            "source-node": {
                "$ref": "#/pScheduler/URLHostPort"
            },
            "test-material": {
                "$ref": "#/pScheduler/String"
            },
            "timeout": {
                "$ref": "#/pScheduler/Duration"
            },
        },
        "required": ["dest"]
    }
    return json_validate(json, schema)
コード例 #4
0
ファイル: validate.py プロジェクト: thom1555/pscheduler
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "host": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "host-node": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "query": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "record": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "timeout": {
                "$ref": "#/pScheduler/Limit/Duration"
            },
            "nameserver": {
                "$ref": "#/pScheduler/Limit/String"
            },
        },
        "additionalProperties": False
    }
    return json_validate(json, schema)
コード例 #5
0
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "dawdled": {
                "$ref": "#/pScheduler/Duration"
            },
            "elapsed-time": {
                "$ref": "#/pScheduler/Duration"
            },
            "received": {
                "$ref": "#/pScheduler/String"
            },
            "sent": {
                "$ref": "#/pScheduler/String"
            },
            "succeeded": {
                "$ref": "#/pScheduler/Boolean"
            },
        },
        "required": [
            "dawdled",
            "elapsed-time",
            "received",
            "sent",
            "succeeded",
        ]
    }
    return json_validate(json, schema)
コード例 #6
0
ファイル: validate.py プロジェクト: krihal/pscheduler
def result_is_valid(json):
    schema = {
        "type":
        "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "succeeded": {
                "$ref": "#/pScheduler/Boolean"
            },
            "loops": {
                "$ref": "#/pScheduler/String"
            },
            "average_put_time": {
                "$ref": "#/pScheduler/Float"
            },
            "average_get_time": {
                "$ref": "#/pScheduler/Float"
            },
            "average_delete_time": {
                "$ref": "#/pScheduler/Float"
            },
            "time": {
                "$ref": "#/pScheduler/Duration"
            }
        },
        "required": [
            "schema", "succeeded", "average_put_time", "average_get_time",
            "average_delete_time"
        ]
    }
    return json_validate(json, schema)
コード例 #7
0
ファイル: validate.py プロジェクト: thom1555/pscheduler
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "succeeded": {
                "$ref": "#/pScheduler/Boolean"
            },
            "time": {
                "$ref": "#/pScheduler/Duration"
            },
            "data": {
                "type": "array",
                "items": {
                    "$ref": "#/pScheduler/SNMPResult"
                }
            },
        },
        "required": [
            "schema",
            "succeeded",
            "data",
            "time",
        ]
    }
    return json_validate(json, schema)
コード例 #8
0
ファイル: numericrange.py プロジェクト: thom1555/pscheduler
    def __init__(self, nrange):
        """Construct a range from a JSON NumericRange."""

        # TODO: Would be nice if this class could treat missing
        # lower/upper as -/+ infinity.

        # TODO: Figure out why this can't just point to a NumericRange

        valid, message = pscheduler.json_validate(nrange, {
            "type": "object",
            "properties": {
                "lower": {"$ref": "#/pScheduler/Numeric"},
                "upper": {"$ref": "#/pScheduler/Numeric"}
            },
            "additionalProperties": False,
            "required": ["lower", "upper"]
        })

        if not valid:
            raise ValueError("Invalid numeric range: %s" % message)

        lower = nrange['lower']
        if type(lower) in [str, unicode]:
            self.lower = pscheduler.si_as_number(lower)
        else:
            self.lower = lower
        self.lower_str = str(lower)

        upper = nrange['upper']
        if type(upper) in [str, unicode]:
            self.upper = pscheduler.si_as_number(upper)
        else:
            self.upper = upper
        self.upper_str = str(upper)
コード例 #9
0
ファイル: validate.py プロジェクト: thom1555/pscheduler
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "host": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "host-node": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "oid": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "dest": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "community": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "version": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "protocol": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "timeout": {
                "$ref": "#/pScheduler/Limit/Duration"
            },
            "security-name": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "auth-protocol": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "priv-protocol": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "auth-key": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "priv-key": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "security-level": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "context": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "type": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "value": {
                "$ref": "#/pScheduler/Limit/String"
            },
        },
        "additionalProperties": False
    }

    return json_validate(json, schema)
コード例 #10
0
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "time": {
                "$ref": "#/pScheduler/Duration"
            },
            "succeeded": {
                "$ref": "#/pScheduler/Boolean"
            },
            "bytes-sent": {
                "$ref": "#/pScheduler/String"
            },
            "throughput": {
                "$ref": "#/pScheduler/String"
            },
        },
        "required": [
            "schema",
            "succeeded",
            "time",
        ]
    }
    return json_validate(json, schema)
コード例 #11
0
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "dawdle": {
                "$ref": "#/pScheduler/Limit/Duration"
            },
            "fail": {
                "$ref": "#/pScheduler/Limit/Probability"
            },
            "dest": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "ip-version": {
                "$ref": "#/pScheduler/Limit/IPVersion"
            },
            "test-material": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "timeout": {
                "$ref": "#/pScheduler/Limit/Duration"
            }
        },
        "additionalProperties": False
    }

    return json_validate(json, schema)
コード例 #12
0
def spec_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "duration": {
                "$ref": "#/pScheduler/Duration"
            },
            "host": {
                "$ref": "#/pScheduler/Host"
            },
            "host-node": {
                "$ref": "#/pScheduler/URLHostPort"
            },
            "parting-comment": {
                "$ref": "#/pScheduler/String"
            },
            "starting-comment": {
                "$ref": "#/pScheduler/String"
            },
        },
        "additionalProperties": False,
        "required": [
            "duration",
        ]
    }

    return json_validate(json, schema, max_schema=MAX_SCHEMA)
コード例 #13
0
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": { "$ref": "#/pScheduler/Cardinal" },
            "algorithm":  { "$ref": "#/pScheduler/Limit/String" },
            "as":         { "$ref": "#/pScheduler/Limit/Boolean" },
            "dest-port":  { "$ref": "#/pScheduler/Limit/Cardinal" },
            "dest":       { "$ref": "#/pScheduler/Limit/String" },
            "first-ttl":  { "$ref": "#/pScheduler/Limit/Cardinal" },
            "fragment":   { "$ref": "#/pScheduler/Limit/Boolean" },
            "hops":       { "$ref": "#/pScheduler/Limit/Cardinal" },
            "hostnames":  { "$ref": "#/pScheduler/Limit/Boolean" },
            "ip-version": { "$ref": "#/pScheduler/Limit/CardinalList" },
            "length":     { "$ref": "#/pScheduler/Limit/Cardinal" },
            "probe-type": { "$ref": "#/pScheduler/Limit/String" },
            "queries":    { "$ref": "#/pScheduler/Limit/Cardinal" },
            "sendwait":   { "$ref": "#/pScheduler/Limit/Duration" },
            "source":     { "$ref": "#/pScheduler/Limit/String" },
            "tos":        { "$ref": "#/pScheduler/Limit/CardinalZeroList" },
            "wait":       { "$ref": "#/pScheduler/Limit/Duration" }
        },
        "additionalProperties": False
        }

    return json_validate(json, schema)
コード例 #14
0
    def test_enumerate_fields(self):
        """
        Run enumerate command, verify is valid JSON, output contain required fields and
        the JSON "name" and "scheduling-class" fields match this classes properties
        """
        #Run command
        result_json = self.run_cmd("")

        #validate JSON returned
        data_validator = {
            "type": "object",
            "properties": {
                "enum": {
                    "$ref": "#/pScheduler/PluginEnumeration/Test"
                }
            },
            "additionalProperties": False,
            "required": ["enum"]
        }
        valid, error = json_validate({"enum": result_json}, data_validator)
        assert valid, error
        #verify name is as expected
        self.assertEqual(result_json['name'], self.name)
        #scheduling class is as expected
        self.assertEqual(result_json['scheduling-class'],
                         self.scheduling_class)
コード例 #15
0
    def __init__(self, drange):
        """Construct a range from a JSON DurationRange."""

        # TODO: Would be nice if this class could treat missing
        # lower/upper as zero or infinity.

        # TODO: Figure out why this can't just point to a DurationRange

        valid, message = pscheduler.json_validate(drange, {
            "type": "object",
            "properties": {
                "lower": {"$ref": "#/pScheduler/Duration"},
                "upper": {"$ref": "#/pScheduler/Duration"}
            },
            "additionalProperties": False,
            "required": ["lower", "upper"]
        })

        if not valid:
            raise ValueError("Invalid duration range: %s" % message)

        self.lower_str = drange['lower']
        self.lower = pscheduler.iso8601_as_timedelta(self.lower_str)
        self.upper_str = drange['upper']
        self.upper = pscheduler.iso8601_as_timedelta(self.upper_str)
コード例 #16
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def spec_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema":            { "$ref": "#/pScheduler/Cardinal" },
            "count":             { "$ref": "#/pScheduler/Cardinal" },
            "dest":              { "$ref": "#/pScheduler/Host" },
            # TODO: This is supposed to be a 20-bit number.  Validate that.
            "flowlabel":         { "$ref": "#/pScheduler/CardinalZero" },
            "hostnames":         { "$ref": "#/pScheduler/Boolean" },
            "interval":          { "$ref": "#/pScheduler/Duration" },
            "ip-version":        { "$ref": "#/pScheduler/ip-version" },
            "source":            { "$ref": "#/pScheduler/Host" },
            "suppress-loopback": { "$ref": "#/pScheduler/Boolean" },
            "tos":               { "$ref": "#/pScheduler/Cardinal" },
            "length":            { "$ref": "#/pScheduler/Cardinal" },
            "ttl":               { "$ref": "#/pScheduler/Cardinal" },
            "deadline":          { "$ref": "#/pScheduler/Duration" },
            "timeout":           { "$ref": "#/pScheduler/Duration" },
            },
        "required": [
            "schema",
            "dest",
            ]
        }
    return json_validate(json, schema)
コード例 #17
0
ファイル: validate.py プロジェクト: thom1555/pscheduler
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "succeeded": {
                "$ref": "#/pScheduler/Boolean"
            },
            "local": {
                "$ref": "#/pScheduler/ClockState"
            },
            "remote": {
                "$ref": "#/pScheduler/ClockState"
            },
            "difference": {
                "$ref": "#/pScheduler/Duration"
            },
        },
        "required": [
            "succeeded",
            "local",
            "remote",
            "difference",
        ]
    }
    return json_validate(json, schema)
コード例 #18
0
ファイル: durationrange.py プロジェクト: perfsonar/pscheduler
    def __init__(self, drange):

        """Construct a range from a JSON DurationRange."""

        # TODO: Would be nice if this class could treat missing
        # lower/upper as zero or infinity.

        # TODO: Figure out why this can't just point to a DurationRange

        valid, message = pscheduler.json_validate(drange, {
            "type": "object",
            "properties": {
                "lower": { "$ref": "#/pScheduler/Duration" },
                "upper": { "$ref": "#/pScheduler/Duration" }
            },
            "additionalProperties": False,
            "required": [ "lower", "upper" ]
        })

        if not valid:
            raise ValueError("Invalid duration range: %s" % message)

        self.lower_str = drange['lower']
        self.lower = pscheduler.iso8601_as_timedelta(self.lower_str)
        self.upper_str = drange['upper']
        self.upper = pscheduler.iso8601_as_timedelta(self.upper_str)
コード例 #19
0
ファイル: numericrange.py プロジェクト: perfsonar/pscheduler
    def __init__(self, nrange):

        """Construct a range from a JSON NumericRange."""

        # TODO: Would be nice if this class could treat missing
        # lower/upper as -/+ infinity.

        # TODO: Figure out why this can't just point to a NumericRange

        valid, message = pscheduler.json_validate(nrange, {
            "type": "object",
            "properties": {
                "lower": { "$ref": "#/pScheduler/Numeric" },
                "upper": { "$ref": "#/pScheduler/Numeric" }
            },
            "additionalProperties": False,
            "required": [ "lower", "upper" ]
        })

        if not valid:
            raise ValueError("Invalid numeric range: %s" % message)

        lower = nrange['lower']
        if type(lower) in [ str, unicode ]:
            self.lower = pscheduler.si_as_number(lower)
        else:
            self.lower = lower
        self.lower_str = str(lower)

        upper = nrange['upper']
        if type(upper) in [ str, unicode ]:
            self.upper = pscheduler.si_as_number(upper)
        else:
            self.upper = upper
        self.upper_str = str(upper)
コード例 #20
0
def spec_is_valid(json):
    schema = {"type": "object",
                # schema, host, host-node, and timeout are standard,
                # and should be included
                "properties": {
                    "schema":       { "$ref": "#/pScheduler/Cardinal" },
                    "parallel":     { "$ref": "#/pScheduler/Cardinal" },

                    "host":         { "$ref": "#/pScheduler/Host"     },

                    "dest":         { "$ref": "#/pScheduler/String"   },
                    "source":       { "$ref": "#/pScheduler/String"   },
                    
                    "timeout":      { "$ref": "#/pScheduler/Duration" }, 
                    "min-bandwith": { "$ref": "#/pScheduler/Cardinal" },
                    
                    "max-size":     { "$ref": "#/pScheduler/Cardinal" },
                    "cleanup":      { "$ref": "#/pScheduler/Boolean"  },
                },
                # If listed here, data of this type MUST be in the test spec
                "required":  [
                    "dest", "source"
                    ],

        "additionalProperties": False
    }

    return json_validate(json, schema)
コード例 #21
0
def data_is_valid(data):
    """Check to see if data is valid for this class.  Returns a tuple of
    (bool, string) indicating valididty and any error message.
    """
    valid, error = pscheduler.json_validate(data, data_validator)
    if not valid:
        return valid, error
    return valid, error
コード例 #22
0
    def __init__(self, source=None):  # Open file or path to file with limit set
        """Construct a limit processor.

        The 'source' argument can be one of three types:

        string - Path to a file to open and read.

        file - Open file handle to read.

        None - The limit processor becomes inert and passes all limits
        unconditionally.
        """

        # If we were given no source, put the processor into an inert
        # mode where everything passes.
        self.inert = source is None
        if self.inert:
            return

        #
        # Load the validation data
        #

        validation_path = os.path.join(os.path.dirname(__file__), "pscheduler-limits-validate.json")
        # TODO: Throw something nicer than IOError if this fails.
        validation_file = open(validation_path, "r")
        validation = pscheduler.json_load(validation_file)
        validation_file.close()

        #
        # Inhale the source and validate it
        #

        if type(source) is str or type(source) is unicode:
            source = open(source, "r")
        elif type(source) is file:
            pass  # We're good with this.
        else:
            raise ValueError("Source must be a file or path")

        # At this point, source is a file.

        assert type(source) is file
        limit_config = pscheduler.json_load(source)

        valid, message = pscheduler.json_validate(limit_config, validation)

        if not valid:
            raise ValueError("Invalid limit file: %s" % message)

        #
        # Set up all of the stages
        #

        self.identifiers = IdentifierSet(limit_config["identifiers"])
        self.classifiers = ClassifierSet(limit_config["classifiers"], self.identifiers)
        self.limits = LimitSet(limit_config["limits"])
        self.applications = ApplicationSet(limit_config["applications"], self.classifiers, self.limits)
コード例 #23
0
ファイル: validate.py プロジェクト: krihal/pscheduler
def result_is_valid(json):
    schema = {
        "local": {
            "hop": {
                "type": "object",
                "properties": {
                    "ip": {
                        "$ref": "#/pScheduler/IPAddress"
                    },
                    "hostname": {
                        "$ref": "#/pScheduler/Host"
                    },
                    "rtt": {
                        "$ref": "#/pScheduler/Duration"
                    },
                    "as": {
                        "$ref": "#/pScheduler/AS"
                    },
                    "error": {
                        "$ref": "#/pScheduler/icmp-error"
                    },
                    "mtu": {
                        "$ref": "#/pScheduler/Cardinal"
                    }
                },
                "required": [
                    # Nothing required.
                ]
            },
            "hoparray": {
                "type": "array",
                "items": {
                    "$ref": "#/local/hop"
                }
            }
        },
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "paths": {
                "type": "array",
                "items": {
                    "$ref": "#/local/hoparray"
                },
            },
            "succeeded": {
                "$ref": "#/pScheduler/Boolean"
            },
        },
        "required": [
            "paths",
            "succeeded",
        ]
    }
    return json_validate(json, schema)
コード例 #24
0
def data_is_valid(data):
    """Check to see if data is valid for this class.  Returns a tuple of
    (bool, string) indicating valididty and any error message.
    """
    valid, error = pscheduler.json_validate(data, data_validator)
    if not valid:
        return valid, error
    if "transform" in data:
        return False, "Transforms are not yet supported."
    return valid, error
コード例 #25
0
def spec_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "count": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "dest": {
                "$ref": "#/pScheduler/Host"
            },
            # There is no dest-node because this is a one-participant test.
            # TODO: This is supposed to be a 20-bit number.  Validate that.
            "flow-label": {
                "$ref": "#/pScheduler/CardinalZero"
            },
            "hostnames": {
                "$ref": "#/pScheduler/Boolean"
            },
            "interval": {
                "$ref": "#/pScheduler/Duration"
            },
            "ip-version": {
                "$ref": "#/pScheduler/ip-version"
            },
            "source": {
                "$ref": "#/pScheduler/Host"
            },
            "source-node": {
                "$ref": "#/pScheduler/URLHostPort"
            },
            "suppress-loopback": {
                "$ref": "#/pScheduler/Boolean"
            },
            "ip-tos": {
                "$ref": "#/pScheduler/IPTOS"
            },
            "length": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "ttl": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "deadline": {
                "$ref": "#/pScheduler/Duration"
            },
            "timeout": {
                "$ref": "#/pScheduler/Duration"
            },
        },
        "required": ["dest"]
    }
    return json_validate(json, schema)
コード例 #26
0
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "source": {
                "$ref": "#/pScheduler/Limit/IPCIDRList"
            },
            "dest": {
                "$ref": "#/pScheduler/Limit/IPCIDRList"
            },
            "endpoint": {
                "$ref": "#/pScheduler/Limit/IPCIDRList"
            },
            "count": {
                "$ref": "#/pScheduler/Limit/Cardinal"
            },
            "flow-label": {
                "$ref": "#/pScheduler/Limit/CardinalZeroList"
            },
            "hostnames": {
                "$ref": "#/pScheduler/Limit/Boolean"
            },
            "interval": {
                "$ref": "#/pScheduler/Limit/Duration"
            },
            "ip-version": {
                "$ref": "#/pScheduler/Limit/IPVersionList"
            },
            "suppress-loopback": {
                "$ref": "#/pScheduler/Limit/Boolean"
            },
            "ip-tos": {
                "$ref": "#/pScheduler/Limit/CardinalList"
            },
            "length": {
                "$ref": "#/pScheduler/Limit/Cardinal"
            },
            "ttl": {
                "$ref": "#/pScheduler/Limit/Cardinal"
            },
            "deadline": {
                "$ref": "#/pScheduler/Limit/Duration"
            },
            "timeout": {
                "$ref": "#/pScheduler/Limit/Duration"
            }
        },
        "additionalProperties": False
    }

    return json_validate(json, schema)
コード例 #27
0
ファイル: validate.py プロジェクト: krihal/pscheduler
def spec_is_valid(json):

    schema = {
        "local": {
            # Local data types such as this can be defined within this file,
            # but are not necessary
        },
        "type": "object",
        # schema, host, host-node, and timeout are standard,
        # and should be included
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "host": {
                "$ref": "#/pScheduler/Host"
            },
            "host-node": {
                "$ref": "#/pScheduler/Host"
            },
            "duration": {
                "$ref": "#/pScheduler/Duration"
            },
            "timeout": {
                "$ref": "#/pScheduler/Duration"
            },
            "_access-key": {
                "$ref": "#/pScheduler/String"
            },
            "bucket": {
                "$ref": "#/pScheduler/String"
            },
            "_secret-key": {
                "$ref": "#/pScheduler/String"
            },
            "url": {
                "$ref": "#/pScheduler/URL"
            },
            "iterations": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "object-size": {
                "$ref": "#/pScheduler/Cardinal"
            }
        },
        # If listed here, data of this type MUST be in the test spec
        "required":
        ["_access-key", "bucket", "_secret-key", "url", "object-size"],
        # Set to false if ONLY required options should be used
        "additionalProperties": True
    }

    return json_validate(json, schema, max_schema=MAX_SCHEMA)
コード例 #28
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "duration":         { "$ref": "#/pScheduler/Limit/Duration" },
            "starting-comment": { "$ref": "#/pScheduler/Limit/String" },
            "parting-comment":  { "$ref": "#/pScheduler/Limit/String" }
        },
        "additionalProperties": False
        }

    return json_validate(json, schema)
コード例 #29
0
ファイル: validate.py プロジェクト: krihal/pscheduler
def spec_is_valid(input_json):

    # Build a temporary structure with a reference that points
    # directly at the validator for the specified version of the
    # schema.  Using oneOf or anyOf results in error messages that are
    # difficult to decipher.

    temp_schema = {
        "local": SPEC_SCHEMA["local"],
        "$ref": "#/local/v%d" % input_json.get("schema", 1)
    }

    return json_validate(input_json, temp_schema, max_schema=MAX_SCHEMA)
コード例 #30
0
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "host":            { "$ref": "#/pScheduler/Limit/String" },
            "host-node":       { "$ref": "#/pScheduler/Limit/String" },
            "testtype":        { "$ref": "#/local/Type" },
            "timeout":         { "$ref": "#/pScheduler/Limit/Duration" },
        },
        "additionalProperties": False
        }

    return json_validate(json, schema)
コード例 #31
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "dawdle":        { "$ref": "#/pScheduler/Limit/Duration" },
            "fail":          { "$ref": "#/pScheduler/Limit/Probability" },
            "dest":          { "$ref": "#/pScheduler/Limit/String" },
            "test-material": { "$ref": "#/pScheduler/Limit/String" },
            "timeout":       { "$ref": "#/pScheduler/Limit/Duration" }
        },
        "additionalProperties": False
        }

    return json_validate(json, schema)
コード例 #32
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "duration":         { "$ref": "#/pScheduler/Duration" },
            "schema":           { "$ref": "#/pScheduler/Cardinal" },
            "succeeded":        { "$ref": "#/pScheduler/Boolean" },
            },
        "required": [
            "duration",
            "schema",
            "succeeded",
            ]
        }
    return json_validate(json, schema)
コード例 #33
0
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "url":          { "$ref": "#/pScheduler/Limit/String" },
            "host":            { "$ref": "#/pScheduler/Limit/String" },
            "host-node":     { "$ref": "#/pScheduler/Limit/String" },
            "timeout":         { "$ref": "#/pScheduler/Limit/Duration" },
            "parse":           { "$ref": "#/pScheduler/Limit/String" },
            "always-succeed":  { "$ref": "#/pScheduler/Boolean" },
        },
        "additionalProperties": False
    }

    return json_validate(json, schema)
コード例 #34
0
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema":     { "$ref": "#/pScheduler/Cardinal" },
            "succeeded":  { "$ref": "#/pScheduler/Boolean" },
            "time":       { "$ref": "#/pScheduler/Duration" },
        },
        "required": [
            "schema",
            "succeeded",
            "time",
            ],
        "additionalProperties": True
    }
    return json_validate(json, schema)
コード例 #35
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def spec_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "duration":         { "$ref": "#/pScheduler/Duration" },
            "host":             { "$ref": "#/pScheduler/Host" },
            "parting-comment":  { "$ref": "#/pScheduler/String" },
            "schema":           { "$ref": "#/pScheduler/Cardinal" },
            "starting-comment": { "$ref": "#/pScheduler/String" },
            },
        "required": [
            "duration",
            "schema",
            ]
        }
    return json_validate(json, schema)
コード例 #36
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def result_is_valid(json):
    schema = {
        "local": {
            "roundtrip": {
                "type": "object",
                "properties": {
                    "ip": { "$ref": "#/pScheduler/IPAddress" },
                    "length": { "$ref": "#/pScheduler/Cardinal" },
                    "rtt": { "$ref": "#/pScheduler/Duration" },
                    "ttl": { "$ref": "#/pScheduler/Cardinal" },
                    "seq": { "$ref": "#/pScheduler/Cardinal" },
                    "error": { "$ref": "#/pScheduler/icmp-error" },
                    },
                "required": [
                    # Nothing required.
                    ]
                }
            },

        "type": "object",
        "properties": {
            "schema": { "$ref": "#/pScheduler/Cardinal" },
            "succeeded": { "$ref": "#/pScheduler/Boolean" },
            "roundtrips": {
                "type": "array",
                "items": { "$ref": "#/local/roundtrip" },
                },
            "sent": { "$ref": "#/pScheduler/Cardinal" },
            "received": { "$ref": "#/pScheduler/CardinalZero" },
            "lost": { "$ref": "#/pScheduler/CardinalZero" },
            "reorders": { "$ref": "#/pScheduler/CardinalZero" },
            "duplicates": { "$ref": "#/pScheduler/CardinalZero" },
            "loss": { "$ref": "#/pScheduler/Probability" },
            "min": { "$ref": "#/pScheduler/Duration" },
            "max": { "$ref": "#/pScheduler/Duration" },
            "mean": { "$ref": "#/pScheduler/Duration" },
            "stddev": { "$ref": "#/pScheduler/Duration" }
            },
        "required": [
            "schema",
            "succeeded",
            "roundtrips",
            "loss",
            ]
        }
    return json_validate(json, schema)
コード例 #37
0
def spec_is_valid(json):

    schema = {
        "type": "object",
        "properties": {
            "schema":       { "$ref": "#/pScheduler/Cardinal" },
            "host":         { "$ref": "#/pScheduler/Host" },
            "host-node":    { "$ref": "#/pScheduler/Host" },
            "url":          { "$ref": "#/pScheduler/URL" },
            "parse":        { "$ref": "#/pScheduler/String" },
            "timeout":      { "$ref": "#/pScheduler/Duration" },
        },
        "required": [ "url" ],
        "additionalProperties": False
    }

    return json_validate(json, schema)
コード例 #38
0
def spec_is_valid(json):

    schema = {
        "local": {
            # Local data types such as this can be defined within this file,
            # but are not necessary
            "Type": {
                "type": "string",
                "enum": ["system", "api"]
            },
            "Spec": {
                "type": "object",
                # schema, host, host-node, and timeout are standard,
                # and should be included
                "properties": {
                    "schema": {
                        "$ref": "#/pScheduler/Cardinal"
                    },
                    "host": {
                        "$ref": "#/pScheduler/Host"
                    },
                    "host-node": {
                        "$ref": "#/pScheduler/Host"
                    },
                    "duration": {
                        "$ref": "#/pScheduler/Duration"
                    },
                    "timeout": {
                        "$ref": "#/pScheduler/Duration"
                    },
                    # Here is the datatype we defined on lines 24-27
                    "testtype": {
                        "$ref": "#/local/Type"
                    },
                },
                # If listed here, data of this type MUST be in the test spec
                "required": [
                    "testtype",
                ],
            }
        },
        # Set to false if ONLY required options should be used
        "additionalProperties": True
    }

    return json_validate(json, schema)
コード例 #39
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def spec_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "dawdle":         { "$ref": "#/pScheduler/Duration" },
            "fail":           { "$ref": "#/pScheduler/Probability" },
            "dest":           { "$ref": "#/pScheduler/Host" },
            "schema":         { "$ref": "#/pScheduler/Cardinal" },
            "source":         { "$ref": "#/pScheduler/Host" },
            "test-material":  { "$ref": "#/pScheduler/String" },
            "timeout":        { "$ref": "#/pScheduler/Duration" },
            },
        "required": [
            "dest",
            "schema",
            ]
        }
    return json_validate(json, schema)
コード例 #40
0
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "succeeded": {
                "$ref": "#/pScheduler/Boolean"
            },
            "gateway-up": {
                "$ref": "#/pScheduler/Boolean"
            },
            "network-up": {
                "$ref": "#/pScheduler/Boolean"
            }
        },
        "required": ["succeeded", "network-up"]
    }
    return json_validate(json, schema)
コード例 #41
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def result_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "dawdled":       { "$ref": "#/pScheduler/Duration" },
            "elapsed-time":  { "$ref": "#/pScheduler/Duration" },
            "received":      { "$ref": "#/pScheduler/String" },
            "schema":        { "$ref": "#/pScheduler/Cardinal" },
            "sent":          { "$ref": "#/pScheduler/String" },
            "succeeded":     { "$ref": "#/pScheduler/Boolean" },
            },
        "required": [
            "dawdled",
            "elapsed-time",
            "received",
            "schema",
            "sent",
            "succeeded",
            ]
        }
    return json_validate(json, schema)
コード例 #42
0
ファイル: validate.py プロジェクト: thom1555/pscheduler
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "schema": {
                "$ref": "#/pScheduler/Cardinal"
            },
            "duration": {
                "$ref": "#/pScheduler/Limit/Duration"
            },
            "starting-comment": {
                "$ref": "#/pScheduler/Limit/String"
            },
            "parting-comment": {
                "$ref": "#/pScheduler/Limit/String"
            }
        },
        "additionalProperties": False
    }

    return json_validate(json, schema)
コード例 #43
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def result_is_valid(json):
    schema = {
        "local": {
            "hop": {
                "type": "object",
                "properties": {
                    "ip": { "$ref": "#/pScheduler/IPAddress" },
                    "host": { "$ref": "#/pScheduler/Host" },
                    "rtt": { "$ref": "#/pScheduler/Duration" },
                    "as": { "$ref": "#/pScheduler/AS" },
                    "error": { "$ref": "#/pScheduler/icmp-error" },
                    "mtu":     { "$ref": "#/pScheduler/Cardinal" }
                    },
                "required": [
                    # Nothing required.
                    ]
                },

            "hoparray": {
                "type": "array",
                "items": { "$ref": "#/local/hop" }
            }
        },

        "type": "object",
        "properties": {
            "paths": {
                "type": "array",
                "items": { "$ref": "#/local/hoparray" },
                },
            "schema": { "$ref": "#/pScheduler/Cardinal" },
            "succeeded": { "$ref": "#/pScheduler/Boolean" },
            },
        "required": [
            "paths",
            "schema",
            "succeeded",
            ]
        }
    return json_validate(json, schema)
コード例 #44
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def limit_is_valid(json):
    schema = {
        "type": "object",
        "properties": {
            "count":             { "$ref": "#/pScheduler/Limit/Cardinal" },
            "dest":              { "$ref": "#/pScheduler/Limit/String" },
            "flowlabel":         { "$ref": "#/pScheduler/Limit/CardinalZeroList" },
            "hostnames":         { "$ref": "#/pScheduler/Limit/Boolean" },
            "interval":          { "$ref": "#/pScheduler/Limit/Duration" },
            "ip-version":        { "$ref": "#/pScheduler/Limit/CardinalList" },
            "source":            { "$ref": "#/pScheduler/Limit/String" },
            "suppress-loopback": { "$ref": "#/pScheduler/Limit/Boolean" },
            "tos":               { "$ref": "#/pScheduler/Limit/CardinalList" },
            "length":            { "$ref": "#/pScheduler/Limit/Cardinal" },
            "ttl":               { "$ref": "#/pScheduler/Limit/Cardinal" },
            "deadline":          { "$ref": "#/pScheduler/Limit/Duration" },
            "timeout":           { "$ref": "#/pScheduler/Limit/Duration" }
        },
        "additionalProperties": False
        }

    return json_validate(json, schema)
コード例 #45
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def spec_is_valid(json):
    schema = {
        "local": {
            "algorithm": {
                "type": "string",
                "enum": ["paris-traceroute"]
                },
            "probe-type": {
                "type": "string",
                "enum": ["icmp", "udp", "tcp"]
                }
            },
        "type": "object",
        "properties": {
            "algorithm":   { "$ref": "#/local/algorithm" },
            "as":          { "$ref": "#/pScheduler/Boolean" },
            "dest-port":   { "$ref": "#/pScheduler/IPPort" },
            "dest":        { "$ref": "#/pScheduler/Host" },
            "first-ttl":   { "$ref": "#/pScheduler/Cardinal" },
            "fragment":    { "$ref": "#/pScheduler/Boolean" },
            "hops":        { "$ref": "#/pScheduler/Cardinal" },
            "hostnames":   { "$ref": "#/pScheduler/Boolean" },
            "ip-version":  { "$ref": "#/pScheduler/ip-version" },
            "length":      { "$ref": "#/pScheduler/Cardinal" },
            "probe-type":  { "$ref": "#/local/probe-type" },
            "queries":     { "$ref": "#/pScheduler/Cardinal" },
            "schema":      { "$ref": "#/pScheduler/Cardinal" },
            "sendwait":    { "$ref": "#/pScheduler/Duration" },
            "source":      { "$ref": "#/pScheduler/Host" },
            "tos":         { "$ref": "#/pScheduler/Cardinal" },
            "wait":        { "$ref": "#/pScheduler/Duration" },
            },
        "required": [
            "schema",
            "dest",
            ]
        }
    return json_validate(json, schema)
コード例 #46
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def spec_is_valid(json):
    
    return json_validate(json, REQUEST_SCHEMA)
コード例 #47
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def limit_is_valid(input_json):
    return json_validate(input_json, LIMIT_SCHEMA)
コード例 #48
0
ファイル: test.py プロジェクト: perfsonar/pscheduler
def test_data_is_valid(data):
    """Check to see if data is valid for this class.  Returns a tuple of
    (bool, string) indicating valididty and any error message.
    """
    return pscheduler.json_validate(data, test_data_validator)
コード例 #49
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def result_is_valid(input_json):
    return json_validate(input_json, RESULT_SCHEMA)
コード例 #50
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def spec_is_valid(input_json):
    return json_validate(input_json, SPEC_SCHEMA)
コード例 #51
0
ファイル: validate.py プロジェクト: perfsonar/pscheduler
def result_is_valid(json):
    
    return json_validate(json, RESPONSE_SCHEMA)