Class: Microsandbox::VolumeInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/microsandbox/volume.rb

Overview

A named persistent volume, from Microsandbox::Volume.create / Microsandbox::Volume.get / Microsandbox::Volume.list.

path is populated when returned from Microsandbox::Volume.create; the storage stats (kind, used_bytes, …) are populated when returned from Microsandbox::Volume.get/Microsandbox::Volume.list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ VolumeInfo

Returns a new instance of VolumeInfo.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/microsandbox/volume.rb', line 12

def initialize(data)
  @name = data["name"]
  @path = data["path"]
  @kind = data["kind"]
  @default = data["default"]
  @quota_mib = data["quota_mib"]
  @used_bytes = data["used_bytes"]
  @capacity_bytes = data["capacity_bytes"]
  @disk_format = data["disk_format"]
  @disk_fstype = data["disk_fstype"]
  @labels = data["labels"] || {}
  @created_at_ms = data["created_at_ms"]
end

Instance Attribute Details

#capacity_bytesObject (readonly)

Returns the value of attribute capacity_bytes.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def capacity_bytes
  @capacity_bytes
end

#disk_formatObject (readonly)

Returns the value of attribute disk_format.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def disk_format
  @disk_format
end

#disk_fstypeObject (readonly)

Returns the value of attribute disk_fstype.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def disk_fstype
  @disk_fstype
end

#labelsObject (readonly)

Returns the value of attribute labels.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def labels
  @labels
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def path
  @path
end

#quota_mibObject (readonly)

Returns the value of attribute quota_mib.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def quota_mib
  @quota_mib
end

#used_bytesObject (readonly)

Returns the value of attribute used_bytes.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def used_bytes
  @used_bytes
end

Instance Method Details

#created_atTime?

Returns:

  • (Time, nil)


40
41
42
# File 'lib/microsandbox/volume.rb', line 40

def created_at
  @created_at_ms && Time.at(@created_at_ms / 1000.0)
end

#default?Boolean

Whether this is the backend's default volume (runtime v0.6.9, see Microsandbox::Volume.get_default).

Returns:

  • (Boolean)


35
36
37
# File 'lib/microsandbox/volume.rb', line 35

def default?
  !!@default
end

#fsVolumeFs

A host-side filesystem view over this volume (read/write its contents without a running sandbox).

Returns:



47
48
49
# File 'lib/microsandbox/volume.rb', line 47

def fs
  @fs ||= VolumeFs.new(Native::Volume.fs(@name.to_s))
end

#inspectObject



51
52
53
# File 'lib/microsandbox/volume.rb', line 51

def inspect
  "#<Microsandbox::VolumeInfo name=#{@name.inspect}#{" kind=#{@kind}" if @kind}>"
end

#kindSymbol?

Returns :dir or :disk (matches the Microsandbox::Volume.create kind: input and the core's canonical names).

Returns:



28
29
30
# File 'lib/microsandbox/volume.rb', line 28

def kind
  @kind&.to_sym
end