Class: Dcmgr::Cli::Storage
- Inherits:
-
Base
- Object
- Thor
- Base
- Dcmgr::Cli::Storage
show all
- Includes:
- Models
- Defined in:
- lib/dcmgr/cli/storage.rb
Constant Summary
Constants included
from Models
Models::CREATE_TABLE_CLASSES
Instance Method Summary
collapse
Instance Method Details
#add(node_id) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/dcmgr/cli/storage.rb', line 20
def add(node_id)
unless (options[:force] == false && Isono::Models::NodeState.exists?(:node_id=>options[:node_id]))
abort("Node ID is not registered yet: #{options[:node_id]}")
end
fields = {:node_id=>options[:node_id],
:offering_disk_space=>options[:disk_space],
:transport_type=>options[:transport_type],
:storage_type=>options[:storage_type],
:export_path=>options[:base_path],
:snapshot_base_path => options[:snapshot_base_path],
:ipaddr=>options[:ipaddr],
:account_id=>options[:account_id],
}
fields.merge!({:uuid => options[:uuid]}) unless options[:uuid].nil?
puts super(StoragePool,fields)
end
|
#del(uuid) ⇒ Object
40
41
42
|
# File 'lib/dcmgr/cli/storage.rb', line 40
def del(uuid)
super(StoragePool,uuid)
end
|
#show(uuid = nil) ⇒ Object
45
46
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
|
# File 'lib/dcmgr/cli/storage.rb', line 45
def show(uuid=nil)
if uuid
st = StoragePool[uuid]
puts ERB.new(<<__END, nil, '-').result(binding)
UUID:
<%= st.canonical_uuid %>
Node ID:
<%= st.node_id %>
Disk space (offerring):
<%= st.offering_disk_space %>MB
Storage:
<%= st.storage_type %>
Transport:
<%= st.transport_type %>
IP Address:
<%= st.ipaddr %>
Export path:
<%= st.export_path %>
Snapshot base path:
<%= st.snapshot_base_path %>
__END
else
cond = {}
all = StoragePool.filter(cond).all
puts ERB.new(<<__END, nil, '-').result(binding)
<%- all.each { |row| -%>
<%= "%-15s %-20s %-10s" % [row.canonical_uuid, row.node_id, row.status] %>
<%- } -%>
__END
end
end
|
#shownodes ⇒ Object
78
79
80
81
82
83
84
85
86
|
# File 'lib/dcmgr/cli/storage.rb', line 78
def shownodes
nodes = Isono::Models::NodeState.filter.all
puts ERB.new(<<__END, nil, '-').result(binding)
<%- nodes.each { |row| -%>
<%= "%-20s %-10s" % [row.node_id, row.state] %>
<%- } -%>
__END
end
|