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

[stormondemand|network] Add a new Network service and move all network code in Compute into Network

This commit is contained in:
Eric Wong 2013-05-25 17:29:10 +08:00
parent 80690e700e
commit 966e2454ee
58 changed files with 187 additions and 131 deletions

View file

@ -9,7 +9,10 @@ module Fog
attributes = attributes.dup # Prevent delete from having side effects
provider = attributes.delete(:provider).to_s.downcase.to_sym
if self.providers.include?(provider)
if provider == :stormondemand
require "fog/storm_on_demand/network"
return Fog::Network::StormOnDemand.new(attributes)
elsif self.providers.include?(provider)
require "fog/#{provider}/network"
return Fog::Network.const_get(Fog.providers[provider]).new(attributes)
end

View file

@ -6,6 +6,7 @@ module Fog
extend Fog::Provider
service(:compute, 'storm_on_demand/compute', 'Compute')
service(:network, 'storm_on_demand/network', 'Network')
service(:storage, 'storm_on_demand/storage', 'Storage')
service(:dns, 'storm_on_demand/dns', 'DNS')
service(:billing, 'storm_on_demand/billing', 'Billing')

View file

@ -16,20 +16,6 @@ module Fog
collection :images
model :server
collection :servers
model :balancer
collection :balancers
model :network_ip
collection :network_ips
model :private_ip
collection :private_ips
model :firewall
collection :firewalls
model :ruleset
collection :rulesets
model :pool
collection :pools
model :zone
collection :zones
model :template
collection :templates
model :product
@ -51,19 +37,6 @@ module Fog
request :server_status
request :update_server
request :remove_balancer_node
request :add_balancer_node
request :add_balancer_service
request :remove_balancer_service
request :check_balancer_available
request :create_balancer
request :delete_balancer
request :update_balancer
request :get_balancer_details
request :list_balancers
request :get_balancer_possible_nodes
request :get_balancer_strategies
request :list_configs
request :get_config_details
@ -77,40 +50,6 @@ module Fog
request :get_image_details
request :update_image
request :restore_image
request :list_private_ips
request :get_private_ip
request :attach_server_to_private_ip
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
request :get_firewall
request :get_firewall_basic_options
request :get_firewall_rules
request :update_firewall
request :create_ruleset
request :get_ruleset
request :list_rulesets
request :update_ruleset
request :create_pool
request :delete_pool
request :get_pool
request :get_assignments
request :update_pool
request :get_zone
request :list_zones
request :set_default_zone
request :get_product
request :get_product_code

View file

@ -1,7 +1,7 @@
require 'fog/core/model'
module Fog
module Compute
module Network
class StormOnDemand
class Balancer < Fog::Model

View file

@ -1,13 +1,13 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/balancer'
require 'fog/storm_on_demand/models/network/balancer'
module Fog
module Compute
module Network
class StormOnDemand
class Balancers < Fog::Collection
model Fog::Compute::StormOnDemand::Balancer
model Fog::Network::StormOnDemand::Balancer
def all(options={})
data = service.list_balancers(options).body['items']

View file

@ -1,7 +1,7 @@
require 'fog/core/model'
module Fog
module Compute
module Network
class StormOnDemand
class Firewall < Fog::Model

View file

@ -1,11 +1,11 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/firewall'
require 'fog/storm_on_demand/models/network/firewall'
module Fog
module Compute
module Network
class StormOnDemand
class Firewalls < Fog::Collection
model Fog::Compute::StormOnDemand::Firewall
model Fog::Network::StormOnDemand::Firewall
def get(server_id)
data = service.get_firewall(:uniq_id => server_id).body

View file

@ -1,7 +1,7 @@
require 'fog/core/model'
module Fog
module Compute
module Network
class StormOnDemand
class NetworkIP < Fog::Model

View file

@ -1,12 +1,12 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/network_ip'
require 'fog/storm_on_demand/models/network/network_ip'
module Fog
module Compute
module Network
class StormOnDemand
class NetworkIPs < Fog::Collection
model Fog::Compute::StormOnDemand::NetworkIP
model Fog::Network::StormOnDemand::NetworkIP
def add(options)
service.add_ip_to_server(options)

View file

@ -1,7 +1,7 @@
require 'fog/core/model'
module Fog
module Compute
module Network
class StormOnDemand
class Pool < Fog::Model

View file

