Class: Fog::Compute::HP::SecurityGroup

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/hp/models/compute/security_group.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#create_rule(range, ip_protocol = "tcp", cidr = "0.0.0.0/0", group_id = nil) ⇒ Object



31
32
33
34
# File 'lib/fog/hp/models/compute/security_group.rb', line 31

def create_rule(range, ip_protocol = "tcp", cidr = "0.0.0.0/0", group_id=nil)
  requires :id
  service.create_security_group_rule(id, ip_protocol, range.min, range.max, cidr, group_id)
end

#delete_all_rulesObject



41
42
43
44
45
46
# File 'lib/fog/hp/models/compute/security_group.rb', line 41

def delete_all_rules()
  self.rules.each do |rule|
    delete_rule(rule['id'])
  end
  true
end

#delete_rule(rule_id) ⇒ Object



36
37
38
39
# File 'lib/fog/hp/models/compute/security_group.rb', line 36

def delete_rule(rule_id)
  service.delete_security_group_rule(rule_id)
  true
end

#destroyObject



16
17
18
19
20
21
# File 'lib/fog/hp/models/compute/security_group.rb', line 16

def destroy
  requires :id

  service.delete_security_group(id)
  true
end

#saveObject



23
24
25
26
27
28
29
# File 'lib/fog/hp/models/compute/security_group.rb', line 23

def save
  requires :name, :description

  data = service.create_security_group(name, description)
  merge_attributes(data.body['security_group'])
  true
end