Class: Fog::Compute::Cloudstack::SecurityGroup

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

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



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

def destroy
  requires :id
  service.delete_security_group('id' => self.id)
  true
end

#egress_rulesObject



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

def egress_rules
  attributes[:egress_rules] || []
end

#ingress_rulesObject



26
27
28
# File 'lib/fog/cloudstack/models/compute/security_group.rb', line 26

def ingress_rules
  attributes[:ingress_rules] || []
end

#rulesObject



44
45
46
# File 'lib/fog/cloudstack/models/compute/security_group.rb', line 44

def rules
  service.security_group_rules.all("security_group_id" => self.id)
end

#saveObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/cloudstack/models/compute/security_group.rb', line 30

def save
  requires :name

  options = {
    'name'        => self.name,
    'account'     => self.,
    'description' => self.description,
    'projectid'   => self.project_id,
    'domainid'    => self.domain_id,
  }
  data = service.create_security_group(options)
  merge_attributes(data['createsecuritygroupresponse']['securitygroup'])
end