Class: Dcmgr::Cli::Spec
Constant Summary collapse
Instance Method Summary collapse
-
#add ⇒ Object
method_option :is_public, :type => :boolean, :aliases => “-p”, :default => false, :desc => “A flag that determines whether the new machine image is public or not.”.
- #del(uuid) ⇒ Object
- #modify(uuid) ⇒ Object
- #show(uuid = nil) ⇒ Object
Instance Method Details
#add ⇒ Object
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([:account_id]) if M::Account[[:account_id]].nil? UnsupportedArchError.raise([:arch]) unless M::HostPool::SUPPORTED_ARCH.member?([:arch]) UnsupportedHypervisorError.raise([:hypervisor]) unless M::HostPool::SUPPORTED_HYPERVISOR.member?([:hypervisor]) fields = .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([:account_id]) if [:account_id] && M::Account[[:account_id]].nil? UnsupportedArchError.raise([:arch]) unless [:arch].nil? || M::HostPool::SUPPORTED_ARCH.member?([:arch]) UnsupportedHypervisorError.raise([:hypervisor]) unless [:hypervisor].nil? || M::HostPool::SUPPORTED_HYPERVISOR.member?([:hypervisor]) super(M::InstanceSpec,uuid,) 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 |