@ -1,12 +1,12 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/pool'
require 'fog/storm_on_demand/models/network/pool'
module Fog
module Compute
module Network
class StormOnDemand
class Pools < Fog::Collection
model Fog::Compute::StormOnDemand::Pool
model Fog::Network::StormOnDemand::Pool
def create(options)
p = service.create_pool(options).body

View file

@ -1,7 +1,7 @@
require 'fog/core/model'
module Fog
module Compute
module Network
class StormOnDemand
class PrivateIp < Fog::Model

View file

@ -1,13 +1,13 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/private_ip'
require 'fog/storm_on_demand/models/network/private_ip'
module Fog
module Compute
module Network
class StormOnDemand
class PrivateIps < Fog::Collection
model Fog::Compute::StormOnDemand::PrivateIp
model Fog::Network::StormOnDemand::PrivateIp
def all
data = service.list_private_ips.body['networks']

View file

@ -1,7 +1,7 @@
require 'fog/core/model'
module Fog
module Compute
module Network
class StormOnDemand
class Ruleset < Fog::Model

View file

@ -1,11 +1,11 @@
require 'fog/core/collection'
require 'fog/storm_on_demand/models/compute/ruleset'
require 'fog/storm_on_demand/models/network/ruleset'
module Fog
module Compute
module Network
class StormOnDemand
class Rulesets < Fog::Collection
model Fog::Compute::StormOnDemand::Ruleset
model Fog::Network::StormOnDemand::Ruleset
def create(name, server_id)
r = service.create_ruleset(:name => name, :uniq_id => server_id).body

View file

@ -1,7 +1,7 @@
require "fog/core/model"
module Fog
module Compute
module Network
class StormOnDemand
class Zone < Fog::Model

View file

@ -1,12 +1,12 @@
require "fog/core/collection"
require "fog/storm_on_demand/models/compute/zone"
require "fog/storm_on_demand/models/network/zone"
module Fog
module Compute
module Network
class StormOnDemand
class Zones < Fog::Collection
model Fog::Compute::StormOnDemand::Zone
model Fog::Network::StormOnDemand::Zone
def get(zone_id)
z = service.get_zone(:id => zone_id).body

View file

@ -0,0 +1,113 @@
require 'fog/storm_on_demand'
require 'fog/storm_on_demand/shared'
require 'fog/network'
module Fog
module Network
class StormOnDemand < Fog::Service
requires :storm_on_demand_username, :storm_on_demand_password
recognizes :storm_on_demand_auth_url
model_path 'fog/storm_on_demand/models/network'
model :balancer
collection :balancers
model :network_ip
collection :network_ips
model :private_ip
collection :private_ips
model :firewall
collection :firewalls
model :ruleset
collection :rulesets
model :pool
collection :pools
model :zone
collection :zones
request_path 'fog/storm_on_demand/requests/network'
request :remove_balancer_node
request :add_balancer_node
request :add_balancer_service
request :remove_balancer_service
request :check_balancer_available
request :create_balancer
request :delete_balancer
request :update_balancer
request :get_balancer_details
request :list_balancers
request :get_balancer_possible_nodes
request :get_balancer_strategies
request :list_private_ips
request :get_private_ip
request :attach_server_to_private_ip
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
request :get_firewall
request :get_firewall_basic_options
request :get_firewall_rules
request :update_firewall
request :create_ruleset
request :get_ruleset
request :list_rulesets
request :update_ruleset
request :create_pool
request :delete_pool
request :get_pool
request :get_assignments
request :update_pool
request :get_zone
request :list_zones
request :set_default_zone
class Mock
def self.data
@data ||= Hash.new
end
def self.reset
@data = nil
end
def self.reset_data(keys=data.keys)
for key in [*keys]
data.delete(key)
end
end
def initialize(options={})
@storm_on_demand_username = options[:storm_on_demand_username]
end
def data
self.class.data[@storm_on_demand_username]
end
def reset_data
self.class.data.delete(@storm_on_demand_username)
end
end
class Real
include Fog::StormOnDemand::RealShared
end
end
end
end

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,12 +1,12 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real
def list_balancers(options = {})
request(
:path => "/Network/LoadBalancer/list",
:body => Fog::JSON.encode(options)
:body => Fog::JSON.encode(:params => options)
)
end

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real

View file

@ -1,5 +1,5 @@
module Fog
module Compute
module Network
class StormOnDemand
class Real