1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 from base_templated_document import TemplatedDocument
19
20 from spacewalk.common.rhnLog import log_debug
21
22 from spacewalk.server.rhnServer.server_hardware import NetworkInformation
23 from spacewalk.server.rhnServer.server_hardware import NetIfaceInformation
24
25 RHN_PREFIX = 'rhn.system.'
26
27
33
34
36
37 - def __init__(self, server, start_delim=None, end_delim=None):
41
43
44 return self.null_call(fname, params, defval)
45
47 self.functions.clear()
48 self.functions.update({
49 RHN_PREFIX + 'sid': self.sid,
50 RHN_PREFIX + 'profile_name': self.profile_name,
51 RHN_PREFIX + 'description': self.description,
52 RHN_PREFIX + 'hostname': self.hostname,
53 RHN_PREFIX + 'ip_address': self.ipaddr,
54 RHN_PREFIX + 'ip6_address': self.ip6addr,
55 RHN_PREFIX + 'custom_info': self.custom_info,
56 RHN_PREFIX + 'net_interface.ip_address': self.net_intf_ipaddr,
57 RHN_PREFIX + 'net_interface.netmask': self.net_intf_netmask,
58 RHN_PREFIX + 'net_interface.broadcast': self.net_intf_broadcast,
59 RHN_PREFIX + 'net_interface.hardware_address': self.net_intf_hwaddr,
60 RHN_PREFIX + 'net_interface.driver_module': self.net_intf_module,
61 RHN_PREFIX + 'net_interface.ip6_address': self.net_intf_ip6addr,
62 RHN_PREFIX + 'net_interface.ip6_netmask': self.net_intf_ip6netmask,
63 })
64
65
66
67
68
69
70
73
76
79
82
85
88
96
106
108 infos = self.server.hardware_by_class(NetIfaceInformation)
109 if infos:
110 network_interfaces = infos[0].db_ifaces
111 else:
112 return None
113
114 for iface in network_interfaces:
115 if iface['name'] == interface_name:
116 return iface
117 return None
118
122
126
130
132 """ get IPv6 address
133
134 interface_name is name of interface, e.g. 'eth0'
135 scope is either 'link', 'universe' or 'host'
136 order is zero based index as there can be more than one IP address
137 for given scope and interface
138 """
139 ipv6 = self._get_interface_info_attr(interface_name, 'ipv6')
140 return self._get_interface_address6_attr(ipv6, scope, order, 'address')
141
143 """ get IPv6 netmask
144
145 interface_name is name of interface, e.g. 'eth0'
146 scope is either 'link', 'universe' or 'host'
147 order is zero based index as there can be more than one IP address
148 for given scope and interface
149 """
150 ipv6 = self._get_interface_info_attr(interface_name, 'ipv6')
151 return self._get_interface_address6_attr(ipv6, scope, order, 'netmask')
152
155
158
160 iface = self._interface_info(interface_name)
161
162 if not iface:
163 return None
164
165 return iface[attr]
166
168 if (address is None) or (len(address.db_ifaces) == 0) or (attr not in address.db_ifaces[0]):
169 return None
170 else:
171 return address.db_ifaces[0][attr]
172
174 """ return attribute of given address
175
176 address is list of interfaces
177 e.g.: [{'scope': 'universe', 'netmask': '64', 'address': '2620:52:0:2223:20c:29ff:fecb:d06e',
178 'interface_id': 127}, {'scope': 'link', 'netmask': '64', 'address':
179 'fe80::20c:29ff:fecb:d06e', 'interface_id': 127}]
180 scope is either 'link', 'universe' or 'host'
181 order is zero based index as there can be more than one IP address
182 for given scope and interface
183 attr is attribute, e.g "netmask"
184 """
185 if (address is None):
186 return None
187 ifaces = [i for i in address.db_ifaces if (i['scope'] == scope)]
188 if (order >= len(ifaces)) or (attr not in ifaces[order]):
189 return None
190 else:
191 return ifaces[order][attr]
192