зеркало из https://github.com/microsoft/fog.git
refactor/cleanup to use service
This commit is contained in:
Родитель
e4d13075fa
Коммит
936cfc0e95
|
@ -1,101 +1,65 @@
|
|||
module Fog
|
||||
module AWS
|
||||
module EC2
|
||||
extend Fog::Service
|
||||
|
||||
class Error < Fog::Errors::Error; end
|
||||
class NotFound < Fog::Errors::NotFound; end
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
|
||||
def self.new(options={})
|
||||
model_path 'fog/aws/models/ec2'
|
||||
model 'address'
|
||||
model 'addresses'
|
||||
model 'flavor'
|
||||
model 'flavors'
|
||||
model 'image'
|
||||
model 'images'
|
||||
model 'key_pair'
|
||||
model 'key_pairs'
|
||||
model 'security_group'
|
||||
model 'security_groups'
|
||||
model 'server'
|
||||
model 'servers'
|
||||
model 'snapshot'
|
||||
model 'snapshots'
|
||||
model 'volume'
|
||||
model 'volumes'
|
||||
|
||||
unless @required
|
||||
require 'fog/aws/models/ec2/address'
|
||||
require 'fog/aws/models/ec2/addresses'
|
||||
require 'fog/aws/models/ec2/flavor'
|
||||
require 'fog/aws/models/ec2/flavors'
|
||||
require 'fog/aws/models/ec2/image'
|
||||
require 'fog/aws/models/ec2/images'
|
||||
require 'fog/aws/models/ec2/key_pair'
|
||||
require 'fog/aws/models/ec2/key_pairs'
|
||||
require 'fog/aws/models/ec2/security_group'
|
||||
require 'fog/aws/models/ec2/security_groups'
|
||||
require 'fog/aws/models/ec2/server'
|
||||
require 'fog/aws/models/ec2/servers'
|
||||
require 'fog/aws/models/ec2/snapshot'
|
||||
require 'fog/aws/models/ec2/snapshots'
|
||||
require 'fog/aws/models/ec2/volume'
|
||||
require 'fog/aws/models/ec2/volumes'
|
||||
require 'fog/aws/parsers/ec2/allocate_address'
|
||||
require 'fog/aws/parsers/ec2/attach_volume'
|
||||
require 'fog/aws/parsers/ec2/basic'
|
||||
require 'fog/aws/parsers/ec2/create_key_pair'
|
||||
require 'fog/aws/parsers/ec2/create_snapshot'
|
||||
require 'fog/aws/parsers/ec2/create_volume'
|
||||
require 'fog/aws/parsers/ec2/describe_addresses'
|
||||
require 'fog/aws/parsers/ec2/describe_availability_zones'
|
||||
require 'fog/aws/parsers/ec2/describe_images'
|
||||
require 'fog/aws/parsers/ec2/describe_instances'
|
||||
require 'fog/aws/parsers/ec2/describe_key_pairs'
|
||||
require 'fog/aws/parsers/ec2/describe_regions'
|
||||
require 'fog/aws/parsers/ec2/describe_reserved_instances'
|
||||
require 'fog/aws/parsers/ec2/describe_security_groups'
|
||||
require 'fog/aws/parsers/ec2/describe_snapshots'
|
||||
require 'fog/aws/parsers/ec2/describe_volumes'
|
||||
require 'fog/aws/parsers/ec2/detach_volume'
|
||||
require 'fog/aws/parsers/ec2/get_console_output'
|
||||
require 'fog/aws/parsers/ec2/run_instances'
|
||||
require 'fog/aws/parsers/ec2/terminate_instances'
|
||||
require 'fog/aws/requests/ec2/allocate_address'
|
||||
require 'fog/aws/requests/ec2/associate_address'
|
||||
require 'fog/aws/requests/ec2/attach_volume'
|
||||
require 'fog/aws/requests/ec2/authorize_security_group_ingress'
|
||||
require 'fog/aws/requests/ec2/create_key_pair'
|
||||
require 'fog/aws/requests/ec2/create_security_group'
|
||||
require 'fog/aws/requests/ec2/create_snapshot'
|
||||
require 'fog/aws/requests/ec2/create_volume'
|
||||
require 'fog/aws/requests/ec2/delete_key_pair'
|
||||
require 'fog/aws/requests/ec2/delete_security_group'
|
||||
require 'fog/aws/requests/ec2/delete_snapshot'
|
||||
require 'fog/aws/requests/ec2/delete_volume'
|
||||
require 'fog/aws/requests/ec2/describe_addresses'
|
||||
require 'fog/aws/requests/ec2/describe_availability_zones'
|
||||
require 'fog/aws/requests/ec2/describe_images'
|
||||
require 'fog/aws/requests/ec2/describe_instances'
|
||||
require 'fog/aws/requests/ec2/describe_reserved_instances'
|
||||
require 'fog/aws/requests/ec2/describe_key_pairs'
|
||||
require 'fog/aws/requests/ec2/describe_regions'
|
||||
require 'fog/aws/requests/ec2/describe_security_groups'
|
||||
require 'fog/aws/requests/ec2/describe_snapshots'
|
||||
require 'fog/aws/requests/ec2/describe_volumes'
|
||||
require 'fog/aws/requests/ec2/detach_volume'
|
||||
require 'fog/aws/requests/ec2/disassociate_address'
|
||||
require 'fog/aws/requests/ec2/get_console_output'
|
||||
require 'fog/aws/requests/ec2/modify_image_attributes'
|
||||
require 'fog/aws/requests/ec2/reboot_instances'
|
||||
require 'fog/aws/requests/ec2/release_address'
|
||||
require 'fog/aws/requests/ec2/revoke_security_group_ingress'
|
||||
require 'fog/aws/requests/ec2/run_instances'
|
||||
require 'fog/aws/requests/ec2/terminate_instances'
|
||||
@required = true
|
||||
end
|
||||
require 'fog/aws/parsers/ec2/basic'
|
||||
|
||||
unless options[:aws_access_key_id]
|
||||
raise ArgumentError.new('aws_access_key_id is required to access ec2')
|
||||
end
|
||||
unless options[:aws_secret_access_key]
|
||||
raise ArgumentError.new('aws_secret_access_key is required to access ec2')
|
||||
end
|
||||
if Fog.mocking?
|
||||
Fog::AWS::EC2::Mock.new(options)
|
||||
else
|
||||
Fog::AWS::EC2::Real.new(options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset_data(keys=Mock.data.keys)
|
||||
Mock.reset_data(keys)
|
||||
end
|
||||
request_path 'fog/aws/requests/ec2'
|
||||
request 'allocate_address'
|
||||
request 'associate_address'
|
||||
request 'attach_volume'
|
||||
request 'authorize_security_group_ingress'
|
||||
request 'create_key_pair'
|
||||
request 'create_security_group'
|
||||
request 'create_snapshot'
|
||||
request 'create_volume'
|
||||
request 'delete_key_pair'
|
||||
request 'delete_security_group'
|
||||
request 'delete_snapshot'
|
||||
request 'delete_volume'
|
||||
request 'describe_addresses'
|
||||
request 'describe_availability_zones'
|
||||
request 'describe_images'
|
||||
request 'describe_instances'
|
||||
request 'describe_reserved_instances'
|
||||
request 'describe_key_pairs'
|
||||
request 'describe_regions'
|
||||
request 'describe_security_groups'
|
||||
request 'describe_snapshots'
|
||||
request 'describe_volumes'
|
||||
request 'detach_volume'
|
||||
request 'disassociate_address'
|
||||
request 'get_console_output'
|
||||
request 'modify_image_attributes'
|
||||
request 'reboot_instances'
|
||||
request 'release_address'
|
||||
request 'revoke_security_group_ingress'
|
||||
request 'run_instances'
|
||||
request 'terminate_instances'
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
|
@ -158,6 +122,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
# Initialize connection to EC2
|
||||
#
|
||||
|
|
|
@ -1,39 +1,31 @@
|
|||
module Fog
|
||||
module AWS
|
||||
module ELB
|
||||
extend Fog::Service
|
||||
|
||||
def self.new(options={})
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
|
||||
unless @required
|
||||
require 'fog/aws/parsers/elb/create_load_balancer'
|
||||
require 'fog/aws/parsers/elb/delete_load_balancer'
|
||||
require 'fog/aws/parsers/elb/deregister_instances_from_load_balancer'
|
||||
require 'fog/aws/parsers/elb/describe_instance_health'
|
||||
require 'fog/aws/parsers/elb/describe_load_balancers'
|
||||
require 'fog/aws/parsers/elb/disable_availability_zones_for_load_balancer'
|
||||
require 'fog/aws/parsers/elb/enable_availability_zones_for_load_balancer'
|
||||
require 'fog/aws/parsers/elb/register_instances_with_load_balancer'
|
||||
require 'fog/aws/requests/elb/create_load_balancer'
|
||||
require 'fog/aws/requests/elb/delete_load_balancer'
|
||||
require 'fog/aws/requests/elb/deregister_instances_from_load_balancer'
|
||||
require 'fog/aws/requests/elb/describe_instance_health'
|
||||
require 'fog/aws/requests/elb/describe_load_balancers'
|
||||
require 'fog/aws/requests/elb/disable_availability_zones_for_load_balancer'
|
||||
require 'fog/aws/requests/elb/enable_availability_zones_for_load_balancer'
|
||||
require 'fog/aws/requests/elb/register_instances_with_load_balancer'
|
||||
@required = true
|
||||
request_path 'fog/aws/requests/elb'
|
||||
request 'create_load_balancer'
|
||||
request 'delete_load_balancer'
|
||||
request 'deregister_instances_from_load_balancer'
|
||||
request 'describe_instance_health'
|
||||
request 'describe_load_balancers'
|
||||
request 'disable_availability_zones_for_load_balancer'
|
||||
request 'enable_availability_zones_for_load_balancer'
|
||||
request 'register_instances_with_load_balancer'
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def initialize(options={})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
unless options[:aws_access_key_id]
|
||||
raise ArgumentError.new('aws_access_key_id is required to access elb')
|
||||
end
|
||||
unless options[:aws_secret_access_key]
|
||||
raise ArgumentError.new('aws_secret_access_key is required to access elb')
|
||||
end
|
||||
Fog::AWS::ELB::Real.new(options)
|
||||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
# Initialize connection to ELB
|
||||
#
|
||||
|
|
|
@ -5,15 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def addresses(attributes = {})
|
||||
Fog::AWS::EC2::Addresses.new({
|
||||
:connection => self
|
||||
}.merge!(attributes))
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def addresses(attributes = {})
|
||||
Fog::AWS::EC2::Addresses.new({
|
||||
:connection => self
|
||||
|
|
|
@ -5,13 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def flavors
|
||||
Fog::AWS::EC2::Flavors.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def flavors
|
||||
Fog::AWS::EC2::Flavors.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -5,13 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def images
|
||||
Fog::AWS::EC2::Images.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def images
|
||||
Fog::AWS::EC2::Images.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -5,13 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def key_pairs
|
||||
Fog::AWS::EC2::KeyPairs.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def key_pairs
|
||||
Fog::AWS::EC2::KeyPairs.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -5,13 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def security_groups
|
||||
Fog::AWS::EC2::SecurityGroups.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def security_groups
|
||||
Fog::AWS::EC2::SecurityGroups.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -5,13 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def servers
|
||||
Fog::AWS::EC2::Servers.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def servers
|
||||
Fog::AWS::EC2::Servers.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -5,15 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def snapshots(attributes = {})
|
||||
Fog::AWS::EC2::Snapshots.new({
|
||||
:connection => self
|
||||
}.merge!(attributes))
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def snapshots(attributes = {})
|
||||
Fog::AWS::EC2::Snapshots.new({
|
||||
:connection => self
|
||||
|
|
|
@ -5,15 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Mock
|
||||
def volumes(attributes = {})
|
||||
Fog::AWS::EC2::Volumes.new({
|
||||
:connection => self
|
||||
}.merge!(attributes))
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def volumes(attributes = {})
|
||||
Fog::AWS::EC2::Volumes.new({
|
||||
:connection => self
|
||||
|
|
|
@ -5,13 +5,7 @@ module Fog
|
|||
module AWS
|
||||
module S3
|
||||
|
||||
class Real
|
||||
def directories
|
||||
Fog::AWS::S3::Directories.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
module Collections
|
||||
def directories
|
||||
Fog::AWS::S3::Directories.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/allocate_address'
|
||||
|
||||
# Acquire an elastic IP address.
|
||||
#
|
||||
# ==== Returns
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/attach_volume'
|
||||
|
||||
# Attach an Amazon EBS volume with a running instance, exposing as specified device
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/create_key_pair'
|
||||
|
||||
# Create a new key pair
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/create_snapshot'
|
||||
|
||||
# Create a snapshot of an EBS volume and store it in S3
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/create_volume'
|
||||
|
||||
# Create an EBS volume
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_addresses'
|
||||
|
||||
# Describe all or specified IP addresses.
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_availability_zones'
|
||||
|
||||
# Describe all or specified availability zones
|
||||
#
|
||||
# ==== Params
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_images'
|
||||
|
||||
# Describe all or specified images.
|
||||
#
|
||||
# ==== Params
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_instances'
|
||||
|
||||
# Describe all or specified instances
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_key_pairs'
|
||||
|
||||
# Describe all or specified key pairs
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_regions'
|
||||
|
||||
# Describe all or specified regions
|
||||
#
|
||||
# ==== Params
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_reserved_instances'
|
||||
|
||||
# Describe all or specified reserved instances
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_security_groups'
|
||||
|
||||
# Describe all or specified security groups
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_snapshots'
|
||||
|
||||
# Describe all or specified snapshots
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/describe_volumes'
|
||||
|
||||
# Describe all or specified volumes.
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/detach_volume'
|
||||
|
||||
# Detach an Amazon EBS volume from a running instance
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/get_console_output'
|
||||
|
||||
# Retrieve console output for specified instance
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/run_instances'
|
||||
|
||||
# Launch specified instances
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module EC2
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/ec2/terminate_instances'
|
||||
|
||||
# Terminate specified instances
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/create_load_balancer'
|
||||
|
||||
# Create a new Elastic Load Balancer
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/delete_load_balancer'
|
||||
|
||||
# Delete an existing Elastic Load Balancer
|
||||
#
|
||||
# Note that this API call, as defined by Amazon, is idempotent.
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/deregister_instances_from_load_balancer'
|
||||
|
||||
# Deregister an instance from an existing ELB
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/describe_instance_health'
|
||||
|
||||
# Get health status for one or more instances on an existing ELB
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/describe_load_balancers'
|
||||
|
||||
# Describe all or specified load balancers
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/disable_availability_zones_for_load_balancer'
|
||||
|
||||
# Disable an availability zone for an existing ELB
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/enable_availability_zones_for_load_balancer'
|
||||
|
||||
# Enable an availability zone for an existing ELB
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/register_instances_with_load_balancer'
|
||||
|
||||
# Register an instance with an existing ELB
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/copy_object'
|
||||
|
||||
# Copy an object from one S3 bucket to another
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/get_bucket'
|
||||
|
||||
# List information about objects in an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/access_control_list'
|
||||
|
||||
# Get access control list for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/get_bucket_location'
|
||||
|
||||
# Get location constraint for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/get_bucket_logging'
|
||||
|
||||
# Get logging status for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/get_bucket_object_versions'
|
||||
|
||||
# List information about object versions in an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/get_bucket_versioning'
|
||||
|
||||
# Get versioning status for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/access_control_list'
|
||||
|
||||
# Get access control list for an S3 object
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/get_request_payment'
|
||||
|
||||
# Get configured payer for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module S3
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/s3/get_service'
|
||||
|
||||
# List information about S3 buckets for authorized user
|
||||
#
|
||||
# ==== Returns
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
# * headers<~Hash>:
|
||||
# * 'ETag'<~String> - etag of new object
|
||||
def put_object(bucket_name, object_name, data, options = {})
|
||||
data = Fog::AWS::S3.parse_data(data)
|
||||
data = parse_data(data)
|
||||
headers = data[:headers].merge!(options)
|
||||
request({
|
||||
:body => data[:body],
|
||||
|
@ -42,7 +42,7 @@ module Fog
|
|||
class Mock
|
||||
|
||||
def put_object(bucket_name, object_name, data, options = {})
|
||||
data = Fog::AWS::S3.parse_data(data)
|
||||
data = parse_data(data)
|
||||
unless data[:body].is_a?(String)
|
||||
data[:body] = data[:body].read
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module SimpleDB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/simpledb/domain_metadata'
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module SimpleDB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/simpledb/get_attributes'
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module SimpleDB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/simpledb/list_domains'
|
||||
|
||||
# List SimpleDB domains
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -3,6 +3,8 @@ module Fog
|
|||
module SimpleDB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/simpledb/select'
|
||||
|
||||
# Select item data from SimpleDB
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -1,82 +1,64 @@
|
|||
module Fog
|
||||
module AWS
|
||||
module S3
|
||||
extend Fog::Service
|
||||
|
||||
def self.new(options={})
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
|
||||
unless @required
|
||||
require 'fog/aws/models/s3/directories'
|
||||
require 'fog/aws/models/s3/directory'
|
||||
require 'fog/aws/models/s3/files'
|
||||
require 'fog/aws/models/s3/file'
|
||||
require 'fog/aws/parsers/s3/access_control_list'
|
||||
require 'fog/aws/parsers/s3/copy_object'
|
||||
require 'fog/aws/parsers/s3/get_bucket'
|
||||
require 'fog/aws/parsers/s3/get_bucket_location'
|
||||
require 'fog/aws/parsers/s3/get_bucket_logging'
|
||||
require 'fog/aws/parsers/s3/get_bucket_object_versions'
|
||||
require 'fog/aws/parsers/s3/get_bucket_versioning'
|
||||
require 'fog/aws/parsers/s3/get_request_payment'
|
||||
require 'fog/aws/parsers/s3/get_service'
|
||||
require 'fog/aws/requests/s3/copy_object'
|
||||
require 'fog/aws/requests/s3/delete_bucket'
|
||||
require 'fog/aws/requests/s3/delete_object'
|
||||
require 'fog/aws/requests/s3/get_bucket'
|
||||
require 'fog/aws/requests/s3/get_bucket_acl'
|
||||
require 'fog/aws/requests/s3/get_bucket_location'
|
||||
require 'fog/aws/requests/s3/get_bucket_logging'
|
||||
require 'fog/aws/requests/s3/get_bucket_object_versions'
|
||||
require 'fog/aws/requests/s3/get_bucket_versioning'
|
||||
require 'fog/aws/requests/s3/get_object'
|
||||
require 'fog/aws/requests/s3/get_object_acl'
|
||||
require 'fog/aws/requests/s3/get_object_torrent'
|
||||
require 'fog/aws/requests/s3/get_object_url'
|
||||
require 'fog/aws/requests/s3/get_request_payment'
|
||||
require 'fog/aws/requests/s3/get_service'
|
||||
require 'fog/aws/requests/s3/head_object'
|
||||
require 'fog/aws/requests/s3/put_bucket'
|
||||
require 'fog/aws/requests/s3/put_bucket_acl'
|
||||
require 'fog/aws/requests/s3/put_bucket_logging'
|
||||
require 'fog/aws/requests/s3/put_bucket_versioning'
|
||||
require 'fog/aws/requests/s3/put_object'
|
||||
require 'fog/aws/requests/s3/put_object_url'
|
||||
require 'fog/aws/requests/s3/put_request_payment'
|
||||
@required = true
|
||||
end
|
||||
model_path 'fog/aws/models/s3'
|
||||
model 'directories'
|
||||
model 'directory'
|
||||
model 'files'
|
||||
model 'file'
|
||||
|
||||
if Fog.mocking?
|
||||
Fog::AWS::S3::Mock.new(options)
|
||||
else
|
||||
Fog::AWS::S3::Real.new(options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.parse_data(data)
|
||||
metadata = {
|
||||
:body => nil,
|
||||
:headers => {}
|
||||
}
|
||||
|
||||
if data.is_a?(String)
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
|
||||
else
|
||||
filename = ::File.basename(data.path)
|
||||
unless (mime_types = MIME::Types.of(filename)).empty?
|
||||
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
||||
end
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
|
||||
end
|
||||
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
||||
metadata
|
||||
end
|
||||
|
||||
def self.reset_data(keys=Mock.data.keys)
|
||||
Mock.reset_data(keys)
|
||||
end
|
||||
request_path 'fog/aws/requests/s3'
|
||||
request 'copy_object'
|
||||
request 'delete_bucket'
|
||||
request 'delete_object'
|
||||
request 'get_bucket'
|
||||
request 'get_bucket_acl'
|
||||
request 'get_bucket_location'
|
||||
request 'get_bucket_logging'
|
||||
request 'get_bucket_object_versions'
|
||||
request 'get_bucket_versioning'
|
||||
request 'get_object'
|
||||
request 'get_object_acl'
|
||||
request 'get_object_torrent'
|
||||
request 'get_object_url'
|
||||
request 'get_request_payment'
|
||||
request 'get_service'
|
||||
request 'head_object'
|
||||
request 'put_bucket'
|
||||
request 'put_bucket_acl'
|
||||
request 'put_bucket_logging'
|
||||
request 'put_bucket_versioning'
|
||||
request 'put_object'
|
||||
request 'put_object_url'
|
||||
request 'put_request_payment'
|
||||
|
||||
module Utils
|
||||
|
||||
def parse_data(data)
|
||||
metadata = {
|
||||
:body => nil,
|
||||
:headers => {}
|
||||
}
|
||||
|
||||
if data.is_a?(String)
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
|
||||
else
|
||||
filename = ::File.basename(data.path)
|
||||
unless (mime_types = MIME::Types.of(filename)).empty?
|
||||
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
||||
end
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
|
||||
end
|
||||
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
||||
metadata
|
||||
end
|
||||
|
||||
def url(params, expires)
|
||||
params[:headers]['Date'] = expires.to_i
|
||||
query = [params[:query]].compact
|
||||
|
@ -85,9 +67,11 @@ module Fog
|
|||
query << "Expires=#{params[:headers]['Date']}"
|
||||
"http://#{params[:host]}/#{params[:path]}?#{query.join('&')}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
include Utils
|
||||
|
||||
def self.data
|
||||
|
@ -115,6 +99,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
include Utils
|
||||
extend Fog::Deprecation
|
||||
deprecate(:reset, :reload)
|
||||
|
@ -137,12 +122,8 @@ module Fog
|
|||
# ==== Returns
|
||||
# * S3 object with connection to aws.
|
||||
def initialize(options={})
|
||||
unless @aws_access_key_id = options[:aws_access_key_id]
|
||||
raise ArgumentError.new('aws_access_key_id is required to access ec2')
|
||||
end
|
||||
unless @aws_secret_access_key = options[:aws_secret_access_key]
|
||||
raise ArgumentError.new('aws_secret_access_key is required to access ec2')
|
||||
end
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||
@hmac = HMAC::SHA1.new(@aws_secret_access_key)
|
||||
@host = options[:host] || case options[:region]
|
||||
when 'ap-southeast-1'
|
||||
|
@ -154,7 +135,7 @@ module Fog
|
|||
end
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
reset
|
||||
reload
|
||||
end
|
||||
|
||||
def reload
|
||||
|
|
|
@ -1,38 +1,23 @@
|
|||
module Fog
|
||||
module AWS
|
||||
module SimpleDB
|
||||
extend Fog::Service
|
||||
|
||||
def self.new(options={})
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
|
||||
unless @required
|
||||
require 'fog/aws/parsers/simpledb/domain_metadata'
|
||||
require 'fog/aws/parsers/simpledb/get_attributes'
|
||||
require 'fog/aws/parsers/simpledb/list_domains'
|
||||
require 'fog/aws/parsers/simpledb/select'
|
||||
require 'fog/aws/requests/simpledb/batch_put_attributes'
|
||||
require 'fog/aws/requests/simpledb/create_domain'
|
||||
require 'fog/aws/requests/simpledb/delete_attributes'
|
||||
require 'fog/aws/requests/simpledb/delete_domain'
|
||||
require 'fog/aws/requests/simpledb/domain_metadata'
|
||||
require 'fog/aws/requests/simpledb/get_attributes'
|
||||
require 'fog/aws/requests/simpledb/list_domains'
|
||||
require 'fog/aws/requests/simpledb/put_attributes'
|
||||
require 'fog/aws/requests/simpledb/select'
|
||||
@required = true
|
||||
end
|
||||
|
||||
if Fog.mocking?
|
||||
Fog::AWS::SimpleDB::Mock.new(options)
|
||||
else
|
||||
Fog::AWS::SimpleDB::Real.new(options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset_data(keys=Mock.data.keys)
|
||||
Mock.reset_data(keys)
|
||||
end
|
||||
request_path 'fog/aws/requests/simpledb'
|
||||
request 'batch_put_attributes'
|
||||
request 'create_domain'
|
||||
request 'delete_attributes'
|
||||
request 'delete_domain'
|
||||
request 'domain_metadata'
|
||||
request 'get_attributes'
|
||||
request 'list_domains'
|
||||
request 'put_attributes'
|
||||
request 'select'
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
|
@ -56,6 +41,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
# Initialize connection to SimpleDB
|
||||
#
|
||||
|
|
|
@ -1,47 +1,29 @@
|
|||
module Fog
|
||||
module Bluebox
|
||||
extend Fog::Service
|
||||
|
||||
class Error < Fog::Errors::Error; end
|
||||
class NotFound < Fog::Errors::NotFound; end
|
||||
requires :bluebox_api_key, :bluebox_customer_id
|
||||
|
||||
def self.new(options={})
|
||||
model_path 'fog/bluebox/models'
|
||||
model 'flavor'
|
||||
model 'flavors'
|
||||
model 'images'
|
||||
model 'server'
|
||||
model 'servers'
|
||||
|
||||
unless @required
|
||||
require 'fog/bluebox/models/flavor'
|
||||
require 'fog/bluebox/models/flavors'
|
||||
require 'fog/bluebox/models/images'
|
||||
require 'fog/bluebox/models/server'
|
||||
require 'fog/bluebox/models/servers'
|
||||
require 'fog/bluebox/requests/create_block'
|
||||
require 'fog/bluebox/requests/destroy_block'
|
||||
require 'fog/bluebox/requests/get_block'
|
||||
require 'fog/bluebox/requests/get_blocks'
|
||||
require 'fog/bluebox/requests/get_product'
|
||||
require 'fog/bluebox/requests/get_products'
|
||||
require 'fog/bluebox/requests/get_template'
|
||||
require 'fog/bluebox/requests/get_templates'
|
||||
require 'fog/bluebox/requests/reboot_block'
|
||||
@required = true
|
||||
end
|
||||
|
||||
unless options[:bluebox_api_key]
|
||||
raise ArgumentError.new('bluebox_api_key is required to access Blue Box')
|
||||
end
|
||||
unless options[:bluebox_customer_id]
|
||||
raise ArgumentError.new('bluebox_customer_id is required to access Blue Box')
|
||||
end
|
||||
if Fog.mocking?
|
||||
Fog::Bluebox::Mock.new(options)
|
||||
else
|
||||
Fog::Bluebox::Real.new(options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset_data(keys=Mock.data.keys)
|
||||
Mock.reset_data(keys)
|
||||
end
|
||||
request_path 'fog/bluebox/requests'
|
||||
request 'create_block'
|
||||
request 'destroy_block'
|
||||
request 'get_block'
|
||||
request 'get_blocks'
|
||||
request 'get_product'
|
||||
request 'get_products'
|
||||
request 'get_template'
|
||||
request 'get_templates'
|
||||
request 'reboot_block'
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
|
@ -63,6 +45,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
def initialize(options={})
|
||||
@bluebox_api_key = options[:bluebox_api_key]
|
||||
|
|
|
@ -4,13 +4,7 @@ require 'fog/bluebox/models/flavor'
|
|||
module Fog
|
||||
module Bluebox
|
||||
|
||||
class Mock
|
||||
def flavors
|
||||
Fog::Bluebox::Flavors.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def flavors
|
||||
Fog::Bluebox::Flavors.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -4,15 +4,7 @@ require 'fog/bluebox/models/image'
|
|||
module Fog
|
||||
module Bluebox
|
||||
|
||||
class Mock
|
||||
def images(attributes = {})
|
||||
Fog::Bluebox::Images.new({
|
||||
:connection => self
|
||||
}.merge!(attributes))
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def images(attributes = {})
|
||||
Fog::Bluebox::Images.new({
|
||||
:connection => self
|
||||
|
|
|
@ -4,13 +4,7 @@ require 'fog/bluebox/models/server'
|
|||
module Fog
|
||||
module Bluebox
|
||||
|
||||
class Mock
|
||||
def servers
|
||||
Fog::Bluebox::Servers.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def servers
|
||||
Fog::Bluebox::Servers.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -1,31 +1,17 @@
|
|||
module Fog
|
||||
module Local
|
||||
extend Fog::Service
|
||||
|
||||
def self.new(options={})
|
||||
requires :local_root
|
||||
|
||||
unless @required
|
||||
require 'fog/local/models/directories'
|
||||
require 'fog/local/models/directory'
|
||||
require 'fog/local/models/file'
|
||||
require 'fog/local/models/files'
|
||||
@required = true
|
||||
end
|
||||
|
||||
unless options[:local_root]
|
||||
raise ArgumentError.new('local_root is required to access local')
|
||||
end
|
||||
if Fog.mocking?
|
||||
Fog::Local::Mock.new(options)
|
||||
else
|
||||
Fog::Local::Real.new(options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset_data(keys=Mock.data.keys)
|
||||
Mock.reset_data(keys)
|
||||
end
|
||||
model_path 'fog/local/models'
|
||||
model 'directories'
|
||||
model 'directory'
|
||||
model 'file'
|
||||
model 'files'
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
|
@ -54,6 +40,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
def initialize(options={})
|
||||
@local_root = ::File.expand_path(options[:local_root])
|
||||
|
|
|
@ -4,13 +4,7 @@ require 'fog/local/models/directory'
|
|||
module Fog
|
||||
module Local
|
||||
|
||||
class Real
|
||||
def directories
|
||||
Fog::Local::Directories.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
module Collections
|
||||
def directories
|
||||
Fog::Local::Directories.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -23,29 +23,34 @@ module Fog
|
|||
request 'put_container'
|
||||
request 'put_object'
|
||||
|
||||
def self.parse_data(data)
|
||||
metadata = {
|
||||
:body => nil,
|
||||
:headers => {}
|
||||
}
|
||||
module Utils
|
||||
|
||||
if data.is_a?(String)
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
|
||||
else
|
||||
filename = ::File.basename(data.path)
|
||||
unless (mime_types = MIME::Types.of(filename)).empty?
|
||||
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
||||
def parse_data(data)
|
||||
metadata = {
|
||||
:body => nil,
|
||||
:headers => {}
|
||||
}
|
||||
|
||||
if data.is_a?(String)
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
|
||||
else
|
||||
filename = ::File.basename(data.path)
|
||||
unless (mime_types = MIME::Types.of(filename)).empty?
|
||||
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
||||
end
|
||||
metadata[:body] = data.read
|
||||
metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
|
||||
end
|
||||
metadata[:body] = data.read
|
||||
metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
|
||||
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
||||
metadata
|
||||
end
|
||||
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
||||
metadata
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
include Utils
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
|
@ -68,6 +73,7 @@ module Fog
|
|||
|
||||
class Real
|
||||
include Collections
|
||||
include Utils
|
||||
|
||||
def initialize(options={})
|
||||
credentials = Fog::Rackspace.authenticate(options)
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
# * container<~String> - Name for container, should be < 256 bytes and must not contain '/'
|
||||
#
|
||||
def put_object(container, object, data)
|
||||
data = Fog::Rackspace::Files.parse_data(data)
|
||||
data = parse_data(data)
|
||||
response = storage_request(
|
||||
:body => data[:body],
|
||||
:expects => 201,
|
||||
|
|
|
@ -26,9 +26,6 @@ module Fog
|
|||
for model in models
|
||||
require [@model_path, model].join('/')
|
||||
end
|
||||
for parser in parsers
|
||||
require [@parser_path, parser].join('/')
|
||||
end
|
||||
for request in requests
|
||||
require [@request_path, request].join('/')
|
||||
end
|
||||
|
@ -56,18 +53,6 @@ module Fog
|
|||
@models ||= []
|
||||
end
|
||||
|
||||
def parser_path(new_path)
|
||||
@parser_path = new_path
|
||||
end
|
||||
|
||||
def parser(new_parser)
|
||||
parsers << new_parser
|
||||
end
|
||||
|
||||
def parsers
|
||||
@parsers ||= []
|
||||
end
|
||||
|
||||
def request_path(new_path)
|
||||
@request_path = new_path
|
||||
end
|
||||
|
|
|
@ -1,46 +1,31 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
extend Fog::Service
|
||||
|
||||
class Error < Fog::Errors::Error; end
|
||||
class NotFound < Fog::Errors::NotFound; end
|
||||
requires :slicehost_password
|
||||
|
||||
def self.new(options={})
|
||||
model_path 'fog/slicehost/models'
|
||||
model 'flavor'
|
||||
model 'flavors'
|
||||
model 'image'
|
||||
model 'images'
|
||||
model 'server'
|
||||
model 'servers'
|
||||
|
||||
unless @required
|
||||
require 'fog/slicehost/models/flavor'
|
||||
require 'fog/slicehost/models/flavors'
|
||||
require 'fog/slicehost/models/image'
|
||||
require 'fog/slicehost/models/images'
|
||||
require 'fog/slicehost/models/server'
|
||||
require 'fog/slicehost/models/servers'
|
||||
require 'fog/slicehost/requests/create_slice'
|
||||
require 'fog/slicehost/requests/delete_slice'
|
||||
require 'fog/slicehost/requests/get_backups'
|
||||
require 'fog/slicehost/requests/get_flavor'
|
||||
require 'fog/slicehost/requests/get_flavors'
|
||||
require 'fog/slicehost/requests/get_image'
|
||||
require 'fog/slicehost/requests/get_images'
|
||||
require 'fog/slicehost/requests/get_slice'
|
||||
require 'fog/slicehost/requests/get_slices'
|
||||
require 'fog/slicehost/requests/reboot_slice'
|
||||
@required = true
|
||||
end
|
||||
|
||||
unless options[:slicehost_password]
|
||||
raise ArgumentError.new('slicehost_password is required to access slicehost')
|
||||
end
|
||||
if Fog.mocking?
|
||||
Fog::Slicehost::Mock.new(options)
|
||||
else
|
||||
Fog::Slicehost::Real.new(options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset_data(keys=Mock.data.keys)
|
||||
Mock.reset_data(keys)
|
||||
end
|
||||
request_path 'fog/slicehost/requests'
|
||||
request 'create_slice'
|
||||
request 'delete_slice'
|
||||
request 'get_backups'
|
||||
request 'get_flavor'
|
||||
request 'get_flavors'
|
||||
request 'get_image'
|
||||
request 'get_images'
|
||||
request 'get_slice'
|
||||
request 'get_slices'
|
||||
request 'reboot_slice'
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
|
@ -62,6 +47,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
def initialize(options={})
|
||||
@slicehost_password = options[:slicehost_password]
|
||||
|
|
|
@ -4,13 +4,7 @@ require 'fog/slicehost/models/flavor'
|
|||
module Fog
|
||||
module Slicehost
|
||||
|
||||
class Mock
|
||||
def flavors
|
||||
Fog::Slicehost::Flavors.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def flavors
|
||||
Fog::Slicehost::Flavors.new(:connection => self)
|
||||
end
|
||||
|
|
|
@ -4,15 +4,7 @@ require 'fog/slicehost/models/image'
|
|||
module Fog
|
||||
module Slicehost
|
||||
|
||||
class Mock
|
||||
def images(attributes = {})
|
||||
Fog::Slicehost::Images.new({
|
||||
:connection => self
|
||||
}.merge!(attributes))
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def images(attributes = {})
|
||||
Fog::Slicehost::Images.new({
|
||||
:connection => self
|
||||
|
|
|
@ -4,13 +4,7 @@ require 'fog/slicehost/models/server'
|
|||
module Fog
|
||||
module Slicehost
|
||||
|
||||
class Mock
|
||||
def servers
|
||||
Fog::Slicehost::Servers.new(:connection => self)
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
module Collections
|
||||
def servers
|
||||
Fog::Slicehost::Servers.new(:connection => self)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче