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.
-
.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.
143 144 145 146 147 148 149 |
# File 'lib/microsandbox/volume.rb', line 143 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.
173 174 175 |
# File 'lib/microsandbox/volume.rb', line 173 def fs(name) VolumeFs.new(Native::Volume.fs(name.to_s)) end |
.get(name) ⇒ VolumeInfo
Metadata for a volume.
153 154 155 |
# File 'lib/microsandbox/volume.rb', line 153 def get(name) VolumeInfo.new(Native::Volume.get(name.to_s)) end |
.list ⇒ Array<VolumeInfo>
All volumes.
159 160 161 |
# File 'lib/microsandbox/volume.rb', line 159 def list Native::Volume.list.map { |info| VolumeInfo.new(info) } end |
.remove(name) ⇒ nil
Remove a volume.
165 166 167 168 |
# File 'lib/microsandbox/volume.rb', line 165 def remove(name) Native::Volume.remove(name.to_s) nil end |