Class: Fog::Compute::OpenStack::SecurityGroup

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/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

#create_security_group_rule(min, max, ip_protocol = "tcp", cidr = "0.0.0.0/0", group_id = nil) ⇒ Object



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

def create_security_group_rule(min, max, ip_protocol = "tcp", cidr = "0.0.0.0/0", group_id = nil)
  Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.')
  requires :id
  service.create_security_group_rule(id, ip_protocol, min, max, cidr, group_id)
end

#delete_security_group_rule(rule_id) ⇒ Object



50
51
52
53
54
# File 'lib/fog/openstack/models/compute/security_group.rb', line 50

def delete_security_group_rule(rule_id)
  Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRule objects to destroy rules.')
  service.delete_security_group_rule(rule_id)
  true
end

#destroyObject



38
39
40
41
42
# File 'lib/fog/openstack/models/compute/security_group.rb', line 38

def destroy
  requires :id
  service.delete_security_group(id)
  true
end

#rulesObject



19
20
21
22
# File 'lib/fog/openstack/models/compute/security_group.rb', line 19

def rules
  Fog::Logger.deprecation('#rules is deprecated. Use #security_group_rules instead')
  attributes[:security_group_rules]
end

#rules=(new_rules) ⇒ Object

no one should be calling this because it doesn’t do anything useful but we deprecated the rules attribute and need to maintain the API



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

def rules=(new_rules)
  Fog::Logger.deprecation('#rules= is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.')
  attributes[:security_group_rules] = new_rules
end

#saveObject



31
32
33
34
35
36
# File 'lib/fog/openstack/models/compute/security_group.rb', line 31

def save
  requires :name, :description
  data = service.create_security_group(name, description)
  merge_attributes(data.body['security_group'])
  true
end

#security_group_rulesObject



15
16
17
# File 'lib/fog/openstack/models/compute/security_group.rb', line 15

def security_group_rules
  Fog::Compute::OpenStack::SecurityGroupRules.new(:service => service).load(attributes[:security_group_rules])
end