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

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

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object



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

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



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

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

#get(rule_id) ⇒ Object



29
30
31
# File 'lib/fog/cloudstack/models/compute/security_group_rules.rb', line 29

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

#security_groupObject



12
13
14
# File 'lib/fog/cloudstack/models/compute/security_group_rules.rb', line 12

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