Method: Deltacloud::Drivers::Eucalyptus::EucalyptusDriver#create_firewall_rule

Defined in:
lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb

#create_firewall_rule(credentials, opts = {}) ⇒ Object

if the rule specifies a source group, port&protocol will be ignored. And source group and cidr range can’t be mixed in a request



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb', line 149

def create_firewall_rule(credentials, opts={})
# only either source groups or cidr IP range can be given, not both;
  if !(opts['groups'].nil?) && opts['groups'].length>0
    ec2 = new_client(credentials)
    opts['groups'].each do |group,owner|
      safely do
        ec2.authorize_security_group_named_ingress(opts['id'], owner, group)
      end
    end
  elsif !(opts['addresses'].nil?) && opts['addresses'].length>0
    ec2 = new_client(credentials)
    opts['addresses'].each do |ip|
      ec2.authorize_security_group_IP_ingress(opts['id'], opts['port_from'], opts['port_to'], opts['protocol'], ip)
    end
  end
end