Revision 3889f749
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
1126 | 1126 |
" network configuration script output: %s" % |
1127 | 1127 |
(tap, result.fail_reason, result.output)) |
1128 | 1128 |
|
1129 |
@classmethod |
|
1130 |
def _UnconfigureNic(cls, instance_name, nic, only_local=True): |
|
1131 |
"""Run ifdown script for a specific NIC |
|
1132 |
|
|
1133 |
This is executed during instance cleanup and NIC hot-unplug |
|
1134 |
|
|
1135 |
@param instance_name: instance we're acting on |
|
1136 |
@type instance_name: string |
|
1137 |
@param nic: nic we're acting on |
|
1138 |
@type nic: nic object |
|
1139 |
@param only_local: whether ifdown script should reset global conf (dns) |
|
1140 |
@type only_local: boolean |
|
1141 |
|
|
1142 |
""" |
|
1143 |
tap = cls._GetInstanceNICTap(instance_name, nic) |
|
1144 |
env = cls._CreateNICEnv(instance_name, nic, tap) |
|
1145 |
arg2 = str(only_local).lower() |
|
1146 |
result = utils.RunCmd([pathutils.KVM_IFDOWN, tap, arg2], env=env) |
|
1147 |
if result.failed: |
|
1148 |
raise errors.HypervisorError("Failed to unconfigure interface %s: %s;" |
|
1149 |
" network configuration script output: %s" % |
|
1150 |
(tap, result.fail_reason, result.output)) |
|
1151 |
|
|
1129 | 1152 |
@staticmethod |
1130 | 1153 |
def _VerifyAffinityPackage(): |
1131 | 1154 |
if affinity is None: |
... | ... | |
2393 | 2416 |
else: |
2394 | 2417 |
self._CallMonitorCommand(name, "system_powerdown", timeout) |
2395 | 2418 |
|
2419 |
@classmethod |
|
2420 |
def _UnconfigureInstanceNICs(cls, instance_name, info=None): |
|
2421 |
"""Get runtime NICs of an instance and unconfigure them |
|
2422 |
|
|
2423 |
""" |
|
2424 |
_, kvm_nics, __, ___ = cls._LoadKVMRuntime(instance_name, info) |
|
2425 |
for nic in kvm_nics: |
|
2426 |
cls._UnconfigureNic(instance_name, nic) |
|
2427 |
|
|
2396 | 2428 |
def CleanupInstance(self, instance_name): |
2397 | 2429 |
"""Cleanup after a stopped instance |
2398 | 2430 |
|
Also available in: Unified diff