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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

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 Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #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/rackspace-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
  connection.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/rackspace-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/rackspace-fog/hp/models/compute/security_group.rb', line 36

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

#destroyObject



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

def destroy
  requires :id

  connection.delete_security_group(id)
  true
end

#saveObject



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

def save
  requires :name, :description

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