本文整理汇总了Golang中github.com/juju/juju/storage.FilesystemSource类的典型用法代码示例。如果您正苦于以下问题:Golang FilesystemSource类的具体用法?Golang FilesystemSource怎么用?Golang FilesystemSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilesystemSource类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testDetachFilesystems
// testDetachFilesystems is a test-case for detaching filesystems that use
// the common "maybeUnmount" method.
func testDetachFilesystems(c *gc.C, commands *mockRunCommand, source storage.FilesystemSource, mounted bool) {
const testMountPoint = "/in/the/place"
cmd := commands.expect("df", "--output=source", filepath.Dir(testMountPoint))
cmd.respond("headers\n/same/as/rootfs", nil)
cmd = commands.expect("df", "--output=source", testMountPoint)
if mounted {
cmd.respond("headers\n/different/to/rootfs", nil)
commands.expect("umount", testMountPoint)
} else {
cmd.respond("headers\n/same/as/rootfs", nil)
}
results, err := source.DetachFilesystems([]storage.FilesystemAttachmentParams{{
Filesystem: names.NewFilesystemTag("0/0"),
FilesystemId: "filesystem-0-0",
AttachmentParams: storage.AttachmentParams{
Machine: names.NewMachineTag("0"),
InstanceId: "inst-id",
},
Path: testMountPoint,
}})
c.Assert(err, jc.ErrorIsNil)
c.Assert(results, gc.HasLen, 1)
c.Assert(results[0], jc.ErrorIsNil)
}
示例2: validateFilesystemParams
// validateFilesystemParams validates a collection of filesystem parameters.
func validateFilesystemParams(
filesystemSource storage.FilesystemSource,
filesystemParams []storage.FilesystemParams,
) ([]storage.FilesystemParams, []error) {
valid := make([]storage.FilesystemParams, 0, len(filesystemParams))
results := make([]error, len(filesystemParams))
for i, params := range filesystemParams {
err := filesystemSource.ValidateFilesystemParams(params)
if err == nil {
valid = append(valid, params)
}
results[i] = err
}
return valid, results
}