@@ -70,13 +70,78 @@ class VLANFirewall < SoftLayer::ModelBase
7070 # depending on the system load and other circumstances.
7171 def change_rules! ( rules_data )
7272 change_object = {
73- "firewallContextAccessControlListId" => self . id ,
73+ "firewallContextAccessControlListId" => rules_ACL_id ( ) ,
7474 "rules" => rules_data
7575 }
7676
7777 self . softlayer_client [ :Network_Firewall_Update_Request ] . createObject ( change_object )
7878 end
7979
80+ ##
81+ # This method asks the firewall to ignore its rule set and pass all traffic
82+ # through the firewall. Compare the behavior of this routine with
83+ # change_routing_bypass!
84+ #
85+ # It is important to note that changing the bypass to :bypass_firewall_rules
86+ # removes ALL the protection offered by the firewall. This routine should be
87+ # used with extreme discretion.
88+ #
89+ # Note that this routine queues a rule change and rule changes may take
90+ # time to process. The change will probably not take effect immediately
91+ #
92+ # The two symbols accepted as arguments by this routine are:
93+ # :apply_firewall_rules - The rules of the firewall are applied to traffic. This is the default operating mode of the firewall
94+ # :bypass_firewall_rules - The rules of the firewall are ignored. In this configuration the firewall provides no protection.
95+ #
96+ def change_rules_bypass! ( bypass_symbol )
97+ change_object = {
98+ "firewallContextAccessControlListId" => rules_ACL_id ( ) ,
99+ "rules" => self . rules
100+ }
101+
102+ case bypass_symbol
103+ when :apply_firewall_rules
104+ change_object [ 'bypassFlag' ] = false
105+ self . softlayer_client [ :Network_Firewall_Update_Request ] . createObject ( change_object )
106+ when :bypass_firewall_rules
107+ change_object [ 'bypassFlag' ] = true
108+ self . softlayer_client [ :Network_Firewall_Update_Request ] . createObject ( change_object )
109+ else
110+ raise ArgumentError , "An invalid parameter was sent to #{ __method__ } . It accepts :apply_firewall_rules and :bypass_firewall_rules"
111+ end
112+ end
113+
114+ ##
115+ # This method allows you to route traffic around the firewall
116+ # and directly to the servers it protects. Compare the behavior of this routine with
117+ # change_rules_bypass!
118+ #
119+ # It is important to note that changing the routing to :route_around_firewall
120+ # removes ALL the protection offered by the firewall. This routine should be
121+ # used with extreme discretion.
122+ #
123+ # Note that this routine constructs a transaction. The Routing change
124+ # may not happen immediately.
125+ #
126+ # The two symbols accepted as arguments by the routine are:
127+ # :route_through_firewall - Network traffic is sent through the firewall to the servers in the VLAN segment it protects. This is the usual operating mode of the firewall.
128+ # :route_around_firewall - Network traffic will be sent directly to the servers in the VLAN segment protected by this firewall. This means that the firewall will *NOT* be protecting those servers.
129+ #
130+ def change_routing_bypass! ( routing_symbol )
131+ vlan_firewall_id = self [ 'networkVlanFirewall' ] [ 'id' ]
132+
133+ raise "Could not identify the device for a VLAN firewall" if !vlan_firewall_id
134+
135+ case routing_symbol
136+ when :route_through_firewall
137+ self . softlayer_client [ :Network_Vlan_Firewall ] . object_with_id ( vlan_firewall_id ) . updateRouteBypass ( false )
138+ when :route_around_firewall
139+ self . softlayer_client [ :Network_Vlan_Firewall ] . object_with_id ( vlan_firewall_id ) . updateRouteBypass ( true )
140+ else
141+ raise ArgumentError , "An invalid parameter was sent to #{ __method__ } . It accepts :route_through_firewall and :route_around_firewall"
142+ end
143+ end
144+
80145 ##
81146 # Returns the name of the primary router the firewall is attached to.
82147 # This is often a "customer router" in one of the datacenters.
@@ -108,7 +173,7 @@ def high_availability?
108173 #
109174 # This list is obtained by asking the account for all the VLANs
110175 # it has that also have a networkVlanFirewall component.
111- def self . find_firewalls ( client )
176+ def self . find_firewalls ( client = nil )
112177 softlayer_client = client || Client . default_client
113178 raise "#{ __method__ } requires a client but none was given and Client::default_client is not set" if !softlayer_client
114179
@@ -117,8 +182,8 @@ def self.find_firewalls(client)
117182 filter . accept ( "networkVlans.networkVlanFirewall" ) . when_it is_not_null
118183 }
119184
120- vlan_firewalls = client [ :Account ] . object_mask ( vlan_firewall_mask ) . object_filter ( vlan_firewall_filter ) . getNetworkVlans
121- vlan_firewalls . collect { |firewall_data | SoftLayer ::VLANFirewall . new ( client , firewall_data ) }
185+ vlan_firewalls = softlayer_client [ :Account ] . object_mask ( vlan_firewall_mask ) . object_filter ( vlan_firewall_filter ) . getNetworkVlans
186+ vlan_firewalls . collect { |firewall_data | SoftLayer ::VLANFirewall . new ( softlayer_client , firewall_data ) }
122187 end
123188
124189
@@ -157,7 +222,7 @@ def rules_ACL_id
157222 end
158223
159224 def self . vlan_firewall_mask
160- return "mask[primaryRouter,highAvailabilityFirewallFlag," +
225+ return "mask[primaryRouter,highAvailabilityFirewallFlag," +
161226 "firewallInterfaces.firewallContextAccessControlLists," +
162227 "networkVlanFirewall[id, datacenter, primaryIpAddress, firewallType, fullyQualifiedDomainName]]"
163228 end
@@ -167,7 +232,16 @@ def self.default_rules_mask
167232 end
168233
169234 def self . default_rules_mask_keys
170- [ 'orderValue' , 'action' , 'destinationIpAddress' , 'destinationIpSubnetMask' , "protocol" , "destinationPortRangeStart" , "destinationPortRangeEnd" , 'sourceIpAddress' , "sourceIpSubnetMask" , "version" ]
235+ [ 'orderValue' ,
236+ 'action' ,
237+ 'destinationIpAddress' ,
238+ 'destinationIpSubnetMask' ,
239+ 'protocol' ,
240+ 'destinationPortRangeStart' ,
241+ 'destinationPortRangeEnd' ,
242+ 'sourceIpAddress' ,
243+ 'sourceIpSubnetMask' ,
244+ 'version' ]
171245 end
172246 end # class Firewall
173247end # module SoftLayer
0 commit comments