Class: Fog::Compute::XenServer::StorageRepository

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

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 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

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



43
44
45
# File 'lib/fog/xenserver/models/compute/storage_repository.rb', line 43

def destroy
  service.destroy_sr reference
end

#pbdsObject



34
35
36
# File 'lib/fog/xenserver/models/compute/storage_repository.rb', line 34

def pbds
  __pbds.collect { |pbd| service.pbds.get pbd }
end

#saveObject

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fog/xenserver/models/compute/storage_repository.rb', line 47

def save
  requires :name
  requires :type

  # host is not a model attribute (not in XAPI at least), 
  # but we need it here
  host = attributes[:host]
  raise ArgumentError.new('host is required for this operation') unless
    host

  # Not sure if this is always required, so not raising exception if nil
  device_config = attributes[:device_config]

  # create_sr request provides sane defaults if some attributes are
  # missing
  attr = service.get_record(
    service.create_sr( host.reference, 
                          name,
                          type,
                          description || '',
                          device_config || {},
                          physical_size || '0',
                          content_type || 'user',
                          shared || false,
                          sm_config || {}),
    'SR'
  )
  merge_attributes attr 
  true
end

#scanObject



38
39
40
41
# File 'lib/fog/xenserver/models/compute/storage_repository.rb', line 38

def scan
  service.scan_sr reference
  reload
end

#set_attribute(name, *val) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/fog/xenserver/models/compute/storage_repository.rb', line 78

def set_attribute(name, *val)
  data = service.set_attribute( 'SR', reference, name, *val )
  # Do not reload automatically for performance reasons
  # We can set multiple attributes at the same time and
  # then reload manually
  #reload
end

#vdisObject



30
31
32
# File 'lib/fog/xenserver/models/compute/storage_repository.rb', line 30

def vdis
  __vdis.collect { |vdi| service.vdis.get vdi }
end