2011-09-23 11:15:01 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Brightbox
|
|
|
|
|
|
|
|
class FirewallPolicy < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
attribute :url
|
|
|
|
attribute :resource_type
|
|
|
|
|
|
|
|
attribute :name
|
|
|
|
attribute :description
|
|
|
|
|
|
|
|
attribute :default
|
|
|
|
|
|
|
|
attribute :server_group_id, :aliases => "server_group", :squash => "id"
|
2011-10-27 05:57:27 -04:00
|
|
|
attribute :created_at, :type => :time
|
2011-09-23 11:15:01 -04:00
|
|
|
attribute :rules
|
|
|
|
|
|
|
|
# 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-09-23 11:15:01 -04:00
|
|
|
options = {
|
|
|
|
:server_group => server_group_id,
|
|
|
|
:name => name,
|
|
|
|
:description => description
|
2013-11-27 12:16:07 -05:00
|
|
|
}.delete_if { |k, v| v.nil? || v == "" }
|
2012-12-22 18:29:21 -05:00
|
|
|
data = service.create_firewall_policy(options)
|
2011-09-23 11:15:01 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def apply_to(server_group_id)
|
2011-10-06 05:33:44 -04:00
|
|
|
requires :identity
|
2011-09-23 11:15:01 -04:00
|
|
|
options = {
|
|
|
|
:server_group => server_group_id
|
|
|
|
}
|
2012-12-22 18:29:21 -05:00
|
|
|
data = service.apply_to_firewall_policy(identity, options)
|
2011-09-23 11:15:01 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2011-10-20 08:14:21 -04:00
|
|
|
def remove(server_group_id)
|
|
|
|
requires :identity
|
|
|
|
options = {
|
|
|
|
:server_group => server_group_id
|
|
|
|
}
|
2012-12-22 18:29:21 -05:00
|
|
|
data = service.remove_firewall_policy(identity, options)
|
2011-10-20 08:14:21 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2011-09-23 11:15:01 -04:00
|
|
|
def destroy
|
|
|
|
requires :identity
|
2013-11-27 12:16:07 -05:00
|
|
|
service.destroy_firewall_policy(identity)
|
2011-09-23 11:15:01 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-10-20 08:14:21 -04:00
|
|
|
end
|