backend/server/config_common/templated_document.py | 44 +++++++++++++++++++++
backend/server/rhnServer/server_hardware.py | 1
2 files changed, 45 insertions(+)
New commits:
commit dd080eae98dde6ae7c09f2df63a004331e760100
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Dec 6 11:51:17 2011 +0100
IPv6: order network interaces
This is due IPv6, sice we can have more address for one interface
name and scope and in configuration files we enumerate the addresses
(commits 8234607 and 62a86f3)
diff --git a/backend/server/rhnServer/server_hardware.py b/backend/server/rhnServer/server_hardware.py
index 85779fb..c9dbc4c 100644
--- a/backend/server/rhnServer/server_hardware.py
+++ b/backend/server/rhnServer/server_hardware.py
@@ -699,6 +699,7 @@ class NetIfaceAddress(Device):
select *
from %s
where interface_id = :interface_id
+ order by interface_id
""" % self.table)
h.execute(interface_id=interface_id)
self.db_ifaces = []
commit 62a86f35a42a3c6960bbac777d16dbc59a1c8652
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Dec 6 11:44:57 2011 +0100
IPv6: implement macro rhn.system.net_interface.ip6_netmask for config files templates
this macro will return IPv6 netmask
diff --git a/backend/server/config_common/templated_document.py b/backend/server/config_common/templated_document.py
index 4c18779..f64d25c 100644
--- a/backend/server/config_common/templated_document.py
+++ b/backend/server/config_common/templated_document.py
@@ -59,6 +59,7 @@ class ServerTemplatedDocument(TemplatedDocument):
RHN_PREFIX + 'net_interface.hardware_address' : self.net_intf_hwaddr,
RHN_PREFIX + 'net_interface.driver_module' : self.net_intf_module,
RHN_PREFIX + 'net_interface.ip6_address' : self.net_intf_ip6addr,
+ RHN_PREFIX + 'net_interface.ip6_netmask' : self.net_intf_ip6netmask,
})
#######################
@@ -141,6 +142,17 @@ class ServerTemplatedDocument(TemplatedDocument):
ipv6 = self._get_interface_info_attr(interface_name, 'ipv6')
return self._get_interface_address6_attr(ipv6, scope, order, 'address')
+ def net_intf_ip6netmask(self, interface_name, scope='universe', order=0):
+ """ get IPv6 netmask
+
+ interface_name is name of interface, e.g. 'eth0'
+ scope is either 'link', 'universe' or 'host'
+ order is zero based index as there can be more than one IP address
+ for given scope and interface
+ """
+ ipv6 = self._get_interface_info_attr(interface_name, 'ipv6')
+ return self._get_interface_address6_attr(ipv6, scope, order, 'netmask')
+
def net_intf_hwaddr(self, interface_name):
return self._get_interface_info_attr(interface_name, 'hw_addr')
commit 82346077ef43a263e8723fa296830f37e8eeb72c
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Dec 6 11:40:26 2011 +0100
IPv6: implement macro rhn.system.net_interface.ip6_address for config files templates
this macro will return IPv6 address
diff --git a/backend/server/config_common/templated_document.py b/backend/server/config_common/templated_document.py
index 58c5b47..4c18779 100644
--- a/backend/server/config_common/templated_document.py
+++ b/backend/server/config_common/templated_document.py
@@ -58,6 +58,7 @@ class ServerTemplatedDocument(TemplatedDocument):
RHN_PREFIX + 'net_interface.broadcast' : self.net_intf_broadcast,
RHN_PREFIX + 'net_interface.hardware_address' : self.net_intf_hwaddr,
RHN_PREFIX + 'net_interface.driver_module' : self.net_intf_module,
+ RHN_PREFIX + 'net_interface.ip6_address' : self.net_intf_ip6addr,
})
#######################
@@ -129,6 +130,17 @@ class ServerTemplatedDocument(TemplatedDocument):
ipv4 = self._get_interface_info_attr(interface_name, 'ipv4')
return self._get_interface_address_attr(ipv4, 'broadcast')
+ def net_intf_ip6addr(self, interface_name, scope='universe', order=0):
+ """ get IPv6 address
+
+ interface_name is name of interface, e.g. 'eth0'
+ scope is either 'link', 'universe' or 'host'
+ order is zero based index as there can be more than one IP address
+ for given scope and interface
+ """
+ ipv6 = self._get_interface_info_attr(interface_name, 'ipv6')
+ return self._get_interface_address6_attr(ipv6, scope, order, 'address')
+
def net_intf_hwaddr(self, interface_name):
return self._get_interface_info_attr(interface_name, 'hw_addr')
@@ -148,3 +160,23 @@ class ServerTemplatedDocument(TemplatedDocument):
return None
else:
return address.db_ifaces[0][attr]
+
+ def _get_interface_address6_attr(self, address, scope, order, attr):
+ """ return attribute of given address
+
+ address is list of interfaces
+ e.g.: [{'scope': 'universe', 'netmask': '64', 'address': '2620:52:0:2223:20c:29ff:fecb:d06e',
+ 'interface_id': 127}, {'scope': 'link', 'netmask': '64', 'address':
+ 'fe80::20c:29ff:fecb:d06e', 'interface_id': 127}]
+ scope is either 'link', 'universe' or 'host'
+ order is zero based index as there can be more than one IP address
+ for given scope and interface
+ attr is attribute, e.g "netmask"
+ """
+ if (address is None):
+ return None
+ ifaces = [i for i in address.db_ifaces if (i['scope'] == scope)]
+ if (order >= len(ifaces)) or (attr not in ifaces[order]):
+ return None
+ else:
+ return ifaces[order][attr]