Ejemplo n.º 1
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)
                }
Ejemplo n.º 2
0
 def update(self, iface, bootproto, ipaddr=None, netmask=None, gateway=None,
            vlanid=None):
     if bootproto not in ["static", "none", "dhcp", None]:
         raise exceptions.InvalidData("Unknown bootprotocol: %s" %
                                      bootproto)
     (valid.IPv4Address() | valid.Empty(or_none=True))(ipaddr)
     (valid.IPv4Address() | valid.Empty(or_none=True))(netmask)
     (valid.IPv4Address() | valid.Empty(or_none=True))(gateway)
Ejemplo n.º 3
0
    def validators(self):
        ip_or_empty = valid.IPAddress() | valid.Empty()
        fqdn_ip_or_empty = valid.FQDNOrIPAddress() | valid.Empty()

        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.vlanid":
            (valid.Number(bounds=[0, 4096]) | valid.Empty()),
        }
Ejemplo n.º 4
0
 def update(self, servers):
     assert type(servers) is list
     servers = filter(lambda i: i.strip() not in ["", None], servers)
     map(valid.IPv4Address(), servers)
     return {"OVIRT_DNS": ",".join(servers) or None}