Revision 5397e0b7 lib/cmdlib.py

b/lib/cmdlib.py
3054 3054
    # set optional parameters to none if they don't exist
3055 3055
    for attr in ["kernel_path", "initrd_path", "hvm_boot_order", "pnode",
3056 3056
                 "iallocator", "hvm_acpi", "hvm_pae", "hvm_cdrom_image_path",
3057
                 "vnc_bind_address"]:
3057
                 "hvm_nic_type", "hvm_disk_type", "vnc_bind_address"]:
3058 3058
      if not hasattr(self.op, attr):
3059 3059
        setattr(self.op, attr, None)
3060 3060

  
......
3269 3269
                                   " like a valid IP address" %
3270 3270
                                   self.op.vnc_bind_address)
3271 3271

  
3272
    # Xen HVM device type checks
3273
    if self.sstore.GetHypervisorType() == constants.HT_XEN_HVM31:
3274
      if self.op.hvm_nic_type not in constants.HT_HVM_VALID_NIC_TYPES:
3275
        raise errors.OpPrereqError("Invalid NIC type %s specified for Xen HVM"
3276
                                   " hypervisor" % self.op.hvm_nic_type)
3277
      if self.op.hvm_disk_type not in constants.HT_HVM_VALID_DISK_TYPES:
3278
        raise errors.OpPrereqError("Invalid disk type %s specified for Xen HVM"
3279
                                   " hypervisor" % self.op.hvm_disk_type)
3280

  
3272 3281
    if self.op.start:
3273 3282
      self.instance_status = 'up'
3274 3283
    else:
......
3334 3343
                            hvm_pae=self.op.hvm_pae,
3335 3344
                            hvm_cdrom_image_path=self.op.hvm_cdrom_image_path,
3336 3345
                            vnc_bind_address=self.op.vnc_bind_address,
3346
                            hvm_nic_type=self.op.hvm_nic_type,
3347
                            hvm_disk_type=self.op.hvm_disk_type,
3337 3348
                            )
3338 3349

  
3339 3350
    feedback_fn("* creating instance disks...")
......
4132 4143
        idict["hvm_acpi"] = instance.hvm_acpi
4133 4144
        idict["hvm_pae"] = instance.hvm_pae
4134 4145
        idict["hvm_cdrom_image_path"] = instance.hvm_cdrom_image_path
4146
        idict["hvm_nic_type"] = instance.hvm_nic_type
4147
        idict["hvm_disk_type"] = instance.hvm_disk_type
4135 4148

  
4136 4149
      if htkind in constants.HTS_REQ_PORT:
4137 4150
        idict["vnc_bind_address"] = instance.vnc_bind_address
......
4203 4216
    self.hvm_boot_order = getattr(self.op, "hvm_boot_order", None)
4204 4217
    self.hvm_acpi = getattr(self.op, "hvm_acpi", None)
4205 4218
    self.hvm_pae = getattr(self.op, "hvm_pae", None)
4219
    self.hvm_nic_type = getattr(self.op, "hvm_nic_type", None)
4220
    self.hvm_disk_type = getattr(self.op, "hvm_disk_type", None)
4206 4221
    self.hvm_cdrom_image_path = getattr(self.op, "hvm_cdrom_image_path", None)
4207 4222
    self.vnc_bind_address = getattr(self.op, "vnc_bind_address", None)
4208 4223
    all_parms = [self.mem, self.vcpus, self.ip, self.bridge, self.mac,
4209 4224
                 self.kernel_path, self.initrd_path, self.hvm_boot_order,
4210 4225
                 self.hvm_acpi, self.hvm_pae, self.hvm_cdrom_image_path,
4211
                 self.vnc_bind_address]
4226
                 self.vnc_bind_address, self.hvm_nic_type, self.hvm_disk_type]
4212 4227
    if all_parms.count(None) == len(all_parms):
4213 4228
      raise errors.OpPrereqError("No changes submitted")
4214 4229
    if self.mem is not None:
......
4334 4349
    if self.hvm_pae is not None:
4335 4350
      instance.hvm_pae = self.hvm_pae
4336 4351
      result.append(("hvm_pae", self.hvm_pae))
4352
    if self.hvm_nic_type is not None:
4353
      instance.hvm_nic_type = self.hvm_nic_type
4354
      result.append(("hvm_nic_type", self.hvm_nic_type))
4355
    if self.hvm_disk_type is not None:
4356
      instance.hvm_disk_type = self.hvm_disk_type
4357
      result.append(("hvm_disk_type", self.hvm_disk_type))
4337 4358
    if self.hvm_cdrom_image_path:
4338 4359
      if self.hvm_cdrom_image_path == constants.VALUE_NONE:
4339 4360
        instance.hvm_cdrom_image_path = None

Also available in: Unified diff