Revision 02a6b50a lib/rapi/rlib2.py

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

  

Also available in: Unified diff