Class: Dcmgr::Cli::Image

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

Defined Under Namespace

Classes: AddOperation

Constant Summary collapse

M =
Dcmgr::Models

Instance Method Summary collapse

Instance Method Details

#del(image_id) ⇒ Object



72
73
74
75
# File 'lib/dcmgr/cli/image.rb', line 72

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

#modify(uuid) ⇒ Object



66
67
68
69
# File 'lib/dcmgr/cli/image.rb', line 66

def modify(uuid)
  #TODO: Check if state is valid here too
  super(M::Image,uuid,options)
end

#show(uuid = nil) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/dcmgr/cli/image.rb', line 78

def show(uuid=nil)
  if uuid
    img = M::Image[uuid]
    print ERB.new("UUID:\n  <%= img.canonical_uuid %>\nBoot Type:\n  <%= img.boot_dev_type %>\nArch:\n  <%= img.arch %>\n<%- if img.description -%>\nDescription:\n  <%= img.description %>\n<%- end -%>\nIs Public:\n  <%= img.is_public %>\nState:\n  <%= img.state %>\n", nil, '-').result(binding)
  else
    cond = {}
    imgs = M::Image.filter(cond).all
    print ERB.new("<%- imgs.each { |row| -%>\n<%= \"%-20s  %-15s %-15s\" % [row.canonical_uuid, row.boot_dev_type, row.arch] %>\n<%- } -%>\n", nil, '-').result(binding)
  end
end