示例#1
0
// FilesystemFromState converts a state.Filesystem to params.Filesystem.
func FilesystemFromState(f state.Filesystem) (params.Filesystem, error) {
	info, err := f.Info()
	if err != nil {
		return params.Filesystem{}, errors.Trace(err)
	}
	result := params.Filesystem{
		f.FilesystemTag().String(),
		"",
		FilesystemInfoFromState(info),
	}
	volumeTag, err := f.Volume()
	if err == nil {
		result.VolumeTag = volumeTag.String()
	} else if err != state.ErrNoBackingVolume {
		return params.Filesystem{}, errors.Trace(err)
	}
	return result, nil
}
示例#2
0
func filesystemsFromStorage(in []storage.Filesystem) []params.Filesystem {
	out := make([]params.Filesystem, len(in))
	for i, f := range in {
		paramsFilesystem := params.Filesystem{
			f.Tag.String(),
			"",
			params.FilesystemInfo{
				f.FilesystemId,
				f.Size,
			},
		}
		if f.Volume != (names.VolumeTag{}) {
			paramsFilesystem.VolumeTag = f.Volume.String()
		}
		out[i] = paramsFilesystem
	}
	return out
}