Class: Dcmgr::Models::StoragePool

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

Constant Summary

Constants inherited from BaseNew

BaseNew::LOCK_TABLES_KEY

Class Method Summary collapse

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?

Class Method Details

.create_pool(params) ⇒ Object



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

def self.create_pool(params)
  self.create(:account_id => params[:account_id],
              :node_id => params[:node_id],
              :offering_disk_space => params[:offering_disk_space],
              :transport_type => params[:transport_type],
              :storage_type => params[:storage_type],
              :export_path => params[:export_path],
              :ipaddr => params[:ipaddr],
              :snapshot_base_path => params[:snapshot_base_path])
end

.get_lists(uuid) ⇒ Object



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

def self.get_lists(uuid)
  self.dataset.where(:account_id => uuid).all.map{|row|
    row.values
  }
end

Instance Method Details

#before_validationObject



25
26
27
28
29
30
31
32
# File 'lib/dcmgr/models/storage_pool.rb', line 25

def before_validation
  export_path = self.export_path
  if export_path =~ /^(\/[a-z0-9]+)+$/
    export_path = export_path.split('/')
    export_path.shift
    self.export_path = export_path.join('/')
  end
end

#create_volume(account_id, size, snapshot_id = nil) ⇒ Object

def find_private_pool(account_id, uuid)

sp = self.dataset.where(:account_id=>).where(:uuid=>uuid)

end



55
56
57
58
59
60
# File 'lib/dcmgr/models/storage_pool.rb', line 55

def create_volume(, size, snapshot_id=nil)
  v = Volume.create(:account_id => ,
                    :storage_pool_id => self.id,
                    :snapshot_id => snapshot_id,
                    :size =>size)
end

#statusObject

Show status of the agent.



63
64
65
# File 'lib/dcmgr/models/storage_pool.rb', line 63

def status
  node.nil? ? :offline : node.state
end

#to_api_documentObject



71
72
73
74
75
# File 'lib/dcmgr/models/storage_pool.rb', line 71

def to_api_document
  h = to_hash
  h.delete(:node_id)
  h
end

#to_hashObject



67
68
69
# File 'lib/dcmgr/models/storage_pool.rb', line 67

def to_hash
  super.merge({:status=>self.status})
end