Class: Dcmgr::Cli::Host
Constant Summary
Constants included
from Models
Models::CREATE_TABLE_CLASSES
Instance Method Summary
collapse
Instance Method Details
#add(node_id) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/dcmgr/cli/host.rb', line 19
def add(node_id)
UnknownUUIDError.raise(options[:account_id]) if Account[options[:account_id]].nil?
UnsupportedArchError.raise(options[:arch]) unless HostPool::SUPPORTED_ARCH.member?(options[:arch])
UnsupportedHypervisorError.raise(options[:hypervisor]) unless HostPool::SUPPORTED_HYPERVISOR.member?(options[:hypervisor])
if (options[:force] == false && Isono::Models::NodeState.filter(:node_id=>node_id).first == nil)
abort("Node ID is not registered yet: #{node_id}")
end
fields = {
:node_id=>node_id,
:offering_cpu_cores=>options[:cpu_cores],
:offering_memory_size=>options[:memory_size],
:hypervisor=>options[:hypervisor],
:arch=>options[:arch],
:account_id=>options[:account_id],
}
fields.merge!({:uuid => options[:uuid]}) unless options[:uuid].nil?
puts super(HostPool,fields)
end
|
#del(uuid) ⇒ Object
58
59
60
|
# File 'lib/dcmgr/cli/host.rb', line 58
def del(uuid)
super(HostPool,uuid)
end
|
#modify(uuid) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/dcmgr/cli/host.rb', line 45
def modify(uuid)
UnknownUUIDError.raise(options[:account_id]) if options[:account_id] && Account[options[:account_id]].nil?
UnsupportedHypervisorError.raise(options[:hypervisor]) unless options[:hypervisor].nil? || HostPool::SUPPORTED_HYPERVISOR.member?(options[:hypervisor])
fields = {
:offering_memory_size=>options[:memory_size],
:offering_cpu_cores=>options[:cpu_cores],
:account_id=>options[:account_id],
:hypervisor=>options[:hypervisor]
}
super(HostPool,uuid,fields)
end
|
#show(uuid = nil) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/dcmgr/cli/host.rb', line 63
def show(uuid=nil)
if uuid
host = HostPool[uuid]
puts ERB.new(<<__END, nil, '-').result(binding)
Host UUID:
<%= host.canonical_uuid %>
Node ID:
<%= host.node_id %>
CPU Cores (offerring):
<%= host.offering_cpu_cores %>
Memory (offerring):
<%= host.offering_memory_size %>MB
Hypervisor:
<%= host.hypervisor %>
__END
else
cond = {}
all = HostPool.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
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/dcmgr/cli/host.rb', line 90
def shownodes
nodes = Isono::Models::NodeState.filter.all
puts ERB.new(<<__END, nil, '-').result(binding)
Node ID State
<%- nodes.each { |row| -%>
<%= "%-20s %-10s" % [row.node_id, row.state] %>
<%- } -%>
__END
end
|