Class: CloudstackSpec::Resource::VpcTier

Inherits:
Base
  • Object
show all
Defined in:
lib/cloudstack_spec/resource/vpc_tier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#get_zone, #inspect, #job_status?, #to_ary, #to_s

Constructor Details

#initialize(name = 'tier11', zonename = nil) ⇒ VpcTier

Returns a new instance of VpcTier.



5
6
7
8
9
10
# File 'lib/cloudstack_spec/resource/vpc_tier.rb', line 5

def initialize(name='tier11', zonename=nil)
  @name   = name
  @connection = CloudstackSpec::Helper::Api.new.connection
  @zone = get_zone(zonename)
  @runner = Specinfra::Runner
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/cloudstack_spec/resource/vpc_tier.rb', line 3

def name
  @name
end

Instance Method Details

#created?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cloudstack_spec/resource/vpc_tier.rb', line 24

def created?
  unless self.exist?
    @connection.create_network(
                :name => @name, 
                :displaytext => @name, 
                :networkofferingid => get_offering_id, 
                :zoneid => @zone['id'],
                :vpcid => $vpc['id'],
                :gateway => '10.10.0.1',
                :netmask => '255.255.255.0',
                :aclid => get_acl_id
               )
  else
    print "  already exist"
    return true
    #return false
  end
end

#destroy?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
51
52
# File 'lib/cloudstack_spec/resource/vpc_tier.rb', line 43

def destroy?
  if self.exist?
    sleep(5)
    job = @connection.delete_network(id: get_tier['id'])
    job_status?(job['jobid'])
  else
    puts "  Does not exist"
    return false
  end
end

#exist?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cloudstack_spec/resource/vpc_tier.rb', line 12

def exist?
  begin  
    if !get_tier.empty?
      return true
    else
      return false
    end
  rescue Exception => e
    return false
  end
end