Revision 7e9e5ffc lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
10055 | 10055 |
objects.NIC.CheckParameterSyntax(check_params) |
10056 | 10056 |
net_uuid = cfg.LookupNetwork(net) |
10057 | 10057 |
name = nic.get(constants.INIC_NAME, None) |
10058 |
if name is not None and name.lower() == constants.VALUE_NONE: |
|
10059 |
name = None |
|
10058 | 10060 |
nic_obj = objects.NIC(mac=mac, ip=nic_ip, name=name, |
10059 | 10061 |
network=net_uuid, nicparams=nicparams) |
10060 | 10062 |
nic_obj.uuid = cfg.GenerateUniqueID(ec_id) |
... | ... | |
10096 | 10098 |
|
10097 | 10099 |
data_vg = disk.get(constants.IDISK_VG, default_vg) |
10098 | 10100 |
name = disk.get(constants.IDISK_NAME, None) |
10101 |
if name is not None and name.lower() == constants.VALUE_NONE: |
|
10102 |
name = None |
|
10099 | 10103 |
new_disk = { |
10100 | 10104 |
constants.IDISK_SIZE: size, |
10101 | 10105 |
constants.IDISK_MODE: mode, |
... | ... | |
13357 | 13361 |
errors.ECODE_INVAL) |
13358 | 13362 |
|
13359 | 13363 |
params[constants.IDISK_SIZE] = size |
13364 |
name = params.get(constants.IDISK_NAME, None) |
|
13365 |
if name is not None and name.lower() == constants.VALUE_NONE: |
|
13366 |
params[constants.IDISK_NAME] = None |
|
13360 | 13367 |
|
13361 | 13368 |
elif op == constants.DDM_MODIFY: |
13362 | 13369 |
if constants.IDISK_SIZE in params: |
13363 | 13370 |
raise errors.OpPrereqError("Disk size change not possible, use" |
13364 | 13371 |
" grow-disk", errors.ECODE_INVAL) |
13365 |
if constants.IDISK_MODE not in params: |
|
13366 |
raise errors.OpPrereqError("Disk 'mode' is the only kind of" |
|
13367 |
" modification supported, but missing", |
|
13368 |
errors.ECODE_NOENT) |
|
13369 |
if len(params) > 1: |
|
13372 |
if len(params) > 2: |
|
13370 | 13373 |
raise errors.OpPrereqError("Disk modification doesn't support" |
13371 | 13374 |
" additional arbitrary parameters", |
13372 | 13375 |
errors.ECODE_INVAL) |
13376 |
name = params.get(constants.IDISK_NAME, None) |
|
13377 |
if name is not None and name.lower() == constants.VALUE_NONE: |
|
13378 |
params[constants.IDISK_NAME] = None |
|
13373 | 13379 |
|
13374 | 13380 |
@staticmethod |
13375 | 13381 |
def _VerifyNicModification(op, params): |
... | ... | |
13378 | 13384 |
""" |
13379 | 13385 |
if op in (constants.DDM_ADD, constants.DDM_MODIFY): |
13380 | 13386 |
ip = params.get(constants.INIC_IP, None) |
13387 |
name = params.get(constants.INIC_NAME, None) |
|
13381 | 13388 |
req_net = params.get(constants.INIC_NETWORK, None) |
13382 | 13389 |
link = params.get(constants.NIC_LINK, None) |
13383 | 13390 |
mode = params.get(constants.NIC_MODE, None) |
13391 |
if name is not None and name.lower() == constants.VALUE_NONE: |
|
13392 |
params[constants.INIC_NAME] = None |
|
13384 | 13393 |
if req_net is not None: |
13385 | 13394 |
if req_net.lower() == constants.VALUE_NONE: |
13386 | 13395 |
params[constants.INIC_NETWORK] = None |
... | ... | |
14232 | 14241 |
"""Modifies a disk. |
14233 | 14242 |
|
14234 | 14243 |
""" |
14235 |
disk.mode = params[constants.IDISK_MODE] |
|
14244 |
changes = [] |
|
14245 |
mode = params.get(constants.IDISK_MODE, None) |
|
14246 |
if mode: |
|
14247 |
disk.mode = mode |
|
14248 |
changes.append(("disk.mode/%d" % idx, disk.mode)) |
|
14236 | 14249 |
|
14237 |
return [ |
|
14238 |
("disk.mode/%d" % idx, disk.mode), |
|
14239 |
] |
|
14250 |
name = params.get(constants.IDISK_NAME, None) |
|
14251 |
disk.name = name |
|
14252 |
changes.append(("disk.name/%d" % idx, disk.name)) |
|
14253 |
|
|
14254 |
return changes |
|
14240 | 14255 |
|
14241 | 14256 |
def _RemoveDisk(self, idx, root, _): |
14242 | 14257 |
"""Removes a disk. |
... | ... | |
14283 | 14298 |
""" |
14284 | 14299 |
changes = [] |
14285 | 14300 |
|
14286 |
for key in [constants.INIC_MAC, constants.INIC_IP]: |
|
14301 |
for key in [constants.INIC_MAC, constants.INIC_IP, constants.INIC_NAME]:
|
|
14287 | 14302 |
if key in params: |
14288 | 14303 |
changes.append(("nic.%s/%d" % (key, idx), params[key])) |
14289 | 14304 |
setattr(nic, key, params[key]) |
Also available in: Unified diff