mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge branch 'master' of https://github.com/geemus/fog into put-object-acl
This commit is contained in:
commit
4aeba71e09
236 changed files with 564 additions and 203 deletions
|
@ -85,29 +85,29 @@ Now you've got a bunch of files in S3: your resume, some code samples,
|
|||
and maybe some pictures of your cat doing funny stuff. Since this is
|
||||
all of vital importance, you need to back it up.
|
||||
|
||||
# copy each file to local disk
|
||||
directory.files.each do |s3_file|
|
||||
File.open(s3_file.key, 'w') do |local_file|
|
||||
local_file.write(s3_file.body)
|
||||
end
|
||||
end
|
||||
# copy each file to local disk
|
||||
directory.files.each do |s3_file|
|
||||
File.open(s3_file.key, 'w') do |local_file|
|
||||
local_file.write(s3_file.body)
|
||||
end
|
||||
end
|
||||
|
||||
One caveat: it's way more efficient to do this:
|
||||
|
||||
# do two things per file
|
||||
directory.files.each do |file|
|
||||
do_one_thing(file)
|
||||
do_another_thing(file)
|
||||
end
|
||||
# do two things per file
|
||||
directory.files.each do |file|
|
||||
do_one_thing(file)
|
||||
do_another_thing(file)
|
||||
end
|
||||
|
||||
than it is to do this:
|
||||
|
||||
# do two things per file
|
||||
directory.files.each do |file|
|
||||
do_one_thing(file)
|
||||
end.each do |file|
|
||||
do_another_thing(file)
|
||||
end
|
||||
# do two things per file
|
||||
directory.files.each do |file|
|
||||
do_one_thing(file)
|
||||
end.each do |file|
|
||||
do_another_thing(file)
|
||||
end
|
||||
|
||||
The reason is that the list of files might be large. Really
|
||||
large. Eat-all-your-RAM-and-ask-for-more large. Therefore, every time
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
require 'fog/core'
|
||||
require 'openssl' # For RSA key pairs
|
||||
require 'base64' # For console output
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
|
@ -8,7 +6,7 @@ module Fog
|
|||
extend Fog::Provider
|
||||
|
||||
service(:auto_scaling, 'aws/auto_scaling')
|
||||
service(:cdn, 'cdn/aws')
|
||||
service(:cdn, 'aws/cdn')
|
||||
service(:compute, 'compute/aws')
|
||||
service(:cloud_formation, 'aws/cloud_formation')
|
||||
service(:cloud_watch, 'aws/cloud_watch')
|
||||
|
@ -20,7 +18,7 @@ module Fog
|
|||
service(:simpledb, 'aws/simpledb')
|
||||
service(:sns, 'aws/sns')
|
||||
service(:sqs, 'aws/sqs')
|
||||
service(:storage, 'storage/aws')
|
||||
service(:storage, 'aws/storage')
|
||||
|
||||
def self.indexed_param(key, values)
|
||||
params = {}
|
|
@ -5,9 +5,9 @@ module Fog
|
|||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :host, :path, :port, :scheme, :version, :persistent
|
||||
|
||||
model_path 'fog/cdn/models/aws'
|
||||
model_path 'fog/aws/cdn/models'
|
||||
|
||||
request_path 'fog/cdn/requests/aws'
|
||||
request_path 'fog/aws/requests/cdn'
|
||||
request 'delete_distribution'
|
||||
request 'delete_streaming_distribution'
|
||||
request 'get_distribution'
|
|
@ -1,5 +1,5 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storage/models/aws/directory'
|
||||
require 'fog/aws/models/storage/directory'
|
||||
|
||||
module Fog
|
||||
module Storage
|
|
@ -1,5 +1,5 @@
|
|||
require 'fog/core/model'
|
||||
require 'fog/storage/models/aws/files'
|
||||
require 'fog/aws/models/storage/files'
|
||||
|
||||
module Fog
|
||||
module Storage
|
|
@ -1,5 +1,5 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storage/models/aws/file'
|
||||
require 'fog/aws/models/storage/file'
|
||||
|
||||
module Fog
|
||||
module Storage
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/distribution'
|
||||
require 'fog/aws/parsers/cdn/distribution'
|
||||
|
||||
# Get information about a distribution from CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/get_distribution_list'
|
||||
require 'fog/aws/parsers/cdn/get_distribution_list'
|
||||
|
||||
# List information about distributions in CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/get_invalidation_list'
|
||||
require 'fog/aws/parsers/cdn/get_invalidation_list'
|
||||
|
||||
# ==== Parameters
|
||||
# * options<~Hash> - config arguments for list. Defaults to {}.
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/streaming_distribution'
|
||||
require 'fog/aws/parsers/cdn/streaming_distribution'
|
||||
|
||||
# Get information about a streaming distribution from CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/get_streaming_distribution_list'
|
||||
require 'fog/aws/parsers/cdn/get_streaming_distribution_list'
|
||||
|
||||
# List information about distributions in CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/distribution'
|
||||
require 'fog/aws/parsers/cdn/distribution'
|
||||
|
||||
# create a new distribution in CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/post_invalidation'
|
||||
require 'fog/aws/parsers/cdn/post_invalidation'
|
||||
|
||||
# List information about distributions in CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/streaming_distribution'
|
||||
require 'fog/aws/parsers/cdn/streaming_distribution'
|
||||
|
||||
# create a new streaming distribution in CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/distribution'
|
||||
require 'fog/aws/parsers/cdn/distribution'
|
||||
|
||||
# update a distribution in CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/cdn/parsers/aws/streaming_distribution'
|
||||
require 'fog/aws/parsers/cdn/streaming_distribution'
|
||||
|
||||
# update a streaming distribution in CloudFront
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/complete_multipart_upload'
|
||||
require 'fog/aws/parsers/storage/complete_multipart_upload'
|
||||
|
||||
# Complete a multipart upload
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/copy_object'
|
||||
require 'fog/aws/parsers/storage/copy_object'
|
||||
|
||||
# Copy an object from one S3 bucket to another
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_bucket'
|
||||
require 'fog/aws/parsers/storage/get_bucket'
|
||||
|
||||
# List information about objects in an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/access_control_list'
|
||||
require 'fog/aws/parsers/storage/access_control_list'
|
||||
|
||||
# Get access control list for an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_bucket_location'
|
||||
require 'fog/aws/parsers/storage/get_bucket_location'
|
||||
|
||||
# Get location constraint for an S3 bucket
|
||||
#
|
||||
|
@ -37,8 +37,17 @@ module Fog
|
|||
def get_bucket_location(bucket_name)
|
||||
response = Excon::Response.new
|
||||
if bucket = self.data[:buckets][bucket_name]
|
||||
location_constraint = case bucket['LocationConstraint']
|
||||
when 'us-east-1'
|
||||
nil
|
||||
when 'eu-east-1'
|
||||
'EU'
|
||||
else
|
||||
bucket['LocationConstraint']
|
||||
end
|
||||
|
||||
response.status = 200
|
||||
response.body = {'LocationConstraint' => bucket['LocationConstraint'] }
|
||||
response.body = {'LocationConstraint' => location_constraint }
|
||||
else
|
||||
response.status = 404
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_bucket_logging'
|
||||
require 'fog/aws/parsers/storage/get_bucket_logging'
|
||||
|
||||
# Get logging status for an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_bucket_object_versions'
|
||||
require 'fog/aws/parsers/storage/get_bucket_object_versions'
|
||||
|
||||
# List information about object versions in an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_bucket_versioning'
|
||||
require 'fog/aws/parsers/storage/get_bucket_versioning'
|
||||
|
||||
# Get versioning status for an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_bucket_website'
|
||||
require 'fog/aws/parsers/storage/get_bucket_website'
|
||||
|
||||
# Get website configuration for an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/access_control_list'
|
||||
require 'fog/aws/parsers/storage/access_control_list'
|
||||
|
||||
# Get access control list for an S3 object
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_request_payment'
|
||||
require 'fog/aws/parsers/storage/get_request_payment'
|
||||
|
||||
# Get configured payer for an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/get_service'
|
||||
require 'fog/aws/parsers/storage/get_service'
|
||||
|
||||
# List information about S3 buckets for authorized user
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/initiate_multipart_upload'
|
||||
require 'fog/aws/parsers/storage/initiate_multipart_upload'
|
||||
|
||||
# Initiate a multipart upload to an S3 bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/list_multipart_uploads'
|
||||
require 'fog/aws/parsers/storage/list_multipart_uploads'
|
||||
|
||||
# List multipart uploads for a bucket
|
||||
#
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/storage/parsers/aws/list_parts'
|
||||
require 'fog/aws/parsers/storage/list_parts'
|
||||
|
||||
# List parts for a multipart upload
|
||||
#
|
|
@ -5,13 +5,13 @@ module Fog
|
|||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent
|
||||
|
||||
model_path 'fog/storage/models/aws'
|
||||
model_path 'fog/aws/models/storage'
|
||||
collection :directories
|
||||
model :directory
|
||||
collection :files
|
||||
model :file
|
||||
|
||||
request_path 'fog/storage/requests/aws'
|
||||
request_path 'fog/aws/requests/storage'
|
||||
request :abort_multipart_upload
|
||||
request :complete_multipart_upload
|
||||
request :copy_object
|
|
@ -9,10 +9,10 @@ module Fog
|
|||
attributes = attributes.dup # prevent delete from having side effects
|
||||
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||
when :aws
|
||||
require 'fog/cdn/aws'
|
||||
require 'fog/aws/cdn'
|
||||
Fog::CDN::AWS.new(attributes)
|
||||
when :rackspace
|
||||
require 'fog/cdn/rackspace'
|
||||
require 'fog/rackspace/cdn'
|
||||
Fog::CDN::Rackspace.new(attributes)
|
||||
else
|
||||
raise ArgumentError.new("#{provider} is not a recognized cdn provider")
|
||||
|
|
|
@ -28,16 +28,19 @@ module Fog
|
|||
request :activate_console_server
|
||||
request :add_listeners_load_balancer
|
||||
request :add_nodes_load_balancer
|
||||
request :add_servers_server_group
|
||||
request :create_api_client
|
||||
request :create_cloud_ip
|
||||
request :create_image
|
||||
request :create_load_balancer
|
||||
request :create_server
|
||||
request :create_server_group
|
||||
request :destroy_api_client
|
||||
request :destroy_cloud_ip
|
||||
request :destroy_image
|
||||
request :destroy_load_balancer
|
||||
request :destroy_server
|
||||
request :destroy_server_group
|
||||
request :get_account
|
||||
request :get_api_client
|
||||
request :get_cloud_ip
|
||||
|
@ -45,6 +48,7 @@ module Fog
|
|||
request :get_interface
|
||||
request :get_load_balancer
|
||||
request :get_server
|
||||
request :get_server_group
|
||||
request :get_server_type
|
||||
request :get_user
|
||||
request :get_zone
|
||||
|
@ -52,13 +56,16 @@ module Fog
|
|||
request :list_cloud_ips
|
||||
request :list_images
|
||||
request :list_load_balancers
|
||||
request :list_server_groups
|
||||
request :list_server_types
|
||||
request :list_servers
|
||||
request :list_users
|
||||
request :list_zones
|
||||
request :map_cloud_ip
|
||||
request :move_servers_server_group
|
||||
request :remove_listeners_load_balancer
|
||||
request :remove_nodes_load_balancer
|
||||
request :remove_servers_server_group
|
||||
request :reset_ftp_password_account
|
||||
request :resize_server
|
||||
request :shutdown_server
|
||||
|
@ -71,6 +78,7 @@ module Fog
|
|||
request :update_image
|
||||
request :update_load_balancer
|
||||
request :update_server
|
||||
request :update_server_group
|
||||
request :update_user
|
||||
|
||||
class Mock
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
# "Server"=>"AmazonEC2"}
|
||||
#
|
||||
|
||||
def authorize_group_and_owner(group, owner)
|
||||
def authorize_group_and_owner(group, owner = nil)
|
||||
requires :name
|
||||
|
||||
connection.authorize_security_group_ingress(
|
||||
|
@ -130,7 +130,7 @@ module Fog
|
|||
# "Server"=>"AmazonEC2"}
|
||||
#
|
||||
|
||||
def revoke_group_and_owner(group, owner)
|
||||
def revoke_group_and_owner(group, owner = nil)
|
||||
requires :name
|
||||
|
||||
connection.revoke_security_group_ingress(
|
||||
|
|
|
@ -7,10 +7,12 @@ module Fog
|
|||
class Account < Fog::Model
|
||||
|
||||
identity :id
|
||||
attribute :resource_type
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :status
|
||||
|
||||
attribute :address_1
|
||||
attribute :address_2
|
||||
attribute :city
|
||||
|
@ -20,18 +22,28 @@ module Fog
|
|||
attribute :country_name
|
||||
attribute :vat_registration_number
|
||||
attribute :telephone_number
|
||||
attribute :telephone_verified
|
||||
attribute :verified_telephone
|
||||
attribute :verified_ip
|
||||
attribute :ram_limit
|
||||
attribute :ram_used
|
||||
attribute :cloud_ips_limit
|
||||
attribute :cloud_ips_used
|
||||
attribute :load_balancers_limit
|
||||
attribute :load_balancers_used
|
||||
attribute :library_ftp_host
|
||||
attribute :library_ftp_user
|
||||
# This is always returned as null/nil unless performing a reset_ftp_password request
|
||||
attribute :library_ftp_password
|
||||
attribute :created_at, :type => :time
|
||||
|
||||
# Boolean flags
|
||||
attribute :valid_credit_card
|
||||
attribute :telephone_verified
|
||||
|
||||
# Times
|
||||
attribute :created_at
|
||||
attribute :verified_at
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :owner_id, :aliases => "owner", :squash => "id"
|
||||
attribute :clients
|
||||
attribute :images
|
||||
|
|
|
@ -7,19 +7,21 @@ module Fog
|
|||
class CloudIp < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :status
|
||||
attribute :resource_type
|
||||
attribute :description
|
||||
|
||||
attribute :reverse_dns
|
||||
attribute :public_ip
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :account_id, :aliases => "account", :squash => "id"
|
||||
attribute :interface_id, :aliases => "interface", :squash => "id"
|
||||
attribute :server_id, :aliases => "server", :squash => "id"
|
||||
attribute :load_balancer, :alias => "load_balancer", :squash => "id"
|
||||
|
||||
def map(interface_to_map)
|
||||
requires :identity
|
||||
|
|
|
@ -7,10 +7,12 @@ module Fog
|
|||
class Flavor < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :status
|
||||
attribute :description
|
||||
|
||||
attribute :handle
|
||||
|
||||
|
@ -19,9 +21,6 @@ module Fog
|
|||
attribute :disk, :aliases => "disk_size"
|
||||
attribute :ram
|
||||
|
||||
attribute :resource_type
|
||||
attribute :description
|
||||
|
||||
def bits
|
||||
0 # This is actually based on the Image type used. 32bit or 64bit Images are supported
|
||||
end
|
||||
|
|
|
@ -7,31 +7,37 @@ module Fog
|
|||
class Image < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :status
|
||||
attribute :description
|
||||
|
||||
attribute :source
|
||||
attribute :source_type
|
||||
|
||||
attribute :ancestor_id, :aliases => "ancestor", :squash => "id"
|
||||
attribute :owner_id, :aliases => "owner", :squash => "id"
|
||||
attribute :arch
|
||||
attribute :virtual_size
|
||||
attribute :disk_size
|
||||
|
||||
attribute :resource_type
|
||||
attribute :description
|
||||
# Boolean flags
|
||||
attribute :public
|
||||
attribute :official
|
||||
attribute :compatibility_mode
|
||||
attribute :virtual_size
|
||||
attribute :disk_size
|
||||
|
||||
# Times
|
||||
attribute :created_at
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :ancestor_id, :aliases => "ancestor", :squash => "id"
|
||||
attribute :owner_id, :aliases => "owner", :squash => "id"
|
||||
|
||||
def ready?
|
||||
status == "available"
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :source, :arch
|
||||
options = {
|
||||
:source => source,
|
||||
|
|
|
@ -7,23 +7,32 @@ module Fog
|
|||
class LoadBalancer < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :url
|
||||
attribute :name
|
||||
attribute :status
|
||||
attribute :resource_type
|
||||
|
||||
attribute :nodes
|
||||
attribute :name
|
||||
attribute :status
|
||||
|
||||
attribute :policy
|
||||
attribute :nodes
|
||||
attribute :healthcheck
|
||||
attribute :listeners
|
||||
|
||||
# Times
|
||||
attribute :created_at
|
||||
attribute :deleted_at
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :account
|
||||
attribute :server
|
||||
attribute :cloud_ip
|
||||
|
||||
def ready?
|
||||
status == 'active'
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :nodes, :listeners, :healthcheck
|
||||
options = {
|
||||
:nodes => nodes,
|
||||
|
|
|
@ -7,23 +7,28 @@ module Fog
|
|||
class Server < Fog::Compute::Server
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :resource_type
|
||||
attribute :url
|
||||
|
||||
attribute :name
|
||||
attribute :state, :aliases => 'status'
|
||||
|
||||
attribute :hostname
|
||||
attribute :created_at, :type => :time
|
||||
attribute :deleted_at, :type => :time
|
||||
attribute :started_at, :type => :time
|
||||
attribute :user_data
|
||||
attribute :console_url
|
||||
attribute :console_token
|
||||
|
||||
attribute :resource_type
|
||||
# Times
|
||||
attribute :created_at
|
||||
attribute :started_at
|
||||
attribute :console_token_expires
|
||||
attribute :deleted_at
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :account_id, :aliases => "account", :squash => "id"
|
||||
attribute :image_id, :aliases => "image", :squash => "id"
|
||||
attribute :flavor_id, :aliases => "server_type", :squash => "id"
|
||||
attribute :zone_id, :aliases => "zone", :squash => "id"
|
||||
|
||||
attribute :snapshots
|
||||
attribute :cloud_ips
|
||||
attribute :interfaces
|
||||
|
@ -95,6 +100,7 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :image_id
|
||||
options = {
|
||||
:image => image_id,
|
||||
|
|
|
@ -7,14 +7,18 @@ module Fog
|
|||
class User < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
attribute :url
|
||||
|
||||
attribute :name
|
||||
attribute :email_address
|
||||
attribute :email_verified
|
||||
attribute :ssh_key
|
||||
|
||||
# Boolean flags
|
||||
attribute :email_verified
|
||||
attribute :messaging_pref
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :account_id, :aliases => "default_account", :squash => "id"
|
||||
attribute :accounts
|
||||
|
||||
|
|
|
@ -7,11 +7,12 @@ module Fog
|
|||
class Zone < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :url
|
||||
attribute :handle
|
||||
attribute :status
|
||||
attribute :resource_type
|
||||
|
||||
attribute :status
|
||||
attribute :handle
|
||||
|
||||
attribute :description
|
||||
|
||||
end
|
||||
|
|
|
@ -38,11 +38,13 @@ module Fog
|
|||
instance = self.data[:instances][instance_id]
|
||||
address = self.data[:addresses][public_ip]
|
||||
if instance && address
|
||||
if current_instance = self.data[:instances][address['instanceId']]
|
||||
current_instance['ipAddress'] = current_instance['originalIpAddress']
|
||||
end
|
||||
address['instanceId'] = instance_id
|
||||
instance['originalIpAddress'] = instance['ipAddress']
|
||||
# detach other address (if any)
|
||||
if self.data[:addresses][instance['originalIpAddress']]
|
||||
self.data[:addresses][instance['originalIpAddress']]['instanceId'] = nil
|
||||
if self.data[:addresses][instance['ipAddress']]
|
||||
self.data[:addresses][instance['ipAddress']]['instanceId'] = nil
|
||||
end
|
||||
instance['ipAddress'] = public_ip
|
||||
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip)
|
||||
|
|
|
@ -62,10 +62,10 @@ module Fog
|
|||
|
||||
if group
|
||||
group['ipPermissions'] ||= []
|
||||
if group_name && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
||||
if group_name && source_group_name = options['SourceSecurityGroupName']
|
||||
['tcp', 'udp'].each do |protocol|
|
||||
group['ipPermissions'] << {
|
||||
'groups' => [{'groupName' => group_name, 'userId' => self.data[:owner_id]}],
|
||||
'groups' => [{'groupName' => source_group_name, 'userId' => (options['SourceSecurityGroupOwnerId'] || self.data[:owner_id]) }],
|
||||
'fromPort' => 1,
|
||||
'ipRanges' => [],
|
||||
'ipProtocol' => protocol,
|
||||
|
@ -73,7 +73,7 @@ module Fog
|
|||
}
|
||||
end
|
||||
group['ipPermissions'] << {
|
||||
'groups' => [{'groupName' => group_name, 'userId' => self.data[:owner_id]}],
|
||||
'groups' => [{'groupName' => source_group_name, 'userId' => (options['SourceSecurityGroupOwnerId'] || self.data[:owner_id]) }],
|
||||
'fromPort' => -1,
|
||||
'ipRanges' => [],
|
||||
'ipProtocol' => 'icmp',
|
||||
|
|
|
@ -45,8 +45,8 @@ module Fog
|
|||
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' does not exist.")
|
||||
end
|
||||
|
||||
if snapshot && size && size != snapshot['volumeSize']
|
||||
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' with the specified size of '#{size}' does not exist.")
|
||||
if snapshot && size && size < snapshot['volumeSize']
|
||||
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' has size #{snapshot['volumeSize']} which is greater than #{size}.")
|
||||
elsif snapshot && !size
|
||||
size = snapshot['volumeSize']
|
||||
end
|
||||
|
|
|
@ -158,6 +158,7 @@ module Fog
|
|||
when 'pending'
|
||||
if Time.now - instance['launchTime'] >= Fog::Mock.delay
|
||||
instance['ipAddress'] = Fog::AWS::Mock.ip_address
|
||||
instance['originalIpAddress'] = instance['ipAddress']
|
||||
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress'])
|
||||
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
|
||||
instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress'])
|
||||
|
|
|
@ -28,6 +28,7 @@ module Fog
|
|||
params.merge!(Fog::AWS.indexed_param('ProductCode', attributes['ProductCode'] || []))
|
||||
request({
|
||||
'Action' => 'ModifyImageAttribute',
|
||||
'ImageId' => image_id,
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::Basic.new
|
||||
}.merge!(params))
|
||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
|||
# Modify instance attributes
|
||||
#
|
||||
# ==== Parameters
|
||||
# * image_id<~String> - Id of machine image to modify
|
||||
# * instance_id<~String> - Id of instance to modify
|
||||
# * attributes<~Hash>:
|
||||
# 'InstanceType.Value'<~String> - New instance type
|
||||
# 'Kernel.Value'<~String> - New kernel value
|
||||
|
@ -21,11 +21,12 @@ module Fog
|
|||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html]
|
||||
#
|
||||
def modify_instance_attributes(image_id, attributes)
|
||||
def modify_instance_attributes(instance_id, attributes)
|
||||
params = {}
|
||||
params.merge!(Fog::AWS.indexed_param('GroupId', attributes['GroupId'] || []))
|
||||
request({
|
||||
'Action' => 'ModifyInstanceAttribute',
|
||||
'InstanceId' => instance_id,
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::Basic.new
|
||||
}.merge!(params))
|
||||
|
|
|
@ -25,6 +25,7 @@ module Fog
|
|||
params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Remove.%d.UserId', attributes['Remove.UserId'] || []))
|
||||
request({
|
||||
'Action' => 'ModifySnapshotAttribute',
|
||||
'SnapshotId' => snapshot_id,
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::Basic.new
|
||||
}.merge!(params))
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue