Class: Fog::Compute::Cloudstack::SecurityGroupRule

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

Instance Method Summary collapse

Instance Method Details

#destroyObject



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

def destroy
  data = service.send("revoke_security_group_#{self.direction}", "id" => self.id)
  job = service.jobs.new(data["revokesecuritygroup#{self.direction}"])
  job.wait_for { ready? }
  job.successful?
end

#port_rangeObject



21
22
23
# File 'lib/fog/cloudstack/models/compute/security_group_rule.rb', line 21

def port_range
  (self.start_port..self.end_port)
end

#reloadObject



40
41
42
43
44
# File 'lib/fog/cloudstack/models/compute/security_group_rule.rb', line 40

def reload
  requires :id, :security_group_id, :cidr

  merge_attributes(security_group.rules.get(self.id))
end

#saveObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/cloudstack/models/compute/security_group_rule.rb', line 25

def save
  requires :security_group_id, :cidr, :direction

  data = service.send("authorize_security_group_#{self.direction}".to_sym, params)
  job = service.jobs.new(data["authorizesecuritygroup#{self.direction}response"])
  job.wait_for { ready? }
  # durty
  merge_attributes(job.result.send("#{self.direction}_rules").last)
  self
end

#security_groupObject



36
37
38
# File 'lib/fog/cloudstack/models/compute/security_group_rule.rb', line 36

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