Revision 02a6b50a
b/lib/cli.py | ||
---|---|---|
284 | 284 |
"OPT_COMPL_ONE_OS", |
285 | 285 |
"OPT_COMPL_ONE_EXTSTORAGE", |
286 | 286 |
"cli_option", |
287 |
"FixHvParams", |
|
287 | 288 |
"SplitNodeOption", |
288 | 289 |
"CalculateOSNames", |
289 | 290 |
"ParseFields", |
... | ... | |
2581 | 2582 |
return nics |
2582 | 2583 |
|
2583 | 2584 |
|
2585 |
def FixHvParams(hvparams): |
|
2586 |
# In Ganeti 2.8.4 the separator for the usb_devices hvparam was changed from |
|
2587 |
# comma to space because commas cannot be accepted on the command line |
|
2588 |
# (they already act as the separator between different hvparams). Still, |
|
2589 |
# RAPI should be able to accept commas for backwards compatibility. |
|
2590 |
# Therefore, we convert spaces into commas here, and we keep the old |
|
2591 |
# parsing logic everywhere else. |
|
2592 |
try: |
|
2593 |
new_usb_devices = hvparams[constants.HV_USB_DEVICES].replace(" ", ",") |
|
2594 |
hvparams[constants.HV_USB_DEVICES] = new_usb_devices |
|
2595 |
except KeyError: |
|
2596 |
#No usb_devices, no modification required |
|
2597 |
pass |
|
2598 |
|
|
2599 |
|
|
2584 | 2600 |
def GenericInstanceCreate(mode, opts, args): |
2585 | 2601 |
"""Add an instance to the cluster via either creation or import. |
2586 | 2602 |
|
... | ... | |
2670 | 2686 |
|
2671 | 2687 |
utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_COMPAT) |
2672 | 2688 |
utils.ForceDictType(hvparams, constants.HVS_PARAMETER_TYPES) |
2689 |
FixHvParams(hvparams) |
|
2673 | 2690 |
|
2674 | 2691 |
if mode == constants.INSTANCE_CREATE: |
2675 | 2692 |
start = opts.start |
b/lib/client/gnt_instance.py | ||
---|---|---|
1311 | 1311 |
|
1312 | 1312 |
utils.ForceDictType(opts.hvparams, constants.HVS_PARAMETER_TYPES, |
1313 | 1313 |
allowed_values=[constants.VALUE_DEFAULT]) |
1314 |
FixHvParams(opts.hvparams) |
|
1314 | 1315 |
|
1315 | 1316 |
nics = _ConvertNicDiskModifications(opts.nics) |
1316 | 1317 |
disks = _ParseDiskSizes(_ConvertNicDiskModifications(opts.disks)) |
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
1384 | 1384 |
|
1385 | 1385 |
# Various types of usb devices, comma separated |
1386 | 1386 |
if hvp[constants.HV_USB_DEVICES]: |
1387 |
for dev in hvp[constants.HV_USB_DEVICES].split(" "):
|
|
1387 |
for dev in hvp[constants.HV_USB_DEVICES].split(","):
|
|
1388 | 1388 |
kvm_cmd.extend(["-usbdevice", dev]) |
1389 | 1389 |
|
1390 | 1390 |
if hvp[constants.HV_KVM_EXTRA]: |
b/lib/rapi/rlib2.py | ||
---|---|---|
885 | 885 |
}) |
886 | 886 |
|
887 | 887 |
|
888 |
def _ConvertUsbDevices(data): |
|
889 |
"""Convert in place the usb_devices string to the proper format. |
|
890 |
|
|
891 |
In Ganeti 2.8.4 the separator for the usb_devices hvparam was changed from |
|
892 |
comma to space because commas cannot be accepted on the command line |
|
893 |
(they already act as the separator between different hvparams). RAPI |
|
894 |
should be able to accept commas for backwards compatibility, but we want |
|
895 |
it to also accept the new space separator. Therefore, we convert |
|
896 |
spaces into commas here and keep the old parsing logic elsewhere. |
|
897 |
|
|
898 |
""" |
|
899 |
try: |
|
900 |
hvparams = data["hvparams"] |
|
901 |
usb_devices = hvparams[constants.HV_USB_DEVICES] |
|
902 |
hvparams[constants.HV_USB_DEVICES] = usb_devices.replace(" ", ",") |
|
903 |
data["hvparams"] = hvparams |
|
904 |
except KeyError: |
|
905 |
#No usb_devices, no modification required |
|
906 |
pass |
|
907 |
|
|
908 |
|
|
888 | 909 |
class R_2_instances(baserlib.OpcodeResource): |
889 | 910 |
"""/2/instances resource. |
890 | 911 |
|
... | ... | |
934 | 955 |
# Remove "__version__" |
935 | 956 |
data.pop(_REQ_DATA_VERSION, None) |
936 | 957 |
|
958 |
_ConvertUsbDevices(data) |
|
959 |
|
|
937 | 960 |
return (data, { |
938 | 961 |
"dry_run": self.dryRun(), |
939 | 962 |
}) |
... | ... | |
1327 | 1350 |
"""Changes parameters of an instance. |
1328 | 1351 |
|
1329 | 1352 |
""" |
1330 |
return (self.request_body, { |
|
1353 |
data = self.request_body.copy() |
|
1354 |
_ConvertUsbDevices(data) |
|
1355 |
|
|
1356 |
return (data, { |
|
1331 | 1357 |
"instance_name": self.items[0], |
1332 | 1358 |
}) |
1333 | 1359 |
|
b/man/gnt-instance.rst | ||
---|---|---|
728 | 728 |
``-usbdevice`` option. See the **qemu**\(1) manpage for the syntax |
729 | 729 |
of the possible components. Note that values set with this |
730 | 730 |
parameter are split on a space character and currently don't support |
731 |
quoting. |
|
731 |
quoting. For backwards compatibility reasons, the RAPI interface keeps |
|
732 |
accepting comma separated lists too. |
|
732 | 733 |
|
733 | 734 |
vga |
734 | 735 |
Valid for the KVM hypervisor. |
Also available in: Unified diff