示例#1
0
    def validate_cpuset(conn, val):
        if val is None or val == "":
            return

        if type(val) is not type("string") or len(val) == 0:
            raise ValueError(_("cpuset must be string"))
        if re.match("^[0-9,-^]*$", val) is None:
            raise ValueError(_("cpuset can only contain numeric, ',', or "
                               "'-' characters"))

        pcpus = _util.get_phy_cpus(conn)
        for c in val.split(','):
            # Redundant commas
            if not c:
                continue

            if "-" in c:
                (x, y) = c.split('-', 1)
                x = int(x)
                y = int(y)
                if x > y:
                    raise ValueError(_("cpuset contains invalid format."))
                if x >= pcpus or y >= pcpus:
                    raise ValueError(_("cpuset's pCPU numbers must be less "
                                       "than pCPUs."))
            else:
                if c.startswith("^"):
                    c = c[1:]
                c = int(c)

                if c >= pcpus:
                    raise ValueError(_("cpuset's pCPU numbers must be less "
                                       "than pCPUs."))
示例#2
0
def _validate_cpuset(conn, val):
    if val is None or val == "":
        return

    if type(val) is not type("string") or len(val) == 0:
        raise ValueError, _("cpuset must be string")
    if re.match("^[0-9,-]*$", val) is None:
        raise ValueError, _("cpuset can only contain numeric, ',', or "
                            "'-' characters")

    pcpus = _util.get_phy_cpus(conn)
    for c in val.split(','):
        if c.find('-') != -1:
            (x, y) = c.split('-')
            if int(x) > int(y):
                raise ValueError, _("cpuset contains invalid format.")
            if int(x) >= pcpus or int(y) >= pcpus:
                raise ValueError, _("cpuset's pCPU numbers must be less "
                                    "than pCPUs.")
        else:
            if len(c) == 0:
                continue

            if int(c) >= pcpus:
                raise ValueError, _("cpuset's pCPU numbers must be less "
                                    "than pCPUs.")
    return
示例#3
0
def _validate_cpuset(conn, val):
    if val is None or val == "":
        return

    if type(val) is not type("string") or len(val) == 0:
        raise ValueError, _("cpuset must be string")
    if re.match("^[0-9,-]*$", val) is None:
        raise ValueError, _("cpuset can only contain numeric, ',', or "
                            "'-' characters")

    pcpus = _util.get_phy_cpus(conn)
    for c in val.split(','):
        if c.find('-') != -1:
            (x, y) = c.split('-')
            if int(x) > int(y):
                raise ValueError, _("cpuset contains invalid format.")
            if int(x) >= pcpus or int(y) >= pcpus:
                raise ValueError, _("cpuset's pCPU numbers must be less "
                                    "than pCPUs.")
        else:
            if len(c) == 0:
                continue

            if int(c) >= pcpus:
                raise ValueError, _("cpuset's pCPU numbers must be less "
                                    "than pCPUs.")
    return
示例#4
0
    def cpuset_str_to_tuple(conn, cpuset):
        DomainNumatune.validate_cpuset(conn, cpuset)
        pinlist = [False] * _util.get_phy_cpus(conn)

        entries = cpuset.split(",")
        for e in entries:
            series = e.split("-", 1)

            if len(series) == 1:
                pinlist[int(series[0])] = True
                continue

            start = int(series[0])
            end = int(series[1])

            for i in range(start, end + 1):
                pinlist[i] = True

        return tuple(pinlist)
示例#5
0
    def cpuset_str_to_tuple(conn, cpuset):
        _validate_cpuset(conn, cpuset)
        pinlist = [False] * _util.get_phy_cpus(conn)

        entries = cpuset.split(",")
        for e in entries:
            series = e.split("-", 1)

            if len(series) == 1:
                pinlist[int(series[0])] = True
                continue

            start = int(series[0])
            end = int(series[1])

            for i in range(start, end):
                pinlist[i] = True

        return tuple(pinlist)
    def validate_cpuset(conn, val):
        if val is None or val == "":
            return

        if type(val) is not type("string") or len(val) == 0:
            raise ValueError(_("cpuset must be string"))
        if re.match("^[0-9,-^]*$", val) is None:
            raise ValueError(
                _("cpuset can only contain numeric, ',', or "
                  "'-' characters"))

        pcpus = _util.get_phy_cpus(conn)
        for c in val.split(','):
            # Redundant commas
            if not c:
                continue

            if "-" in c:
                (x, y) = c.split('-', 1)
                x = int(x)
                y = int(y)
                if x > y:
                    raise ValueError(_("cpuset contains invalid format."))
                if x >= pcpus or y >= pcpus:
                    raise ValueError(
                        _("cpuset's pCPU numbers must be less "
                          "than pCPUs."))
            else:
                if c.startswith("^"):
                    c = c[1:]
                c = int(c)

                if c >= pcpus:
                    raise ValueError(
                        _("cpuset's pCPU numbers must be less "
                          "than pCPUs."))