Revision 31a853d2

b/lib/cmdlib.py
3294 3294
    """
3295 3295
    # set optional parameters to none if they don't exist
3296 3296
    for attr in ["kernel_path", "initrd_path", "hvm_boot_order", "pnode",
3297
                 "iallocator"]:
3297
                 "iallocator", "hvm_acpi", "hvm_pae", "hvm_cdrom_image_path",
3298
                 "vnc_bind_address"]:
3298 3299
      if not hasattr(self.op, attr):
3299 3300
        setattr(self.op, attr, None)
3300 3301

  
......
3484 3485
                                 " destination node '%s'" %
3485 3486
                                 (self.op.bridge, pnode.name))
3486 3487

  
3488
    # hvm_cdrom_image_path verification
3489
    if self.op.hvm_cdrom_image_path is not None:
3490
      if not os.path.isabs(self.op.hvm_cdrom_image_path):
3491
        raise errors.OpPrereqError("The path to the HVM CDROM image must"
3492
                                   " be an absolute path or None, not %s" %
3493
                                   self.op.hvm_cdrom_image_path)
3494
      if not os.path.isfile(self.op.hvm_cdrom_image_path):
3495
        raise errors.OpPrereqError("The HVM CDROM image must either be a"
3496
                                   " regular file or a symlink pointing to"
3497
                                   " an existing regular file, not %s" %
3498
                                   self.op.hvm_cdrom_image_path)
3499

  
3500
    # vnc_bind_address verification
3501
    if self.op.vnc_bind_address is not None:
3502
      if not utils.IsValidIP(self.op.vnc_bind_address):
3503
        raise errors.OpPrereqError("given VNC bind address '%s' doesn't look"
3504
                                   " like a valid IP address" %
3505
                                   self.op.vnc_bind_address)
3506

  
3487 3507
    if self.op.start:
3488 3508
      self.instance_status = 'up'
3489 3509
    else:
......
3511 3531
    else:
3512 3532
      network_port = None
3513 3533

  
3534
    if self.op.vnc_bind_address is None:
3535
      self.op.vnc_bind_address = constants.VNC_DEFAULT_BIND_ADDRESS
3536

  
3514 3537
    # this is needed because os.path.join does not accept None arguments
3515 3538
    if self.op.file_storage_dir is None:
3516 3539
      string_file_storage_dir = ""
......
3542 3565
                            kernel_path=self.op.kernel_path,
3543 3566
                            initrd_path=self.op.initrd_path,
3544 3567
                            hvm_boot_order=self.op.hvm_boot_order,
3568
                            hvm_acpi=self.op.hvm_acpi,
3569
                            hvm_pae=self.op.hvm_pae,
3570
                            hvm_cdrom_image_path=self.op.hvm_cdrom_image_path,
3571
                            vnc_bind_address=self.op.vnc_bind_address,
3545 3572
                            )
3546 3573

  
3547 3574
    feedback_fn("* creating instance disks...")
......
4231 4258
        "kernel_path": instance.kernel_path,
4232 4259
        "initrd_path": instance.initrd_path,
4233 4260
        "hvm_boot_order": instance.hvm_boot_order,
4261
        "hvm_acpi": instance.hvm_acpi,
4262
        "hvm_pae": instance.hvm_pae,
4263
        "hvm_cdrom_image_path": instance.hvm_cdrom_image_path,
4264
        "vnc_bind_address": instance.vnc_bind_address,
4234 4265
        }
4235 4266

  
4236 4267
      result[instance.name] = idict
......
4290 4321
    self.kernel_path = getattr(self.op, "kernel_path", None)
4291 4322
    self.initrd_path = getattr(self.op, "initrd_path", None)
4292 4323
    self.hvm_boot_order = getattr(self.op, "hvm_boot_order", None)
4293
    all_params = [self.mem, self.vcpus, self.ip, self.bridge, self.mac,
4294
                  self.kernel_path, self.initrd_path, self.hvm_boot_order]
4295
    if all_params.count(None) == len(all_params):
4324
    self.hvm_acpi = getattr(self.op, "hvm_acpi", None)
4325
    self.hvm_pae = getattr(self.op, "hvm_pae", None)
4326
    self.hvm_cdrom_image_path = getattr(self.op, "hvm_cdrom_image_path", None)
4327
    self.vnc_bind_address = getattr(self.op, "vnc_bind_address", None)
4328
    all_parms = [self.mem, self.vcpus, self.ip, self.bridge, self.mac,
4329
                 self.kernel_path, self.initrd_path, self.hvm_boot_order,
4330
                 self.hvm_acpi, self.hvm_pae, self.hvm_cdrom_image_path,
4331
                 self.vnc_bind_address]
4332
    if all_parms.count(None) == len(all_parms):
4296 4333
      raise errors.OpPrereqError("No changes submitted")
4297 4334
    if self.mem is not None:
4298 4335
      try:
......
4351 4388
                                     " must be one or more of [acdn]"
4352 4389
                                     " or 'default'")
4353 4390

  
4391
    # hvm_cdrom_image_path verification
4392
    if self.op.hvm_cdrom_image_path is not None:
4393
      if not os.path.isabs(self.op.hvm_cdrom_image_path):
4394
        raise errors.OpPrereqError("The path to the HVM CDROM image must"
4395
                                   " be an absolute path or None, not %s" %
4396
                                   self.op.hvm_cdrom_image_path)
4397
      if not os.path.isfile(self.op.hvm_cdrom_image_path):
4398
        raise errors.OpPrereqError("The HVM CDROM image must either be a"
4399
                                   " regular file or a symlink pointing to"
4400
                                   " an existing regular file, not %s" %
4401
                                   self.op.hvm_cdrom_image_path)
4402

  
4403
    # vnc_bind_address verification
4404
    if self.op.vnc_bind_address is not None:
4405
      if not utils.IsValidIP(self.op.vnc_bind_address):
4406
        raise errors.OpPrereqError("given VNC bind address '%s' doesn't look"
4407
                                   " like a valid IP address" %
4408
                                   self.op.vnc_bind_address)
4409

  
4354 4410
    instance = self.cfg.GetInstanceInfo(
4355 4411
      self.cfg.ExpandInstanceName(self.op.instance_name))
4356 4412
    if instance is None:
......
4394 4450
      else:
4395 4451
        instance.hvm_boot_order = self.hvm_boot_order
4396 4452
      result.append(("hvm_boot_order", self.hvm_boot_order))
4453
    if self.hvm_acpi:
4454
      result.append(("hvm_acpi", self.hvm_acpi))
4455
    if self.hvm_pae:
4456
      result.append(("hvm_pae", self.hvm_pae))
4457
    if self.hvm_cdrom_image_path:
4458
      result.append(("hvm_cdrom_image_path", self.hvm_cdrom_image_path))
4459
    if self.vnc_bind_address:
4460
      instance.vnc_bind_address = self.vnc_bind_address
4461
      result.append(("vnc_bind_address", self.vnc_bind_address))
4397 4462

  
4398 4463
    self.cfg.AddInstance(instance)
4399 4464

  
b/lib/constants.py
160 160
TCP_PING_TIMEOUT = 10
161 161
GANETI_RUNAS = "root"
162 162
DEFAULT_VG = "xenvg"
163
BIND_ADDRESS_GLOBAL = "0.0.0.0"
163 164

  
164 165
# valid os status
165 166
OS_VALID_STATUS = "VALID"
......
189 190
HT_HVM_VNC_BASE_PORT = 5900
190 191
HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
191 192
VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password"
193
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
192 194

  
193 195
# Cluster Verify steps
194 196
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
b/lib/opcodes.py
282 282
    "disk_template", "snode", "swap_size", "mode",
283 283
    "vcpus", "ip", "bridge", "src_node", "src_path", "start",
284 284
    "wait_for_sync", "ip_check", "mac",
285
    "kernel_path", "initrd_path", "hvm_boot_order",
285
    "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi",
286
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address",
286 287
    "file_storage_dir", "file_driver",
287 288
    "iallocator",
288 289
    ]
......
372 373
  OP_ID = "OP_INSTANCE_SET_PARAMS"
373 374
  __slots__ = [
374 375
    "instance_name", "mem", "vcpus", "ip", "bridge", "mac",
375
    "kernel_path", "initrd_path", "hvm_boot_order",
376
    "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi",
377
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address"
376 378
    ]
377 379

  
378 380

  
b/scripts/gnt-instance
40 40
_SHUTDOWN_INSTANCES = "instances"
41 41

  
42 42

  
43
_VALUE_TRUE = "true"
44

  
43 45
_LIST_DEF_FIELDS = [
44 46
  "name", "os", "pnode", "status", "oper_ram",
45 47
  ]
......
254 256
  kernel_path = _TransformPath(opts.kernel_path)
255 257
  initrd_path = _TransformPath(opts.initrd_path)
256 258

  
259
  hvm_acpi = opts.hvm_acpi == _VALUE_TRUE
260
  hvm_pae = opts.hvm_pae == _VALUE_TRUE
261

  
262
  if ((opts.hvm_cdrom_image_path is not None) and
263
      (opts.hvm_cdrom_image_path.lower() == constants.VALUE_NONE)):
264
    hvm_cdrom_image_path = None
265
  else:
266
    hvm_cdrom_image_path = opts.hvm_cdrom_image_path
267

  
257 268
  op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem,
258 269
                                disk_size=opts.size, swap_size=opts.swap,
259 270
                                disk_template=opts.disk_template,
......
266 277
                                mac=opts.mac,
267 278
                                kernel_path=kernel_path,
268 279
                                initrd_path=initrd_path,
280
                                iallocator=opts.iallocator,
269 281
                                hvm_boot_order=opts.hvm_boot_order,
270 282
                                file_storage_dir=opts.file_storage_dir,
271 283
                                file_driver=opts.file_driver,
272
                                iallocator=opts.iallocator)
284
                                hvm_acpi=hvm_acpi, hvm_pae=hvm_pae,
285
                                hvm_cdrom_image_path=hvm_cdrom_image_path,
286
                                vnc_bind_address=opts.vnc_bind_address)
287

  
273 288
  SubmitOpCode(op)
274 289
  return 0
275 290

  
......
641 656
    else:
642 657
      initrd = instance["initrd_path"]
643 658
    buf.write("       initrd: %s\n" % initrd)
644
    buf.write("  HVM boot order: %s\n" % instance["hvm_boot_order"])
659
    buf.write("  HVM:\n")
660
    buf.write("    - boot order: %s\n" % instance["hvm_boot_order"])
661
    buf.write("    - ACPI support: %s\n" % instance["hvm_acpi"])
662
    buf.write("    - PAE support: %s\n" % instance["hvm_pae"])
663
    buf.write("    - virtual CDROM: %s\n" % instance["hvm_cdrom_image_path"])
664
    buf.write("  VNC bind address: %s\n" % instance["vnc_bind_address"])
645 665
    buf.write("  Hardware:\n")
646 666
    buf.write("    - VCPUs: %d\n" % instance["vcpus"])
647 667
    buf.write("    - memory: %dMiB\n" % instance["memory"])
......
673 693

  
674 694
  """
