[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Remove unused Vifctl.vifctl and Vifctl.set_vif_name. Remove the bridge and



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 021324804fbd8b84ad5fc519491318c9e2d54291
# Parent  82cdb5efc3a8d8feb157512bce057abb91dade32
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@xxxxxxxxxxxxx>

diff -r 82cdb5efc3a8 -r 021324804fbd tools/python/xen/xend/Vifctl.py
--- a/tools/python/xen/xend/Vifctl.py   Fri Oct 21 10:08:48 2005
+++ b/tools/python/xen/xend/Vifctl.py   Fri Oct 21 10:21:05 2005
@@ -19,87 +19,17 @@
 """Xend interface to networking control scripts.
 """
 import os
-import os.path
-import xen.util.process
 
-from xen.xend import XendRoot
-xroot = XendRoot.instance()
+import XendRoot
 
-"""Where network control scripts live."""
-SCRIPT_DIR = xroot.network_script_dir
 
-def network(op, script=None, bridge=None, antispoof=None):
+def network(op):
     """Call a network control script.
-    Xend calls this with op 'start' when it starts.
 
-    @param op:        operation (start, stop, status)
-    @param script:    network script name
-    @param bridge:    xen bridge
-    @param antispoof: whether to enable IP antispoofing rules
+    @param op: operation (start, stop)
     """
-    if op not in ['start', 'stop', 'status']:
-        raise ValueError('Invalid operation:' + op)
-    if script is None:
-        script = xroot.get_network_script()
-    if bridge is None:
-        bridge = xroot.get_vif_bridge()
-    if antispoof is None:
-        antispoof = xroot.get_vif_antispoof()
-    script = os.path.join(SCRIPT_DIR, script)
-    args = [op]
-    args.append("bridge='%s'" % bridge)
-    if antispoof:
-        args.append("antispoof=yes")
-    else:
-        args.append("antispoof=no")
-    args = ' '.join(args)
-    ret = xen.util.process.runscript(script + ' ' + args)
-    if len(ret):
-        return ret.splitlines()[0]
-
-def set_vif_name(vif_old, vif_new):
-    if vif_old == vif_new:
-        vif = vif_new
-        return vif
-    if os.system("ip link show %s" % vif_old) == 0:
-        os.system("ip link set %s down" % vif_old)
-        os.system("ip link set %s name %s" % (vif_old, vif_new))
-        os.system("ip link set %s up" % vif_new)
-    if os.system("ip link show %s" % vif_new) == 0:
-        vif = vif_new
-    else:
-        vif = vif_old
-    return vif
-
-def vifctl(op, vif=None, script=None, domain=None, mac=None, bridge=None, 
ipaddr=None):
-    """Call a vif control script.
-    Xend calls this when bringing vifs up or down.
-
-    @param op:     vif operation (up, down)
-    @param vif:    vif name
-    @param script: name of control script
-    @param domain: name of domain the vif is on
-    @param mac:    vif MAC address
-    @param bridge: bridge to add the vif to
-    @param ipaddr: list of ipaddrs the vif may use
-    """
-    if op not in ['up', 'down']:
-        raise ValueError('Invalid operation:' + op)
-    if script is None:
-        script = xroot.get_vif_script()
-    if bridge is None:
-        bridge = xroot.get_vif_bridge()
-    script = os.path.join(SCRIPT_DIR, script)
-    args = [op]
-    args.append("vif='%s'" % vif)
-    args.append("domain='%s'" % domain)
-    args.append("mac='%s'" % mac)
-    if bridge:
-        args.append("bridge='%s'" % bridge)
-    if ipaddr:
-        ips = ' '.join(ipaddr)
-        args.append("ip='%s'" % ips)
-    args = ' '.join(args)
-    ret = xen.util.process.runscript(script + ' ' + args)
-    if len(ret):
-        return ret.splitlines()[0]
+    if op not in ['start', 'stop']:
+        raise ValueError('Invalid operation: ' + op)
+    script = XendRoot.instance().get_network_script()
+    if script:
+        os.spawnl(os.P_WAIT, script, script, op)
diff -r 82cdb5efc3a8 -r 021324804fbd tools/python/xen/xend/XendRoot.py
--- a/tools/python/xen/xend/XendRoot.py Fri Oct 21 10:08:48 2005
+++ b/tools/python/xen/xend/XendRoot.py Fri Oct 21 10:21:05 2005
@@ -243,11 +243,17 @@
         """
         return self.get_config_value("xend-unix-path", 
self.xend_unix_path_default)
 
-    def get_block_script(self, type):
-        return self.get_config_value('block-%s' % type, '')
-
     def get_network_script(self):
-        return self.get_config_value('network-script', '')
+        """@return the script used to alter the network configuration when
+        Xend starts and stops, or None if no such script is specified."""
+        
+        s = self.get_config_value('network-script')
+
+        if s:
+            return os.path.join(self.network_script_dir, s)
+        else:
+            return None
+
 
     def get_enable_dump(self):
         return self.get_config_bool('enable-dump', 'no')
@@ -257,9 +263,6 @@
 
     def get_vif_script(self):
         return self.get_config_value('vif-script', 'vif-bridge')
-
-    def get_vif_antispoof(self):
-        return self.get_config_bool('vif-antispoof', 'yes')
 
     def get_dom0_min_mem(self):
         return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.