Class: Dcmgr::Cli::Spec

Inherits:
Base
  • Object
show all
Defined in:
lib/dcmgr/cli/spec.rb

Constant Summary collapse

M =
Dcmgr::Models

Instance Method Summary collapse

Instance Method Details

#addObject

method_option :is_public, :type => :boolean, :aliases => “-p”, :default => false, :desc => “A flag that determines whether the new machine image is public or not.”



18
19
20
21
22
23
24
25
26
# File 'lib/dcmgr/cli/spec.rb', line 18

def add
  UnknownUUIDError.raise(options[:account_id]) if M::Account[options[:account_id]].nil?
  UnsupportedArchError.raise(options[:arch]) unless M::HostPool::SUPPORTED_ARCH.member?(options[:arch])
  UnsupportedHypervisorError.raise(options[:hypervisor]) unless M::HostPool::SUPPORTED_HYPERVISOR.member?(options[:hypervisor])
  fields = options.dup
  fields[:config] = {
  }
  puts super(M::InstanceSpec, fields)
end

#del(uuid) ⇒ Object



44
45
46
47
# File 'lib/dcmgr/cli/spec.rb', line 44

def del(uuid)
  UnknownUUIDError.raise(uuid) if M::InstanceSpec[uuid].nil?
  super(M::InstanceSpec, uuid)
end

#modify(uuid) ⇒ Object



36
37
38
39
40
41
# File 'lib/dcmgr/cli/spec.rb', line 36

def modify(uuid)
  UnknownUUIDError.raise(options[:account_id]) if options[:account_id] && M::Account[options[:account_id]].nil?
  UnsupportedArchError.raise(options[:arch]) unless options[:arch].nil? || M::HostPool::SUPPORTED_ARCH.member?(options[:arch])
  UnsupportedHypervisorError.raise(options[:hypervisor]) unless options[:hypervisor].nil? || M::HostPool::SUPPORTED_HYPERVISOR.member?(options[:hypervisor])
  super(M::InstanceSpec,uuid,options)
end

#show(uuid = nil) ⇒ Object



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
76
77
78
79
80
# File 'lib/dcmgr/cli/spec.rb', line 50

def show(uuid=nil)
  if uuid
    spec = M::InstanceSpec[uuid]
    print ERB.new(<<__END, nil, '-').result(binding)
UUID:
  <%= spec.canonical_uuid %>
Account ID:
  <%= spec.account_id %>
Hypervisor:
  <%= spec.hypervisor %>
Arch:
  <%= spec.arch %>
CPU Cores:
  <%= spec.cpu_cores %>
Memory Size:
  <%= spec.memory_size %>
Quota Weight:
  <%= spec.quota_weight %>
Hypervisor Configuration:
  <%= spec.config.inspect %>
__END
  else
    cond = {}
    specs = M::InstanceSpec.filter(cond).all
    print ERB.new(<<__END, nil, '-').result(binding)
<%- specs.each { |row| -%>
<%= "%-20s  %-15s %-15s" % [row.canonical_uuid, row.account_id, row.arch] %>
<%- } -%>
__END
  end
end