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

[stormondemand|compute] Add Network IP APIs

This commit is contained in:
Eric Wong 2013-05-22 10:57:14 +08:00
parent 3d470a210a
commit 128f819896
10 changed files with 195 additions and 2 deletions

View file

@ -20,6 +20,8 @@ module Fog
collection :servers
model :balancer
collection :balancers
model :network_ip
collection :network_ips
model :private_ip
collection :private_ips
model :stat
@ -77,6 +79,14 @@ module Fog
request :detach_server_from_private_ip
request :check_server_attached
request :add_ip_to_server
request :get_ip_details
request :list_network_ips
request :list_ip_public_accounts
request :list_network_public_ips
request :remove_ip_from_server
request :request_new_ips
class Mock
def self.data

View file

@ -0,0 +1,23 @@
require 'fog/code/model'
module Fog
module Compute
class StormOnDemand
class NetworkIP < Fog::model
identity :id
attribute :broadcast
attribute :gateway
attribute :ip
attribute :netmask
attribute :reverse_dns
def initialize(attributes={})
super
end
end
end
end
end

View file

@ -0,0 +1,48 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/network_ip'
module Fog
module Compute
class StormOnDemand
class NetworkIPs < Fog::Collection
model Fog::Compute::StormOnDemand::NetworkIP
def add(options)
service.add_ip_to_server(options)
true
end
def get(server_id, ip)
data = service.get_ip_details(:uniq_id => server_id, :ip => ip).body
new(data)
end
def all(options={})
data = service.list_network_ips(options).body[:items]
load(data)
end
def get_public_accounts(options={})
service.list_ip_public_accounts(options).body[:items]
end
def all_public(options={})
data = service.list_network_public_ips(options).body[:items]
load(data)
end
def remove(options)
service.remove_ip_from_server(options)
true
end
def request_new_ips(options)
service.request_new_ips(options)
true
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def add_ip_to_server(options={})
request(
:path => '/Network/IP/add',
: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_ip_details(options={})
request(
:path => '/Network/IP/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 list_ip_public_accounts(options={})
request(
:path => '/Network/IP/listAccntPublic',
: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_network_ips(options={})
request(
:path => '/Network/IP/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 list_network_public_ips(options={})
request(
:path => '/Network/IP/listPublic',
: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 remove_ip_from_server(options={})
request(
:path => '/Network/IP/remove',
: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 request_new_ips(options={})
request(
:path => '/Network/IP/request',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end