Revision bef9c750
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
150 | 150 |
script.write("# this is autogenerated by Ganeti, please do not edit\n#\n") |
151 | 151 |
script.write("export INSTANCE=%s\n" % instance.name) |
152 | 152 |
script.write("export MAC=%s\n" % nic.mac) |
153 |
script.write("export IP=%s\n" % nic.ip) |
|
154 |
script.write("export BRIDGE=%s\n" % nic.bridge) |
|
153 |
if nic.ip: |
|
154 |
script.write("export IP=%s\n" % nic.ip) |
|
155 |
script.write("export MODE=%s\n" % nic.nicparams[constants.NIC_MODE]) |
|
156 |
if nic.nicparams[constants.NIC_LINK]: |
|
157 |
script.write("export LINK=%s\n" % nic.nicparams[constants.NIC_LINK]) |
|
158 |
if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED: |
|
159 |
script.write("export BRIDGE=%s\n" % nic.nicparams[constants.NIC_LINK]) |
|
155 | 160 |
script.write("export INTERFACE=$1\n") |
156 | 161 |
# TODO: make this configurable at ./configure time |
157 | 162 |
script.write("if [ -x '%s' ]; then\n" % self._KVM_NETWORK_SCRIPT) |
158 | 163 |
script.write(" # Execute the user-specific vif file\n") |
159 | 164 |
script.write(" %s\n" % self._KVM_NETWORK_SCRIPT) |
160 | 165 |
script.write("else\n") |
161 |
script.write(" # Connect the interface to the bridge\n") |
|
162 | 166 |
script.write(" /sbin/ifconfig $INTERFACE 0.0.0.0 up\n") |
163 |
script.write(" /usr/sbin/brctl addif $BRIDGE $INTERFACE\n") |
|
167 |
if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED: |
|
168 |
script.write(" # Connect the interface to the bridge\n") |
|
169 |
script.write(" /usr/sbin/brctl addif $BRIDGE $INTERFACE\n") |
|
170 |
elif nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_ROUTED: |
|
171 |
script.write(" # Route traffic targeted at the IP to the interface\n") |
|
172 |
script.write(" /sbin/ip route add $IP/32 dev $INTERFACE\n") |
|
173 |
interface_proxy_arp = "/proc/sys/net/ipv4/conf/$INTERFACE/proxy_arp" |
|
174 |
script.write(" /bin/echo 1 > %s\n" % interface_proxy_arp) |
|
164 | 175 |
script.write("fi\n\n") |
165 | 176 |
# As much as we'd like to put this in our _ROOT_DIR, that will happen to be |
166 | 177 |
# mounted noexec sometimes, so we'll have to find another place. |
Also available in: Unified diff