Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Update lxc config to allow mounting loop devices #1826
Merged
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
095188c
Update lxc config to allow mounting loop devices
wallyworld 9373cdd
Change lxc storage config so that we ony enable mounting loop devices…
wallyworld 7c436e6
Explicitly specify loop devices to mount in lxc
wallyworld ccac8a1
Add env config setting to force user to explicitly allow lxc loop mounts
wallyworld d4771d4
Revert explicit block device enumeration
wallyworld 0a7500b
Fix typo
wallyworld 8dff45f
Add code comment
wallyworld cc860e6
A couple of clean ups
wallyworld 8ddaa37
Fix test
wallyworld aec8123
Fix whitespace in tests
wallyworld
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,44 @@ | ||
| +// Copyright 2015 Canonical Ltd. | ||
| +// Licensed under the AGPLv3, see LICENCE file for details. | ||
| + | ||
| +package container | ||
| + | ||
| +import ( | ||
| + "errors" | ||
| + | ||
| + "github.com/juju/juju/storage" | ||
| + "github.com/juju/juju/storage/provider" | ||
| +) | ||
| + | ||
| +// ErrLoopMountNotAllowed is used when loop devices are requested to be | ||
| +// mounted inside an LXC container, but this has not been allowed using | ||
| +// an environment config setting. | ||
| +var ErrLoopMountNotAllowed = errors.New(` | ||
| +Mounting of loop devices inside LXC containers must be explicitly enabled using this environment config setting: | ||
| + allow-lxc-loop-mounts=true | ||
| +`[1:]) | ||
| + | ||
| +// StorageConfig defines how the container will be configured to support | ||
| +// storage requirements. | ||
| +type StorageConfig struct { | ||
| + | ||
| + // AllowMount is true is the container is required to allow | ||
| + // mounting block devices. | ||
| + AllowMount bool | ||
| +} | ||
| + | ||
| +// NewStorageConfig returns a StorageConfig used to specify the | ||
| +// configuration the container uses to support storage. | ||
| +func NewStorageConfig(volumes []storage.VolumeParams) *StorageConfig { | ||
| + allowMount := false | ||
| + // If there is a volume using a loop provider, then | ||
| + // allow mount must be true. | ||
| + for _, v := range volumes { | ||
| + allowMount = v.Provider == provider.LoopProviderType | ||
| + if allowMount { | ||
| + break | ||
| + } | ||
| + } | ||
| + // TODO(wallyworld) - add config for HostLoopProviderType | ||
| + return &StorageConfig{allowMount} | ||
| +} |
Oops, something went wrong.