Revision e8022bef lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
183 | 183 |
script = StringIO() |
184 | 184 |
script.write("#!/bin/sh\n") |
185 | 185 |
script.write("# this is autogenerated by Ganeti, please do not edit\n#\n") |
186 |
script.write("PATH=$PATH:/sbin:/usr/sbin\n") |
|
186 | 187 |
script.write("export INSTANCE=%s\n" % instance.name) |
187 | 188 |
script.write("export MAC=%s\n" % nic.mac) |
188 | 189 |
if nic.ip: |
... | ... | |
198 | 199 |
script.write(" # Execute the user-specific vif file\n") |
199 | 200 |
script.write(" %s\n" % self._KVM_NETWORK_SCRIPT) |
200 | 201 |
script.write("else\n") |
201 |
script.write(" /sbin/ifconfig $INTERFACE 0.0.0.0 up\n")
|
|
202 |
script.write(" ifconfig $INTERFACE 0.0.0.0 up\n") |
|
202 | 203 |
if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED: |
203 | 204 |
script.write(" # Connect the interface to the bridge\n") |
204 |
script.write(" /usr/sbin/brctl addif $BRIDGE $INTERFACE\n")
|
|
205 |
script.write(" brctl addif $BRIDGE $INTERFACE\n") |
|
205 | 206 |
elif nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_ROUTED: |
206 | 207 |
if not nic.ip: |
207 | 208 |
raise errors.HypervisorError("nic/%d is routed, but has no ip." % seq) |
208 | 209 |
script.write(" # Route traffic targeted at the IP to the interface\n") |
209 | 210 |
if nic.nicparams[constants.NIC_LINK]: |
210 |
script.write(" while /sbin/ip rule del dev $INTERFACE; do :; done\n")
|
|
211 |
script.write(" /sbin/ip rule add dev $INTERFACE table $LINK\n")
|
|
212 |
script.write(" /sbin/ip route replace $IP table $LINK proto static"
|
|
211 |
script.write(" while ip rule del dev $INTERFACE; do :; done\n") |
|
212 |
script.write(" ip rule add dev $INTERFACE table $LINK\n") |
|
213 |
script.write(" ip route replace $IP table $LINK proto static" |
|
213 | 214 |
" dev $INTERFACE\n") |
214 | 215 |
else: |
215 |
script.write(" /sbin/ip route replace $IP proto static"
|
|
216 |
script.write(" ip route replace $IP proto static" |
|
216 | 217 |
" dev $INTERFACE\n") |
217 | 218 |
interface_v4_conf = "/proc/sys/net/ipv4/conf/$INTERFACE" |
218 | 219 |
interface_v6_conf = "/proc/sys/net/ipv6/conf/$INTERFACE" |
Also available in: Unified diff