Revision 6785674e

b/lib/cmdlib.py
3153 3153
  HTYPE = constants.HTYPE_INSTANCE
3154 3154
  _OP_REQP = ["instance_name", "mem_size", "disk_size",
3155 3155
              "disk_template", "swap_size", "mode", "start", "vcpus",
3156
              "wait_for_sync", "ip_check", "mac"]
3156
              "wait_for_sync", "ip_check", "mac", "hvparams"]
3157 3157
  REQ_BGL = False
3158 3158

  
3159 3159
  def _ExpandNode(self, node):
......
3174 3174
    self.needed_locks = {}
3175 3175

  
3176 3176
    # set optional parameters to none if they don't exist
3177
    for attr in ["kernel_path", "initrd_path", "pnode", "snode",
3178
                 "iallocator", "hvm_boot_order", "hvm_acpi", "hvm_pae",
3179
                 "hvm_cdrom_image_path", "hvm_nic_type", "hvm_disk_type",
3180
                 "vnc_bind_address", "hypervisor"]:
3177
    for attr in ["pnode", "snode", "iallocator", "hypervisor"]:
3181 3178
      if not hasattr(self.op, attr):
3182 3179
        setattr(self.op, attr, None)
3183 3180

  
......
3202 3199
                                 " cluster (%s)" % (self.op.hypervisor,
3203 3200
                                  ",".join(enabled_hvs)))
3204 3201

  
3202
    # check hypervisor parameter syntax (locally)
3203

  
3204
    hv_type = hypervisor.GetHypervisor(self.op.hypervisor)
3205
    hv_type.CheckParameterSyntax(self.op.hvparams)
3206

  
3205 3207
    #### instance parameters check
3206 3208

  
3207 3209
    # instance name verification
......
3237 3239
        raise errors.OpPrereqError("invalid MAC address specified: %s" %
3238 3240
                                   self.op.mac)
3239 3241

  
3240
    # boot order verification
3241
    if self.op.hvm_boot_order is not None:
3242
      if len(self.op.hvm_boot_order.strip("acdn")) != 0:
3243
        raise errors.OpPrereqError("invalid boot order specified,"
3244
                                   " must be one or more of [acdn]")
3245 3242
    # file storage checks
3246 3243
    if (self.op.file_driver and
3247 3244
        not self.op.file_driver in constants.FILE_DRIVER):
......
3435 3432
                                   " the primary node.")
3436 3433
      self.secondaries.append(self.op.snode)
3437 3434

  
3435
    nodenames = [pnode.name] + self.secondaries
3436

  
3438 3437
    req_size = _ComputeDiskSize(self.op.disk_template,
3439 3438
                                self.op.disk_size, self.op.swap_size)
3440 3439

  
3441 3440
    # Check lv size requirements
3442 3441
    if req_size is not None:
3443
      nodenames = [pnode.name] + self.secondaries
3444 3442
      nodeinfo = self.rpc.call_node_info(nodenames, self.cfg.GetVGName(),
3445 3443
                                         self.op.hypervisor)
3446 3444
      for node in nodenames:
......
3457 3455
                                     " %d MB available, %d MB required" %
3458 3456
                                     (node, info['vg_free'], req_size))
3459 3457

  
3458
    # hypervisor parameter validation
3459
    hvinfo = self.rpc.call_hypervisor_validate_params(nodenames,
3460
                                                      self.op.hypervisor,
3461
                                                      self.op.hvparams)
3462
    for node in nodenames:
3463
      info = hvinfo.get(node, None)
3464
      if not info or not isinstance(info, (tuple, list)):
3465
        raise errors.OpPrereqError("Cannot get current information"
3466
                                   " from node '%s' (%s)" % (node, info))
3467
      if not info[0]:
3468
        raise errors.OpPrereqError("Hypervisor parameter validation failed:"
3469
                                   " %s" % info[1])
3470

  
3460 3471
    # os verification
3461 3472
    os_obj = self.rpc.call_os_get(pnode.name, self.op.os_type)
3462 3473
    if not os_obj:
3463 3474
      raise errors.OpPrereqError("OS '%s' not in supported os list for"
3464 3475
                                 " primary node"  % self.op.os_type)
3465 3476

  
3466
    if self.op.kernel_path == constants.VALUE_NONE:
3467
      raise errors.OpPrereqError("Can't set instance kernel to none")
3468

  
3469 3477
    # bridge check on primary node
3470 3478
    if not self.rpc.call_bridges_exist(self.pnode.name, [self.op.bridge]):
3471 3479
      raise errors.OpPrereqError("target bridge '%s' does not exist on"
......
3478 3486
                           "creating instance %s" % self.op.instance_name,
3479 3487
                           self.op.mem_size, self.op.hypervisor)
