312 |
312 |
return "'xm info' failed: %s, %s" % (result.fail_reason, result.output)
|
313 |
313 |
|
314 |
314 |
@staticmethod
|
315 |
|
def _GetConfigFileDiskData(block_devices):
|
|
315 |
def _GetConfigFileDiskData(block_devices, blockdev_prefix):
|
316 |
316 |
"""Get disk directive for xen config file.
|
317 |
317 |
|
318 |
318 |
This method builds the xen config disk directive according to the
|
... | ... | |
321 |
321 |
@param block_devices: list of tuples (cfdev, rldev):
|
322 |
322 |
- cfdev: dict containing ganeti config disk part
|
323 |
323 |
- rldev: ganeti.bdev.BlockDev object
|
|
324 |
@param blockdev_prefix: a string containing blockdevice prefix,
|
|
325 |
e.g. "sd" for /dev/sda
|
324 |
326 |
|
325 |
327 |
@return: string containing disk directive for xen instance config file
|
326 |
328 |
|
... | ... | |
333 |
335 |
if len(block_devices) > 24:
|
334 |
336 |
# 'z' - 'a' = 24
|
335 |
337 |
raise errors.HypervisorError("Too many disks")
|
336 |
|
# FIXME: instead of this hardcoding here, each of PVM/HVM should
|
337 |
|
# directly export their info (currently HVM will just sed this info)
|
338 |
|
namespace = ["sd" + chr(i + ord('a')) for i in range(24)]
|
|
338 |
namespace = [blockdev_prefix + chr(i + ord('a')) for i in range(24)]
|
339 |
339 |
for sd_name, (cfdev, dev_path) in zip(namespace, block_devices):
|
340 |
340 |
if cfdev.mode == constants.DISK_RDWR:
|
341 |
341 |
mode = "w"
|
... | ... | |
459 |
459 |
constants.HV_KERNEL_ARGS: hv_base.NO_CHECK,
|
460 |
460 |
constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
|
461 |
461 |
constants.HV_MIGRATION_MODE: hv_base.MIGRATION_MODE_CHECK,
|
|
462 |
# TODO: Add a check for the blockdev prefix (matching [a-z:] or similar).
|
|
463 |
constants.HV_BLOCKDEV_PREFIX: hv_base.NO_CHECK,
|
462 |
464 |
}
|
463 |
465 |
|
464 |
466 |
@classmethod
|
... | ... | |
509 |
511 |
nic_str += ", bridge=%s" % nic.nicparams[constants.NIC_LINK]
|
510 |
512 |
vif_data.append("'%s'" % nic_str)
|
511 |
513 |
|
512 |
|
disk_data = cls._GetConfigFileDiskData(block_devices)
|
|
514 |
disk_data = cls._GetConfigFileDiskData(block_devices,
|
|
515 |
hvp[constants.HV_BLOCKDEV_PREFIX])
|
513 |
516 |
|
514 |
517 |
config.write("vif = [%s]\n" % ",".join(vif_data))
|
515 |
518 |
config.write("disk = [%s]\n" % ",".join(disk_data))
|
... | ... | |
639 |
642 |
vif_data.append("'%s'" % nic_str)
|
640 |
643 |
|
641 |
644 |
config.write("vif = [%s]\n" % ",".join(vif_data))
|
642 |
|
disk_data = cls._GetConfigFileDiskData(block_devices)
|
643 |
|
disk_type = hvp[constants.HV_DISK_TYPE]
|
644 |
|
if disk_type in (None, constants.HT_DISK_IOEMU):
|
645 |
|
replacement = ",ioemu:hd"
|
646 |
|
else:
|
647 |
|
replacement = ",hd"
|
648 |
|
disk_data = [line.replace(",sd", replacement) for line in disk_data]
|
|
645 |
|
|
646 |
disk_data = cls._GetConfigFileDiskData(block_devices,
|
|
647 |
hvp[constants.HV_BLOCKDEV_PREFIX])
|
|
648 |
|
649 |
649 |
iso_path = hvp[constants.HV_CDROM_IMAGE_PATH]
|
650 |
650 |
if iso_path:
|
651 |
651 |
iso = "'file:%s,hdc:cdrom,r'" % iso_path
|