Class: CloudstackSpec::Resource::TemplateFromSnapshot
- Inherits:
-
Base
- Object
- Base
- CloudstackSpec::Resource::TemplateFromSnapshot
show all
- Defined in:
- lib/cloudstack_spec/resource/template_from_snapshot.rb
Instance Attribute Summary
Attributes inherited from Base
#name
Instance Method Summary
collapse
Methods inherited from Base
#get_zone, #initialize, #inspect, #job_status?, #to_ary, #to_s
Instance Method Details
#created? ⇒ Boolean
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/cloudstack_spec/resource/template_from_snapshot.rb', line 35
def created?
if self.exist?
return 'template already exist'
else
snapshot = get_snapshot
if ! snapshot.empty?
new_template = @connection.create_template(
name: @name,
displaytext: @name,
ostypeid: get_vm['ostypeid'],
passwordenabled: 'true',
snapshotid: get_snapshot['id']
)
creation_job = new_template['jobid']
end
end
end
|
#exist? ⇒ Boolean
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/cloudstack_spec/resource/template_from_snapshot.rb', line 9
def exist?
begin
if tpl['count'].nil?
return false
else
return true
end
rescue Exception => e
return false
end
end
|
#ready? ⇒ Boolean
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/cloudstack_spec/resource/template_from_snapshot.rb', line 21
def ready?
if ! tpl["count"].nil?
isready = tpl["template"].first["isready"]
if isready
return true
else
return tpl["template"].first["status"]
end
else
return "#{name}: not found"
end
end
|
#tpl ⇒ Object
5
6
7
|
# File 'lib/cloudstack_spec/resource/template_from_snapshot.rb', line 5
def tpl
@connection.list_templates(:templatefilter => "all", :name => name)
end
|