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



74
75
76
77
# File 'lib/dcmgr/cli/image.rb', line 74

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

#features(uuid) ⇒ Object



116
117
118
119
120
121
122
123
124
# File 'lib/dcmgr/cli/image.rb', line 116

def features(uuid)
  img = M::Image[uuid]
  UnknownUUIDError.raise(uuid) if img.nil?

  if options[:virtio]
    img.set_feature(:virtio, options[:virtio])
  end
  img.save_changes
end

#modify(uuid) ⇒ Object



68
69
70
71
# File 'lib/dcmgr/cli/image.rb', line 68

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

#show(uuid = nil) ⇒ Object



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
107
108
109
110
111
112
# File 'lib/dcmgr/cli/image.rb', line 80

def show(uuid=nil)
  if uuid
    img = M::Image[uuid] || UnknownUUIDError.raise(uuid)
    print ERB.new(<<__END, nil, '-').result(binding)
UUID:
  <%= img.canonical_uuid %>
Boot Type:
  <%= img.boot_dev_type == M::Image::BOOT_DEV_LOCAL ? 'local' : 'volume'%>
Arch:
  <%= img.arch %>
<%- if img.description -%>
MD5 Sum:
  <%= img.md5sum %>
Description:
  <%= img.description %>
<%- end -%>
Is Public:
  <%= img.is_public %>
State:
  <%= img.state %>
Features:
<%= img.features %>
__END
  else
    cond = {}
    imgs = M::Image.filter(cond).all
    print ERB.new(<<__END, nil, '-').result(binding)
<%- imgs.each { |row| -%>
<%= row.canonical_uuid %>\t<%= row.boot_dev_type == M::Image::BOOT_DEV_LOCAL ? 'local' : 'volume'%>\t<%= row.arch %>
<%- } -%>
__END
  end
end