Skip to content

Commit

Permalink
Merge pull request #312 from jaypipes/revert-iscsi
Browse files Browse the repository at this point in the history
Revert "Detect iSCSI devices"
  • Loading branch information
jaypipes committed Mar 25, 2022
2 parents 95585aa + d0958f4 commit 6d4903c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
3 changes: 0 additions & 3 deletions pkg/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const (
DRIVE_TYPE_FDD // Floppy disk drive
DRIVE_TYPE_ODD // Optical disk drive
DRIVE_TYPE_SSD // Solid-state drive
DRIVE_TYPE_ISCSI // iSCSI drive
)

var (
Expand All @@ -39,7 +38,6 @@ var (
DRIVE_TYPE_FDD: "FDD",
DRIVE_TYPE_ODD: "ODD",
DRIVE_TYPE_SSD: "SSD",
DRIVE_TYPE_ISCSI: "ISCSI",
}

// NOTE(fromani): the keys are all lowercase and do not match
Expand All @@ -53,7 +51,6 @@ var (
"fdd": DRIVE_TYPE_FDD,
"odd": DRIVE_TYPE_ODD,
"ssd": DRIVE_TYPE_SSD,
"iscsi": DRIVE_TYPE_ISCSI,
}
)

Expand Down
3 changes: 0 additions & 3 deletions pkg/block/block_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@ func disks(ctx *context.Context, paths *linuxpath.Paths) []*Disk {
size := diskSizeBytes(paths, dname)
pbs := diskPhysicalBlockSizeBytes(paths, dname)
busPath := diskBusPath(paths, dname)
if strings.Contains(busPath, "-iscsi-") {
driveType = DRIVE_TYPE_ISCSI
}
node := diskNUMANodeID(paths, dname)
vendor := diskVendor(paths, dname)
model := diskModel(paths, dname)
Expand Down
36 changes: 1 addition & 35 deletions pkg/block/block_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package block

import (
"fmt"
"github.com/jaypipes/ghw/pkg/util"
"io/ioutil"
"os"
"path/filepath"
Expand All @@ -20,6 +19,7 @@ import (

"github.com/jaypipes/ghw/pkg/context"
"github.com/jaypipes/ghw/pkg/linuxpath"
"github.com/jaypipes/ghw/pkg/util"
)

func TestParseMountEntry(t *testing.T) {
Expand Down Expand Up @@ -187,40 +187,6 @@ func TestDiskTypes(t *testing.T) {
}
}

func TestISCSI(t *testing.T) {
if _, ok := os.LookupEnv("GHW_TESTING_SKIP_BLOCK"); ok {
t.Skip("Skipping block tests.")
}

baseDir, _ := ioutil.TempDir("", "test")
defer os.RemoveAll(baseDir)
ctx := context.New()
ctx.Chroot = baseDir
paths := linuxpath.New(ctx)

_ = os.MkdirAll(paths.SysBlock, 0755)
_ = os.MkdirAll(paths.RunUdevData, 0755)

// Emulate an iSCSI device
_ = os.Mkdir(filepath.Join(paths.SysBlock, "sda"), 0755)
_ = ioutil.WriteFile(filepath.Join(paths.SysBlock, "sda", "size"), []byte("500118192\n"), 0644)
_ = ioutil.WriteFile(filepath.Join(paths.SysBlock, "sda", "dev"), []byte("259:0\n"), 0644)
_ = os.Mkdir(filepath.Join(paths.SysBlock, "sda", "queue"), 0755)
_ = ioutil.WriteFile(filepath.Join(paths.SysBlock, "sda", "queue", "rotational"), []byte("0\n"), 0644)
_ = ioutil.WriteFile(filepath.Join(paths.SysBlock, "sda", "queue", "physical_block_size"), []byte("512\n"), 0644)
_ = os.Mkdir(filepath.Join(paths.SysBlock, "sda", "device"), 0755)
_ = ioutil.WriteFile(filepath.Join(paths.SysBlock, "sda", "device", "vendor"), []byte("LIO-ORG\n"), 0644)
udevData := "E:ID_MODEL=disk0\nE:ID_SERIAL=6001405961d8b6f55cf48beb0de296b2\n" +
"E:ID_PATH=ip-192.168.130.10:3260-iscsi-iqn.2022-01.com.redhat.foo:disk0-lun-0\n" +
"E:ID_WWN=0x6001405961d8b6f55cf48beb0de296b2\n"
_ = ioutil.WriteFile(filepath.Join(paths.RunUdevData, "b259:0"), []byte(udevData), 0644)

diskInventory := disks(ctx, paths)
if diskInventory[0].DriveType != DRIVE_TYPE_ISCSI {
t.Fatalf("Got drive type %s, but expected ISCSI", diskInventory[0].DriveType)
}
}

func TestDiskPartLabel(t *testing.T) {
if _, ok := os.LookupEnv("GHW_TESTING_SKIP_BLOCK"); ok {
t.Skip("Skipping block tests.")
Expand Down

0 comments on commit 6d4903c

Please sign in to comment.