1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[stormondemand|compute] Add Firewall Ruleset APIs

This commit is contained in:
Eric Wong 2013-05-22 15:00:55 +08:00
parent 186c8f4c43
commit 109e1cd473
7 changed files with 126 additions and 0 deletions

View file

@ -26,6 +26,8 @@ module Fog
collection :private_ips
model :firewall
collection :firewalls
model :ruleset
collection :rulesets
model :stat
collection :stats
model :template
@ -94,6 +96,11 @@ module Fog
request :get_firewall_rules
request :update_firewall
request :create_ruleset
request :get_ruleset
request :list_rulesets
request :update_ruleset
class Mock
def self.data

View file

@ -0,0 +1,27 @@
require 'fog/core/model'
module Fog
module Compute
class StormOnDemand
class Ruleset < Fog::Model
attribute :accnt
attribute :destination_ip
attribute :rules
attribute :ruleset
attribute :uniq_id
def initialize(attributes={})
super
end
def update(rules)
requires :ruleset
service.update_ruleset(:ruleset => ruleset, :rules => rules)
true
end
end
end
end
end

View file

@ -0,0 +1,28 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/ruleset'
module Fog
module Compute
class StormOnDemand
class Rulesets < Fog::Collection
model Fog::Compute::StormOnDemand::Ruleset
def create(name, server_id)
r = service.create_ruleset(:name => name, :uniq_id => server_id).body
new(r)
end
def get(ruleset)
r = service.get_ruleset(:ruleset => ruleset).body
new(r)
end
def all(options={})
r = service.list_rulesets(options).body[:item]
load(r)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def create_ruleset(options={})
request(
:path => '/Network/Firewall/Ruleset/create',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def get_ruleset(options={})
request(
:path => '/Network/Firewall/Ruleset/details',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def list_rulesets(options={})
request(
:path => '/Network/Firewall/Ruleset/list',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def update_ruleset(options={})
request(
:path => '/Network/Firewall/Ruleset/update',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end