コード例 #1
0
ファイル: defaults.py プロジェクト: oVirt/Node
 def update(self, bootproto, ipaddr, netmask, gateway):
     if bootproto not in ["auto", "static", "none", "dhcp", None]:
         raise exceptions.InvalidData("Unknown bootprotocol: %s" %
                                      bootproto)
     (valid.IPv6Address() | valid.Empty(or_none=True))(ipaddr)
     (valid.IPv6Address() | valid.Empty(or_none=True))(netmask)
     (valid.IPv6Address() | valid.Empty(or_none=True))(gateway)
コード例 #2
0
    def validators(self):
        ip_or_empty = valid.IPAddress() | valid.Empty()
        fqdn_ip_or_empty = valid.FQDNOrIPAddress() | valid.Empty()

        valid_bond_name = valid.RegexValidator("^(bond[0-9]{1,2}|007)$",
                                               "a valid bond name (bond[0-99])"
                                               )
                                               # No regex, but for users ^

        return {"hostname": fqdn_ip_or_empty,
                "dns[0]": ip_or_empty,
                "dns[1]": ip_or_empty,
                "ntp[0]": fqdn_ip_or_empty,
                "ntp[1]": fqdn_ip_or_empty,

                "dialog.nic.ipv4.address": valid.IPv4Address() | valid.Empty(),
                "dialog.nic.ipv4.netmask": valid.IPv4Address() | valid.Empty(),
                "dialog.nic.ipv4.gateway": valid.IPv4Address() | valid.Empty(),
                "dialog.nic.ipv6.address": valid.IPv6Address() | valid.Empty(),
                "dialog.nic.ipv6.netmask": (valid.Number(bounds=[0, 128]) |
                                            valid.Empty()),
                "dialog.nic.ipv6.gateway": valid.IPv6Address() | valid.Empty(),
                "dialog.nic.vlanid": (valid.Number(bounds=[0, 4096]) |
                                      valid.Empty()),

                "bond.name": valid_bond_name,
                "bond.options": valid.Text(min_length=1)
                }
コード例 #3
0
ファイル: ping.py プロジェクト: oVirt/Node
    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """

        if "ping.address" in self._model:
            addr = self._model["ping.address"]
            count = self._model["ping.count"]
            self.logger.debug("Pinging %s" % addr)

            cmd = "ping"
            if valid.IPv6Address().validate(addr):
                cmd = "ping6"

            cmd = "%s -c %s %s" % (cmd, count, addr)

            ping = PingThread(self, cmd, count)
            ping.start()
コード例 #4
0
ファイル: ping.py プロジェクト: ArchipelProject/Node
    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """

        if "ping.address" in self._model:
            addr = self._model["ping.address"]
            count = self._model["ping.count"]
            self.logger.debug("Pinging %s" % addr)

            cmd = "ping"
            if valid.IPv6Address().validate(addr):
                cmd = "ping6"

            cmd = "%s -c %s %s" % (cmd, count, addr)
            out = ""
            current = 0
            for line in process.pipe_async(cmd):
                out += line
                if "icmp_req" in line:
                    current += 100.0 / float(count)
                    self.widgets["ping.progress"].current(current)
                self.widgets["ping.result"].text("Result:\n\n%s" % out)
コード例 #5
0
 def __str__(self):
     txt = str(self.address)
     if valid.IPv6Address().validate(txt):
         txt = "[%s]" % txt
     return txt