ia64/xen-unstable
changeset 7465:021324804fbd
Remove unused Vifctl.vifctl and Vifctl.set_vif_name. Remove the bridge and
antispoof parameters from Vifctl.network -- these are already handled by the
script, so it is redundant to have a separate override for these parameters
coming from outside. Don't use xen.util.process.runscript, because we don't
need to return the output, and therefore can just use os.spawnl.
Remove XendRoot.get_vif_antispoof, matching change above.
Prefix XendRoot.network_script_dir onto the return value for
XendRoot.get_network_script(), removing that burden from callers.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
antispoof parameters from Vifctl.network -- these are already handled by the
script, so it is redundant to have a separate override for these parameters
coming from outside. Don't use xen.util.process.runscript, because we don't
need to return the output, and therefore can just use os.spawnl.
Remove XendRoot.get_vif_antispoof, matching change above.
Prefix XendRoot.network_script_dir onto the return value for
XendRoot.get_network_script(), removing that burden from callers.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | emellor@leeni.uk.xensource.com |
---|---|
date | Fri Oct 21 11:21:05 2005 +0100 (2005-10-21) |
parents | 82cdb5efc3a8 |
children | 4d49f61a7fee |
files | tools/python/xen/xend/Vifctl.py tools/python/xen/xend/XendRoot.py |
line diff
1.1 --- a/tools/python/xen/xend/Vifctl.py Fri Oct 21 11:08:48 2005 +0100 1.2 +++ b/tools/python/xen/xend/Vifctl.py Fri Oct 21 11:21:05 2005 +0100 1.3 @@ -19,87 +19,17 @@ 1.4 """Xend interface to networking control scripts. 1.5 """ 1.6 import os 1.7 -import os.path 1.8 -import xen.util.process 1.9 1.10 -from xen.xend import XendRoot 1.11 -xroot = XendRoot.instance() 1.12 - 1.13 -"""Where network control scripts live.""" 1.14 -SCRIPT_DIR = xroot.network_script_dir 1.15 - 1.16 -def network(op, script=None, bridge=None, antispoof=None): 1.17 - """Call a network control script. 1.18 - Xend calls this with op 'start' when it starts. 1.19 +import XendRoot 1.20 1.21 - @param op: operation (start, stop, status) 1.22 - @param script: network script name 1.23 - @param bridge: xen bridge 1.24 - @param antispoof: whether to enable IP antispoofing rules 1.25 - """ 1.26 - if op not in ['start', 'stop', 'status']: 1.27 - raise ValueError('Invalid operation:' + op) 1.28 - if script is None: 1.29 - script = xroot.get_network_script() 1.30 - if bridge is None: 1.31 - bridge = xroot.get_vif_bridge() 1.32 - if antispoof is None: 1.33 - antispoof = xroot.get_vif_antispoof() 1.34 - script = os.path.join(SCRIPT_DIR, script) 1.35 - args = [op] 1.36 - args.append("bridge='%s'" % bridge) 1.37 - if antispoof: 1.38 - args.append("antispoof=yes") 1.39 - else: 1.40 - args.append("antispoof=no") 1.41 - args = ' '.join(args) 1.42 - ret = xen.util.process.runscript(script + ' ' + args) 1.43 - if len(ret): 1.44 - return ret.splitlines()[0] 1.45 + 1.46 +def network(op): 1.47 + """Call a network control script. 1.48 1.49 -def set_vif_name(vif_old, vif_new): 1.50 - if vif_old == vif_new: 1.51 - vif = vif_new 1.52 - return vif 1.53 - if os.system("ip link show %s" % vif_old) == 0: 1.54 - os.system("ip link set %s down" % vif_old) 1.55 - os.system("ip link set %s name %s" % (vif_old, vif_new)) 1.56 - os.system("ip link set %s up" % vif_new) 1.57 - if os.system("ip link show %s" % vif_new) == 0: 1.58 - vif = vif_new 1.59 - else: 1.60 - vif = vif_old 1.61 - return vif 1.62 - 1.63 -def vifctl(op, vif=None, script=None, domain=None, mac=None, bridge=None, ipaddr=None): 1.64 - """Call a vif control script. 1.65 - Xend calls this when bringing vifs up or down. 1.66 - 1.67 - @param op: vif operation (up, down) 1.68 - @param vif: vif name 1.69 - @param script: name of control script 1.70 - @param domain: name of domain the vif is on 1.71 - @param mac: vif MAC address 1.72 - @param bridge: bridge to add the vif to 1.73 - @param ipaddr: list of ipaddrs the vif may use 1.74 + @param op: operation (start, stop) 1.75 """ 1.76 - if op not in ['up', 'down']: 1.77 - raise ValueError('Invalid operation:' + op) 1.78 - if script is None: 1.79 - script = xroot.get_vif_script() 1.80 - if bridge is None: 1.81 - bridge = xroot.get_vif_bridge() 1.82 - script = os.path.join(SCRIPT_DIR, script) 1.83 - args = [op] 1.84 - args.append("vif='%s'" % vif) 1.85 - args.append("domain='%s'" % domain) 1.86 - args.append("mac='%s'" % mac) 1.87 - if bridge: 1.88 - args.append("bridge='%s'" % bridge) 1.89 - if ipaddr: 1.90 - ips = ' '.join(ipaddr) 1.91 - args.append("ip='%s'" % ips) 1.92 - args = ' '.join(args) 1.93 - ret = xen.util.process.runscript(script + ' ' + args) 1.94 - if len(ret): 1.95 - return ret.splitlines()[0] 1.96 + if op not in ['start', 'stop']: 1.97 + raise ValueError('Invalid operation: ' + op) 1.98 + script = XendRoot.instance().get_network_script() 1.99 + if script: 1.100 + os.spawnl(os.P_WAIT, script, script, op)
2.1 --- a/tools/python/xen/xend/XendRoot.py Fri Oct 21 11:08:48 2005 +0100 2.2 +++ b/tools/python/xen/xend/XendRoot.py Fri Oct 21 11:21:05 2005 +0100 2.3 @@ -243,11 +243,17 @@ class XendRoot: 2.4 """ 2.5 return self.get_config_value("xend-unix-path", self.xend_unix_path_default) 2.6 2.7 - def get_block_script(self, type): 2.8 - return self.get_config_value('block-%s' % type, '') 2.9 + def get_network_script(self): 2.10 + """@return the script used to alter the network configuration when 2.11 + Xend starts and stops, or None if no such script is specified.""" 2.12 + 2.13 + s = self.get_config_value('network-script') 2.14 2.15 - def get_network_script(self): 2.16 - return self.get_config_value('network-script', '') 2.17 + if s: 2.18 + return os.path.join(self.network_script_dir, s) 2.19 + else: 2.20 + return None 2.21 + 2.22 2.23 def get_enable_dump(self): 2.24 return self.get_config_bool('enable-dump', 'no') 2.25 @@ -258,9 +264,6 @@ class XendRoot: 2.26 def get_vif_script(self): 2.27 return self.get_config_value('vif-script', 'vif-bridge') 2.28 2.29 - def get_vif_antispoof(self): 2.30 - return self.get_config_bool('vif-antispoof', 'yes') 2.31 - 2.32 def get_dom0_min_mem(self): 2.33 return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default) 2.34