675 695
  if not (opts.mem or opts.vcpus or opts.ip or opts.bridge or opts.mac or
676
          opts.kernel_path or opts.initrd_path or opts.hvm_boot_order):
696
          opts.kernel_path or opts.initrd_path or opts.hvm_boot_order or
697
          opts.hvm_acpi or opts.hvm_acpi or opts.hvm_cdrom_image_path or
698
          opts.vnc_bind_address):
677 699
    logger.ToStdout("Please give at least one of the parameters.")
678 700
    return 1
679 701

  
......
684 706
  else:
685 707
    hvm_boot_order = opts.hvm_boot_order
686 708

  
709
  hvm_acpi = opts.hvm_acpi == _VALUE_TRUE
710
  hvm_pae = opts.hvm_pae == _VALUE_TRUE
711

  
712
  if ((opts.hvm_cdrom_image_path is not None) and
713
      (opts.hvm_cdrom_image_path.lower() == constants.VALUE_NONE)):
714
    hvm_cdrom_image_path = None
715
  else:
716
    hvm_cdrom_image_path = opts.hvm_cdrom_image_path
717

  
687 718
  op = opcodes.OpSetInstanceParams(instance_name=args[0], mem=opts.mem,
688 719
                                   vcpus=opts.vcpus, ip=opts.ip,
689 720
                                   bridge=opts.bridge, mac=opts.mac,
690 721
                                   kernel_path=opts.kernel_path,
691 722
                                   initrd_path=opts.initrd_path,
692
                                   hvm_boot_order=hvm_boot_order)
