Class: Microsandbox::Volume
- Inherits:
-
Object
- Object
- Microsandbox::Volume
- Defined in:
- lib/microsandbox/volume.rb
Overview
Management of named persistent volumes. Mount them into a sandbox via
Sandbox.create(..., volumes: { "/data" => { named: "my-vol" } }).
Class Method Summary collapse
-
.create(name, kind: "dir", size_mib: nil, quota_mib: nil, labels: nil) ⇒ VolumeInfo
Create a named volume.
-
.fs(name) ⇒ VolumeFs
A host-side filesystem view over a named volume (read/write its contents without a running sandbox).
-
.get(name) ⇒ VolumeInfo
Metadata for a volume.
-
.get_default ⇒ VolumeInfo
The backend's default volume (runtime v0.6.9).
-
.list ⇒ Array<VolumeInfo>
All volumes.
-
.remove(name) ⇒ nil
Remove a volume.
Class Method Details
.create(name, kind: "dir", size_mib: nil, quota_mib: nil, labels: nil) ⇒ VolumeInfo
Create a named volume.
151 152 153 154 155 156 157 |
# File 'lib/microsandbox/volume.rb', line 151 def create(name, kind: "dir", size_mib: nil, quota_mib: nil, labels: nil) opts = {"kind" => kind.to_s} opts["size_mib"] = Integer(size_mib) if size_mib opts["quota_mib"] = Integer(quota_mib) if quota_mib opts["labels"] = labels.each_with_object({}) { |(k, v), a| a[k.to_s] = v.to_s } if labels VolumeInfo.new(Native::Volume.create(name.to_s, opts)) end |
.fs(name) ⇒ VolumeFs
A host-side filesystem view over a named volume (read/write its contents without a running sandbox). The volume need not be mounted.
189 190 191 |
# File 'lib/microsandbox/volume.rb', line 189 def fs(name) VolumeFs.new(Native::Volume.fs(name.to_s)) end |
.get(name) ⇒ VolumeInfo
Metadata for a volume.
161 162 163 |
# File 'lib/microsandbox/volume.rb', line 161 def get(name) VolumeInfo.new(Native::Volume.get(name.to_s)) end |
.get_default ⇒ VolumeInfo
The backend's default volume (runtime v0.6.9). Cloud backend only — the full Microsandbox::VolumeInfo#fs surface works against it; the local backend raises UnsupportedError to avoid accidental host access.
169 170 171 |
# File 'lib/microsandbox/volume.rb', line 169 def get_default VolumeInfo.new(Native::Volume.get_default) end |
.list ⇒ Array<VolumeInfo>
All volumes.
175 176 177 |
# File 'lib/microsandbox/volume.rb', line 175 def list Native::Volume.list.map { |info| VolumeInfo.new(info) } end |
.remove(name) ⇒ nil
Remove a volume.
181 182 183 184 |
# File 'lib/microsandbox/volume.rb', line 181 def remove(name) Native::Volume.remove(name.to_s) nil end |