Antoni Segura Puimedon has uploaded a new change for review.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
caps: add reporting of all ipv4 addresses
With this patch, we add a new field to the reported device information. This new field is 'ipv4addrs', that just like the current 'ipv6addrs' reports all the addresses of the device (each for its own address family). With this new reporting, now 'addr' and 'netmask' are specifically reporting the primary address.
Change-Id: I364a2737182b3a3cac914f1bbd3d707e1346f40f Signed-off-by: Antoni S. Puimedon asegurap@redhat.com --- M lib/vdsm/netinfo.py M lib/vdsm/netlink.py M vdsm_api/vdsmapi-schema.json 3 files changed, 55 insertions(+), 29 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/28063/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py index 0c1f2e4..e25def9 100644 --- a/lib/vdsm/netinfo.py +++ b/lib/vdsm/netinfo.py @@ -348,14 +348,17 @@ def getIpInfo(dev, ipaddrs): ipv4addr = '' ipv4netmask = '' + ipv4addrs = [] ipv6addrs = [] for addr in ipaddrs[dev]: if addr['family'] == 'inet': - ipv4addr, prefix = addr['address'].split('/') - ipv4netmask = prefix2netmask(addr['prefixlen']) + ipv4addrs.append(addr['address']) + if 'secondary' not in addr['flags']: + ipv4addr, prefix = addr['address'].split('/') + ipv4netmask = prefix2netmask(addr['prefixlen']) else: ipv6addrs.append(addr['address']) - return ipv4addr, ipv4netmask, ipv6addrs + return ipv4addr, ipv4netmask, ipv4addrs, ipv6addrs
def getipv6addrs(dev): @@ -522,11 +525,12 @@ # comment when the version is no longer supported. data['interface'] = iface
- ipv4addr, ipv4netmask, ipv6addrs = getIpInfo(iface, ipaddrs) + ipv4addr, ipv4netmask, ipv4addrs, ipv6addrs = getIpInfo(iface, ipaddrs) data.update({'iface': iface, 'bridged': bridged, 'addr': ipv4addr, 'netmask': ipv4netmask, 'bootproto4': 'dhcp' if iface in dhcp4 else 'none', 'gateway': getgateway(gateways, iface), + 'ipv4addrs': ipv4addrs, 'ipv6addrs': ipv6addrs, 'ipv6gateway': ipv6routes.get(iface, '::'), 'mtu': str(getMtu(iface))}) @@ -644,9 +648,10 @@
def _devinfo(link, ipaddrs): - ipv4addr, ipv4netmask, ipv6addrs = getIpInfo(link.name, ipaddrs) + ipv4addr, ipv4netmask, ipv4addrs, ipv6addrs = getIpInfo(link.name, ipaddrs) return {'addr': ipv4addr, 'cfg': getIfaceCfg(link.name), + 'ipv4addrs': ipv4addrs, 'ipv6addrs': ipv6addrs, 'mtu': str(link.mtu), 'netmask': ipv4netmask} diff --git a/lib/vdsm/netlink.py b/lib/vdsm/netlink.py index 1638ef7..f75ea9c 100644 --- a/lib/vdsm/netlink.py +++ b/lib/vdsm/netlink.py @@ -130,7 +130,7 @@ 'family': _addr_family(addr), 'prefixlen': _rtnl_addr_get_prefixlen(addr), 'scope': _addr_scope(addr), - 'flags': _rtnl_addr_get_flags(addr), + 'flags': _addr_flags(addr), 'address': _addr_local(addr)}
@@ -192,6 +192,13 @@ return _rtnl_link_operstate2str(state, operstate, sizeof(operstate))
+def _addr_flags(addr): + """Returns the textual translation of the address flags""" + flags = (c_char * (CHARBUFFSIZE * 2))() + return frozenset(_rtnl_addr_flags2str(_rtnl_addr_get_flags(addr), flags, + sizeof(flags)).split(',')) + + def _addr_scope(addr): """Returns the scope name for which the address is defined.""" scope = (c_char * CHARBUFFSIZE)() @@ -225,6 +232,7 @@ _char_proto = CFUNCTYPE(c_char_p, c_void_p) _void_proto = CFUNCTYPE(c_void_p, c_void_p) _none_proto = CFUNCTYPE(None, c_void_p) +_int_char_proto = CFUNCTYPE(c_char_p, c_int, c_char_p, c_size_t)
if _ethtool_uses_libnl3(): LIBNL = CDLL('libnl-3.so.200', use_errno=True) @@ -310,6 +318,7 @@ _rtnl_addr_get_scope = _int_proto(('rtnl_addr_get_scope', LIBNL_ROUTE)) _rtnl_addr_get_flags = _int_proto(('rtnl_addr_get_flags', LIBNL_ROUTE)) _rtnl_addr_get_local = _void_proto(('rtnl_addr_get_local', LIBNL_ROUTE)) +_rtnl_addr_flags2str = _int_char_proto(('rtnl_addr_flags2str', LIBNL_ROUTE))
_nl_addr2str = CFUNCTYPE(c_char_p, c_void_p, c_char_p, c_size_t)(( 'nl_addr2str', LIBNL)) @@ -317,12 +326,10 @@ 'rtnl_link_get_by_name', LIBNL_ROUTE)) _rtnl_link_i2name = CFUNCTYPE(c_char_p, c_void_p, c_int, c_char_p, c_size_t)(( 'rtnl_link_i2name', LIBNL_ROUTE)) -_rtnl_link_operstate2str = CFUNCTYPE(c_char_p, c_int, c_char_p, c_size_t)(( - 'rtnl_link_operstate2str', LIBNL_ROUTE)) -_nl_af2str = CFUNCTYPE(c_char_p, c_int, c_char_p, c_size_t)(('nl_af2str', - LIBNL)) -_rtnl_scope2str = CFUNCTYPE(c_char_p, c_int, c_char_p, c_size_t)(( - 'rtnl_scope2str', LIBNL_ROUTE)) +_rtnl_link_operstate2str = _int_char_proto(('rtnl_link_operstate2str', + LIBNL_ROUTE)) +_nl_af2str = _int_char_proto(('nl_af2str', LIBNL)) +_rtnl_scope2str = _int_char_proto(('rtnl_scope2str', LIBNL_ROUTE))
_nl_link_cache = partial(_cache_manager, _rtnl_link_alloc_cache) _nl_addr_cache = partial(_cache_manager, _rtnl_addr_alloc_cache) diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 554d9f8..bad8353 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -573,11 +573,14 @@ # @stp: Whether Spanning Tree Protocol status for the bridge device # should be turned on # -# @addr: The IP address assigned to the bridge device +# @addr: The primary IPv4 address assigned to the bridge device # -# @netmask: The netmask of the defined subnet +# @netmask: The primary IPv4 netmask of the defined subnet # # @gateway: The IP address of the subnet's gateway +# +# @ipv4addrs: A list of IPv4 addresses in the format of 'address/prefixlen' +# that are assigned to the vlan device (new in version 4.15.0) # # @ipv6addrs: A list of IPv6 addresses in the format of 'address/prefixlen' # that are assigned to the bridge device @@ -605,10 +608,11 @@ ## {'type': 'NetInfoBridgedNetwork', 'data': {'ports': ['str'], 'stp': 'bool', 'addr': 'str', - 'netmask': 'str', 'gateway': 'str', 'ipv6addrs': ['str'], - 'ipv6gateway': 'str', 'mtu': 'uint', 'cfg': 'StringMap', - 'bridged': 'bool', '*qosInbound': 'BandwidthParams', - '*qosOutbound': 'BandwidthParams', 'opts': 'StringMap'}} + 'netmask': 'str', 'gateway': 'str', 'ipv4addrs': ['str'], + 'ipv6addrs': ['str'], 'ipv6gateway': 'str', 'mtu': 'uint', + 'cfg': 'StringMap', 'bridged': 'bool', + '*qosInbound': 'BandwidthParams', '*qosOutbound': 'BandwidthParams', + 'opts': 'StringMap'}}
## # @NetInfoBridgelessNetwork: @@ -645,9 +649,12 @@ # # @speed: The reported speed of the nic # -# @addr: The IP address assigned to the nic +# @addr: The primary IPv4 address assigned to the nic device # -# @netmask: The netmask of the defined subnet +# @netmask: The primary IPv4 netmask of the defined subnet +# +# @ipv4addrs: A list of IPv4 addresses in the format of 'address/prefixlen' +# that are assigned to the vlan device (new in version 4.15.0) # # @ipv6addrs: A list of IPv6 addresses in the format of 'address/prefixlen' # that are assigned to the nic @@ -663,8 +670,8 @@ ## {'type': 'NetInfoNic', 'data': {'speed': 'int', 'addr': 'str', 'netmask': 'str', - 'ipv6addrs': ['str'], 'hwaddr': 'str', 'mtu': 'uint', - '*permhwaddr': 'str'}} + 'ipv4addrs': ['str'], 'ipv6addrs': ['str'], 'hwaddr': 'str', + 'mtu': 'uint', '*permhwaddr': 'str'}}
## # @NetInfoBond: @@ -673,9 +680,12 @@ # # @slaves: A list of devices that are enslaved to the bond device # -# @addr: The IP address assigned to the bond +# @addr: The primary IPv4 address assigned to the bond device # -# @netmask: The netmask of the defined subnet +# @netmask: The primary IPv4 netmask of the defined subnet +# +# @ipv4addrs: A list of IPv4 addresses in the format of 'address/prefixlen' +# that are assigned to the vlan device (new in version 4.15.0) # # @ipv6addrs: A list of IPv6 addresses in the format of 'address/prefixlen' # that are assigned to the bond device @@ -690,8 +700,8 @@ ## {'type': 'NetInfoBond', 'data': {'slaves': ['str'], 'addr': 'str', 'netmask': 'str', - 'ipv6addrs': ['str'], 'hwaddr': 'str', 'cfg': 'StringMap', - 'mtu': 'uint'}} + 'ipv4addrs': ['str'], 'ipv6addrs': ['str'], 'hwaddr': 'str', + 'cfg': 'StringMap', 'mtu': 'uint'}}
## # @NetInfoVlan: @@ -700,9 +710,12 @@ # # @iface: The network device associated with the vlan # -# @addr: The IP address assigned to the vlan device +# @addr: The primary IPv4 address assigned to the vlan device # -# @netmask: The netmask of the defined subnet +# @netmask: The primary IPv4 netmask of the defined subnet +# +# @ipv4addrs: A list of IPv4 addresses in the format of 'address/prefixlen' +# that are assigned to the vlan device (new in version 4.15.0) # # @ipv6addrs: A list of IPv6 addresses in the format of 'address/prefixlen' # that are assigned to the vlan device @@ -715,7 +728,8 @@ ## {'type': 'NetInfoVlan', 'data': {'iface': 'str', 'addr': 'str', 'netmask': 'str', - 'ipv6addrs': ['str'], 'mtu': 'uint', 'vlanid': 'uint'}} + 'ipv4addrs': ['str'], 'ipv6addrs': ['str'], 'mtu': 'uint', + 'vlanid': 'uint'}}
## # @NumaNode:
oVirt Jenkins CI Server has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 1:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_network_functional_tests_gerrit/139... : There was an infra issue, please contact infra@ovirt.org
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/9215/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit/9358/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/8427/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 2:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_network_functional_tests_gerrit/139... : There was an infra issue, please contact infra@ovirt.org
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/9217/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit/9360/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/8429/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 3:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_network_functional_tests_gerrit/140... : There was an infra issue, please contact infra@ovirt.org
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/9226/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit/9369/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/8438/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 4:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_network_functional_tests_gerrit/140... : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/9235/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit/9378/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/8447/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 5:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_network_functional_tests_gerrit/142... : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/9308/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit/9451/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/8520/ : SUCCESS
Antoni Segura Puimedon has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 5: Verified+1
Dan Kenigsberg has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 5: Code-Review+2
it would have been nicer if this patch included a test for these new reported values. But I suppose that the follow-up patch is sufficient.
Dan Kenigsberg has submitted this change and it was merged.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
caps: add reporting of all ipv4 addresses
With this patch, we add a new field to the reported device information. This new field is 'ipv4addrs', that just like the current 'ipv6addrs' reports all the addresses of the device (each for its own address family). With this new reporting, now 'addr' and 'netmask' are specifically reporting the primary address.
Change-Id: I364a2737182b3a3cac914f1bbd3d707e1346f40f Signed-off-by: Antoni S. Puimedon asegurap@redhat.com Reviewed-on: http://gerrit.ovirt.org/28063 Reviewed-by: Dan Kenigsberg danken@redhat.com --- M lib/vdsm/netinfo.py M lib/vdsm/netlink.py M vdsm_api/vdsmapi-schema.json 3 files changed, 55 insertions(+), 29 deletions(-)
Approvals: Antoni Segura Puimedon: Verified Dan Kenigsberg: Looks good to me, approved
oVirt Jenkins CI Server has posted comments on this change.
Change subject: caps: add reporting of all ipv4 addresses ......................................................................
Patch Set 6:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_create-rpms_merged/1366/ : SUCCESS
vdsm-patches@lists.fedorahosted.org