3480 3488

  
3481
    # hvm_cdrom_image_path verification
3482
    if self.op.hvm_cdrom_image_path is not None:
3483
      # FIXME (als): shouldn't these checks happen on the destination node?
3484
      if not os.path.isabs(self.op.hvm_cdrom_image_path):
3485
        raise errors.OpPrereqError("The path to the HVM CDROM image must"
3486
                                   " be an absolute path or None, not %s" %
3487
                                   self.op.hvm_cdrom_image_path)
3488
      if not os.path.isfile(self.op.hvm_cdrom_image_path):
3489
        raise errors.OpPrereqError("The HVM CDROM image must either be a"
3490
                                   " regular file or a symlink pointing to"
3491
                                   " an existing regular file, not %s" %
3492
                                   self.op.hvm_cdrom_image_path)
3493

  
3494
    # vnc_bind_address verification
3495
    if self.op.vnc_bind_address is not None:
3496
      if not utils.IsValidIP(self.op.vnc_bind_address):
3497
        raise errors.OpPrereqError("given VNC bind address '%s' doesn't look"
3498
                                   " like a valid IP address" %
3499
                                   self.op.vnc_bind_address)
3500

  
3501
    # Xen HVM device type checks
3502
    if self.op.hypervisor == constants.HT_XEN_HVM:
3503
      if self.op.hvm_nic_type not in constants.HT_HVM_VALID_NIC_TYPES:
3504
        raise errors.OpPrereqError("Invalid NIC type %s specified for Xen HVM"
3505
                                   " hypervisor" % self.op.hvm_nic_type)
3506
      if self.op.hvm_disk_type not in constants.HT_HVM_VALID_DISK_TYPES:
3507
        raise errors.OpPrereqError("Invalid disk type %s specified for Xen HVM"
3508
                                   " hypervisor" % self.op.hvm_disk_type)
3509

  
3510 3489
    if self.op.start:
3511 3490
      self.instance_status = 'up'
3512 3491
    else:
......
3534 3513
    else:
3535 3514
      network_port = None
3536 3515

  
3537
    if self.op.vnc_bind_address is None:
3538
      self.op.vnc_bind_address = constants.VNC_DEFAULT_BIND_ADDRESS
3516
    ##if self.op.vnc_bind_address is None:
3517
    ##  self.op.vnc_bind_address = constants.VNC_DEFAULT_BIND_ADDRESS
3539 3518

  
3540 3519
    # this is needed because os.path.join does not accept None arguments
3541 3520
    if self.op.file_storage_dir is None:
......
3565 3544
                            disk_template=self.op.disk_template,
3566 3545
                            status=self.instance_status,
3567 3546
                            network_port=network_port,
3568
                            kernel_path=self.op.kernel_path,
3569
                            initrd_path=self.op.initrd_path,
3570
                            hvm_boot_order=self.op.hvm_boot_order,
3571
                            hvm_acpi=self.op.hvm_acpi,
3572
                            hvm_pae=self.op.hvm_pae,
3573
                            hvm_cdrom_image_path=self.op.hvm_cdrom_image_path,
3574
                            vnc_bind_address=self.op.vnc_bind_address,
3575
                            hvm_nic_type=self.op.hvm_nic_type,
3576
                            hvm_disk_type=self.op.hvm_disk_type,
3547
                            hvparams=self.op.hvparams,
3577 3548
                            hypervisor=self.op.hypervisor,
3578 3549
                            )
3579 3550

  
b/lib/objects.py
514 514
    "disks",
515 515
    "disk_template",
516 516
    "network_port",
517
    "kernel_path",
518
    "initrd_path",
519
    "hvm_boot_order",
520
    "hvm_acpi",
521
    "hvm_pae",
522
    "hvm_cdrom_image_path",
523
    "hvm_nic_type",
524
    "hvm_disk_type",
525
    "vnc_bind_address",
526 517
    "serial_no",
527 518
    ]
528 519

  
b/lib/opcodes.py
323 323
    "disk_template", "snode", "swap_size", "mode",
324 324
    "vcpus", "ip", "bridge", "src_node", "src_path", "start",
325 325
    "wait_for_sync", "ip_check", "mac",
326
    "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi",
327
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address",
328 326
    "file_storage_dir", "file_driver",
329
    "iallocator", "hvm_nic_type", "hvm_disk_type",
330
    "hypervisor",
327
    "iallocator",
328
    "hypervisor", "hvparams", "beparams",
331 329
    ]
332 330

  
333 331

  
b/scripts/gnt-instance
266 266

  
267 267
  (pnode, snode) = SplitNodeOption(opts.node)
268 268

  
269
  kernel_path = _TransformPath(opts.kernel_path)
