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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

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 Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #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



50
51
52
53
54
55
56
57
# File 'lib/fog/xenserver/models/compute/vdi.rb', line 50

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



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

def destroy
  service.destroy_vdi reference
end

#parentObject



67
68
69
# File 'lib/fog/xenserver/models/compute/vdi.rb', line 67

def parent
  service.vdis.get __parent
end

#saveObject



83
84
85
86
87
# File 'lib/fog/xenserver/models/compute/vdi.rb', line 83

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

#set_attribute(name, *val) ⇒ Object



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

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

#snapshot_ofObject



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

def snapshot_of
  service.vdis.get __sr
end

#snapshotsObject



71
72
73
74
75
# File 'lib/fog/xenserver/models/compute/vdi.rb', line 71

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

#srObject



97
98
99
# File 'lib/fog/xenserver/models/compute/vdi.rb', line 97

def sr
  storage_repository
end

#storage_repositoryObject



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

def storage_repository
  service.storage_repositories.get __sr
end

#vbdsObject



77
78
79
80
81
# File 'lib/fog/xenserver/models/compute/vdi.rb', line 77

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