Petr Šebek has posted comments on this change. Change subject: Add IPv6 support to configNetwork ......................................................................
Patch Set 1: (13 comments) .................................................... File vdsm/configNetwork.py Line 47: bondingOptions=None, nics=None, mtu=None, ipaddr=None, Line 48: netmask=None, gateway=None, bootproto=None, Line 49: ipv6addr=None, ipv6gateway=None, ipv6autoconf=None, Line 50: dhcpv6=None, Line 51: _netinfo=None, configurator=None, blockingdhcp=None, Done Line 52: implicitBonding=None, defaultRoute=None, **opts): Line 53: """ Line 54: Constructs an object hierarchy that describes the network configuration Line 55: that is passed in the parameters. Line 65: :param gateway: IPv4 address in dotted decimal format. Line 66: :param bootproto: protocol for getting IP config for the net, e.g., 'dhcp' Line 67: :param ipv6addr: IPv6 address in format address[/prefixlen]. Line 68: :param ipv6gateway: IPv6 address in format address[/prefixlen]. Line 69: :param ipv6autoconf: whether to use stateless autoconfiguration. Done Line 70: :param dhcpv6: whether to use DHCPv6. Line 71: :param _netinfo: network information snapshot. Line 72: :param configurator: instance to use to apply the network configuration. Line 73: :param blockingdhcp: whether to acquire dhcp IP config in a synced manner. Line 472: netmask="<ip>" Line 473: gateway="<ip>" Line 474: bootproto="..." Line 475: delay="..." Line 476: onboot="yes"|"no" Done Line 477: (other options will be passed to the config file AS-IS) Line 478: -- OR -- Line 479: remove=True (other attributes can't be specified) Line 480: .................................................... File vdsm/netconf/ifcfg.py Line 470: cfg = cfg + 'MTU=%d\n' % mtu Line 471: if defaultRoute: Line 472: cfg = cfg + 'DEFROUTE=%s\n' % defaultRoute Line 473: cfg += 'NM_CONTROLLED=no\n' Line 474: if ipv6addr or ipv6gateway or ipv6autoconf or dhcpv6: Done Line 475: cfg += 'IPV6INIT=yes\n' Line 476: ipv6autoconf = 'no' Line 477: if ipv6addr is not None: Line 478: cfg += 'IPV6ADDR=%s\n' % pipes.quote(ipv6addr) Line 472: cfg = cfg + 'DEFROUTE=%s\n' % defaultRoute Line 473: cfg += 'NM_CONTROLLED=no\n' Line 474: if ipv6addr or ipv6gateway or ipv6autoconf or dhcpv6: Line 475: cfg += 'IPV6INIT=yes\n' Line 476: ipv6autoconf = 'no' Done Line 477: if ipv6addr is not None: Line 478: cfg += 'IPV6ADDR=%s\n' % pipes.quote(ipv6addr) Line 479: if ipv6gateway is not None: Line 480: cfg += 'IPV6_DEFAULTGW=%s\n' % pipes.quote(ipv6gateway) Line 480: cfg += 'IPV6_DEFAULTGW=%s\n' % pipes.quote(ipv6gateway) Line 481: elif dhcpv6: Line 482: cfg += 'DHCPV6C=yes\n' Line 483: if ipv6autoconf: Line 484: ipv6autoconf = 'yes' Yes my bad. Line 485: cfg += 'IPV6_AUTOCONF=%s\n' % pipes.quote(ipv6autoconf) Line 486: BLACKLIST = ['TYPE', 'NAME', 'DEVICE', 'bondingOptions', Line 487: 'force', 'blockingdhcp', Line 488: 'connectivityCheck', 'connectivityTimeout', Line 481: elif dhcpv6: Line 482: cfg += 'DHCPV6C=yes\n' Line 483: if ipv6autoconf: Line 484: ipv6autoconf = 'yes' Line 485: cfg += 'IPV6_AUTOCONF=%s\n' % pipes.quote(ipv6autoconf) Done Line 486: BLACKLIST = ['TYPE', 'NAME', 'DEVICE', 'bondingOptions', Line 487: 'force', 'blockingdhcp', Line 488: 'connectivityCheck', 'connectivityTimeout', Line 489: 'implicitBonding'] .................................................... File vdsm/netmodels.py Line 27: from vdsm import netinfo Line 28: import neterrors as ne Line 29: Line 30: Line 31: class NetDevice(object): Namedtuple is a tuple => have constant length with all values always filled. If I wanted to use this tuple I would have to fill missing value with None or empty string. Basic idea about that is that I don't want to use constant length container to variable length data. Line 32: def __init__(self, name, configurator, ipconfig=None, mtu=None): Line 33: self.name = name Line 34: self.ip = ipconfig Line 35: self.mtu = mtu Line 330: self.defaultRoute) Line 331: Line 332: @classmethod Line 333: def validateAddress(cls, address): Line 334: addr = address.split('/', 1) I can't use this. Prefix is optional so I would get ValueError when there is only address. Line 335: try: Line 336: socket.inet_pton(socket.AF_INET6, addr[0]) Line 337: except socket.error: Line 338: raise ConfigNetworkError(ne.ERR_BAD_ADDR, '%r is not a valid IPv6 ' Line 332: @classmethod Line 333: def validateAddress(cls, address): Line 334: addr = address.split('/', 1) Line 335: try: Line 336: socket.inet_pton(socket.AF_INET6, addr[0]) Commented above, prefixlen is optional Line 337: except socket.error: Line 338: raise ConfigNetworkError(ne.ERR_BAD_ADDR, '%r is not a valid IPv6 ' Line 339: 'address.' % address) Line 340: if len(addr) == 2: Line 337: except socket.error: Line 338: raise ConfigNetworkError(ne.ERR_BAD_ADDR, '%r is not a valid IPv6 ' Line 339: 'address.' % address) Line 340: if len(addr) == 2: Line 341: cls.validatePrefixlen(addr[1]) Commented above. Line 342: Line 343: @classmethod Line 344: def validatePrefixlen(cls, prefixlen): Line 345: try: Line 340: if len(addr) == 2: Line 341: cls.validatePrefixlen(addr[1]) Line 342: Line 343: @classmethod Line 344: def validatePrefixlen(cls, prefixlen): Prefix means address of network. We want validate value of prefix length, common abbreviation is prefixlen. Here is form of IPv6 address: http://tools.ietf.org/html/rfc4291#section-2.3 Line 345: try: Line 346: prefixlen = int(prefixlen) Line 347: if prefixlen < 0 or prefixlen > 127: Line 348: raise ConfigNetworkError(ne.ERR_BAD_ADDR, '%r is not valid ' Line 343: @classmethod Line 344: def validatePrefixlen(cls, prefixlen): Line 345: try: Line 346: prefixlen = int(prefixlen) Line 347: if prefixlen < 0 or prefixlen > 127: I wanted to avoid not and braces, but if you think its more readable then ok. Line 348: raise ConfigNetworkError(ne.ERR_BAD_ADDR, '%r is not valid ' Line 349: 'IPv6 prefixlen.' % prefixlen) Line 350: except ValueError: Line 351: raise ConfigNetworkError(ne.ERR_BAD_ADDR, '%r is not valid ' -- To view, visit http://gerrit.ovirt.org/18284 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8ed056b683f0cb893b2edcf1ae673c64ce5cd18c Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr Šebek <pse...@redhat.com> Gerrit-Reviewer: Antoni Segura Puimedon <asegu...@redhat.com> Gerrit-Reviewer: Petr Šebek <pse...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches