Class: CloudstackSpec::Resource::Domain
- Inherits:
-
Base
- Object
- Base
- CloudstackSpec::Resource::Domain
show all
- Defined in:
- lib/cloudstack_spec/resource/domain.rb
Instance Attribute Summary
Attributes inherited from Base
#name
Instance Method Summary
collapse
Methods inherited from Base
#get_zone, #inspect, #job_status?, #to_ary, #to_s
Constructor Details
#initialize(name = nil) ⇒ Domain
5
6
7
8
9
10
|
# File 'lib/cloudstack_spec/resource/domain.rb', line 5
def initialize(name=nil)
@name = name
@connection = CloudstackSpec::Helper::Api.new.connection
$domainid = domain_id
end
|
Instance Method Details
#created? ⇒ Boolean
24
25
26
27
28
29
30
31
32
|
# File 'lib/cloudstack_spec/resource/domain.rb', line 24
def created?
if self.exist?
puts " Domain already exist"
return true
else
domain = @connection.create_domain(name: @name)
$domainid = domain_id
end
end
|
#destroy? ⇒ Boolean
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/cloudstack_spec/resource/domain.rb', line 34
def destroy?
sleep(5)
if self.exist?
job = @connection.delete_domain(id: domain_id)
return job_status?(job['jobid'])
else
puts " Domain does not exist"
return false
end
end
|
#exist? ⇒ Boolean
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cloudstack_spec/resource/domain.rb', line 12
def exist?
begin
if domain.empty?
return false
else
return true
end
rescue Exception => e
return false
end
end
|