Class: Oc::Run::Images
- Inherits:
-
Base
- Object
- Base
- Oc::Run::Images
show all
- Defined in:
- lib/system/run/commands/images.rb
Instance Attribute Summary
Attributes inherited from Base
#config, #options
Instance Method Summary
collapse
Methods inherited from Base
description, example, get_object_name, meta, method_added, option, options, summary, syntax
Instance Method Details
#destroy(*args) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/system/run/commands/images.rb', line 76
def destroy(*args)
id = args[0]
if id.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc images destroy [IMAGE_ID]".yellow
else
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
result = barge.image.destroy(id)
if !result.success?
puts "#{result.message}".red
else
puts "Image destroyed".green
end
end
end
|
#run(*args) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/system/run/commands/images.rb', line 6
def run(*args)
result = barge.image.all
if !result.success?
puts "Error: Please check your information".red
else
puts "Images".yellow
rows = []
rows << [
'ID',
'Name',
'Distribution',
'Public',
'Regions'
]
result.images.each do |image|
rows << [
image.id,
image.name.to_s.red,
image.distribution.to_s.red,
image.public.to_s == "true" ? "True".green : "False".red,
image.regions.join(",").yellow
]
end
table = Terminal::Table.new :rows => rows
puts table
end
end
|
#show(*args) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/system/run/commands/images.rb', line 36
def show(*args)
id = args[0]
if id.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc images show [IMAGE_ID]".yellow
else
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
result = barge.image.show(id)
if !result.success?
puts "#{result.message}".red
else
puts "Images".yellow
rows = []
rows << [
'ID',
'Name',
'Distribution',
'Public',
'Regions'
]
image = result.image
rows << [
image.id,
image.name.to_s.red,
image.distribution.to_s.red,
image.public.to_s == "true" ? "True".green : "False".red,
image.regions.join(",").yellow
]
table = Terminal::Table.new :rows => rows
puts table
end
end
end
|
#transfer(*args) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/system/run/commands/images.rb', line 95
def transfer(*args)
id = args[0]
region_id = args[1]
if id.nil? or region_id.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc images transfer [IMAGE_ID] [REGION_ID]".yellow
else
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
raise ArgumentError, "Argument Error - #{region_id}" unless region_id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
result = barge.image.transfer(id, region: region_id)
if !result.success?
puts "#{result.message}".red
else
puts "Image transfered".green
end
end
end
|
#update(*args) ⇒ Object
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/system/run/commands/images.rb', line 116
def update(*args)
id = args[0]
name = args[1]
if id.nil? or name.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc images transfer [IMAGE_ID] [NAME]".yellow
else
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
result = barge.image.update(id, {:name => name})
if !result.success?
puts "#{result.message}".red
else
puts "Image updated".green
end
end
end
|