270
  initrd_path = _TransformPath(opts.initrd_path)
269
  hypervisor = None
270
  hvparams = {}
271
  if opts.hypervisor:
272
    hypervisor, hvparams = opts.hypervisor
271 273

  
272
  hvm_acpi = opts.hvm_acpi == _VALUE_TRUE
273
  hvm_pae = opts.hvm_pae == _VALUE_TRUE
274
##  kernel_path = _TransformPath(opts.kernel_path)
275
##  initrd_path = _TransformPath(opts.initrd_path)
274 276

  
275
  if ((opts.hvm_cdrom_image_path is not None) and
276
      (opts.hvm_cdrom_image_path.lower() == constants.VALUE_NONE)):
277
    hvm_cdrom_image_path = None
278
  else:
279
    hvm_cdrom_image_path = opts.hvm_cdrom_image_path
277
##  hvm_acpi = opts.hvm_acpi == _VALUE_TRUE
278
##  hvm_pae = opts.hvm_pae == _VALUE_TRUE
279

  
280
##  if ((opts.hvm_cdrom_image_path is not None) and
281
##      (opts.hvm_cdrom_image_path.lower() == constants.VALUE_NONE)):
282
##    hvm_cdrom_image_path = None
283
##  else:
284
##    hvm_cdrom_image_path = opts.hvm_cdrom_image_path
280 285

  
281 286
  op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem,
282 287
                                disk_size=opts.size, swap_size=opts.swap,
......
288 293
                                start=opts.start, ip_check=opts.ip_check,
289 294
                                wait_for_sync=opts.wait_for_sync,
290 295
                                mac=opts.mac,
291
                                kernel_path=kernel_path,
292
                                initrd_path=initrd_path,
296
                                hypervisor=hypervisor,
297
                                hvparams=hvparams,
293 298
                                iallocator=opts.iallocator,
294
                                hvm_boot_order=opts.hvm_boot_order,
295 299
                                file_storage_dir=opts.file_storage_dir,
296 300
                                file_driver=opts.file_driver,
297
                                hvm_acpi=hvm_acpi, hvm_pae=hvm_pae,
298
                                hvm_cdrom_image_path=hvm_cdrom_image_path,
299
                                vnc_bind_address=opts.vnc_bind_address,
300
                                hvm_nic_type=opts.hvm_nic_type,
301
                                hvm_disk_type=opts.hvm_disk_type)
301
                                )
302 302

  
303 303
  SubmitOrSend(op, opts)
304 304
  return 0
......
918 918
  make_option("--iallocator", metavar="<NAME>",
919 919
              help="Select nodes for the instance automatically using the"
920 920
              " <NAME> iallocator plugin", default=None, type="string"),
921
  make_option("--hvm-acpi", dest="hvm_acpi",
922
              help="ACPI support for HVM (true|false)",
923
              metavar="<BOOL>", choices=["true", "false"]),
924
  make_option("--hvm-nic-type", dest="hvm_nic_type",
925
              help="Type of virtual NIC for HVM "
926
              "(rtl8139,ne2k_pci,ne2k_isa,paravirtual)",
927
              metavar="NICTYPE", choices=[constants.HT_HVM_NIC_RTL8139,
928
                                          constants.HT_HVM_NIC_NE2K_PCI,
929
                                          constants.HT_HVM_NIC_NE2K_ISA,
930
                                          constants.HT_HVM_DEV_PARAVIRTUAL],
931
              default=constants.HT_HVM_NIC_RTL8139),
932
  make_option("--hvm-disk-type", dest="hvm_disk_type",
933
              help="Type of virtual disks for HVM (ioemu,paravirtual)",
934
              metavar="DISKTYPE", choices=[constants.HT_HVM_DEV_IOEMU,
935
                                           constants.HT_HVM_DEV_PARAVIRTUAL],
936
              default=constants.HT_HVM_DEV_IOEMU,),
937
  make_option("--hvm-pae", dest="hvm_pae",
938
              help="PAE support for HVM (true|false)",
939
              metavar="<BOOL>", choices=["true", "false"]),
940
  make_option("--hvm-cdrom-image-path", dest="hvm_cdrom_image_path",
941
              help="CDROM image path for HVM (absolute path or None)",
942
              default=None, type="string", metavar="<CDROMIMAGE>"),
921
  ikv_option("-H", "--hypervisor", dest="hypervisor",
922
              help="Hypervisor and hypervisor options, in the format"
923
              " hypervisor:option=value,option=value,...", default=None,
924
              type="identkeyval"),
943 925
  make_option("--vnc-bind-address", dest="vnc_bind_address",
944 926
              help="bind address for VNC (IP address)",
945 927
              default=None, type="string", metavar="<VNCADDRESS>"),

Also available in: Unified diff