Class: HP::Cloud::SecurityGroupHelper

Inherits:
BaseHelper
  • Object
show all
Defined in:
lib/hpcloud/security_group_helper.rb

Instance Attribute Summary collapse

Attributes inherited from BaseHelper

#connection, #cstatus, #fog

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHelper

#destroy, #is_valid?, #set_error, #to_hash

Constructor Details

#initialize(connection, foggy = nil) ⇒ SecurityGroupHelper

Returns a new instance of SecurityGroupHelper.



31
32
33
34
35
36
37
38
# File 'lib/hpcloud/security_group_helper.rb', line 31

def initialize(connection, foggy = nil)
  super(connection, foggy)
  return if foggy.nil?
  @id = foggy.id
  @name = foggy.name
  @description = foggy.description
  @tenant_id = foggy.tenant_id
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



25
26
27
# File 'lib/hpcloud/security_group_helper.rb', line 25

def description
  @description
end

#idObject

Returns the value of attribute id.



25
26
27
# File 'lib/hpcloud/security_group_helper.rb', line 25

def id
  @id
end

#nameObject

Returns the value of attribute name.



25
26
27
# File 'lib/hpcloud/security_group_helper.rb', line 25

def name
  @name
end

Class Method Details

.get_keysObject



27
28
29
# File 'lib/hpcloud/security_group_helper.rb', line 27

def self.get_keys()
  return [ "id", "name", "description" ]
end

Instance Method Details

#saveObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/hpcloud/security_group_helper.rb', line 40

def save
  return false if is_valid? == false
  if @fog.nil?
    hsh = {:name => @name, :description => @description}
    security_group = @connection.network.security_groups.new(hsh)
    if security_group.nil?
      set_error("Error creating security group")
      return false
    end
    security_group.save
    @fog = security_group
    @id = security_group.id
    return true
  else
    raise "Update not implemented"
  end
end