MCPcopy Create free account
hub / github.com/cloudfoundry/bosh-agent / NewLinuxDiskManager

Function NewLinuxDiskManager

platform/disk/linux_disk_manager.go:35–96  ·  view source on GitHub ↗
(
	logger boshlog.Logger,
	runner boshsys.CmdRunner,
	fs boshsys.FileSystem,
	opts LinuxDiskManagerOpts,
)

Source from the content-addressed store, hash-verified

33}
34
35func NewLinuxDiskManager(
36 logger boshlog.Logger,
37 runner boshsys.CmdRunner,
38 fs boshsys.FileSystem,
39 opts LinuxDiskManagerOpts,
40) Manager {
41 var mounter Mounter
42 var mountsSearcher MountsSearcher
43
44 // By default we want to use most reliable source of
45 // mount information which is /proc/mounts
46 mountsSearcher = NewProcMountsSearcher(fs)
47
48 // Bind mounting in a container (warden) will not allow
49 // reliably determine which device backs a mount point,
50 // so we use less reliable source of mount information:
51 // the mount command which returns information from /etc/mtab.
52 if opts.BindMount {
53 mountsSearcher = NewCmdMountsSearcher(runner)
54 }
55
56 mounter = NewLinuxMounter(runner, mountsSearcher, 1*time.Second)
57
58 if opts.BindMount {
59 mounter = NewLinuxBindMounter(mounter)
60 }
61
62 var ephemeralPartitioner, persistentPartitioner Partitioner
63
64 diskUtil := NewUtil(runner, mounter, fs, logger)
65 partedPartitioner := NewPartedPartitioner(logger, runner, clock.NewClock())
66 sfDiskPartitioner := NewSfdiskPartitioner(logger, runner, clock.NewClock())
67
68 switch opts.PartitionerType {
69 case "parted":
70 ephemeralPartitioner = NewEphemeralDevicePartitioner(partedPartitioner, logger, runner)
71 persistentPartitioner = partedPartitioner
72 case "sfdisk":
73 ephemeralPartitioner = sfDiskPartitioner
74 persistentPartitioner = sfDiskPartitioner
75 case "":
76 ephemeralPartitioner = NewEphemeralDevicePartitioner(partedPartitioner, logger, runner)
77 persistentPartitioner = NewPersistentDevicePartitioner(sfDiskPartitioner, partedPartitioner, diskUtil, logger)
78 default:
79 panic(fmt.Sprintf("Unknown partitioner type '%s'", opts.PartitionerType))
80 }
81
82 return linuxDiskManager{
83 ephemeralPartitioner: ephemeralPartitioner,
84 diskUtil: diskUtil,
85 formatter: NewLinuxFormatter(runner, fs),
86 fs: fs,
87 logger: logger,
88 mounter: mounter,
89 mountsSearcher: mountsSearcher,
90 partedPartitioner: partedPartitioner,
91 sfDiskPartitioner: sfDiskPartitioner,
92 persistentPartitioner: persistentPartitioner,

Callers 1

Calls 11

NewProcMountsSearcherFunction · 0.85
NewCmdMountsSearcherFunction · 0.85
NewLinuxMounterFunction · 0.85
NewLinuxBindMounterFunction · 0.85
NewUtilFunction · 0.85
NewPartedPartitionerFunction · 0.85
NewSfdiskPartitionerFunction · 0.85
NewLinuxFormatterFunction · 0.85
NewRootDevicePartitionerFunction · 0.85

Tested by

no test coverage detected