aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnubhav Shelat <ashelat@redhat.com>2023-06-01 16:27:35 -0400
committerJohn Kacur <jkacur@redhat.com>2023-06-06 12:48:55 -0400
commit0ba98b12775b5394aab2205df29d93439d625cc3 (patch)
treec88d8608389dcf00a0bcb11f8e999d5004740761
parent2de834b44c2a731bc25449d84456396c0d519198 (diff)
downloadrteval-0ba98b12775b5394aab2205df29d93439d625cc3.tar.gz
Added code to check if the proc/net/if_inet6 file exists while loading IPv6 addresses in the IPv6Addresses class
Added code to check if the proc/net/if_inet6 file exists while loading IPv6 addresses in the IPv6Addresses class. If it doesn't, then the system has IPv6 disabled, and that chunk of code is passed. Signed-off-by: Anubhav Shelat <ashelat@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--rteval/sysinfo/newnet.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/rteval/sysinfo/newnet.py b/rteval/sysinfo/newnet.py
index 63417d9..2911400 100644
--- a/rteval/sysinfo/newnet.py
+++ b/rteval/sysinfo/newnet.py
@@ -72,19 +72,23 @@ class IPv6Addresses():
and a list of ipv6addresses
'''
MYP = '/proc/net/if_inet6'
- with open(MYP, 'r') as f:
- mystr = f.readline().strip()
- while len(mystr) > 0:
- ipv6addr , _, _, _, _, intf = mystr.split()
- ipv6addr = compress_iv6(ipv6addr)
- if intf == 'lo':
- mystr = f.readline().strip()
- continue
- if intf not in self.data:
- self.data[intf] = [ipv6addr]
- else:
- self.data[intf].append(ipv6addr)
+ try:
+ with open(MYP, 'r') as f:
mystr = f.readline().strip()
+ while len(mystr) > 0:
+ ipv6addr , _, _, _, _, intf = mystr.split()
+ ipv6addr = compress_iv6(ipv6addr)
+ if intf == 'lo':
+ mystr = f.readline().strip()
+ continue
+ if intf not in self.data:
+ self.data[intf] = [ipv6addr]
+ else:
+ self.data[intf].append(ipv6addr)
+ mystr = f.readline().strip()
+ # if IPv6 is disabled, the if_net6 files does not exist, so we can pass
+ except FileNotFoundError:
+ pass
class IPv4Addresses():
''' Obtains a list of IPv4 addresses from the proc file system '''