Revision 82187135 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
5770 | 5770 |
# MAC address verification |
5771 | 5771 |
mac = nic.get("mac", constants.VALUE_AUTO) |
5772 | 5772 |
if mac not in (constants.VALUE_AUTO, constants.VALUE_GENERATE): |
5773 |
if not utils.IsValidMac(mac.lower()): |
|
5774 |
raise errors.OpPrereqError("Invalid MAC address specified: %s" % |
|
5775 |
mac, errors.ECODE_INVAL) |
|
5776 |
else: |
|
5777 |
try: |
|
5778 |
self.cfg.ReserveMAC(mac, self.proc.GetECId()) |
|
5779 |
except errors.ReservationError: |
|
5780 |
raise errors.OpPrereqError("MAC address %s already in use" |
|
5781 |
" in cluster" % mac, |
|
5782 |
errors.ECODE_NOTUNIQUE) |
|
5773 |
mac = utils.NormalizeAndValidateMac(mac) |
|
5774 |
|
|
5775 |
try: |
|
5776 |
self.cfg.ReserveMAC(mac, self.proc.GetECId()) |
|
5777 |
except errors.ReservationError: |
|
5778 |
raise errors.OpPrereqError("MAC address %s already in use" |
|
5779 |
" in cluster" % mac, |
|
5780 |
errors.ECODE_NOTUNIQUE) |
|
5783 | 5781 |
|
5784 | 5782 |
# bridge verification |
5785 | 5783 |
bridge = nic.get("bridge", None) |
... | ... | |
7536 | 7534 |
if 'mac' in nic_dict: |
7537 | 7535 |
nic_mac = nic_dict['mac'] |
7538 | 7536 |
if nic_mac not in (constants.VALUE_AUTO, constants.VALUE_GENERATE): |
7539 |
if not utils.IsValidMac(nic_mac): |
|
7540 |
raise errors.OpPrereqError("Invalid MAC address %s" % nic_mac, |
|
7541 |
errors.ECODE_INVAL) |
|
7537 |
nic_mac = utils.NormalizeAndValidateMac(nic_mac) |
|
7538 |
|
|
7542 | 7539 |
if nic_op != constants.DDM_ADD and nic_mac == constants.VALUE_AUTO: |
7543 | 7540 |
raise errors.OpPrereqError("'auto' is not a valid MAC address when" |
7544 | 7541 |
" modifying an existing nic", |
Also available in: Unified diff