Class: Fog::Compute::XenServer::VDI

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#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

#initialize(attributes = {}) ⇒ VDI

Default VDI type is system Default size 8GB Sharable is false by default read_only is false by default



47
48
49
50
51
52
53
54
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 47

def initialize(attributes = {})
  self.virtual_size ||= '8589934592' unless attributes[:virtual_size]
  self.type ||= 'system' unless attributes[:type]
  self.read_only ||= false unless attributes[:read_only]
  self.sharable ||= false unless attributes[:sharable]
  self.other_config ||= {} unless attributes[:other_config]
  super 
end

Instance Method Details

#destroyObject



86
87
88
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 86

def destroy
  connection.destroy_vdi reference
end

#parentObject



64
65
66
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 64

def parent
  connection.vdis.get __parent
end

#saveObject



80
81
82
83
84
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 80

def save
  requires :name, :storage_repository
  ref = connection.create_vdi attributes
  merge_attributes connection.vdis.get(ref).attributes
end

#set_attribute(name, *val) ⇒ Object



56
57
58
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 56

def set_attribute(name, *val)
  data = connection.set_attribute( 'VDI', reference, name, *val )
end

#snapshot_ofObject



60
61
62
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 60

def snapshot_of
  connection.vdis.get __sr
end

#snapshotsObject



68
69
70
71
72
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 68

def snapshots
  __snapshots.collect do |ref|
    connection.vdis.get ref
  end
end

#srObject



94
95
96
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 94

def sr
  storage_repository
end

#storage_repositoryObject



90
91
92
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 90

def storage_repository
  connection.storage_repositories.get __sr
end

#vbdsObject



74
75
76
77
78
# File 'lib/rackspace-fog/xenserver/models/compute/vdi.rb', line 74

def vbds
  __vbds.collect do |ref|
    connection.vbds.get ref
  end
end