mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
xenserver: Synchronize scripts with XenServer 6.0.0.
This commit updates the "vif" and "interface-reconfigure" scripts installed by Open vSwitch on Citrix XenServer with those in XenServer 6.0.0. Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -150,6 +150,30 @@ remove_from_bridge()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
call_hook_script() {
|
||||||
|
local domid=$1
|
||||||
|
local action=$2
|
||||||
|
# Call the VIF hotplug hook if present
|
||||||
|
if [ -x /etc/xapi.d/vif-hotplug ]; then
|
||||||
|
local vm=$(xenstore-read "/local/domain/$domid/vm" 2>/dev/null)
|
||||||
|
if [ $? -eq 0 -a -n "${vm}" ] ; then
|
||||||
|
local vm_uuid=$(xenstore-read "$vm/uuid" 2>/dev/null)
|
||||||
|
fi
|
||||||
|
if [ -n "${vm_uuid}" ] ; then
|
||||||
|
logger -t scripts-vif "VM UUID ${vm_uuid}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local vif_uuid=$(xenstore-read "${PRIVATE}/vif-uuid" 2>/dev/null)
|
||||||
|
if [ -n "${vif_uuid}" ] ; then
|
||||||
|
logger -t scripts-vif "VIF UUID ${vif_uuid}"
|
||||||
|
fi
|
||||||
|
if [ -n "${vif_uuid}" -a -n "${vm_uuid}" ] ; then
|
||||||
|
logger -t scripts-vif "Calling VIF hotplug hook for VM ${vm_uuid}, VIF ${vif_uuid}"
|
||||||
|
/etc/xapi.d/vif-hotplug -action "${action}" -vifuuid "${vif_uuid}" -vmuuid "${vm_uuid}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
NETWORK_MODE=$(cat /etc/xensource/network.conf)
|
NETWORK_MODE=$(cat /etc/xensource/network.conf)
|
||||||
ACTION=$1
|
ACTION=$1
|
||||||
|
|
||||||
@@ -171,8 +195,13 @@ esac
|
|||||||
|
|
||||||
case ${TYPE} in
|
case ${TYPE} in
|
||||||
vif)
|
vif)
|
||||||
DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'`
|
if [ -z ${XENBUS_PATH} ]; then
|
||||||
DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'`
|
DOMID=$3
|
||||||
|
DEVID=$4
|
||||||
|
else
|
||||||
|
DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'`
|
||||||
|
DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'`
|
||||||
|
fi
|
||||||
dev=vif${DOMID}.${DEVID}
|
dev=vif${DOMID}.${DEVID}
|
||||||
;;
|
;;
|
||||||
tap)
|
tap)
|
||||||
@@ -210,6 +239,7 @@ online)
|
|||||||
|
|
||||||
# xs-xen.pq.hq:91e986b8e49f netback-wait-for-hotplug
|
# xs-xen.pq.hq:91e986b8e49f netback-wait-for-hotplug
|
||||||
xenstore-write "/local/domain/0/backend/vif/${DOMID}/${DEVID}/hotplug-status" "connected"
|
xenstore-write "/local/domain/0/backend/vif/${DOMID}/${DEVID}/hotplug-status" "connected"
|
||||||
|
call_hook_script $DOMID "${ACTION}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -222,8 +252,14 @@ add)
|
|||||||
remove)
|
remove)
|
||||||
if [ "${TYPE}" = "vif" ] ;then
|
if [ "${TYPE}" = "vif" ] ;then
|
||||||
xenstore-rm "${HOTPLUG}/hotplug"
|
xenstore-rm "${HOTPLUG}/hotplug"
|
||||||
|
call_hook_script $DOMID "${ACTION}"
|
||||||
fi
|
fi
|
||||||
logger -t scripts-vif "${dev} has been removed"
|
logger -t scripts-vif "${dev} has been removed"
|
||||||
remove_from_bridge
|
remove_from_bridge
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
move)
|
||||||
|
if [ "${TYPE}" = "vif" ] ;then
|
||||||
|
add_to_bridge
|
||||||
|
fi
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -508,9 +508,8 @@ class DatabaseCache(object):
|
|||||||
host = session.xenapi.host.get_by_uuid(inventory['INSTALLATION_UUID'])
|
host = session.xenapi.host.get_by_uuid(inventory['INSTALLATION_UUID'])
|
||||||
|
|
||||||
self.__get_pif_records_from_xapi(session, host)
|
self.__get_pif_records_from_xapi(session, host)
|
||||||
|
|
||||||
self.__get_tunnel_records_from_xapi(session)
|
|
||||||
self.__get_pool_records_from_xapi(session)
|
self.__get_pool_records_from_xapi(session)
|
||||||
|
self.__get_tunnel_records_from_xapi(session)
|
||||||
self.__get_vlan_records_from_xapi(session)
|
self.__get_vlan_records_from_xapi(session)
|
||||||
self.__get_bond_records_from_xapi(session)
|
self.__get_bond_records_from_xapi(session)
|
||||||
self.__get_network_records_from_xapi(session)
|
self.__get_network_records_from_xapi(session)
|
||||||
@@ -576,9 +575,11 @@ class DatabaseCache(object):
|
|||||||
for (ref,rec) in self.__pools.items():
|
for (ref,rec) in self.__pools.items():
|
||||||
self.__to_xml(xml, xml.documentElement, _POOL_XML_TAG, ref, rec, _POOL_ATTRS)
|
self.__to_xml(xml, xml.documentElement, _POOL_XML_TAG, ref, rec, _POOL_ATTRS)
|
||||||
|
|
||||||
f = open(cache_file, 'w')
|
temp_file = cache_file + ".%d" % os.getpid()
|
||||||
|
f = open(temp_file, 'w')
|
||||||
f.write(xml.toprettyxml())
|
f.write(xml.toprettyxml())
|
||||||
f.close()
|
f.close()
|
||||||
|
os.rename(temp_file, cache_file)
|
||||||
|
|
||||||
def get_pif_by_uuid(self, uuid):
|
def get_pif_by_uuid(self, uuid):
|
||||||
pifs = map(lambda (ref,rec): ref,
|
pifs = map(lambda (ref,rec): ref,
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import syslog
|
|||||||
import traceback
|
import traceback
|
||||||
import re
|
import re
|
||||||
import random
|
import random
|
||||||
|
import syslog
|
||||||
|
|
||||||
management_pif = None
|
management_pif = None
|
||||||
|
|
||||||
@@ -144,10 +145,11 @@ def netdev_remap_name(pif, already_renamed=[]):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def rename_netdev(old_name, new_name):
|
def rename_netdev(old_name, new_name):
|
||||||
log("Changing the name of %s to %s" % (old_name, new_name))
|
raise Error("Trying to rename %s to %s - This functionality has been removed" % (old_name, new_name))
|
||||||
run_command(['/sbin/ifconfig', old_name, 'down'])
|
# log("Changing the name of %s to %s" % (old_name, new_name))
|
||||||
if not run_command(['/sbin/ip', 'link', 'set', old_name, 'name', new_name]):
|
# run_command(['/sbin/ifconfig', old_name, 'down'])
|
||||||
raise Error("Could not rename %s to %s" % (old_name, new_name))
|
# if not run_command(['/sbin/ip', 'link', 'set', old_name, 'name', new_name]):
|
||||||
|
# raise Error("Could not rename %s to %s" % (old_name, new_name))
|
||||||
|
|
||||||
pifrec = db().get_pif_record(pif)
|
pifrec = db().get_pif_record(pif)
|
||||||
device = pifrec['device']
|
device = pifrec['device']
|
||||||
@@ -197,7 +199,11 @@ def ifup(netdev):
|
|||||||
"""Bring up a network interface"""
|
"""Bring up a network interface"""
|
||||||
if not os.path.exists(root_prefix() + "/etc/sysconfig/network-scripts/ifcfg-%s" % netdev):
|
if not os.path.exists(root_prefix() + "/etc/sysconfig/network-scripts/ifcfg-%s" % netdev):
|
||||||
raise Error("ifup: device %s exists but ifcfg-%s does not" % (netdev,netdev))
|
raise Error("ifup: device %s exists but ifcfg-%s does not" % (netdev,netdev))
|
||||||
|
d = os.getenv("DHCLIENTARGS","")
|
||||||
|
if os.path.exists("/etc/firstboot.d/data/firstboot_in_progress"):
|
||||||
|
os.putenv("DHCLIENTARGS", d + " -T 240 " )
|
||||||
run_command(["/sbin/ifup", netdev])
|
run_command(["/sbin/ifup", netdev])
|
||||||
|
os.putenv("DHCLIENTARGS", d )
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -269,6 +275,7 @@ def ipdev_open_ifcfg(pif):
|
|||||||
f.write("XEMANAGED=yes\n")
|
f.write("XEMANAGED=yes\n")
|
||||||
f.write("DEVICE=%s\n" % ipdev)
|
f.write("DEVICE=%s\n" % ipdev)
|
||||||
f.write("ONBOOT=no\n")
|
f.write("ONBOOT=no\n")
|
||||||
|
f.write("NOZEROCONF=yes\n")
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
@@ -356,6 +363,10 @@ def ipdev_configure_network(pif, dp):
|
|||||||
|
|
||||||
pifs_on_host = [p for p in db().get_all_pifs() if not p in pif_get_bond_masters(pif)]
|
pifs_on_host = [p for p in db().get_all_pifs() if not p in pif_get_bond_masters(pif)]
|
||||||
|
|
||||||
|
# now prune out bond slaves as they are not connected to the IP
|
||||||
|
# stack and so cannot be used as gateway or DNS devices.
|
||||||
|
pifs_on_host = [ p for p in pifs_on_host if len(pif_get_bond_masters(p)) == 0]
|
||||||
|
|
||||||
# loop through all the pifs on this host looking for one with
|
# loop through all the pifs on this host looking for one with
|
||||||
# other-config:peerdns = true, and one with
|
# other-config:peerdns = true, and one with
|
||||||
# other-config:default-route=true
|
# other-config:default-route=true
|
||||||
|
|||||||
Reference in New Issue
Block a user