Revision 31a853d2 lib/cmdlib.py
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 |
|
Also available in: Unified diff