Class: Dcmgr::Cli::Host
- Includes:
- Models
- Defined in:
- lib/dcmgr/cli/host.rb
Instance Method Summary collapse
- #add(node_id) ⇒ Object
- #del(uuid) ⇒ Object
- #modify(uuid) ⇒ Object
- #show(uuid = nil) ⇒ Object
- #shownodes ⇒ Object
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 38 39 40 |
# File 'lib/dcmgr/cli/host.rb', line 20 def add(node_id) UnknownUUIDError.raise([:account_id]) if Account[[:account_id]].nil? UnsupportedArchError.raise([:arch]) unless HostNode::SUPPORTED_ARCH.member?([:arch]) UnsupportedHypervisorError.raise([:hypervisor]) unless HostNode::SUPPORTED_HYPERVISOR.member?([:hypervisor]) unless ([:force] || Isono::Models::NodeState.find(:node_id=>node_id)) abort("Node ID is not registered yet: #{node_id}") end fields = { :name=>[:name], :node_id=>node_id, :offering_cpu_cores=>[:cpu_cores], :offering_memory_size=>[:memory_size], :hypervisor=>[:hypervisor], :arch=>[:arch], :account_id=>[:account_id], } fields.merge!({:uuid => [:uuid]}) unless [:uuid].nil? puts super(HostNode,fields) end |
#del(uuid) ⇒ Object
62 63 64 |
# File 'lib/dcmgr/cli/host.rb', line 62 def del(uuid) super(HostNode,uuid) end |
#modify(uuid) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dcmgr/cli/host.rb', line 48 def modify(uuid) UnknownUUIDError.raise([:account_id]) if [:account_id] && Account[[:account_id]].nil? UnsupportedHypervisorError.raise([:hypervisor]) unless [:hypervisor].nil? || HostNode::SUPPORTED_HYPERVISOR.member?([:hypervisor]) fields = { :name=>[:name], :offering_memory_size=>[:memory_size], :offering_cpu_cores=>[:cpu_cores], :account_id=>[:account_id], :hypervisor=>[:hypervisor] } super(HostNode,uuid,fields) end |
#show(uuid = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/dcmgr/cli/host.rb', line 67 def show(uuid=nil) if uuid host = HostNode[uuid] || UnknownUUIDError.raise(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 = HostNode.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
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/dcmgr/cli/host.rb', line 94 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 |