Class: Fog::Compute::Cloudstack::SecurityGroupRules

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/cloudstack/models/compute/security_group_rules.rb

Instance Attribute Summary

Attributes inherited from Fog::Collection

#service

Instance Method Summary collapse

Methods inherited from Fog::Collection

#clear, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

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::Collection

Instance Method Details

#all(options = {}) ⇒ Object



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

def all(options={})
  merge_attributes(options)
  security_group = self.security_group
  rules = security_group.ingress_rules.map{|r| r.merge("direction" => "ingress", "security_group_id" => security_group_id)}
  rules += security_group.egress_rules.map{|r| r.merge("direction" => "egress", "security_group_id" => security_group_id)}
  load(rules)
end

#create(attributes) ⇒ Object



18
19
20
21
# File 'lib/fog/cloudstack/models/compute/security_group_rules.rb', line 18

def create(attributes)
  model = self.new(attributes.merge(:security_group_id => self.security_group_id))
  model.save
end

#get(rule_id) ⇒ Object



31
32
33
# File 'lib/fog/cloudstack/models/compute/security_group_rules.rb', line 31

def get(rule_id)
  all.find{|r| r.id == rule_id}
end

#security_groupObject



14
15
16
# File 'lib/fog/cloudstack/models/compute/security_group_rules.rb', line 14

def security_group
  service.security_groups.get(self.security_group_id)
end