Revision 3882937a lib/rapi/rlib2.py

b/lib/rapi/rlib2.py
1055 1055
    return baserlib.SubmitJob([op])
1056 1056

  
1057 1057

  
1058
def _ParseModifyInstanceRequest(name, data):
1059
  """Parses a request for modifying an instance.
1060

  
1061
  @rtype: L{opcodes.OpSetInstanceParams}
1062
  @return: Instance modify opcode
1063

  
1064
  """
1065
  osparams = baserlib.CheckParameter(data, "osparams", default={})
1066
  force = baserlib.CheckParameter(data, "force", default=False)
1067
  nics = baserlib.CheckParameter(data, "nics", default=[])
1068
  disks = baserlib.CheckParameter(data, "disks", default=[])
1069
  disk_template = baserlib.CheckParameter(data, "disk_template", default=None)
1070
  remote_node = baserlib.CheckParameter(data, "remote_node", default=None)
1071
  os_name = baserlib.CheckParameter(data, "os_name", default=None)
1072
  force_variant = baserlib.CheckParameter(data, "force_variant", default=False)
1073

  
1074
  # HV/BE parameters
1075
  hvparams = baserlib.CheckParameter(data, "hvparams", default={})
1076
  utils.ForceDictType(hvparams, constants.HVS_PARAMETER_TYPES,
1077
                      allowed_values=[constants.VALUE_DEFAULT])
1078

  
1079
  beparams = baserlib.CheckParameter(data, "beparams", default={})
1080
  utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES,
1081
                      allowed_values=[constants.VALUE_DEFAULT])
1082

  
1083
  return opcodes.OpSetInstanceParams(instance_name=name, hvparams=hvparams,
1084
                                     beparams=beparams, osparams=osparams,
1085
                                     force=force, nics=nics, disks=disks,
1086
                                     disk_template=disk_template,
1087
                                     remote_node=remote_node, os_name=os_name,
1088
                                     force_variant=force_variant)
1089

  
1090

  
1091
class R_2_instances_name_modify(baserlib.R_Generic):
1092
  """/2/instances/[instance_name]/modify resource.
1093

  
1094
  """
1095
  def PUT(self):
1096
    """Changes some parameters of an instance.
1097

  
1098
    @return: a job id
1099

  
1100
    """
1101
    baserlib.CheckType(self.request_body, dict, "Body contents")
1102

  
1103
    op = _ParseModifyInstanceRequest(self.items[0], self.request_body)
1104

  
1105
    return baserlib.SubmitJob([op])
1106

  
1107

  
1058 1108
class _R_Tags(baserlib.R_Generic):
1059 1109
  """ Quasiclass for tagging resources
1060 1110

  

Also available in: Unified diff