723
                                   hvm_boot_order=hvm_boot_order,
724
                                   hvm_acpi=hvm_acpi, hvm_pae=hvm_pae,
725
                                   hvm_cdrom_image_path=hvm_cdrom_image_path,
726
                                   vnc_bind_address=opts.vnc_bind_address)
727

  
693 728
  result = SubmitOpCode(op)
694 729

  
695 730
  if result:
......
792 827
  make_option("--iallocator", metavar="<NAME>",
793 828
              help="Select nodes for the instance automatically using the"
794 829
              " <NAME> iallocator plugin", default=None, type="string"),
830
  make_option("--hvm-acpi", dest="hvm_acpi",
831
              help="ACPI support for HVM (true|false)",
832
              metavar="<BOOL>", choices=["true", "false"]),
833
  make_option("--hvm-pae", dest="hvm_pae",
834
              help="PAE support for HVM (true|false)",
835
              metavar="<BOOL>", choices=["true", "false"]),
836
  make_option("--hvm-cdrom-image-path", dest="hvm_cdrom_image_path",
837
              help="CDROM image path for HVM (absolute path or None)",
838
              default=None, type="string", metavar="<CDROMIMAGE>"),
839
  make_option("--vnc-bind-address", dest="vnc_bind_address",
840
              help="bind address for VNC (IP address)",
841
              default=None, type="string", metavar="<VNCADDRESS>"),
795 842
  ]
796 843

  
797 844
commands = {
......
899 946
                          help="boot device order for HVM"
900 947
                          "(either one or more of [acdn] or 'default')",
901 948
                          default=None, type="string", metavar="<BOOTORDER>"),
949
              make_option("--hvm-acpi", dest="hvm_acpi",
950
                          help="ACPI support for HVM (true|false)",
951
                          metavar="<BOOL>", choices=["true", "false"]),
952
              make_option("--hvm-pae", dest="hvm_pae",
953
                          help="PAE support for HVM (true|false)",
954
                          metavar="<BOOL>", choices=["true", "false"]),
955
              make_option("--hvm-cdrom-image-path",
956
                          dest="hvm_cdrom_image_path",
957
                          help="CDROM image path for HVM"
958
                          "(absolute path or None)",
959
                          default=None, type="string", metavar="<CDROMIMAGE>"),
960
              make_option("--vnc-bind-address", dest="vnc_bind_address",
961
                          help="bind address for VNC (IP address)",
962
                          default=None, type="string", metavar="<VNCADDRESS>"),
902 963
              ],
903 964
             "<instance>", "Alters the parameters of an instance"),
904 965
  'shutdown': (ShutdownInstance, ARGS_ANY,

Also available in: Unified diff