~raharper/curtin/trunk.vmtest-reuse-output

« back to all changes in this revision

Viewing changes to curtin/commands/block_meta.py

  • Committer: Scott Moser
  • Author(s): Nish Aravamudan
  • Date: 2017-02-22 20:36:06 UTC
  • mfrom: (450.3.45 curtin)
  • Revision ID: smoser@ubuntu.com-20170222203606-71yzbu6a5m27b7of
Add iSCSI disk support.

iSCSI disks are specified following RFC4173
(https://tools.ietf.org/html/rfc4173) as:

  path: iscsi:[user:pass[:iuser:ipass]@]host:proto:port:lun:targetname

Unittests for iSCSI target parsing have been added as well as a vmtests
for testing iSCSI targets via tgt with all possible authentication
combinations.

For standalone testing, tools/find-tgt has been added to spawn a tgt
server as a regular user for serving iSCSI disks.

tools/jenkins-runner has been updated to use tools/find-tgt for the
automated vmtests.

Additionally, we add two new subcommands for working with iscsi volumes:
 block-attach-iscsi
 block-detach-iscsi

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from collections import OrderedDict
19
19
from curtin import (block, config, util)
20
 
from curtin.block import (mdadm, mkfs, clear_holders, lvm)
 
20
from curtin.block import (mdadm, mkfs, clear_holders, lvm, iscsi)
21
21
from curtin.log import LOG
22
22
from curtin.reporter import events
23
23
 
273
273
        if vol.get('serial'):
274
274
            volume_path = block.lookup_disk(vol.get('serial'))
275
275
        elif vol.get('path'):
276
 
            # resolve any symlinks to the dev_kname so sys/class/block access
277
 
            # is valid.  ie, there are no udev generated values in sysfs
278
 
            volume_path = os.path.realpath(vol.get('path'))
 
276
            if vol.get('path').startswith('iscsi:'):
 
277
                i = iscsi.ensure_disk_connected(vol.get('path'))
 
278
                volume_path = os.path.realpath(i.devdisk_path)
 
279
            else:
 
280
                # resolve any symlinks to the dev_kname so
 
281
                # sys/class/block access is valid.  ie, there are no
 
282
                # udev generated values in sysfs
 
283
                volume_path = os.path.realpath(vol.get('path'))
279
284
        elif vol.get('wwn'):
280
285
            by_wwn = '/dev/disk/by-id/wwn-%s' % vol.get('wwn')
281
286
            volume_path = os.path.realpath(by_wwn)
629
634
                options = "sw"
630
635
            else:
631
636
                path = "/%s" % path
632
 
                options = "defaults"
 
637
                if volume.get('type') == "partition":
 
638
                    disk_block_path = get_path_to_storage_volume(
 
639
                        volume.get('device'), storage_config)
 
640
                    disk_kname = block.path_to_kname(disk_block_path)
 
641
                    if iscsi.kname_is_iscsi(disk_kname):
 
642
                        options = "_netdev"
 
643
                    else:
 
644
                        options = "defaults"
 
645
                elif volume.get('type') == "disk":
 
646
                    disk_kname = block.path_to_kname(location)
 
647
                    if iscsi.kname_is_iscsi(disk_kname):
 
648
                        options = "_netdev"
 
649
                    else:
 
650
                        options = "defaults"
 
651
                else:
 
652
                    options = "defaults"
633
653
 
634
654
            if filesystem.get('fstype') in ["fat", "fat12", "fat16", "fat32",
635
655
                                            "fat64"]: