Class: Fog::Compute::VirtualBox::Medium

Inherits:
Model
  • Object
show all
Defined in:
lib/rackspace-fog/virtual_box/models/compute/medium.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



33
34
35
36
37
# File 'lib/rackspace-fog/virtual_box/models/compute/medium.rb', line 33

def destroy
  requires :raw
  raw.close
  true
end

#medium_formatObject



40
41
42
43
44
45
# File 'lib/rackspace-fog/virtual_box/models/compute/medium.rb', line 40

def medium_format
  Fog::Compute::VirtualBox::MediumFormat.new(
    :connection => connection,
    :raw        => raw.medium_format
  )
end

#saveObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rackspace-fog/virtual_box/models/compute/medium.rb', line 47

def save
  requires :device_type, :location, :read_only

  if File.exists?(location)

    access_mode = if read_only
      :access_mode_read_only
    else
      :access_mode_read_write
    end

    self.raw = connection.open_medium(location, device_type, access_mode)

  else

    raise Fog::Errors::Error.new('Creating a new medium is not yet implemented. Contributions welcome!')

  end
end