Add and remove rules in a Security group
Example for adding and removing rules in a Security Group.
Adding Rules
=begin
@author Ryan Tiffany
=end
require 'softlayer_api'
require 'pp'
client = SoftLayer::Client.new(:timeout => 120)
secGroupId = 84301
# Create an object template to create the item.
objectTemplate = {
'direction' => 'ingress',
'protocol' => 'tcp',
'portRangeMin' => 22,
'portRangeMax' => 22,
'ethertype' => 'IPv4',
'remoteIp' => '0.0.0.0/0'
}
newRules = client['SoftLayer_Network_SecurityGroup'].object_with_id(secGroupId).addRules([objectTemplate])
pp newRules
Removing rules
=begin
@author Ryan Tiffany
=end
require 'softlayer_api'
require 'pp'
client = SoftLayer::Client.new(:timeout => 120)
secGroupId = 45101
# Create an object template to create the item.
objectTemplate = [ 48501, 48401 ]
remove = client['SoftLayer_Network_SecurityGroup'].object_with_id(secGroupId).removeRules(objectTemplate)
pp remove