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:
parent
3d470a210a
commit
128f819896
10 changed files with 195 additions and 2 deletions
|
@ -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
|
||||
|
@ -75,8 +77,16 @@ module Fog
|
|||
request :get_private_ip
|
||||
request :attach_server_to_private_ip
|
||||
request :detach_server_from_private_ip
|
||||
request :check_server_attached
|
||||
|
||||
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
|
||||
|
|
23
lib/fog/storm_on_demand/models/compute/network_ip.rb
Normal file
23
lib/fog/storm_on_demand/models/compute/network_ip.rb
Normal 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
|
48
lib/fog/storm_on_demand/models/compute/network_ips.rb
Normal file
48
lib/fog/storm_on_demand/models/compute/network_ips.rb
Normal 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
|
16
lib/fog/storm_on_demand/requests/compute/add_ip_to_server.rb
Normal file
16
lib/fog/storm_on_demand/requests/compute/add_ip_to_server.rb
Normal 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
|
16
lib/fog/storm_on_demand/requests/compute/get_ip_details.rb
Normal file
16
lib/fog/storm_on_demand/requests/compute/get_ip_details.rb
Normal 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
|
|
@ -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
|
16
lib/fog/storm_on_demand/requests/compute/list_network_ips.rb
Normal file
16
lib/fog/storm_on_demand/requests/compute/list_network_ips.rb
Normal 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
|
|
@ -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
|
|
@ -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
|
16
lib/fog/storm_on_demand/requests/compute/request_new_ips.rb
Normal file
16
lib/fog/storm_on_demand/requests/compute/request_new_ips.rb
Normal 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
|
Loading…
Add table
Reference in a new issue