2011-09-23 11:15:01 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Brightbox
|
|
|
|
|
|
|
|
class FirewallRule < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
attribute :url
|
|
|
|
attribute :resource_type
|
|
|
|
|
|
|
|
attribute :description
|
|
|
|
|
|
|
|
attribute :source
|
|
|
|
attribute :source_port
|
|
|
|
attribute :destination
|
|
|
|
attribute :destination_port
|
|
|
|
attribute :protocol
|
|
|
|
attribute :icmp_type_name
|
2011-10-27 05:57:27 -04:00
|
|
|
attribute :created_at, :type => :time
|
2011-09-23 11:15:01 -04:00
|
|
|
|
|
|
|
attribute :firewall_policy_id, :aliases => "firewall_policy", :squash => "id"
|
|
|
|
|
|
|
|
# Sticking with existing Fog behaviour, save does not update but creates a new resource
|
|
|
|
def save
|
2012-12-22 21:45:05 -05:00
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
2011-10-27 09:28:03 -04:00
|
|
|
requires :firewall_policy_id
|
2011-09-23 11:15:01 -04:00
|
|
|
options = {
|
|
|
|
:firewall_policy => firewall_policy_id,
|
|
|
|
:protocol => protocol,
|
|
|
|
:description => description,
|
|
|
|
:source => source,
|
|
|
|
:source_port => source_port,
|
|
|
|
:destination => destination,
|
|
|
|
:destination_port => destination_port,
|
|
|
|
:icmp_type_name => icmp_type_name
|
|
|
|
}.delete_if {|k,v| v.nil? || v == "" }
|
2012-12-22 18:29:21 -05:00
|
|
|
data = service.create_firewall_rule(options)
|
2011-09-23 11:15:01 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :identity
|
2012-12-22 18:29:21 -05:00
|
|
|
service.destroy_firewall_rule(identity)
|
2011-09-23 11:15:01 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2011-10-27 05:57:27 -04:00
|
|
|
end
|