Codebase list ifupdown-multi / 41b1789
ifupdown-multi.py: Port to Python 3 (Closes: #943060) Robert Edmonds 3 years ago
1 changed file(s) with 7 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
0 #!/usr/bin/env python
0 #!/usr/bin/env python3
11
22 # Copyright (c) 2013 by Farsight Security, Inc.
33 #
5656 if not os.path.isdir(dname):
5757 rc = run('mkdir %s' % dname)
5858 if rc != 0:
59 raise Exception, 'unable to create directory %s' % dname
59 raise Exception('unable to create directory %s' % dname)
6060
6161 class ifupdownMulti:
6262 def __init__(self, env):
6464
6565 self.cfg = {}
6666 for key in required_keys:
67 if env.has_key(key):
67 if key in env:
6868 self.cfg[key] = env[key]
6969 else:
70 raise Exception, 'missing environment variable %s' % key
70 raise Exception('missing environment variable %s' % key)
7171 for key in additional_keys:
72 if env.has_key(key):
72 if key in env:
7373 if key == 'IF_MULTI_GATEWAY_WEIGHT' and self.cfg['ADDRFAM'] == 'inet6':
7474 logging.warning('multi_gateway_weight not supported with IPv6')
7575 else:
7676 self.cfg[key] = env[key]
7777 if not self.cfg['MODE'] in ('start', 'stop'):
78 raise Exception, 'unknown ifupdown mode %s' % self.cfg['MODE']
78 raise Exception('unknown ifupdown mode %s' % self.cfg['MODE'])
7979 if self.cfg['ADDRFAM'] == 'inet':
8080 self.cfg['ip'] = 'ip'
8181 elif self.cfg['ADDRFAM'] == 'inet6':
145145 nexthop = f.readline().strip()
146146 if nexthop:
147147 run('%s route delete %s' % (self.cfg['ip'], nexthop))
148 except IOError, e:
148 except IOError as e:
149149 if e.errno != errno.ENOENT:
150150 raise
151151