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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #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

#destroyObject



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

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



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

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

#reloadObject



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

def reload
  requires :id, :security_group_id, :cidr

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

#saveObject



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

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



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

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