Revision 4fd90052
b/lib/cmdlib/instance.py | ||
---|---|---|
217 | 217 |
nic_ip = ip |
218 | 218 |
|
219 | 219 |
# TODO: check the ip address for uniqueness |
220 |
if nic_mode == constants.NIC_MODE_ROUTED and not nic_ip: |
|
221 |
raise errors.OpPrereqError("Routed nic mode requires an ip address", |
|
220 |
if nic_mode == constants.NIC_MODE_ROUTED and not nic_ip and not net: |
|
221 |
raise errors.OpPrereqError("Routed nic mode requires an ip address" |
|
222 |
" if not attached to a network", |
|
222 | 223 |
errors.ECODE_INVAL) |
223 | 224 |
|
224 | 225 |
# MAC address verification |
... | ... | |
2638 | 2639 |
|
2639 | 2640 |
elif new_mode == constants.NIC_MODE_ROUTED: |
2640 | 2641 |
ip = params.get(constants.INIC_IP, old_ip) |
2641 |
if ip is None: |
|
2642 |
if ip is None and not new_net_uuid:
|
|
2642 | 2643 |
raise errors.OpPrereqError("Cannot set the NIC IP address to None" |
2643 |
" on a routed NIC", errors.ECODE_INVAL) |
|
2644 |
" on a routed NIC if not attached to a" |
|
2645 |
" network", errors.ECODE_INVAL) |
|
2644 | 2646 |
|
2645 | 2647 |
elif new_mode == constants.NIC_MODE_OVS: |
2646 | 2648 |
# TODO: check OVS link |
b/test/py/cmdlib/instance_unittest.py | ||
---|---|---|
225 | 225 |
def testRoutedNoIp(self): |
226 | 226 |
op = self.CopyOpCode(self.diskless_op, |
227 | 227 |
nics=[{ |
228 |
constants.INIC_NETWORK: constants.VALUE_NONE, |
|
228 | 229 |
constants.INIC_MODE: constants.NIC_MODE_ROUTED |
229 | 230 |
}]) |
230 | 231 |
self.ExecOpCodeExpectOpPrereqError( |
231 |
op, "Routed nic mode requires an ip address") |
|
232 |
op, "Routed nic mode requires an ip address" |
|
233 |
" if not attached to a network") |
|
232 | 234 |
|
233 | 235 |
def testValicMac(self): |
234 | 236 |
op = self.CopyOpCode(self.diskless_op, |
... | ... | |
2017 | 2019 |
op = self.CopyOpCode(self.op, |
2018 | 2020 |
nics=[(constants.DDM_MODIFY, 0, |
2019 | 2021 |
{ |
2022 |
constants.INIC_NETWORK: constants.VALUE_NONE, |
|
2020 | 2023 |
constants.INIC_MODE: constants.NIC_MODE_ROUTED |
2021 | 2024 |
})]) |
2022 | 2025 |
self.ExecOpCodeExpectOpPrereqError( |
2023 |
op, "Cannot set the NIC IP address to None on a routed NIC") |
|
2026 |
op, "Cannot set the NIC IP address to None on a routed NIC" |
|
2027 |
" if not attached to a network") |
|
2024 | 2028 |
|
2025 | 2029 |
def testModifyNicSetMac(self): |
2026 | 2030 |
op = self.CopyOpCode(self.op, |
Also available in: Unified diff