class OpenStack::Nova::Compute::Rule
An OpenStack
Security Group Rule
Attributes¶ ↑
-
ip_protocol
- Protocol: tcp, udp or icmp -
from_port
- Initial port -
to_port
- Final port -
parent_group_id
- The security group this rule belongs to -
cidr
- A cidr
Public Instance Methods
icmp?()
click to toggle source
True if this rule refers to ICMP
# File lib/open_stack/nova/compute/security_group.rb, line 125 def icmp? ip_protocol == 'icmp' end
parent_group()
click to toggle source
Parent group for this rule
# File lib/open_stack/nova/compute/security_group.rb, line 118 def parent_group unless parent_group_id.nil? @parent_group ||= SecurityGroup.find(parent_group_id) end end
parent_group=(group)
click to toggle source
Set the parent security group (if the rule is not persisted)
Attributes¶ ↑
-
group
: An instance ofOpenStack::Nova::Compute::SecurityGroup
or a security group id
# File lib/open_stack/nova/compute/security_group.rb, line 110 def parent_group=(group) unless persisted? @parent_group = nil self.parent_group_id = group.is_a?(OpenStack::Nova::Compute::SecurityGroup) ? group.id : group end end
tcp?()
click to toggle source
True if this rule refers to TCP
# File lib/open_stack/nova/compute/security_group.rb, line 135 def tcp? ip_protocol == 'tcp' end
udp?()
click to toggle source
True if this rule refers to UDP
# File lib/open_stack/nova/compute/security_group.rb, line 130 def udp? ip_protocol == 'udp' end
Protected Instance Methods
initialize(attributes = {}, persisted = false)
click to toggle source
Calls superclass method
# File lib/open_stack/nova/compute/security_group.rb, line 79 def initialize(attributes = {}, persisted = false) # :notnew: attributes = attributes.with_indifferent_access new_attributes = { :id => attributes[:id], :ip_protocol => attributes[:ip_protocol], :from_port => attributes[:from_port], :to_port => attributes[:to_port], :cidr => attributes[:cidr] || (attributes[:ip_range].present? ? attributes[:ip_range][:cidr] : nil), :parent_group_id => attributes[:parent_group].present? ? attributes[:parent_group].id : nil } super(new_attributes, persisted) end