From 186c8f4c4306586638ce70a89e69d310e2dac20f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 22 May 2013 11:21:35 +0800 Subject: [PATCH] [stormondemand|compute] Add Firewall APIs --- lib/fog/storm_on_demand/compute.rb | 7 ++++ .../models/compute/firewall.rb | 20 ++++++++++++ .../models/compute/firewalls.rb | 32 +++++++++++++++++++ .../requests/compute/get_firewall.rb | 16 ++++++++++ .../compute/get_firewall_basic_options.rb | 16 ++++++++++ .../requests/compute/get_firewall_rules.rb | 16 ++++++++++ .../requests/compute/update_firewall.rb | 16 ++++++++++ 7 files changed, 123 insertions(+) create mode 100644 lib/fog/storm_on_demand/models/compute/firewall.rb create mode 100644 lib/fog/storm_on_demand/models/compute/firewalls.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/get_firewall.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/get_firewall_basic_options.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/get_firewall_rules.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/update_firewall.rb diff --git a/lib/fog/storm_on_demand/compute.rb b/lib/fog/storm_on_demand/compute.rb index c3420d3cc..2d08b3938 100644 --- a/lib/fog/storm_on_demand/compute.rb +++ b/lib/fog/storm_on_demand/compute.rb @@ -24,6 +24,8 @@ module Fog collection :network_ips model :private_ip collection :private_ips + model :firewall + collection :firewalls model :stat collection :stats model :template @@ -87,6 +89,11 @@ module Fog request :remove_ip_from_server request :request_new_ips + request :get_firewall + request :get_firewall_basic_options + request :get_firewall_rules + request :update_firewall + class Mock def self.data diff --git a/lib/fog/storm_on_demand/models/compute/firewall.rb b/lib/fog/storm_on_demand/models/compute/firewall.rb new file mode 100644 index 000000000..54a51213b --- /dev/null +++ b/lib/fog/storm_on_demand/models/compute/firewall.rb @@ -0,0 +1,20 @@ +require 'fog/core/model' + +module Fog + module Compute + class StormOnDemand + + class Firewall < Fog::Model + attribute :allow + attribute :rules + attribute :ruleset + attribute :type + + def initialize(attributes={}) + super + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/models/compute/firewalls.rb b/lib/fog/storm_on_demand/models/compute/firewalls.rb new file mode 100644 index 000000000..4a3101392 --- /dev/null +++ b/lib/fog/storm_on_demand/models/compute/firewalls.rb @@ -0,0 +1,32 @@ +require 'fog/core/collections' +require 'fog/storm_on_demand/models/compute/firewall' + +module Fog + module Compute + class StormOnDemand + class Firewalls < Fog::Collection + model Fog::Compute::StormOnDemand::Firewall + + def get(server_id) + data = service.get_firewall(:uniq_id => server_id).body + new(data) + end + + def basic_options(server_id) + res = service.get_firewall_basic_options(:uniq_id => server_id).body + res[:options] + end + + def rules(server_id) + service.get_firewall_rules(:uniq_id => server_id).body[:rules] + end + + def update(options) + service.update_firewall(options) + true + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_firewall.rb b/lib/fog/storm_on_demand/requests/compute/get_firewall.rb new file mode 100644 index 000000000..c4855a0a1 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_firewall.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_firewall(options={}) + request( + :path => '/Network/Firewall/details', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_firewall_basic_options.rb b/lib/fog/storm_on_demand/requests/compute/get_firewall_basic_options.rb new file mode 100644 index 000000000..c0cdd4bf3 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_firewall_basic_options.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_firewall_basic_options(options={}) + request( + :path => '/Network/Firewall/getBasicOptions', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_firewall_rules.rb b/lib/fog/storm_on_demand/requests/compute/get_firewall_rules.rb new file mode 100644 index 000000000..95fcf94b3 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_firewall_rules.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_firewall_rules(options={}) + request( + :path => '/Network/Firewall/rules', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/update_firewall.rb b/lib/fog/storm_on_demand/requests/compute/update_firewall.rb new file mode 100644 index 000000000..c245c538d --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/update_firewall.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def update_firewalls(options={}) + request( + :path => '/Network/Firewall/update', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end \ No newline at end of file