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 APIs

This commit is contained in:
Eric Wong 2013-05-22 11:21:35 +08:00
parent 128f819896
commit 186c8f4c43
7 changed files with 123 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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