vswitch-related shell functions for the administrator's
convenience.
+ etc_udev_xen-backend.rules
+
+ udev rules for invoking the XenServer "vif" and "tap" scripts.
+
etc_xapi.d_plugins_vswitch-cfg-update
xapi plugin script to update the cache of configuration items
vswitch-aware replacement for Citrix script of the same name.
- root_vswitch_scripts_dump-vif-details
-
- Script to retrieve extended information about VIFs that are
- needed by the controller. This is called by the "vif" script,
- which is run when virtual interfaces are added and removed.
-
usr_share_vswitch_scripts_refresh-xs-network-uuids
Script to refresh bridge.<bridge>.xs-network-uuids keys, which
xenserver/etc_init.d_vswitch-xapi-update \
xenserver/etc_logrotate.d_vswitch \
xenserver/etc_profile.d_vswitch.sh \
+ xenserver/etc_udev_xen-backend.rules \
xenserver/etc_xapi.d_plugins_vswitch-cfg-update \
xenserver/etc_xensource_scripts_vif \
xenserver/opt_xensource_libexec_interface-reconfigure \
xenserver/usr_sbin_brctl \
xenserver/usr_sbin_xen-bugtool \
xenserver/usr_share_vswitch_scripts_sysconfig.template \
- xenserver/usr_share_vswitch_scripts_dump-vif-details \
+ xenserver/usr_share_vswitch_scripts_vif-on-internal-bridge \
xenserver/usr_share_vswitch_scripts_refresh-xs-network-uuids \
xenserver/vswitch-xen.spec
test -e /etc/sysconfig/vswitch && . /etc/sysconfig/vswitch
# General config variables in /etc/sysconfig/vswitch
-: ${ENABLE_BRCOMPAT:=y}
-: ${ENABLE_FAKE_PROC_NET:=y}
+: ${ENABLE_BRCOMPAT:=n}
+: ${ENABLE_FAKE_PROC_NET:=n}
: ${FORCE_COREFILES:=y}
# Config variables specific to ovs-vswitchd
action "Inserting llc module" modprobe llc
action "Inserting openvswitch module" modprobe openvswitch_mod
fi
- if [ -n "$BRCOMPATD_PIDFILE" ] && ! lsmod | grep -q "brcompat_mod"; then
+ if [ "$ENABLE_BRCOMPAT" = "y" ] && [ -n "$BRCOMPATD_PIDFILE" ] && ! lsmod | grep -q "brcompat_mod"; then
action "Inserting brcompat module" modprobe brcompat_mod
fi
}
fi
start_vswitchd
- start_brcompatd
+ if [ "${ENABLE_BRCOMPAT}" = "y" ] ; then
+ start_brcompatd
+ fi
reload_vswitchd # ensures ovs-vswitchd has fully read config file.
touch /var/lock/subsys/vswitch
}
;;
status)
status -p ovs-vswitchd.pid ovs-vswitchd
- status -p ovs-brcompatd.pid ovs-brcompatd
+ rc=$?
+ if [ $rc -eq 0 ] && [ "$ENABLE_BRCOMPAT" = "y" ] ; then
+ status -p ovs-brcompatd.pid ovs-brcompatd
+ rc=$?
+ fi
+ exit $rc
;;
version)
/usr/sbin/ovs-vswitchd -V
/var/log/ovs-vswitchd.log /var/log/ovs-brcompatd.log {
sharedscripts
+ missingok
postrotate
# Tell ovs-vswitchd and ovs-brcompatd to reopen their log files
/sbin/service vswitch reload
--- /dev/null
+SUBSYSTEM=="xen-backend", KERNEL=="tap*", RUN+="/etc/xensource/scripts/tap $env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xensource/scripts/block $env{ACTION}"
+
+SUBSYSTEM=="xen-backend", KERNEL=="vif*", RUN+="/etc/xensource/scripts/vif $env{ACTION} vif"
+SUBSYSTEM=="net", KERNEL=="tap*", RUN+="/etc/xensource/scripts/vif $env{ACTION} tap"
+
+KERNEL=="evtchn", NAME="xen/%k"
+
+# blktap devices created by blktapctrl
+KERNEL=="blktap[0-9]*", OPTIONS="ignore_device"
raise XenAPIPlugin.Failure("MORE_THAN_ONE_POOL_FOR_HOST", [])
pool = session.xenapi.pool.get_record(pools[0])
try:
- controller = pool["other_config"]["vSwitchController"]
+ controller = pool["vswitch_controller"]
except KeyError, e:
controller = ""
currentController = vswitchCurrentController()
vsctl="/usr/bin/ovs-vsctl"
dump_vif_details="/usr/share/vswitch/scripts/dump-vif-details"
service="/sbin/service"
-
-TYPE=`echo ${XENBUS_PATH} | cut -f 2 -d '/'`
-DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'`
-DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'`
-
-XAPI=/xapi/${DOMID}/hotplug/${TYPE}/${DEVID}
-HOTPLUG=/xapi/${DOMID}/hotplug/${TYPE}/${DEVID}
-PRIVATE=/xapi/${DOMID}/private/${TYPE}/${DEVID}
-BRCTL=/usr/sbin/brctl
-IP=/sbin/ip
-
+IP="/sbin/ip"
+vif_on_internal_bridge="/usr/share/vswitch/scripts/vif-on-internal-bridge"
handle_promiscuous()
{
- local arg=$(xenstore-read "${PRIVATE}/other-config/promiscuous")
+ local arg=$(xenstore-read "${PRIVATE}/other-config/promiscuous" 2>/dev/null)
if [ $? -eq 0 -a -n "${arg}" ] ; then
case "${arg}" in
- true|on) logger -t script-vif "${vif}: Promiscuous ports are not supported via vSwitch." ;;
+ true|on) logger -t script-vif "${dev}: Promiscuous ports are not supported via vSwitch." ;;
*) ;;
esac
fi
handle_ethtool()
{
local opt=$1
- local arg=$(xenstore-read "${PRIVATE}/other-config/ethtool-${opt}")
+ local arg=$(xenstore-read "${PRIVATE}/other-config/ethtool-${opt}" 2>/dev/null)
if [ $? -eq 0 -a -n "${arg}" ] ; then
case "${arg}" in
- true|on) /sbin/ethtool -K "${vif}" "${opt}" on ;;
- false|off) /sbin/ethtool -K "${vif}" "${opt}" off ;;
- *) logger -t scripts-vif "Unknown ethtool argument ${opt}=${arg} on ${vif}/${VIFUUID}" ;;
+ true|on) /sbin/ethtool -K "${dev}" "${opt}" on ;;
+ false|off) /sbin/ethtool -K "${dev}" "${opt}" off ;;
+ *) logger -t scripts-vif "Unknown ethtool argument ${opt}=${arg} on ${dev}/${VIFUUID}" ;;
esac
fi
}
handle_mtu()
{
- local mtu=$(xenstore-read "${PRIVATE}/MTU")
+ local mtu=$(xenstore-read "${PRIVATE}/MTU" 2>/dev/null)
if [ $? -eq 0 -a -n "${mtu}" ]; then
- echo "${mtu}" > /sys/class/net/${vif}/mtu
+ echo "${mtu}" > /sys/class/net/${dev}/mtu
fi
}
+handle_vif_details()
+{
+ local vif_details=
+ local net_uuid=$(xenstore-read "${PRIVATE}/network-uuid" 2>/dev/null)
+ if [ -n "${net_uuid}" ] ; then
+ vif_details="$vif_details --add=port.${dev}.net-uuid=${net_uuid}"
+ fi
+
+ local address=$(xenstore-read "/local/domain/$DOMID/device/vif/$DEVID/mac" 2>/dev/null)
+ if [ -n "${address}" ] ; then
+ vif_details="$vif_details --add=port.${dev}.vif-mac=${address}"
+ fi
+
+ local vif_uuid=$(xenstore-read "${PRIVATE}/vif-uuid" 2>/dev/null)
+ if [ -n "${vif_uuid}" ] ; then
+ vif_details="$vif_details --add=port.${dev}.vif-uuid=${vif_uuid}"
+ fi
+
+ 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
+ vif_details="$vif_details --add=port.${dev}.vm-uuid=${vm_uuid}"
+ fi
+
+ # vNetManager needs to know the network UUID(s) associated with
+ # each datapath. Normally interface-reconfigure adds them, but
+ # interface-reconfigure never gets called for internal networks
+ # (xapi does the addbr ioctl internally), so we have to do it
+ # here instead for internal networks. This is only acceptable
+ # because xapi is lazy about creating internal networks: it
+ # only creates one just before it adds the first vif to it.
+ # There may still be a brief delay between the initial
+ # ovs-vswitchd connection to vNetManager and setting this
+ # configuration variable, but vNetManager can tolerate that.
+ local internal=$(${vif_on_internal_bridge} ${DOMID} ${DEVID})
+ if [ "$internal" = "true" ]; then
+ local bridge=$(xenstore-read "${PRIVATE}/bridge" 2>/dev/null)
+ local net_uuid=$(xenstore-read "${PRIVATE}/network-uuid" 2>/dev/null)
+ local key="bridge.${bridge}.xs-network-uuids"
+
+ vif_details="$vif_details --del-match=${key}=*"
+ vif_details="$vif_details --add=${key}=${net_uuid}"
+ fi
+
+ echo ${vif_details}
+}
+
add_to_bridge()
{
local address=$(xenstore-read "${PRIVATE}/bridge-MAC")
if [ $? -ne 0 -o -z "${address}" ]; then
logger -t scripts-vif "Failed to read ${PRIVATE}/bridge-MAC from xenstore"
+ exit 1
fi
local bridge=$(xenstore-read "${PRIVATE}/bridge")
if [ $? -ne 0 -o -z "${bridge}" ]; then
logger -t scripts-vif "Failed to read ${PRIVATE}/bridge from xenstore"
+ exit 1
fi
- logger -t scripts-vif "Adding ${vif} to ${bridge} with address ${address}"
+ logger -t scripts-vif "Adding ${dev} to ${bridge} with address ${address}"
local VLAN_ID=$($vsctl br-to-vlan $bridge)
local vid=
vid="--add=vlan.${vif}.tag=${VLAN_ID}"
fi
- ${IP} link set "${vif}" down || logger -t scripts-vif "Failed to ip link set ${vif} down"
- ${IP} link set "${vif}" arp off || logger -t scripts-vif "Failed to ip link set ${vif} arp off"
- ${IP} link set "${vif}" multicast off || logger -t scripts-vif "Failed to ip link set ${vif} multicast off"
- ${IP} link set "${vif}" address "${address}" || logger -t scripts-vif "Failed to ip link set ${vif} address ${address}"
- ${IP} addr flush "${vif}" || logger -t scripts-vif "Failed to ip addr flush ${vif}"
-
- local vif_details=$($dump_vif_details $DOMID $DEVID)
- if [ $? -ne 0 -o -z "${vif_details}" ]; then
- logger -t scripts-vif "Failed to retrieve vif details for vswitch"
+ if [ "$type" = "vif" ] ; then
+ local vif_details=$(handle_vif_details)
fi
+ ${IP} link set "${dev}" down || logger -t scripts-vif "Failed to ip link set ${dev} down"
+ ${IP} link set "${dev}" arp off || logger -t scripts-vif "Failed to ip link set ${dev} arp off"
+ ${IP} link set "${dev}" multicast off || logger -t scripts-vif "Failed to ip link set ${dev} multicast off"
+ ${IP} link set "${dev}" address "${address}" || logger -t scripts-vif "Failed to ip link set ${dev} address ${address}"
+ ${IP} addr flush "${dev}" || logger -t scripts-vif "Failed to ip addr flush ${dev}"
+
$cfg_mod -F /etc/ovs-vswitchd.conf \
- --del-match="bridge.*.port=$vif" \
- --del-match="vlan.$vif.trunks=*" \
- --del-match="vlan.$vif.tag=*" \
- --del-match="port.$vif.[!0-9]*" \
- --add="bridge.$bridge.port=$vif" \
+ --del-match="bridge.*.port=${dev}" \
+ --del-match="vlan.${dev}.trunks=*" \
+ --del-match="vlan.${dev}.tags=*" \
+ --del-match="port.${dev}.[!0-9]*" \
+ --add="bridge.$bridge.port=${dev}" \
$vid $vif_details -c
$service vswitch reload
- ${IP} link set "${vif}" up || logger -t scripts-vif "Failed to ip link set ${vif} up"
+ ${IP} link set "${dev}" up || logger -t scripts-vif "Failed to ip link set ${dev} up"
}
-echo Called as "$@" "$TYPE" "$DOMID" "$DEVID" | logger -t scripts-vif
-case "$1" in
-online)
- handle_ethtool rx
- handle_ethtool tx
- handle_ethtool sg
- handle_ethtool tso
- handle_ethtool ufo
- handle_ethtool gso
+type=$2
- handle_mtu
- add_to_bridge
- handle_promiscuous
+case ${type} in
+ vif)
+ DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'`
+ DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'`
+ dev=vif${DOMID}.${DEVID}
+ ;;
+ tap)
+ dev=$INTERFACE
+ DOMID=`echo ${dev#tap} | cut -f 1 -d '.'`
+ DEVID=`echo ${dev#tap} | cut -f 2 -d '.'`
+ ;;
+ *)
+ logger -t scripts-vif "unknown interface type ${type}"
+ exit 1
+ ;;
+esac
- xenstore-write "${HOTPLUG}/vif" "${vif}"
- xenstore-write "${HOTPLUG}/hotplug" "online"
+XAPI=/xapi/${DOMID}/hotplug/vif/${DEVID}
+HOTPLUG=/xapi/${DOMID}/hotplug/vif/${DEVID}
+PRIVATE=/xapi/${DOMID}/private/vif/${DEVID}
- # xs-xen.pq.hq:91e986b8e49f netback-wait-for-hotplug
- xenstore-write "/local/domain/0/backend/vif/${DOMID}/${DEVID}/hotplug-status" "connected"
+echo Called as "$@" "$DOMID" "$DEVID" | logger -t scripts-vif
+case "$1" in
+online)
+ if [ "${type}" = "vif" ] ; then
+ handle_ethtool rx
+ handle_ethtool tx
+ handle_ethtool sg
+ handle_ethtool tso
+ handle_ethtool ufo
+ handle_ethtool gso
+
+ handle_mtu
+ add_to_bridge
+ handle_promiscuous
+
+ xenstore-write "${HOTPLUG}/vif" "${dev}"
+ xenstore-write "${HOTPLUG}/hotplug" "online"
+
+ # xs-xen.pq.hq:91e986b8e49f netback-wait-for-hotplug
+ xenstore-write "/local/domain/0/backend/vif/${DOMID}/${DEVID}/hotplug-status" "connected"
+ fi
+ ;;
+add)
+ if [ "${type}" = "tap" ] ; then
+ add_to_bridge
+ fi
;;
+
remove)
- xenstore-rm "${HOTPLUG}/hotplug"
- vif=vif${DOMID}.${DEVID}
- logger -t scripts-vif "${vif} has been removed"
+ if [ "${type}" = "vif" ] ;then
+ xenstore-rm "${HOTPLUG}/hotplug"
+ fi
+ logger -t scripts-vif "${dev} has been removed"
$cfg_mod -vANY:console:emer -F /etc/ovs-vswitchd.conf \
- --del-match="bridge.*.port=${vif}" \
- --del-match="vlan.${vif}.trunks=*" \
- --del-match="vlan.${vif}.tag=*" \
- --del-match="port.${vif}.[!0-9]*" -c
+ --del-match="bridge.*.port=${dev}" \
+ --del-match="vlan.${dev}.trunks=*" \
+ --del-match="vlan.${dev}.tag=*" \
+ --del-match="port.${dev}.[!0-9]*" -c
$service vswitch reload
;;
esac
self.hostsUpdated = 0
pool = data.GetPoolForThisHost()
if pool is not None:
- self.controller = pool.get("other_config", {}).get("vSwitchController", "")
+ self.controller = pool.get("vswitch_controller", "")
else:
self.controller = ""
lambda: self.getController()),
ChoiceDef(Lang("Delete pool-wide controller"),
lambda: self.deleteController()),
- ChoiceDef(Lang("Resync server controller config"),
- lambda: self.syncController()),
# ChoiceDef(Lang("Restart ovs-vswitchd"),
# lambda: self.restartService("vswitch")),
# ChoiceDef(Lang("Restart ovs-brcompatd"),
except Exception, e:
Layout.Inst().PushDialogue(InfoDialogue(Lang("Controller deletion failed")))
- def syncController(self):
- Layout.Inst().PopDialogue()
- Layout.Inst().TransientBanner(Lang("Resyncing controller setting..."))
- try:
- Task.Sync(lambda s: self._updateThisServer(s))
- Layout.Inst().PushDialogue(InfoDialogue(Lang("Resyncing controller config successful")))
- except Exception, e:
- Layout.Inst().PushDialogue(InfoDialogue(Lang("Resyncing controller config failed")))
-
def SetController(self, ip):
self.hostsInPool = 0
self.hostsUpdated = 0
- Task.Sync(lambda s: self._modifyPoolConfig(s, "vSwitchController", ip))
- # Should be done asynchronously, maybe with an external script?
- Task.Sync(lambda s: self._updateActiveServers(s))
+ Task.Sync(lambda s: self._modifyPoolConfig(s, ip or ""))
- def _modifyPoolConfig(self, session, key, value):
+ def _modifyPoolConfig(self, session, value):
"""Modify pool configuration.
- If value == None then delete key, otherwise set key to value."""
+ If value == None then delete configuration, otherwise set to value."""
pools = session.xenapi.pool.get_all()
# We assume there is only ever one pool...
if len(pools) == 0:
- log.error("No pool for host.")
- raise XenAPIPlugin.Failure("NO_POOL_FOR_HOST", [])
+ XSLogFatal(Lang("No pool found for host."))
+ return
if len(pools) > 1:
- log.error("More than one pool for host.")
- raise XenAPIPlugin.Failure("MORE_THAN_ONE_POOL_FOR_HOST", [])
- session.xenapi.pool.remove_from_other_config(pools[0], key)
- if value != None:
- session.xenapi.pool.add_to_other_config(pools[0], key, value)
+ XSLogFatal(Lang("More than one pool for host."))
+ return
+ session.xenapi.pool.set_vswitch_controller(value)
Data.Inst().Update()
- def _updateActiveServers(self, session):
- hosts = session.xenapi.host.get_all()
- self.hostsUpdated = 0
- self.hostsInPool = len(hosts)
- self.UpdateFields()
- for host in hosts:
- Layout.Inst().TransientBanner("Updating host %d out of %d"
- % (self.hostsUpdated + 1, self.hostsInPool))
- session.xenapi.host.call_plugin(host, "vswitch-cfg-update", "update", {})
- self.hostsUpdated = self.hostsUpdated + 1
-
- def _updateThisServer(self, session):
- data = Data.Inst()
- host = data.host.opaqueref()
- session.xenapi.host.call_plugin(host, "vswitch-cfg-update", "update", {})
-
-
class XSFeatureVSwitch:
@classmethod
pool = data.GetPoolForThisHost()
if pool is not None:
- dbController = pool.get("other_config", {}).get("vSwitchController", "")
+ dbController = pool.get("vswitch_controller", "")
else:
dbController = ""
inPane.NewLine()
inPane.AddStatusField(Lang("ovs-vswitchd status", 20),
VSwitchService.Inst("vswitch", "ovs-vswitchd").status())
- inPane.AddStatusField(Lang("ovs-brcompatd status", 20),
- VSwitchService.Inst("vswitch", "ovs-brcompatd").status())
+ #inPane.AddStatusField(Lang("ovs-brcompatd status", 20),
+ # VSwitchService.Inst("vswitch", "ovs-brcompatd").status())
inPane.AddKeyHelpField( {
Lang("<Enter>") : Lang("Reconfigure"),
}
)
-# Register this plugin when module is imported
-XSFeatureVSwitch().Register()
+# Register this plugin when module is imported, IFF vswitchd is running
+if os.path.exists('/var/run/ovs-vswitchd.pid'):
+ XSFeatureVSwitch().Register()
+++ /dev/null
-#!/usr/bin/python
-#
-# Script to retrieve extended information about VIFs that are
-# needed by the controller. This is called by the "vif" script,
-# which is run when virtual interfaces are added and removed.
-
-# Copyright (C) 2009 Nicira Networks, Inc.
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without warranty of any kind.
-
-import sys
-import XenAPI
-import xen.lowlevel.xs
-
-# Query XenStore for the opaque reference of this vif
-def get_vif_ref(domid, devid):
- xenstore = xen.lowlevel.xs.xs()
- t = xenstore.transaction_start()
- vif_ref = xenstore.read(t, '/xapi/%s/private/vif/%s/ref' % (domid, devid))
- xenstore.transaction_end(t)
- return vif_ref
-
-# Query XAPI for the information we need using the vif's opaque reference
-def dump_vif_info(domid, devid, vif_ref):
- vif_info = []
- session = XenAPI.xapi_local()
- session.xenapi.login_with_password("root", "")
- try:
- vif_rec = session.xenapi.VIF.get_record(vif_ref)
- net_rec = session.xenapi.network.get_record(vif_rec["network"])
- vm_uuid = session.xenapi.VM.get_uuid(vif_rec["VM"])
-
- # Data to allow vNetManager to associate VIFs with xapi data
- add_port = '--add=port.vif%s.%s' % (domid, devid)
- vif_info.append('%s.net-uuid=%s' % (add_port, net_rec["uuid"]))
- vif_info.append('%s.vif-mac=%s' % (add_port, vif_rec["MAC"]))
- vif_info.append('%s.vif-uuid=%s' % (add_port, vif_rec["uuid"]))
- vif_info.append('%s.vm-uuid=%s' % (add_port, vm_uuid))
-
- # vNetManager needs to know the network UUID(s) associated with
- # each datapath. Normally interface-reconfigure adds them, but
- # interface-reconfigure never gets called for internal networks
- # (xapi does the addbr ioctl internally), so we have to do it
- # here instead for internal networks. This is only acceptable
- # because xapi is lazy about creating internal networks: it
- # only creates one just before it adds the first vif to it.
- # There may still be a brief delay between the initial
- # ovs-vswitchd connection to vNetManager and setting this
- # configuration variable, but vNetManager can tolerate that.
- if not net_rec['PIFs']:
- key = 'bridge.%s.xs-network-uuids' % net_rec['bridge']
- value = net_rec['uuid']
- vif_info.append('--del-match=%s=*' % key)
- vif_info.append('--add=%s=%s' % (key, value))
- finally:
- session.xenapi.session.logout()
- print ' '.join(vif_info)
-
-if __name__ == '__main__':
- if len(sys.argv) != 3:
- sys.stderr.write("ERROR: %s <domid> <devid>\n" % sys.argv[0])
- sys.exit(1)
-
- domid = sys.argv[1]
- devid = sys.argv[2]
-
- vif_ref = get_vif_ref(domid, devid)
- if not vif_ref:
- sys.stderr.write("ERROR: Could not find interface vif%s.%s\n"
- % (domid, devid))
- sys.exit(1)
-
- dump_vif_info(domid, devid, vif_ref)
- sys.exit(0)
# ENABLE_BRCOMPAT: If 'y' than emulate linux bridging interfaces
# using the brcompat kernel module and ovs-brcompatd daemon
-# ENABLE_BRCOMPAT=y
+# ENABLE_BRCOMPAT=n
# ENABLE_FAKE_PROC_NET: If 'y' then emulate linux bonding and vlan
# files in /proc as if the bonding and vlan demultiplexing done in
# ovs-vswitchd were being implemented using existing Linux mechanisms.
# This is useful in some cases when replacing existing solutions.
-# ENABLE_FAKE_PROC_NET=y
+# ENABLE_FAKE_PROC_NET=n
# FORCE_COREFILES: If 'y' then core files will be enabled.
# FORCE_COREFILES=y
--- /dev/null
+#!/usr/bin/python
+#
+# Script to determine whether a vif is on an internal bridge
+
+# Copyright (C) 2009 Nicira Networks, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without warranty of any kind.
+
+import sys
+import XenAPI
+import xen.lowlevel.xs
+
+# Query XenStore for the opaque reference of this vif
+def get_vif_ref(domid, devid):
+ xenstore = xen.lowlevel.xs.xs()
+ t = xenstore.transaction_start()
+ vif_ref = xenstore.read(t, '/xapi/%s/private/vif/%s/ref' % (domid, devid))
+ xenstore.transaction_end(t)
+ return vif_ref
+
+# Query XAPI for the information we need using the vif's opaque reference
+def dump_vif_info(domid, devid, vif_ref):
+ try:
+ session = XenAPI.xapi_local()
+ session.xenapi.login_with_password("root", "")
+ vif_rec = session.xenapi.VIF.get_record(vif_ref)
+ net_rec = session.xenapi.network.get_record(vif_rec["network"])
+
+ if len(net_rec['PIFs']) == 0:
+ sys.stdout.write("true\n")
+ else:
+ sys.stdout.write("false\n")
+
+ finally:
+ session.xenapi.session.logout()
+
+if __name__ == '__main__':
+ if (len(sys.argv) != 3):
+ sys.stderr.write("ERROR: %s <domid> <devid>\n" % sys.argv[0])
+ sys.exit(1)
+
+ domid = sys.argv[1]
+ devid = sys.argv[2]
+
+ vif_ref = get_vif_ref(domid, devid)
+ if not vif_ref:
+ sys.stderr.write("ERROR: Could not find interface vif%s.%s\n"
+ % (domid, devid))
+ sys.exit(1)
+
+ dump_vif_info(domid, devid, vif_ref)
+ sys.exit(0)
+
$RPM_BUILD_ROOT/usr/share/vswitch/scripts/interface-reconfigure
install -m 755 xenserver/etc_xensource_scripts_vif \
$RPM_BUILD_ROOT/usr/share/vswitch/scripts/vif
-install -m 755 xenserver/usr_share_vswitch_scripts_dump-vif-details \
- $RPM_BUILD_ROOT/usr/share/vswitch/scripts/dump-vif-details
+install -m 755 xenserver/usr_share_vswitch_scripts_vif-on-internal-bridge \
+ $RPM_BUILD_ROOT/usr/share/vswitch/scripts/vif-on-internal-bridge
install -m 755 xenserver/usr_share_vswitch_scripts_refresh-xs-network-uuids \
$RPM_BUILD_ROOT/usr/share/vswitch/scripts/refresh-xs-network-uuids
install -m 755 xenserver/usr_sbin_xen-bugtool \
$RPM_BUILD_ROOT/usr/share/vswitch/scripts/brctl
install -m 755 xenserver/usr_share_vswitch_scripts_sysconfig.template \
$RPM_BUILD_ROOT/usr/share/vswitch/scripts/sysconfig.template
+install -m 644 xenserver/etc_udev_xen-backend.rules \
+ $RPM_BUILD_ROOT/usr/share/vswitch/scripts/xen-backend.rules
install -m 644 \
xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
$RPM_BUILD_ROOT/usr/share/vswitch/scripts/XSFeatureVSwitch.py
b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
51970ad613a3996d5997e18e44db47da /opt/xensource/libexec/interface-reconfigure
5654c8c36699fcc8744ca9cd5b855414 /usr/sbin/xen-bugtool
+883820a78723ee21340f31099b18f18e /etc/udev/xen-backend.rules
EOF
then
printf "\nVerified host scripts from XenServer 5.5.0.\n\n"
b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
ce451d3c985fd1db6497a363f0d9dedb /opt/xensource/libexec/interface-reconfigure
2b53f500431fcba5276c896e9e4281b9 /usr/sbin/xen-bugtool
+883820a78723ee21340f31099b18f18e /etc/udev/xen-backend.rules
EOF
then
printf "\nVerified host scripts from XenServer 5.5.900.\n\n"
/opt/xensource/libexec/interface-reconfigure \
/etc/xensource/scripts/vif \
/usr/sbin/xen-bugtool \
- /usr/sbin/brctl
+ /usr/sbin/brctl \
+ /etc/udev/xen-backend.rules
do
s=$(basename "$f")
t=$(readlink "$f")
/opt/xensource/libexec/interface-reconfigure \
/etc/xensource/scripts/vif \
/usr/sbin/xen-bugtool \
- /usr/sbin/brctl
+ /usr/sbin/brctl \
+ /etc/udev/xen-backend.rules
do
s=$(basename "$f")
if [ ! -f "/usr/lib/vswitch/xs-original/$s" ]; then
/etc/profile.d/vswitch.sh
/lib/modules/%{xen_version}/kernel/net/vswitch/openvswitch_mod.ko
/lib/modules/%{xen_version}/kernel/net/vswitch/brcompat_mod.ko
-/usr/share/vswitch/scripts/dump-vif-details
/usr/share/vswitch/scripts/refresh-xs-network-uuids
/usr/share/vswitch/scripts/interface-reconfigure
/usr/share/vswitch/scripts/vif
/usr/share/vswitch/scripts/XSFeatureVSwitch.py
/usr/share/vswitch/scripts/brctl
/usr/share/vswitch/scripts/sysconfig.template
+/usr/share/vswitch/scripts/vif-on-internal-bridge
+/usr/share/vswitch/scripts/xen-backend.rules
# Following two files are generated automatically by rpm. We don't
# really need them and they won't be used on the XenServer, but there
# isn't an obvious place to get rid of them since they are generated