~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/hotplug/Linux/vif2

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
dir=$(dirname "$0")
 
4
. "$dir/xen-hotplug-common.sh"
 
5
. "$dir/xen-network-common.sh"
 
6
 
 
7
bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
 
8
if [ -z "$bridge" ]
 
9
    then
 
10
    nr_bridges=$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - 1))
 
11
    if [ "$nr_bridges" != 1 ]
 
12
        then
 
13
        fatal "no bridge specified, and don't know which one to use ($nr_bridges found)"
 
14
    fi
 
15
    bridge=$(brctl show | cut -d "
 
16
" -f 2 | cut -f 1)
 
17
fi
 
18
 
 
19
command="$1"
 
20
shift
 
21
 
 
22
case "$command" in
 
23
    "online")
 
24
        if [ "$bridge" != "-" ]
 
25
            then
 
26
            setup_bridge_port "$vif"
 
27
            add_to_bridge "$bridge" "$vif"
 
28
        else
 
29
            # Just let the normal udev rules for interfaces handle it.
 
30
            true
 
31
        fi
 
32
        success
 
33
        ;;
 
34
 
 
35
    "add")
 
36
        success
 
37
        ;;
 
38
 
 
39
    "remove")
 
40
        ;;
 
41
 
 
42
    *)
 
43
        echo "Unknown command: $command"
 
44
        echo 'Valid commands are: add, remove, online'
 
45
        exit 1
 
46
esac