Class: Dcmgr::Models::InstanceSpec

Inherits:
AccountResource show all
Defined in:
lib/dcmgr/models/instance_spec.rb

Constant Summary

Constants inherited from BaseNew

BaseNew::LOCK_TABLES_KEY

Instance Method Summary collapse

Methods inherited from AccountResource

#account

Methods inherited from BaseNew

Proxy, dataset, default_row_lock_mode=, install_data, install_data_hooks, lock!, unlock!, #with_timestamps?

Instance Method Details

#before_validateObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/dcmgr/models/instance_spec.rb', line 34

def before_validate
  default_config =
    case self.hypervisor
    when HostPool::HYPERVISOR_KVM
      {:block_driver=>'virtio', :nic_driver=>'virtio'}
    end

  self.config = default_config.merge(self.config || {})
  super
end

#to_api_documentObject



51
52
53
54
55
# File 'lib/dcmgr/models/instance_spec.rb', line 51

def to_api_document
  doc = to_hash
  doc.delete(:config)
  doc
end

#to_hashObject



45
46
47
48
49
# File 'lib/dcmgr/models/instance_spec.rb', line 45

def to_hash
  super.merge({:config=>self.config, # yaml -> Hash
                :storage => self.storage, # yaml -> Hash
              })
end