def add_directlun(prefix):
# Find LUN GUIDs
iscsi_host = prefix.virt_env.get_vm(SD_ISCSI_HOST_NAME)
ret = iscsi_host.ssh(['cat', '/root/multipath.txt'])
nt.assert_equals(ret.code, 0)
all_guids = ret.out.splitlines()
lun_guid = all_guids[SD_ISCSI_NR_LUNS] # Take the first unused LUN. 0-(SD_ISCSI_NR_LUNS) are used by iSCSI SD
ips = iscsi_host.all_ips()
luns = []
for ip in ips:
lun=types.LogicalUnit(
id=lun_guid,
address=ip,
port=SD_ISCSI_PORT,
target=SD_ISCSI_TARGET,
username='username',
password='password',
)
luns.append(lun)
dlun_params = types.Disk(
name=DLUN_DISK_NAME,
format=types.DiskFormat.RAW,
lun_storage=types.HostStorage(
type=types.StorageType.ISCSI,
logical_units=luns,
),
sgio=types.ScsiGenericIO.UNFILTERED,
)
api = prefix.virt_env.engine_vm().get_api_v4()
engine = api.system_service()
disk_attachments_service = test_utils.get_disk_attachments_service(engine, VM0_NAME)
disk_attachments_service.add(types.DiskAttachment(
disk=dlun_params,
interface=types.DiskInterface.VIRTIO_SCSI))
disk_service = test_utils.get_disk_service(engine, DLUN_DISK_NAME)
attachment_service = disk_attachments_service.attachment_service(disk_service.get().id)
nt.assert_not_equal(
attachment_service.get(),
None,
'Direct LUN disk not attached'
)
评论列表
文章目录