mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fixing merge issues with master
This commit is contained in:
commit
427c0b2aa0
531 changed files with 2191 additions and 2046 deletions
39
RELEASE.md
Normal file
39
RELEASE.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Release process
|
||||
|
||||
This is fog's current release process, documented so people know what is
|
||||
currently done.
|
||||
|
||||
## Versioning
|
||||
|
||||
fog uses semantic versioning (http://semver.org/)
|
||||
|
||||
## When we release
|
||||
|
||||
Releases occur monthly and are manually handled by fog's Benevolent
|
||||
Dictator Wes (@geemus).
|
||||
|
||||
To request a new release please raise an issue.
|
||||
|
||||
## Prepare the release
|
||||
|
||||
* Ensure the code is passing on the CI server [](http://travis-ci.org/fog/fog)
|
||||
* Ensure the code is passing for live tests (Requires Credentials for all
|
||||
services)
|
||||
* Ensure working on **master**
|
||||
* Update the version number (`lib/fog/version.rb`)
|
||||
* Run `rake changelog` to update `changelog.txt`
|
||||
* Run `rake release` to prepare the release which does:
|
||||
* Prepares the release (`rake release:prepare`)
|
||||
* Builds the gem
|
||||
* Tags the commit
|
||||
* Creates commits for version
|
||||
* Publishes the release (`rake release:publish`)
|
||||
* Pushes commit and tag to Github (Requires Credentials)
|
||||
* Pushes gem to Rubygems (Requires Credentials)
|
||||
|
||||
## Announce the release
|
||||
|
||||
Once the release is prepared and uploaded it needs to be announced.
|
||||
|
||||
* Send an email to https://groups.google.com/forum/?fromgroups#!forum/ruby-fog
|
||||
* Tweet as @fog on Twitter (Requires Credentials)
|
37
Rakefile
37
Rakefile
|
@ -95,16 +95,43 @@ end
|
|||
#
|
||||
#############################################################################
|
||||
|
||||
task :release => :build do
|
||||
unless `git branch` =~ /^\* master$/
|
||||
puts "You must be on the master branch to release!"
|
||||
exit!
|
||||
task :release => ["release:prepare", "release:publish"]
|
||||
|
||||
namespace :release do
|
||||
task :preflight do
|
||||
unless `git branch` =~ /^\* master$/
|
||||
puts "You must be on the master branch to release!"
|
||||
exit!
|
||||
end
|
||||
if `git tag` =~ /^\* v#{version}$/
|
||||
puts "Tag v#{version} already exists!"
|
||||
exit!
|
||||
end
|
||||
end
|
||||
sh "gem install pkg/#{name}-#{version}.gem"
|
||||
|
||||
task :prepare => :preflight do
|
||||
Rake::Task[:build].invoke
|
||||
sh "gem install pkg/#{name}-#{version}.gem"
|
||||
Rake::Task[:git_mark_release].invoke
|
||||
end
|
||||
|
||||
task :publish do
|
||||
Rake::Task[:git_push_release].invoke
|
||||
Rake::Task[:gem_push].invoke
|
||||
end
|
||||
end
|
||||
|
||||
task :git_mark_release do
|
||||
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
||||
sh "git tag v#{version}"
|
||||
end
|
||||
|
||||
task :git_push_release do
|
||||
sh "git push origin master"
|
||||
sh "git push origin v#{version}"
|
||||
end
|
||||
|
||||
task :gem_push do
|
||||
sh "gem push pkg/#{name}-#{version}.gem"
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
|||
def all
|
||||
directory ? ns = directory.key : ns = ''
|
||||
ns = ns + '/' unless ns =~ /\/$/
|
||||
data = connection.get_namespace(ns).body[:DirectoryList]
|
||||
data = service.get_namespace(ns).body[:DirectoryList]
|
||||
data = {:DirectoryEntry => []} if data.kind_of? String
|
||||
data[:DirectoryEntry] = [data[:DirectoryEntry]] if data[:DirectoryEntry].kind_of? Hash
|
||||
dirs = data[:DirectoryEntry].select {|de| de[:FileType] == 'directory'}
|
||||
|
@ -28,7 +28,7 @@ module Fog
|
|||
def get(key, options = {})
|
||||
return nil if key == '' # Root dir shouldn't be retrieved like this.
|
||||
key =~ /\/$/ ? ns = key : ns = key + '/'
|
||||
res = connection.get_namespace ns
|
||||
res = service.get_namespace ns
|
||||
emc_meta = res.headers['x-emc-meta']
|
||||
obj_id = emc_meta.scan(/objectid=(\w+),/).flatten[0]
|
||||
new(:objectid => obj_id, :key => ns)
|
||||
|
|
|
@ -12,25 +12,25 @@ module Fog
|
|||
def files
|
||||
@files ||= begin
|
||||
Fog::Storage::Atmos::Files.new(
|
||||
:directory => self,
|
||||
:connection => connection
|
||||
)
|
||||
end
|
||||
:directory => self,
|
||||
:service => service
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def directories
|
||||
@directories ||= begin
|
||||
Fog::Storage::Atmos::Directories.new(
|
||||
:directory => self,
|
||||
:connection => connection
|
||||
)
|
||||
end
|
||||
Fog::Storage::Atmos::Directories.new(
|
||||
:directory => self,
|
||||
:service => service
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def save
|
||||
self.key = attributes[:directory].key + key if attributes[:directory]
|
||||
self.key = key + '/' unless key =~ /\/$/
|
||||
res = connection.post_namespace key
|
||||
res = service.post_namespace key
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -42,7 +42,7 @@ module Fog
|
|||
d.destroy(opts)
|
||||
end
|
||||
end
|
||||
connection.delete_namespace key
|
||||
service.delete_namespace key
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ module Fog
|
|||
end
|
||||
|
||||
def copy(target_directory_key, target_file_key, options={})
|
||||
target_directory = connection.directories.new(:key => target_directory_key)
|
||||
target_directory = service.directories.new(:key => target_directory_key)
|
||||
target_directory.files.create(
|
||||
:key => target_file_key,
|
||||
:body => body
|
||||
|
@ -38,7 +38,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :directory, :key
|
||||
connection.delete_namespace([directory.key, key].join('/'))
|
||||
service.delete_namespace([directory.key, key].join('/'))
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -60,15 +60,15 @@ module Fog
|
|||
file = directory.files.head(key)
|
||||
self.objectid = if file.present? then file.attributes['x-emc-meta'].scan(/objectid=(\w+),/).flatten[0] else nil end
|
||||
if self.objectid.present?
|
||||
uri = URI::HTTP.build(:scheme => connection.ssl? ? "http" : "https" , :host => connection.host, :port => connection.port.to_i, :path => "/rest/objects/#{self.objectid}" )
|
||||
uri = URI::HTTP.build(:scheme => service.ssl? ? "http" : "https" , :host => service.host, :port => service.port.to_i, :path => "/rest/objects/#{self.objectid}" )
|
||||
|
||||
sb = "GET\n"
|
||||
sb += uri.path.downcase + "\n"
|
||||
sb += connection.uid + "\n"
|
||||
sb += service.uid + "\n"
|
||||
sb += String(expires.to_i())
|
||||
|
||||
signature = connection.sign( sb )
|
||||
uri.query = "uid=#{CGI::escape(connection.uid)}&expires=#{expires.to_i()}&signature=#{CGI::escape(signature)}"
|
||||
signature = service.sign( sb )
|
||||
uri.query = "uid=#{CGI::escape(service.uid)}&expires=#{expires.to_i()}&signature=#{CGI::escape(signature)}"
|
||||
uri.to_s
|
||||
else
|
||||
nil
|
||||
|
@ -83,11 +83,11 @@ module Fog
|
|||
options[:headers]['Content-Type'] = content_type if content_type
|
||||
options[:body] = body
|
||||
begin
|
||||
data = connection.post_namespace(ns, options)
|
||||
data = service.post_namespace(ns, options)
|
||||
self.objectid = data.headers['location'].split('/')[-1]
|
||||
rescue => error
|
||||
if error.message =~ /The resource you are trying to create already exists./
|
||||
data = connection.put_namespace(ns, options)
|
||||
data = service.put_namespace(ns, options)
|
||||
else
|
||||
raise error
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
|||
requires :directory
|
||||
directory ? ns = directory.key : ns = ''
|
||||
ns = ns + '/' unless ns =~ /\/$/
|
||||
data = connection.get_namespace(ns).body[:DirectoryList]
|
||||
data = service.get_namespace(ns).body[:DirectoryList]
|
||||
data = {:DirectoryEntry => []} if data.kind_of? String
|
||||
data[:DirectoryEntry] = [data[:DirectoryEntry]] if data[:DirectoryEntry].kind_of? Hash
|
||||
files = data[:DirectoryEntry].select {|de| de[:FileType] == 'regular'}
|
||||
|
@ -32,7 +32,7 @@ module Fog
|
|||
|
||||
def get(key, &block)
|
||||
requires :directory
|
||||
data = connection.get_namespace(directory.key + key, :parse => false)#, &block)
|
||||
data = service.get_namespace(directory.key + key, :parse => false)#, &block)
|
||||
file_data = data.headers.merge({
|
||||
:body => data.body,
|
||||
:key => key
|
||||
|
@ -51,7 +51,7 @@ module Fog
|
|||
|
||||
def head(key, options = {})
|
||||
requires :directory
|
||||
data = connection.head_namespace(directory.key + key, :parse => false)
|
||||
data = service.head_namespace(directory.key + key, :parse => false)
|
||||
file_data = data.headers.merge({
|
||||
:body => data.body,
|
||||
:key => key
|
||||
|
|
|
@ -11,7 +11,7 @@ module Fog
|
|||
data = []
|
||||
next_token = nil
|
||||
loop do
|
||||
result = connection.describe_scaling_activities('NextToken' => next_token).body['DescribeScalingActivitiesResult']
|
||||
result = service.describe_scaling_activities('NextToken' => next_token).body['DescribeScalingActivitiesResult']
|
||||
data += result['Activities']
|
||||
next_token = result['NextToken']
|
||||
break if next_token.nil?
|
||||
|
@ -20,7 +20,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.describe_scaling_activities('ActivityId' => identity).body['DescribeScalingActivitiesResult']['Activities'].first
|
||||
data = service.describe_scaling_activities('ActivityId' => identity).body['DescribeScalingActivitiesResult']['Activities'].first
|
||||
new(data) unless data.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
attribute :status_message, :aliases => 'StatusMessage'
|
||||
|
||||
def group
|
||||
connection.groups.get(attributes['AutoScalingGroupName'])
|
||||
service.groups.get(attributes['AutoScalingGroupName'])
|
||||
end
|
||||
|
||||
def save
|
||||
|
|
|
@ -41,7 +41,7 @@ module Fog
|
|||
|
||||
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
||||
options.delete_if { |key, value| value.nil? }
|
||||
connection.create_launch_configuration(image_id, instance_type, id, options) #, listeners.map{|l| l.to_params})
|
||||
service.create_launch_configuration(image_id, instance_type, id, options) #, listeners.map{|l| l.to_params})
|
||||
|
||||
# reload instead of merge attributes b/c some attrs (like HealthCheck)
|
||||
# may be set, but only the DNS name is returned in the create_load_balance
|
||||
|
@ -56,7 +56,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_launch_configuration(id)
|
||||
service.delete_launch_configuration(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
data = []
|
||||
next_token = nil
|
||||
loop do
|
||||
result = connection.describe_launch_configurations('NextToken' => next_token).body['DescribeLaunchConfigurationsResult']
|
||||
result = service.describe_launch_configurations('NextToken' => next_token).body['DescribeLaunchConfigurationsResult']
|
||||
data += result['LaunchConfigurations']
|
||||
next_token = result['NextToken']
|
||||
break if next_token.nil?
|
||||
|
@ -25,7 +25,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.describe_launch_configurations('LaunchConfigurationNames' => identity).body['DescribeLaunchConfigurationsResult']['LaunchConfigurations'].first
|
||||
data = service.describe_launch_configurations('LaunchConfigurationNames' => identity).body['DescribeLaunchConfigurationsResult']['LaunchConfigurations'].first
|
||||
new(data) unless data.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -45,37 +45,37 @@ module Fog
|
|||
data = []
|
||||
next_token = nil
|
||||
loop do
|
||||
result = connection.describe_scaling_activities('AutoScalingGroupName' => id, 'NextToken' => next_token).body['DescribeScalingActivitiesResult']
|
||||
result = service.describe_scaling_activities('AutoScalingGroupName' => id, 'NextToken' => next_token).body['DescribeScalingActivitiesResult']
|
||||
data += result['Activities']
|
||||
next_token = result['NextToken']
|
||||
break if next_token.nil?
|
||||
end
|
||||
Fog::AWS::AutoScaling::Activities.new({
|
||||
:data => data,
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
#:load_balancer => self
|
||||
})
|
||||
end
|
||||
|
||||
def configuration
|
||||
requires :launch_configuration_name
|
||||
connection.configurations.get(launch_configuration_name)
|
||||
service.configurations.get(launch_configuration_name)
|
||||
end
|
||||
|
||||
def disable_metrics_collection(metrics = {})
|
||||
requires :id
|
||||
connection.disable_metrics_collection(id, 'Metrics' => metrics)
|
||||
service.disable_metrics_collection(id, 'Metrics' => metrics)
|
||||
reload
|
||||
end
|
||||
|
||||
def enable_metrics_collection(granularity = '1Minute', metrics = {})
|
||||
requires :id
|
||||
connection.enable_metrics_collection(id, granularity, 'Metrics' => metrics)
|
||||
service.enable_metrics_collection(id, granularity, 'Metrics' => metrics)
|
||||
reload
|
||||
end
|
||||
|
||||
def instances
|
||||
Fog::AWS::AutoScaling::Instances.new(:connection => connection).load(attributes[:instances])
|
||||
Fog::AWS::AutoScaling::Instances.new(:service => service).load(attributes[:instances])
|
||||
end
|
||||
|
||||
def instances_in_service
|
||||
|
@ -88,13 +88,13 @@ module Fog
|
|||
|
||||
def resume_processes(processes = [])
|
||||
requires :id
|
||||
connection.resume_processes(id, 'ScalingProcesses' => processes)
|
||||
service.resume_processes(id, 'ScalingProcesses' => processes)
|
||||
reload
|
||||
end
|
||||
|
||||
def suspend_processes(processes = [])
|
||||
requires :id
|
||||
connection.suspend_processes(id, 'ScalingProcesses' => processes)
|
||||
service.suspend_processes(id, 'ScalingProcesses' => processes)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -112,7 +112,7 @@ module Fog
|
|||
requires :max_size
|
||||
requires :min_size
|
||||
|
||||
connection.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size, options)
|
||||
service.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size, options)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -126,13 +126,13 @@ module Fog
|
|||
|
||||
opts = {}
|
||||
opts.merge!({'ForceDelete' => true}) if options[:force]
|
||||
|
||||
connection.delete_auto_scaling_group(id, opts)
|
||||
|
||||
service.delete_auto_scaling_group(id, opts)
|
||||
end
|
||||
|
||||
def update
|
||||
requires :id
|
||||
connection.update_auto_scaling_group(id, options)
|
||||
service.update_auto_scaling_group(id, options)
|
||||
reload
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
data = []
|
||||
next_token = nil
|
||||
loop do
|
||||
result = connection.describe_auto_scaling_groups('NextToken' => next_token).body['DescribeAutoScalingGroupsResult']
|
||||
result = service.describe_auto_scaling_groups('NextToken' => next_token).body['DescribeAutoScalingGroupsResult']
|
||||
data += result['AutoScalingGroups']
|
||||
next_token = result['NextToken']
|
||||
break if next_token.nil?
|
||||
|
@ -25,7 +25,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.describe_auto_scaling_groups('AutoScalingGroupNames' => identity).body['DescribeAutoScalingGroupsResult']['AutoScalingGroups'].first
|
||||
data = service.describe_auto_scaling_groups('AutoScalingGroupNames' => identity).body['DescribeAutoScalingGroupsResult']['AutoScalingGroups'].first
|
||||
new(data) unless data.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -17,22 +17,22 @@ module Fog
|
|||
end
|
||||
|
||||
def group
|
||||
connection.groups.get(attributes['AutoScalingGroupName'])
|
||||
service.groups.get(attributes['AutoScalingGroupName'])
|
||||
end
|
||||
|
||||
def configuration
|
||||
connection.configurations.get(attributes['LaunchConfigurationName'])
|
||||
service.configurations.get(attributes['LaunchConfigurationName'])
|
||||
end
|
||||
|
||||
def set_health(health_status, options)
|
||||
requires :id
|
||||
connection.set_instance_health(health_status, id, options)
|
||||
service.set_instance_health(health_status, id, options)
|
||||
reload
|
||||
end
|
||||
|
||||
def terminate(should_decrement_desired_capacity)
|
||||
requires :id
|
||||
connection.terminate_instance_in_auto_scaling_group(id, should_decrement_desired_capacity)
|
||||
service.terminate_instance_in_auto_scaling_group(id, should_decrement_desired_capacity)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -51,7 +51,7 @@ module Fog
|
|||
|
||||
#def destroy
|
||||
# requires :id
|
||||
# connection.delete_auto_scaling_group(id)
|
||||
# service.delete_auto_scaling_group(id)
|
||||
#end
|
||||
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ module Fog
|
|||
data = []
|
||||
next_token = nil
|
||||
loop do
|
||||
result = connection.describe_auto_scaling_instances('NextToken' => next_token).body['DescribeAutoScalingInstancesResult']
|
||||
result = service.describe_auto_scaling_instances('NextToken' => next_token).body['DescribeAutoScalingInstancesResult']
|
||||
data += result['AutoScalingInstances']
|
||||
next_token = result['NextToken']
|
||||
break if next_token.nil?
|
||||
|
@ -20,7 +20,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.describe_auto_scaling_instances('InstanceIds' => identity).body['DescribeAutoScalingInstancesResult']['AutoScalingInstances'].first
|
||||
data = service.describe_auto_scaling_instances('InstanceIds' => identity).body['DescribeAutoScalingInstancesResult']['AutoScalingInstances'].first
|
||||
new(data) unless data.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
|||
data = []
|
||||
next_token = nil
|
||||
loop do
|
||||
result = connection.describe_policies('NextToken' => next_token).body['DescribePoliciesResult']
|
||||
result = service.describe_policies('NextToken' => next_token).body['DescribePoliciesResult']
|
||||
data += result['ScalingPolicies']
|
||||
next_token = result['NextToken']
|
||||
break if next_token.nil?
|
||||
|
@ -24,7 +24,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get(identity, auto_scaling_group = nil)
|
||||
data = connection.describe_policies('PolicyNames' => identity, 'AutoScalingGroupName' => auto_scaling_group).body['DescribePoliciesResult']['ScalingPolicies'].first
|
||||
data = service.describe_policies('PolicyNames' => identity, 'AutoScalingGroupName' => auto_scaling_group).body['DescribePoliciesResult']['ScalingPolicies'].first
|
||||
new(data) unless data.nil?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,14 +31,14 @@ module Fog
|
|||
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
||||
options.delete_if { |key, value| value.nil? }
|
||||
|
||||
connection.put_scaling_policy(adjustment_type, auto_scaling_group_name, id, scaling_adjustment, options)
|
||||
service.put_scaling_policy(adjustment_type, auto_scaling_group_name, id, scaling_adjustment, options)
|
||||
reload
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
requires :auto_scaling_group_name
|
||||
connection.delete_policy(auto_scaling_group_name, id)
|
||||
service.delete_policy(auto_scaling_group_name, id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,27 +18,27 @@ module Fog
|
|||
|
||||
def environments
|
||||
requires :name
|
||||
connection.environments.all({'ApplicationName' => name})
|
||||
service.environments.all({'ApplicationName' => name})
|
||||
end
|
||||
|
||||
def events
|
||||
requires :name
|
||||
connection.events.all({'ApplicationName' => name})
|
||||
service.events.all({'ApplicationName' => name})
|
||||
end
|
||||
|
||||
def templates
|
||||
requires :name
|
||||
connection.templates.all({'ApplicationName' => name})
|
||||
service.templates.all({'ApplicationName' => name})
|
||||
end
|
||||
|
||||
def versions
|
||||
requires :name
|
||||
connection.versions.all({'ApplicationName' => name})
|
||||
service.versions.all({'ApplicationName' => name})
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :name
|
||||
connection.delete_application(name)
|
||||
service.delete_application(name)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -50,7 +50,7 @@ module Fog
|
|||
}
|
||||
options['Description'] = description unless description.nil?
|
||||
|
||||
data = connection.create_application(options).body['CreateApplicationResult']['Application']
|
||||
data = service.create_application(options).body['CreateApplicationResult']['Application']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -59,4 +59,4 @@ module Fog
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,12 +9,12 @@ module Fog
|
|||
model Fog::AWS::ElasticBeanstalk::Application
|
||||
|
||||
def all(application_names=[])
|
||||
data = connection.describe_applications(application_names).body['DescribeApplicationsResult']['Applications']
|
||||
data = service.describe_applications(application_names).body['DescribeApplicationsResult']['Applications']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
def get(application_name)
|
||||
if data = connection.describe_applications([application_name]).body['DescribeApplicationsResult']['Applications'].first
|
||||
if data = service.describe_applications([application_name]).body['DescribeApplicationsResult']['Applications'].first
|
||||
new(data)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ module Fog
|
|||
# Returns the current live resources for this environment
|
||||
def live_resources
|
||||
requires :id
|
||||
data = connection.describe_environment_resources({'EnvironmentId' => id}).body['DescribeEnvironmentResourcesResult']['EnvironmentResources']
|
||||
data = service.describe_environment_resources({'EnvironmentId' => id}).body['DescribeEnvironmentResourcesResult']['EnvironmentResources']
|
||||
data.delete('EnvironmentName') # Delete the environment name from the result, only return actual resources
|
||||
data
|
||||
end
|
||||
|
@ -54,26 +54,26 @@ module Fog
|
|||
# Return events related to this version
|
||||
def events
|
||||
requires :id
|
||||
connection.events.all({'EnvironmentId' => id})
|
||||
service.events.all({'EnvironmentId' => id})
|
||||
end
|
||||
|
||||
# Restarts the app servers in this environment
|
||||
def restart_app_server
|
||||
requires :id
|
||||
connection.restart_app_server({'EnvironmentId' => id})
|
||||
service.restart_app_server({'EnvironmentId' => id})
|
||||
reload
|
||||
end
|
||||
|
||||
# Rebuilds the environment
|
||||
def rebuild
|
||||
requires :id
|
||||
connection.rebuild_environment({'EnvironmentId' => id})
|
||||
service.rebuild_environment({'EnvironmentId' => id})
|
||||
reload
|
||||
end
|
||||
|
||||
def swap_cnames(source)
|
||||
requires :name
|
||||
connection.swap_environment_cnames({
|
||||
service.swap_environment_cnames({
|
||||
'SourceEnvironmentName' => source.name,
|
||||
'DestinationEnvironmentName' => name
|
||||
})
|
||||
|
@ -84,7 +84,7 @@ module Fog
|
|||
# Return the version object for this environment
|
||||
def version
|
||||
requires :application_name, :version_label
|
||||
connection.versions.get(application_name, version_label)
|
||||
service.versions.get(application_name, version_label)
|
||||
end
|
||||
|
||||
# Update the running version of this environment
|
||||
|
@ -102,7 +102,7 @@ module Fog
|
|||
raise "Version label not specified."
|
||||
end
|
||||
|
||||
data = connection.update_environment({
|
||||
data = service.update_environment({
|
||||
'EnvironmentId' => id,
|
||||
'VersionLabel' => new_version_label
|
||||
}).body['UpdateEnvironmentResult']
|
||||
|
@ -112,7 +112,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.terminate_environment({'EnvironmentId' => id})
|
||||
service.terminate_environment({'EnvironmentId' => id})
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -133,7 +133,7 @@ module Fog
|
|||
}
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.create_environment(options).body['CreateEnvironmentResult']
|
||||
data = service.create_environment(options).body['CreateEnvironmentResult']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -142,4 +142,4 @@ module Fog
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
model Fog::AWS::ElasticBeanstalk::Environment
|
||||
|
||||
def all(options={})
|
||||
data = connection.describe_environments(options).body['DescribeEnvironmentsResult']['Environments']
|
||||
data = service.describe_environments(options).body['DescribeEnvironmentsResult']['Environments']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,7 @@ module Fog
|
|||
def get(environment_name)
|
||||
options = { 'EnvironmentNames' => [environment_name] }
|
||||
|
||||
if data = connection.describe_environments(options).body['DescribeEnvironmentsResult']['Environments'].first
|
||||
if data = service.describe_environments(options).body['DescribeEnvironmentsResult']['Environments'].first
|
||||
new(data)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
model Fog::AWS::ElasticBeanstalk::Event
|
||||
|
||||
def all(options={})
|
||||
data = connection.describe_events(options).body['DescribeEventsResult']['Events']
|
||||
data = service.describe_events(options).body['DescribeEventsResult']['Events']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
# Returns an array of options that may be set on this template
|
||||
def options
|
||||
requires :name, :application_name
|
||||
data = connection.describe_configuration_options({
|
||||
data = service.describe_configuration_options({
|
||||
'ApplicationName' => application_name,
|
||||
'TemplateName' => name
|
||||
})
|
||||
|
@ -33,7 +33,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :name, :application_name
|
||||
connection.delete_configuration_template(application_name, name)
|
||||
service.delete_configuration_template(application_name, name)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -51,7 +51,7 @@ module Fog
|
|||
}
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.create_configuration_template(options).body['CreateConfigurationTemplateResult']
|
||||
data = service.create_configuration_template(options).body['CreateConfigurationTemplateResult']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -67,7 +67,7 @@ module Fog
|
|||
}
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.update_configuration_template(options).body['UpdateConfigurationTemplateResult']
|
||||
data = service.update_configuration_template(options).body['UpdateConfigurationTemplateResult']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -75,4 +75,4 @@ module Fog
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ module Fog
|
|||
# Initialize with empty array
|
||||
data = []
|
||||
|
||||
applications = connection.describe_applications(application_filter).body['DescribeApplicationsResult']['Applications']
|
||||
applications = service.describe_applications(application_filter).body['DescribeApplicationsResult']['Applications']
|
||||
applications.each { |application|
|
||||
application['ConfigurationTemplates'].each { |template_name|
|
||||
begin
|
||||
|
@ -29,7 +29,7 @@ module Fog
|
|||
'ApplicationName' => application['ApplicationName'],
|
||||
'TemplateName' => template_name
|
||||
}
|
||||
settings = connection.describe_configuration_settings(options).body['DescribeConfigurationSettingsResult']['ConfigurationSettings']
|
||||
settings = service.describe_configuration_settings(options).body['DescribeConfigurationSettingsResult']['ConfigurationSettings']
|
||||
if settings.length == 1
|
||||
# Add to data
|
||||
data << settings.first
|
||||
|
@ -54,7 +54,7 @@ module Fog
|
|||
# There is no describe call for templates, so we must use describe_configuration_settings. Unfortunately,
|
||||
# it throws an exception if template name doesn't exist, which is inconsistent, catch and return nil
|
||||
begin
|
||||
data = connection.describe_configuration_settings(options).body['DescribeConfigurationSettingsResult']['ConfigurationSettings']
|
||||
data = service.describe_configuration_settings(options).body['DescribeConfigurationSettingsResult']['ConfigurationSettings']
|
||||
if data.length == 1
|
||||
result = new(data.first)
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
|||
# Return events related to this version
|
||||
def events
|
||||
requires :label, :application_name
|
||||
connection.events.all({
|
||||
service.events.all({
|
||||
'ApplicationName' => application_name,
|
||||
'VersionLabel' => label
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ module Fog
|
|||
# Returns environments running this version
|
||||
def environments
|
||||
requires :label, :application_name
|
||||
connection.environments.all({
|
||||
service.environments.all({
|
||||
'ApplicationName' => application_name,
|
||||
'VersionLabel' => label
|
||||
})
|
||||
|
@ -37,7 +37,7 @@ module Fog
|
|||
|
||||
def destroy(delete_source_bundle = nil)
|
||||
requires :label, :application_name
|
||||
connection.delete_application_version(application_name, label, delete_source_bundle)
|
||||
service.delete_application_version(application_name, label, delete_source_bundle)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -53,7 +53,7 @@ module Fog
|
|||
}
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.create_application_version(options).body['CreateApplicationVersionResult']['ApplicationVersion']
|
||||
data = service.create_application_version(options).body['CreateApplicationVersionResult']['ApplicationVersion']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -69,11 +69,11 @@ module Fog
|
|||
}
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.update_application_version(options).body['UpdateApplicationVersionResult']['ApplicationVersion']
|
||||
data = service.update_application_version(options).body['UpdateApplicationVersionResult']['ApplicationVersion']
|
||||
merge_attributes(data)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,12 +9,12 @@ module Fog
|
|||
model Fog::AWS::ElasticBeanstalk::Version
|
||||
|
||||
def all(options={})
|
||||
data = connection.describe_application_versions(options).body['DescribeApplicationVersionsResult']['ApplicationVersions']
|
||||
data = service.describe_application_versions(options).body['DescribeApplicationVersionsResult']['ApplicationVersions']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
def get(application_name, version_label)
|
||||
if data = connection.describe_application_versions({
|
||||
if data = service.describe_application_versions({
|
||||
'ApplicationName' => application_name,
|
||||
'VersionLabels' => [version_label]
|
||||
}).body['DescribeApplicationVersionsResult']['ApplicationVersions']
|
||||
|
|
|
@ -37,7 +37,7 @@ module Fog
|
|||
@invalidations ||= begin
|
||||
Fog::CDN::AWS::Invalidations.new(
|
||||
:distribution => self,
|
||||
:connection => connection
|
||||
:service => service
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -54,15 +54,15 @@ module Fog
|
|||
private
|
||||
|
||||
def delete_distribution(identity, etag)
|
||||
connection.delete_distribution(identity, etag)
|
||||
service.delete_distribution(identity, etag)
|
||||
end
|
||||
|
||||
def put_distribution_config(identity, etag, options)
|
||||
connection.put_distribution_config(identity, etag, options)
|
||||
service.put_distribution_config(identity, etag, options)
|
||||
end
|
||||
|
||||
def post_distribution(options = {})
|
||||
connection.post_distribution(options)
|
||||
service.post_distribution(options)
|
||||
end
|
||||
|
||||
def attributes_to_options
|
||||
|
|
|
@ -16,11 +16,11 @@ module Fog
|
|||
attribute :is_truncated, :aliases => 'IsTruncated'
|
||||
|
||||
def get_distribution(dist_id)
|
||||
connection.get_distribution(dist_id)
|
||||
service.get_distribution(dist_id)
|
||||
end
|
||||
|
||||
def list_distributions(options = {})
|
||||
connection.get_distribution_list(options)
|
||||
service.get_distribution_list(options)
|
||||
end
|
||||
|
||||
alias :each_distribution_this_page :each
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
def save
|
||||
requires :paths, :caller_reference
|
||||
raise "Submitted invalidation cannot be submitted again" if persisted?
|
||||
response = connection.post_invalidation(distribution.identity, paths, caller_reference)
|
||||
response = service.post_invalidation(distribution.identity, paths, caller_reference)
|
||||
merge_attributes(invalidation_to_attributes(response.body))
|
||||
true
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ module Fog
|
|||
options[:max_items] ||= max_items
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.get_invalidation_list(distribution.identity, options).body
|
||||
data = service.get_invalidation_list(distribution.identity, options).body
|
||||
|
||||
merge_attributes(data.reject {|key, value| !['IsTruncated', 'MaxItems', 'NextMarker', 'Marker'].include?(key)})
|
||||
|
||||
|
@ -31,7 +31,7 @@ module Fog
|
|||
def get(invalidation_id)
|
||||
requires :distribution
|
||||
|
||||
data = connection.get_invalidation(distribution.identity, invalidation_id).body
|
||||
data = service.get_invalidation(distribution.identity, invalidation_id).body
|
||||
|
||||
if data
|
||||
invalidation = new(data)
|
||||
|
|
|
@ -41,15 +41,15 @@ module Fog
|
|||
private
|
||||
|
||||
def delete_distribution(identity, etag)
|
||||
connection.delete_streaming_distribution(identity, etag)
|
||||
service.delete_streaming_distribution(identity, etag)
|
||||
end
|
||||
|
||||
def put_distribution_config(identity, etag, options)
|
||||
connection.put_streaming_distribution_config(identity, etag, options)
|
||||
service.put_streaming_distribution_config(identity, etag, options)
|
||||
end
|
||||
|
||||
def post_distribution(options = {})
|
||||
connection.post_streaming_distribution(options)
|
||||
service.post_streaming_distribution(options)
|
||||
end
|
||||
|
||||
def attributes_to_options
|
||||
|
|
|
@ -16,11 +16,11 @@ module Fog
|
|||
attribute :is_truncated, :aliases => 'IsTruncated'
|
||||
|
||||
def get_distribution(dist_id)
|
||||
connection.get_streaming_distribution(dist_id)
|
||||
service.get_streaming_distribution(dist_id)
|
||||
end
|
||||
|
||||
def list_distributions(options = {})
|
||||
connection.get_streaming_distribution_list(options)
|
||||
service.get_streaming_distribution_list(options)
|
||||
end
|
||||
|
||||
alias :each_distribution_this_page :each
|
||||
|
|
|
@ -46,13 +46,13 @@ module Fog
|
|||
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
||||
options.delete_if { |key, value| value.nil? }
|
||||
|
||||
connection.put_metric_alarm(options)
|
||||
service.put_metric_alarm(options)
|
||||
reload
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_alarms(id)
|
||||
service.delete_alarms(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,33 +6,33 @@ module Fog
|
|||
class CloudWatch
|
||||
class AlarmData < Fog::Collection
|
||||
model Fog::AWS::CloudWatch::AlarmDatum
|
||||
|
||||
|
||||
def all(conditions={})
|
||||
data = connection.describe_alarms(conditions).body['DescribeAlarmsResult']['MetricAlarms']
|
||||
data = service.describe_alarms(conditions).body['DescribeAlarmsResult']['MetricAlarms']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
|
||||
def get(namespace, metric_name, dimensions=nil, period=nil, statistic=nil, unit=nil)
|
||||
list_opts = {'Namespace' => namespace, 'MetricName' => metric_name}
|
||||
if dimensions
|
||||
dimensions_array = dimensions.collect do |name, value|
|
||||
{'Name' => name, 'Value' => value}
|
||||
end
|
||||
list_opts.merge!('Dimensions' => dimensions_array)
|
||||
list_opts.merge!('Dimensions' => dimensions_array)
|
||||
end
|
||||
if period
|
||||
list_opts.merge!('Period' => period)
|
||||
list_opts.merge!('Period' => period)
|
||||
end
|
||||
if statistic
|
||||
list_opts.merge!('Statistic' => statistic)
|
||||
list_opts.merge!('Statistic' => statistic)
|
||||
end
|
||||
if unit
|
||||
list_opts.merge!('Unit' => unit)
|
||||
list_opts.merge!('Unit' => unit)
|
||||
end
|
||||
data = connection.describe_alarms_for_metric(list_opts).body['DescribeAlarmsForMetricResult']['MetricAlarms']
|
||||
data = service.describe_alarms_for_metric(list_opts).body['DescribeAlarmsForMetricResult']['MetricAlarms']
|
||||
load(data)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
attribute :comparison_operator, :aliases => 'ComparisonOperator'
|
||||
attribute :state_reason, :aliases => 'StateReason'
|
||||
attribute :action_enabled, :aliases => 'ActionsEnabled'
|
||||
attribute :period, :aliases => 'Period'
|
||||
attribute :period, :aliases => 'Period'
|
||||
attribute :evaluation_periods, :aliases => 'EvaluationPeriods'
|
||||
attribute :threshold, :aliases => 'Threshold'
|
||||
attribute :alarm_actions, :aliases => 'AlarmActions'
|
||||
|
@ -40,7 +40,7 @@ module Fog
|
|||
'AlarmName' => alarm_name,
|
||||
'ComparisonOperator' => comparison_operator,
|
||||
'EvaluationPeriods' => evaluation_periods,
|
||||
'MetricName' => metric_name,
|
||||
'MetricName' => metric_name,
|
||||
'Namespace' => namespace,
|
||||
'Period' => period,
|
||||
'Statistic' => statistic,
|
||||
|
@ -57,7 +57,7 @@ module Fog
|
|||
alarm_definition.merge!('OKActions' => ok_actions) if ok_actions
|
||||
alarm_definition.merge!('Unit' => unit) if unit
|
||||
|
||||
connection.put_metric_alarm(alarm_definition)
|
||||
service.put_metric_alarm(alarm_definition)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
|||
model Fog::AWS::CloudWatch::AlarmHistory
|
||||
|
||||
def all(conditions={})
|
||||
data = connection.describe_alarm_history(conditions).body['DescribeAlarmHistoryResult']['AlarmHistoryItems']
|
||||
data = service.describe_alarm_history(conditions).body['DescribeAlarmHistoryResult']['AlarmHistoryItems']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
|||
data = []
|
||||
next_token = nil
|
||||
loop do
|
||||
result = connection.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult']
|
||||
result = service.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult']
|
||||
data += result['MetricAlarms']
|
||||
next_token = result['NextToken']
|
||||
break if next_token.nil?
|
||||
|
@ -21,23 +21,23 @@ module Fog
|
|||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first
|
||||
data = service.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first
|
||||
new(data) unless data.nil?
|
||||
end
|
||||
|
||||
#alarm_names is an array of alarm names
|
||||
def delete(alarm_names)
|
||||
connection.delete_alarms(alarm_names)
|
||||
service.delete_alarms(alarm_names)
|
||||
true
|
||||
end
|
||||
|
||||
def disable(alarm_names)
|
||||
connection.disable_alarm_actions(alarm_names)
|
||||
service.disable_alarm_actions(alarm_names)
|
||||
true
|
||||
end
|
||||
|
||||
def enable(alarm_names)
|
||||
connection.enable_alarm_actions(alarm_names)
|
||||
service.enable_alarm_actions(alarm_names)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
|||
attribute :namespace, :aliases => 'Namespace'
|
||||
attribute :dimensions, :aliases => 'Dimensions'
|
||||
attribute :value
|
||||
|
||||
|
||||
def save
|
||||
requires :metric_name
|
||||
requires :namespace
|
||||
|
@ -36,7 +36,7 @@ module Fog
|
|||
'SampleCount' => sample_count
|
||||
})
|
||||
end
|
||||
connection.put_metric_data(namespace, [put_opts])
|
||||
service.put_metric_data(namespace, [put_opts])
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,17 +6,17 @@ module Fog
|
|||
class CloudWatch
|
||||
class MetricStatistics < Fog::Collection
|
||||
model Fog::AWS::CloudWatch::MetricStatistic
|
||||
|
||||
|
||||
def all(conditions)
|
||||
metricName = conditions['MetricName']
|
||||
namespace = conditions['Namespace']
|
||||
dimensions = conditions['Dimensions']
|
||||
get_metric_opts = {"StartTime" => (Time.now-3600).iso8601, "EndTime" => Time.now.iso8601, "Period" => 300}.merge(conditions)
|
||||
data = connection.get_metric_statistics(get_metric_opts).body['GetMetricStatisticsResult']['Datapoints']
|
||||
data = service.get_metric_statistics(get_metric_opts).body['GetMetricStatisticsResult']['Datapoints']
|
||||
data.collect! { |datum| datum.merge('MetricName' => metricName, 'Namespace' => namespace, 'Dimensions' => dimensions) }
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ module Fog
|
|||
model Fog::AWS::CloudWatch::Metric
|
||||
|
||||
def all(conditions={})
|
||||
result = connection.list_metrics(conditions).body['ListMetricsResult']
|
||||
result = service.list_metrics(conditions).body['ListMetricsResult']
|
||||
merge_attributes("NextToken" => result["NextToken"])
|
||||
load(result['Metrics']) # an array of attribute hashes
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ module Fog
|
|||
subset = subset.all("NextToken" => next_token)
|
||||
subset.each_metric_this_page {|m| yield m }
|
||||
end
|
||||
|
||||
|
||||
self
|
||||
end
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ module Fog
|
|||
end
|
||||
# list_opts.merge!('Dimensions' => dimensions_array)
|
||||
end
|
||||
if data = connection.list_metrics(list_opts).body['ListMetricsResult']['Metrics'].first
|
||||
if data = service.list_metrics(list_opts).body['ListMetricsResult']['Metrics'].first
|
||||
new(data)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ module Fog
|
|||
def destroy
|
||||
requires :public_ip
|
||||
|
||||
connection.release_address(allocation_id || public_ip)
|
||||
service.release_address(allocation_id || public_ip)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -35,12 +35,12 @@ module Fog
|
|||
end
|
||||
|
||||
def server
|
||||
connection.servers.get(server_id)
|
||||
service.servers.get(server_id)
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
data = connection.allocate_address(domain).body
|
||||
data = service.allocate_address(domain).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
if @server
|
||||
|
@ -57,7 +57,7 @@ module Fog
|
|||
else
|
||||
@server = nil
|
||||
self.server_id = new_server.id
|
||||
connection.associate_address(server_id, public_ip, network_interface_id, allocation_id)
|
||||
service.associate_address(server_id, public_ip, network_interface_id, allocation_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ module Fog
|
|||
@server = nil
|
||||
self.server_id = nil
|
||||
if persisted?
|
||||
connection.disassociate_address(public_ip)
|
||||
service.disassociate_address(public_ip)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ module Fog
|
|||
filters = {'public-ip' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_addresses(filters).body
|
||||
data = service.describe_addresses(filters).body
|
||||
load(
|
||||
data['addressesSet'].map do |address|
|
||||
address.reject {|key, value| value.nil? || value.empty? }
|
||||
|
@ -81,7 +81,7 @@ module Fog
|
|||
|
||||
def get(public_ip)
|
||||
if public_ip
|
||||
self.class.new(:connection => connection).all('public-ip' => public_ip).first
|
||||
self.class.new(:service => service).all('public-ip' => public_ip).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
#
|
||||
def associate(vpc_id)
|
||||
requires :id
|
||||
connection.attach_dhcp_option(id, vpc_id)
|
||||
service.attach_dhcp_option(id, vpc_id)
|
||||
#reload
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_dhcp_options(id)
|
||||
service.delete_dhcp_options(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :dhcp_configuration_set
|
||||
data = connection.create_dhcp_options(dhcp_configuration_set).body['dhcpOptionsSet'].first
|
||||
data = service.create_dhcp_options(dhcp_configuration_set).body['dhcpOptionsSet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -59,7 +59,7 @@ module Fog
|
|||
filters = {'dhcp-options-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_dhcp_options(filters).body
|
||||
data = service.describe_dhcp_options(filters).body
|
||||
load(data['dhcpOptionsSet'])
|
||||
end
|
||||
|
||||
|
@ -80,7 +80,7 @@ module Fog
|
|||
|
||||
def get(dhcp_options_id)
|
||||
if dhcp_options_id
|
||||
self.class.new(:connection => connection).all('dhcp-options-id' => dhcp_options_id).first
|
||||
self.class.new(:service => service).all('dhcp-options-id' => dhcp_options_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ module Fog
|
|||
#
|
||||
|
||||
def get(flavor_id)
|
||||
self.class.new(:connection => connection).all.detect {|flavor| flavor.id == flavor_id}
|
||||
self.class.new(:service => service).all.detect {|flavor| flavor.id == flavor_id}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -27,11 +27,11 @@ module Fog
|
|||
attribute :name
|
||||
|
||||
def deregister(delete_snapshot = false)
|
||||
connection.deregister_image(id)
|
||||
service.deregister_image(id)
|
||||
|
||||
if(delete_snapshot && root_device_type == "ebs")
|
||||
block_device = block_device_mapping.detect {|block_device| block_device['deviceName'] == root_device_name}
|
||||
@connection.snapshots.new(:id => block_device['snapshotId']).destroy
|
||||
service.snapshots.new(:id => block_device['snapshotId']).destroy
|
||||
else
|
||||
true
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
attribute :filters
|
||||
|
||||
model Fog::Compute::AWS::Image
|
||||
|
||||
|
||||
# Creates a new Amazon machine image
|
||||
#
|
||||
# AWS.images.new
|
||||
|
@ -38,7 +38,7 @@ module Fog
|
|||
# tags=nil
|
||||
# >
|
||||
#
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
|
@ -46,13 +46,13 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_images(filters).body
|
||||
data = service.describe_images(filters).body
|
||||
load(data['imagesSet'])
|
||||
end
|
||||
|
||||
|
||||
def get(image_id)
|
||||
if image_id
|
||||
self.class.new(:connection => connection).all('image-id' => image_id).first
|
||||
self.class.new(:service => service).all('image-id' => image_id).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
#
|
||||
def attach(vpc_id)
|
||||
requires :id
|
||||
connection.attach_internet_gateway(id, vpc_id)
|
||||
service.attach_internet_gateway(id, vpc_id)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ module Fog
|
|||
#
|
||||
def detach(vpc_id)
|
||||
requires :id
|
||||
connection.detach_internet_gateway(id, vpc_id)
|
||||
service.detach_internet_gateway(id, vpc_id)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -54,7 +54,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_internet_gateway(id)
|
||||
service.delete_internet_gateway(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -68,7 +68,7 @@ module Fog
|
|||
# requestId and a internetGateway object
|
||||
#
|
||||
def save
|
||||
data = connection.create_internet_gateway.body['internetGatewaySet'].first
|
||||
data = service.create_internet_gateway.body['internetGatewaySet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -59,7 +59,7 @@ module Fog
|
|||
filters = {'internet-gateway-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_internet_gateways(filters).body
|
||||
data = service.describe_internet_gateways(filters).body
|
||||
load(data['internetGatewaySet'])
|
||||
end
|
||||
|
||||
|
@ -80,7 +80,7 @@ module Fog
|
|||
|
||||
def get(internet_gateway_id)
|
||||
if internet_gateway_id
|
||||
self.class.new(:connection => connection).all('internet-gateway-id' => internet_gateway_id).first
|
||||
self.class.new(:service => service).all('internet-gateway-id' => internet_gateway_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
def destroy
|
||||
requires :name
|
||||
|
||||
connection.delete_key_pair(name)
|
||||
service.delete_key_pair(name)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -24,9 +24,9 @@ module Fog
|
|||
requires :name
|
||||
|
||||
data = if public_key
|
||||
connection.import_key_pair(name, public_key).body
|
||||
service.import_key_pair(name, public_key).body
|
||||
else
|
||||
connection.create_key_pair(name).body
|
||||
service.create_key_pair(name).body
|
||||
end
|
||||
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
||||
merge_attributes(new_attributes)
|
||||
|
@ -35,7 +35,7 @@ module Fog
|
|||
end
|
||||
|
||||
def write(path="#{ENV['HOME']}/.ssh/fog_#{Fog.credential.to_s}_#{name}.pem")
|
||||
|
||||
|
||||
if writable?
|
||||
split_private_key = private_key.split(/\n/)
|
||||
File.open(path, "w") do |f|
|
||||
|
|
|
@ -55,7 +55,7 @@ module Fog
|
|||
filters = {'key-name' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_key_pairs(filters).body
|
||||
data = service.describe_key_pairs(filters).body
|
||||
load(data['keySet'])
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ module Fog
|
|||
|
||||
def get(key_name)
|
||||
if key_name
|
||||
self.class.new(:connection => connection).all('key-name' => key_name).first
|
||||
self.class.new(:service => service).all('key-name' => key_name).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
|||
class NetworkInterface < Fog::Model
|
||||
|
||||
identity :network_interface_id, :aliases => 'networkInterfaceId'
|
||||
attribute :state
|
||||
attribute :state
|
||||
attribute :request_id, :aliases => 'requestId'
|
||||
attribute :network_interface_id, :aliases => 'networkInterfaceId'
|
||||
attribute :subnet_id, :aliases => 'subnetId'
|
||||
|
@ -40,7 +40,7 @@ module Fog
|
|||
def destroy
|
||||
requires :network_interface_id
|
||||
|
||||
connection.delete_network_interface(network_interface_id)
|
||||
service.delete_network_interface(network_interface_id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -58,7 +58,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :subnet_id
|
||||
data = connection.create_network_interface(subnet_id).body['networkInterface']
|
||||
data = service.create_network_interface(subnet_id).body['networkInterface']
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -88,7 +88,7 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_network_interfaces(filters).body
|
||||
data = service.describe_network_interfaces(filters).body
|
||||
load(data['networkInterfaceSet'])
|
||||
end
|
||||
|
||||
|
@ -126,7 +126,7 @@ module Fog
|
|||
|
||||
def get(nic_id)
|
||||
if nic_id
|
||||
self.class.new(:connection => connection).all('network-interface-id' => nic_id).first
|
||||
self.class.new(:service => service).all('network-interface-id' => nic_id).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module Fog
|
|||
|
||||
requires_one :name, :group_id
|
||||
|
||||
connection.authorize_security_group_ingress(
|
||||
service.authorize_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'SourceSecurityGroupName' => group,
|
||||
|
@ -101,7 +101,7 @@ module Fog
|
|||
]
|
||||
end
|
||||
|
||||
connection.authorize_security_group_ingress(
|
||||
service.authorize_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'IpPermissions' => [ ip_permission ]
|
||||
|
@ -121,9 +121,9 @@ module Fog
|
|||
requires_one :name, :group_id
|
||||
|
||||
if group_id.nil?
|
||||
connection.delete_security_group(name)
|
||||
service.delete_security_group(name)
|
||||
else
|
||||
connection.delete_security_group(nil, group_id)
|
||||
service.delete_security_group(nil, group_id)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
@ -159,7 +159,7 @@ module Fog
|
|||
|
||||
requires_one :name, :group_id
|
||||
|
||||
connection.revoke_security_group_ingress(
|
||||
service.revoke_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'SourceSecurityGroupName' => group,
|
||||
|
@ -215,7 +215,7 @@ module Fog
|
|||
]
|
||||
end
|
||||
|
||||
connection.revoke_security_group_ingress(
|
||||
service.revoke_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'IpPermissions' => [ ip_permission ]
|
||||
|
@ -235,7 +235,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :description, :name
|
||||
data = connection.create_security_group(name, description, vpc_id).body
|
||||
data = service.create_security_group(name, description, vpc_id).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -63,7 +63,7 @@ module Fog
|
|||
filters = {'group-name' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_security_groups(filters).body
|
||||
data = service.describe_security_groups(filters).body
|
||||
load(data['securityGroupInfo'])
|
||||
end
|
||||
|
||||
|
@ -87,7 +87,7 @@ module Fog
|
|||
|
||||
def get(group_name)
|
||||
if group_name
|
||||
self.class.new(:connection => connection).all('group-name' => group_name).first
|
||||
self.class.new(:service => service).all('group-name' => group_name).first
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,7 +110,7 @@ module Fog
|
|||
|
||||
def get_by_id(group_id)
|
||||
if group_id
|
||||
self.class.new(:connection => connection).all('group-id' => group_id).first
|
||||
self.class.new(:service => service).all('group-id' => group_id).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,9 +53,13 @@ module Fog
|
|||
def initialize(attributes={})
|
||||
self.groups ||= ["default"] unless (attributes[:subnet_id] || attributes[:security_group_ids])
|
||||
self.flavor_id ||= 't1.micro'
|
||||
|
||||
# Old 'connection' is renamed as service and should be used instead
|
||||
prepare_service_value(attributes)
|
||||
|
||||
self.image_id ||= begin
|
||||
self.username = 'ubuntu'
|
||||
case attributes[:connection].instance_variable_get(:@region) # Ubuntu 10.04 LTS 64bit (EBS)
|
||||
case @service.instance_variable_get(:@region) # Ubuntu 10.04 LTS 64bit (EBS)
|
||||
when 'ap-northeast-1'
|
||||
'ami-5e0fa45f'
|
||||
when 'ap-southeast-1'
|
||||
|
@ -80,19 +84,19 @@ module Fog
|
|||
def addresses
|
||||
requires :id
|
||||
|
||||
connection.addresses(:server => self)
|
||||
service.addresses(:server => self)
|
||||
end
|
||||
|
||||
def console_output
|
||||
requires :id
|
||||
|
||||
connection.get_console_output(id)
|
||||
service.get_console_output(id)
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.terminate_instances(id)
|
||||
service.terminate_instances(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -106,13 +110,13 @@ module Fog
|
|||
end
|
||||
|
||||
def flavor
|
||||
@flavor ||= connection.flavors.all.detect {|flavor| flavor.id == flavor_id}
|
||||
@flavor ||= service.flavors.all.detect {|flavor| flavor.id == flavor_id}
|
||||
end
|
||||
|
||||
def key_pair
|
||||
requires :key_name
|
||||
|
||||
connection.key_pairs.all(key_name).first
|
||||
service.key_pairs.all(key_name).first
|
||||
end
|
||||
|
||||
def key_pair=(new_keypair)
|
||||
|
@ -125,7 +129,7 @@ module Fog
|
|||
|
||||
def reboot
|
||||
requires :id
|
||||
connection.reboot_instances(id)
|
||||
service.reboot_instances(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -166,14 +170,14 @@ module Fog
|
|||
options.delete('SubnetId')
|
||||
end
|
||||
|
||||
data = connection.run_instances(image_id, 1, 1, options)
|
||||
data = service.run_instances(image_id, 1, 1, options)
|
||||
merge_attributes(data.body['instancesSet'].first)
|
||||
|
||||
if tags = self.tags
|
||||
# expect eventual consistency
|
||||
Fog.wait_for { self.reload rescue nil }
|
||||
for key, value in (self.tags = tags)
|
||||
connection.tags.create(
|
||||
service.tags.create(
|
||||
:key => key,
|
||||
:resource_id => self.identity,
|
||||
:value => value
|
||||
|
@ -205,19 +209,19 @@ module Fog
|
|||
|
||||
def start
|
||||
requires :id
|
||||
connection.start_instances(id)
|
||||
service.start_instances(id)
|
||||
true
|
||||
end
|
||||
|
||||
def stop(force = false)
|
||||
requires :id
|
||||
connection.stop_instances(id, force)
|
||||
service.stop_instances(id, force)
|
||||
true
|
||||
end
|
||||
|
||||
def volumes
|
||||
requires :id
|
||||
connection.volumes(:server => self)
|
||||
service.volumes(:server => self)
|
||||
end
|
||||
|
||||
#I tried to call it monitoring= and be smart with attributes[]
|
||||
|
@ -227,9 +231,9 @@ module Fog
|
|||
if persisted?
|
||||
case new_monitor
|
||||
when true
|
||||
response = connection.monitor_instances(identity)
|
||||
response = service.monitor_instances(identity)
|
||||
when false
|
||||
response = connection.unmonitor_instances(identity)
|
||||
response = service.unmonitor_instances(identity)
|
||||
else
|
||||
raise ArgumentError.new("only Boolean allowed here")
|
||||
end
|
||||
|
|
|
@ -61,7 +61,7 @@ module Fog
|
|||
filters = {'instance-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_instances(filters).body
|
||||
data = service.describe_instances(filters).body
|
||||
load(
|
||||
data['reservationSet'].map do |reservation|
|
||||
reservation['instancesSet'].map do |instance|
|
||||
|
@ -72,13 +72,13 @@ module Fog
|
|||
end
|
||||
|
||||
def bootstrap(new_attributes = {})
|
||||
server = connection.servers.new(new_attributes)
|
||||
server = service.servers.new(new_attributes)
|
||||
|
||||
unless new_attributes[:key_name]
|
||||
# first or create fog_#{credential} keypair
|
||||
name = Fog.respond_to?(:credential) && Fog.credential || :default
|
||||
unless server.key_pair = connection.key_pairs.get("fog_#{name}")
|
||||
server.key_pair = connection.key_pairs.create(
|
||||
unless server.key_pair = service.key_pairs.get("fog_#{name}")
|
||||
server.key_pair = service.key_pairs.create(
|
||||
:name => "fog_#{name}",
|
||||
:public_key => server.public_key
|
||||
)
|
||||
|
@ -86,7 +86,7 @@ module Fog
|
|||
end
|
||||
|
||||
# make sure port 22 is open in the first security group
|
||||
security_group = connection.security_groups.get(server.groups.first)
|
||||
security_group = service.security_groups.get(server.groups.first)
|
||||
authorized = security_group.ip_permissions.detect do |ip_permission|
|
||||
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
||||
ip_permission['fromPort'] == 22 &&
|
||||
|
@ -145,7 +145,7 @@ module Fog
|
|||
|
||||
def get(server_id)
|
||||
if server_id
|
||||
self.class.new(:connection => connection).all('instance-id' => server_id).first
|
||||
self.class.new(:service => service).all('instance-id' => server_id).first
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_snapshot(id)
|
||||
service.delete_snapshot(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ module Fog
|
|||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
requires :volume_id
|
||||
|
||||
data = connection.create_snapshot(volume_id, description).body
|
||||
data = service.create_snapshot(volume_id, description).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
@ -40,7 +40,7 @@ module Fog
|
|||
|
||||
def volume
|
||||
requires :id
|
||||
connection.describe_volumes(volume_id)
|
||||
service.describe_volumes(volume_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -23,17 +23,17 @@ module Fog
|
|||
filters = {'snapshot-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_snapshots(filters.merge!(options)).body
|
||||
data = service.describe_snapshots(filters.merge!(options)).body
|
||||
load(data['snapshotSet'])
|
||||
if volume
|
||||
self.replace(self.select {|snapshot| snapshot.volume_id == volume.id})
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
def get(snapshot_id)
|
||||
if snapshot_id
|
||||
self.class.new(:connection => connection).all('snapshot-id' => snapshot_id).first
|
||||
self.class.new(:service => service).all('snapshot-id' => snapshot_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'fog/compute/models/server'
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
||||
|
||||
class SpotRequest < Fog::Compute::Server
|
||||
|
||||
identity :id, :aliases => 'spotInstanceRequestId'
|
||||
|
@ -37,13 +37,16 @@ module Fog
|
|||
|
||||
attr_writer :iam_instance_profile_name, :iam_instance_profile_arn
|
||||
|
||||
|
||||
def initialize(attributes={})
|
||||
self.groups ||= ["default"]
|
||||
self.flavor_id ||= 't1.micro'
|
||||
self.image_id ||= begin
|
||||
self.username = 'ubuntu'
|
||||
case attributes[:connection].instance_variable_get(:@region) # Ubuntu 10.04 LTS 64bit (EBS)
|
||||
|
||||
# Old 'connection' is renamed as service and should be used instead
|
||||
prepare_service_value(attributes)
|
||||
|
||||
case @service.instance_variable_get(:@region) # Ubuntu 10.04 LTS 64bit (EBS)
|
||||
when 'ap-northeast-1'
|
||||
'ami-5e0fa45f'
|
||||
when 'ap-southeast-1'
|
||||
|
@ -62,14 +65,14 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.cancel_spot_instance_requests(id)
|
||||
service.cancel_spot_instance_requests(id)
|
||||
true
|
||||
end
|
||||
|
||||
def key_pair
|
||||
requires :key_name
|
||||
|
||||
connection.key_pairs.all(key_name).first
|
||||
service.key_pairs.all(key_name).first
|
||||
end
|
||||
|
||||
def key_pair=(new_keypair)
|
||||
|
@ -100,7 +103,7 @@ module Fog
|
|||
'ValidFrom' => valid_from,
|
||||
'ValidUntil' => valid_until }
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
|
||||
# If subnet is defined then this is a Virtual Private Cloud.
|
||||
# subnet & security group cannot co-exist. Attempting to specify
|
||||
# both subnet and groups will cause an error. Instead please make
|
||||
|
@ -111,7 +114,7 @@ module Fog
|
|||
options.delete('LaunchSpecification.SubnetId')
|
||||
end
|
||||
|
||||
data = connection.request_spot_instances(image_id, flavor_id, price, options).body
|
||||
data = service.request_spot_instances(image_id, flavor_id, price, options).body
|
||||
spot_instance_request = data['spotInstanceRequestSet'].first
|
||||
spot_instance_request['launchSpecification'].each do |name,value|
|
||||
spot_instance_request['LaunchSpecification.' + name[0,1].upcase + name[1..-1]] = value
|
||||
|
@ -124,4 +127,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,9 +5,9 @@ module Fog
|
|||
module Compute
|
||||
class AWS
|
||||
class SpotRequests < Fog::Collection
|
||||
|
||||
|
||||
attribute :filters
|
||||
|
||||
|
||||
model Fog::Compute::AWS::SpotRequest
|
||||
|
||||
def initialize(attributes)
|
||||
|
@ -21,7 +21,7 @@ module Fog
|
|||
filters = {'spot-instance-request-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_spot_instance_requests(filters).body
|
||||
data = service.describe_spot_instance_requests(filters).body
|
||||
load(
|
||||
data['spotInstanceRequestSet'].map do |spot_instance_request|
|
||||
spot_instance_request['LaunchSpecification.Placement.AvailabilityZone'] = spot_instance_request['launchedAvailabilityZone']
|
||||
|
@ -29,19 +29,19 @@ module Fog
|
|||
spot_instance_request['LaunchSpecification.' + name[0,1].upcase + name[1..-1]] = value
|
||||
end
|
||||
spot_instance_request.merge(:groups => spot_instance_request['LaunchSpecification.GroupSet'])
|
||||
spot_instance_request
|
||||
spot_instance_request
|
||||
end.flatten
|
||||
)
|
||||
end
|
||||
|
||||
def bootstrap(new_attributes = {})
|
||||
spot_request = connection.spot_requests.new(new_attributes)
|
||||
spot_request = service.spot_requests.new(new_attributes)
|
||||
|
||||
unless new_attributes[:key_name]
|
||||
# first or create fog_#{credential} keypair
|
||||
name = Fog.respond_to?(:credential) && Fog.credential || :default
|
||||
unless spot_request.key_pair = connection.key_pairs.get("fog_#{name}")
|
||||
spot_request.key_pair = connection.key_pairs.create(
|
||||
unless spot_request.key_pair = service.key_pairs.get("fog_#{name}")
|
||||
spot_request.key_pair = service.key_pairs.create(
|
||||
:name => "fog_#{name}",
|
||||
:public_key => spot_request.public_key
|
||||
)
|
||||
|
@ -49,7 +49,7 @@ module Fog
|
|||
end
|
||||
|
||||
# make sure port 22 is open in the first security group
|
||||
security_group = connection.security_groups.get(spot_request.groups.first)
|
||||
security_group = service.security_groups.get(spot_request.groups.first)
|
||||
authorized = security_group.ip_permissions.detect do |ip_permission|
|
||||
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
||||
ip_permission['fromPort'] == 22 &&
|
||||
|
@ -62,10 +62,10 @@ module Fog
|
|||
|
||||
spot_request.save
|
||||
Fog.wait_for { spot_request.reload.ready? rescue nil }
|
||||
server = connection.servers.get(spot_request.instance_id)
|
||||
server = service.servers.get(spot_request.instance_id)
|
||||
if spot_request.tags
|
||||
for key, value in spot_request.tags
|
||||
connection.tags.create(
|
||||
service.tags.create(
|
||||
:key => key,
|
||||
:resource_id => spot_request.instance_id,
|
||||
:value => value
|
||||
|
@ -79,7 +79,7 @@ module Fog
|
|||
|
||||
def get(spot_request_id)
|
||||
if spot_request_id
|
||||
self.class.new(:connection => connection).all('spot-instance-request-id' => spot_request_id).first
|
||||
self.class.new(:service => service).all('spot-instance-request-id' => spot_request_id).first
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
|||
class Subnet < Fog::Model
|
||||
|
||||
identity :subnet_id, :aliases => 'subnetId'
|
||||
attribute :state
|
||||
attribute :state
|
||||
attribute :vpc_id, :aliases => 'vpcId'
|
||||
attribute :cidr_block, :aliases => 'cidrBlock'
|
||||
attribute :available_ip_address_count, :aliases => 'availableIpAddressCount'
|
||||
|
@ -27,7 +27,7 @@ module Fog
|
|||
def destroy
|
||||
requires :subnet_id
|
||||
|
||||
connection.delete_subnet(subnet_id)
|
||||
service.delete_subnet(subnet_id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :vpc_id, :cidr_block
|
||||
data = connection.create_subnet(vpc_id, cidr_block).body['subnetSet'].first
|
||||
data = service.create_subnet(vpc_id, cidr_block).body['subnetSet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -63,7 +63,7 @@ module Fog
|
|||
filters = {'subnet-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_subnets(filters).body
|
||||
data = service.describe_subnets(filters).body
|
||||
load(data['subnetSet'])
|
||||
end
|
||||
|
||||
|
@ -88,7 +88,7 @@ module Fog
|
|||
|
||||
def get(subnet_id)
|
||||
if subnet_id
|
||||
self.class.new(:connection => connection).all('subnet-id' => subnet_id).first
|
||||
self.class.new(:service => service).all('subnet-id' => subnet_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :key, :resource_id
|
||||
connection.delete_tags(resource_id, key => value)
|
||||
service.delete_tags(resource_id, key => value)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
requires :key, :resource_id
|
||||
connection.create_tags(resource_id, key => value)
|
||||
service.create_tags(resource_id, key => value)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_tags(filters).body
|
||||
data = service.describe_tags(filters).body
|
||||
load(data['tagSet'])
|
||||
end
|
||||
|
||||
|
||||
def get(key)
|
||||
if key
|
||||
self.class.new(:connection => connection).all('key' => key)
|
||||
self.class.new(:service => service).all('key' => key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_volume(id)
|
||||
service.delete_volume(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ module Fog
|
|||
requires :iops
|
||||
end
|
||||
|
||||
data = connection.create_volume(availability_zone, size, 'SnapshotId' => snapshot_id, 'VolumeType' => type, 'Iops' => iops).body
|
||||
data = service.create_volume(availability_zone, size, 'SnapshotId' => snapshot_id, 'VolumeType' => type, 'Iops' => iops).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
|
||||
|
@ -55,7 +55,7 @@ module Fog
|
|||
# expect eventual consistency
|
||||
Fog.wait_for { self.reload rescue nil }
|
||||
for key, value in (self.tags = tags)
|
||||
connection.tags.create(
|
||||
service.tags.create(
|
||||
:key => key,
|
||||
:resource_id => self.identity,
|
||||
:value => value
|
||||
|
@ -71,7 +71,7 @@ module Fog
|
|||
|
||||
def server
|
||||
requires :server_id
|
||||
connection.servers('instance-id' => server_id)
|
||||
service.servers('instance-id' => server_id)
|
||||
end
|
||||
|
||||
def server=(new_server)
|
||||
|
@ -84,12 +84,12 @@ module Fog
|
|||
|
||||
def snapshots
|
||||
requires :id
|
||||
connection.snapshots(:volume => self)
|
||||
service.snapshots(:volume => self)
|
||||
end
|
||||
|
||||
def snapshot(description)
|
||||
requires :id
|
||||
connection.create_snapshot(id, description)
|
||||
service.create_snapshot(id, description)
|
||||
end
|
||||
|
||||
def force_detach
|
||||
|
@ -110,7 +110,7 @@ module Fog
|
|||
requires :device
|
||||
@server = nil
|
||||
self.server_id = new_server.id
|
||||
connection.attach_volume(server_id, id, device)
|
||||
service.attach_volume(server_id, id, device)
|
||||
reload
|
||||
end
|
||||
end
|
||||
|
@ -119,7 +119,7 @@ module Fog
|
|||
@server = nil
|
||||
self.server_id = nil
|
||||
if persisted?
|
||||
connection.detach_volume(id, 'Force' => force)
|
||||
service.detach_volume(id, 'Force' => force)
|
||||
reload
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ module Fog
|
|||
filters = {'volume-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_volumes(filters).body
|
||||
data = service.describe_volumes(filters).body
|
||||
load(data['volumeSet'])
|
||||
if server
|
||||
self.replace(self.select {|volume| volume.server_id == server.id})
|
||||
|
@ -102,7 +102,7 @@ module Fog
|
|||
|
||||
def get(volume_id)
|
||||
if volume_id
|
||||
self.class.new(:connection => connection).all('volume-id' => volume_id).first
|
||||
self.class.new(:service => service).all('volume-id' => volume_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_vpc(id)
|
||||
service.delete_vpc(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -50,7 +50,7 @@ module Fog
|
|||
def save
|
||||
requires :cidr_block
|
||||
|
||||
data = connection.create_vpc(cidr_block).body['vpcSet'].first
|
||||
data = service.create_vpc(cidr_block).body['vpcSet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -61,7 +61,7 @@ module Fog
|
|||
filters = {'vpc-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_vpcs(filters).body
|
||||
data = service.describe_vpcs(filters).body
|
||||
load(data['vpcSet'])
|
||||
end
|
||||
|
||||
|
@ -82,7 +82,7 @@ module Fog
|
|||
|
||||
def get(vpc_id)
|
||||
if vpc_id
|
||||
self.class.new(:connection => connection).all('vpc-id' => vpc_id).first
|
||||
self.class.new(:service => service).all('vpc-id' => vpc_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
options = attributes_to_options('DELETE')
|
||||
connection.change_resource_record_sets(zone.id, [options])
|
||||
service.change_resource_record_sets(zone.id, [options])
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ module Fog
|
|||
|
||||
def save
|
||||
options = attributes_to_options('CREATE')
|
||||
data = connection.change_resource_record_sets(zone.id, [options]).body
|
||||
data = service.change_resource_record_sets(zone.id, [options]).body
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -54,7 +54,7 @@ module Fog
|
|||
merge_attributes(new_attributes)
|
||||
options << attributes_to_options('CREATE')
|
||||
|
||||
data = connection.change_resource_record_sets(zone.id, options).body
|
||||
data = service.change_resource_record_sets(zone.id, options).body
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -69,7 +69,7 @@ module Fog
|
|||
def reload
|
||||
# If we have a change_id (newly created or modified), then reload performs a get_change to update status.
|
||||
if change_id
|
||||
data = connection.get_change(change_id).body
|
||||
data = service.get_change(change_id).body
|
||||
merge_attributes(data)
|
||||
self
|
||||
else
|
||||
|
|
|
@ -28,7 +28,7 @@ module Fog
|
|||
options[:identifier] ||= identifier
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.list_resource_record_sets(zone.id, options).body
|
||||
data = service.list_resource_record_sets(zone.id, options).body
|
||||
# NextRecordIdentifier is completely absent instead of nil, so set to nil, or iteration breaks.
|
||||
data['NextRecordIdentifier'] = nil unless data.has_key?('NextRecordIdentifier')
|
||||
|
||||
|
@ -57,7 +57,7 @@ module Fog
|
|||
}
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
batch = connection.list_resource_record_sets(zone.id, options).body
|
||||
batch = service.list_resource_record_sets(zone.id, options).body
|
||||
# NextRecordIdentifier is completely absent instead of nil, so set to nil, or iteration breaks.
|
||||
batch['NextRecordIdentifier'] = nil unless batch.has_key?('NextRecordIdentifier')
|
||||
|
||||
|
@ -92,7 +92,7 @@ module Fog
|
|||
}
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.list_resource_record_sets(zone.id, options).body
|
||||
data = service.list_resource_record_sets(zone.id, options).body
|
||||
# Get first record
|
||||
data = data['ResourceRecordSets'].shift
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.delete_hosted_zone(identity)
|
||||
service.delete_hosted_zone(identity)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ module Fog
|
|||
@records ||= begin
|
||||
Fog::DNS::AWS::Records.new(
|
||||
:zone => self,
|
||||
:connection => connection
|
||||
:service => service
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ module Fog
|
|||
options = {}
|
||||
options[:caller_ref] = caller_reference if caller_reference
|
||||
options[:comment] = description if description
|
||||
data = connection.create_hosted_zone(domain, options).body
|
||||
data = service.create_hosted_zone(domain, options).body
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
|
|
@ -15,12 +15,12 @@ module Fog
|
|||
def all(options = {})
|
||||
options['marker'] ||= marker
|
||||
options['maxitems'] ||= max_items
|
||||
data = connection.list_hosted_zones(options).body['HostedZones']
|
||||
data = service.list_hosted_zones(options).body['HostedZones']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(zone_id)
|
||||
data = connection.get_hosted_zone(zone_id).body
|
||||
data = service.get_hosted_zone(zone_id).body
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
|
|
|
@ -35,7 +35,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_cache_cluster(id)
|
||||
service.delete_cache_cluster(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,7 @@ module Fog
|
|||
parameter_group ||= Hash.new
|
||||
notification_config ||= Hash.new
|
||||
|
||||
connection.create_cache_cluster(
|
||||
service.create_cache_cluster(
|
||||
id, {
|
||||
:node_type => node_type,
|
||||
:security_group_names => security_groups,
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
|
||||
def all
|
||||
load(
|
||||
connection.describe_cache_clusters(
|
||||
service.describe_cache_clusters(
|
||||
nil, :show_node_info => true
|
||||
).body['CacheClusters']
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ module Fog
|
|||
|
||||
def get(identity, show_node_info = true)
|
||||
new(
|
||||
connection.describe_cache_clusters(
|
||||
service.describe_cache_clusters(
|
||||
identity, :show_node_info => show_node_info
|
||||
).body['CacheClusters'].first
|
||||
)
|
||||
|
|
|
@ -12,13 +12,13 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_cache_parameter_group(id)
|
||||
service.delete_cache_parameter_group(id)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
requires :id
|
||||
connection.create_cache_parameter_group(
|
||||
service.create_cache_parameter_group(
|
||||
id,
|
||||
description = id,
|
||||
family = 'memcached1.4'
|
||||
|
|
|
@ -10,13 +10,13 @@ module Fog
|
|||
|
||||
def all
|
||||
load(
|
||||
connection.describe_cache_parameter_groups.body['CacheParameterGroups']
|
||||
service.describe_cache_parameter_groups.body['CacheParameterGroups']
|
||||
)
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
new(
|
||||
connection.describe_cache_parameter_groups(
|
||||
service.describe_cache_parameter_groups(
|
||||
identity
|
||||
).body['CacheParameterGroups'].first
|
||||
)
|
||||
|
|
|
@ -17,20 +17,20 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_cache_security_group(id)
|
||||
service.delete_cache_security_group(id)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
requires :id
|
||||
requires :description
|
||||
connection.create_cache_security_group(id, description)
|
||||
service.create_cache_security_group(id, description)
|
||||
end
|
||||
|
||||
def authorize_ec2_group(group_name, group_owner_id=owner_id)
|
||||
requires :id
|
||||
requires :owner_id if group_owner_id.nil?
|
||||
data = connection.authorize_cache_security_group_ingress(
|
||||
data = service.authorize_cache_security_group_ingress(
|
||||
id, group_name, group_owner_id
|
||||
)
|
||||
merge_attributes(data.body['CacheSecurityGroup'])
|
||||
|
@ -39,7 +39,7 @@ module Fog
|
|||
def revoke_ec2_group(group_name, group_owner_id=owner_id)
|
||||
requires :id
|
||||
requires :owner_id if group_owner_id.nil?
|
||||
data = connection.revoke_cache_security_group_ingress(
|
||||
data = service.revoke_cache_security_group_ingress(
|
||||
id, group_name, group_owner_id
|
||||
)
|
||||
merge_attributes(data.body['CacheSecurityGroup'])
|
||||
|
|
|
@ -10,13 +10,13 @@ module Fog
|
|||
|
||||
def all
|
||||
load(
|
||||
connection.describe_cache_security_groups.body['CacheSecurityGroups']
|
||||
service.describe_cache_security_groups.body['CacheSecurityGroups']
|
||||
)
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
new(
|
||||
connection.describe_cache_security_groups(
|
||||
service.describe_cache_security_groups(
|
||||
identity
|
||||
).body['CacheSecurityGroups'].first
|
||||
)
|
||||
|
|
|
@ -19,13 +19,13 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :load_balancer, :instance_port, :lb_port, :protocol, :instance_protocol
|
||||
connection.create_load_balancer_listeners(load_balancer.id, [to_params])
|
||||
service.create_load_balancer_listeners(load_balancer.id, [to_params])
|
||||
reload
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :load_balancer, :lb_port
|
||||
connection.delete_load_balancer_listeners(load_balancer.id, [lb_port])
|
||||
service.delete_load_balancer_listeners(load_balancer.id, [lb_port])
|
||||
reload
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ module Fog
|
|||
|
||||
def initialize(attributes={})
|
||||
if attributes[:subnet_ids] ||= attributes['Subnets']
|
||||
attributes[:availability_zones] ||= attributes['AvailabilityZones']
|
||||
attributes[:availability_zones] ||= attributes['AvailabilityZones']
|
||||
else
|
||||
attributes[:availability_zones] ||= attributes['AvailabilityZones'] || %w(us-east-1a us-east-1b us-east-1c us-east-1d)
|
||||
end
|
||||
|
@ -38,51 +38,51 @@ module Fog
|
|||
|
||||
def register_instances(instances)
|
||||
requires :id
|
||||
data = connection.register_instances_with_load_balancer(instances, id).body['RegisterInstancesWithLoadBalancerResult']
|
||||
data = service.register_instances_with_load_balancer(instances, id).body['RegisterInstancesWithLoadBalancerResult']
|
||||
data['Instances'].map!{|h| h['InstanceId']}
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def deregister_instances(instances)
|
||||
requires :id
|
||||
data = connection.deregister_instances_from_load_balancer(instances, id).body['DeregisterInstancesFromLoadBalancerResult']
|
||||
data = service.deregister_instances_from_load_balancer(instances, id).body['DeregisterInstancesFromLoadBalancerResult']
|
||||
data['Instances'].map!{|h| h['InstanceId']}
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def enable_availability_zones(zones)
|
||||
requires :id
|
||||
data = connection.enable_availability_zones_for_load_balancer(zones, id).body['EnableAvailabilityZonesForLoadBalancerResult']
|
||||
data = service.enable_availability_zones_for_load_balancer(zones, id).body['EnableAvailabilityZonesForLoadBalancerResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def disable_availability_zones(zones)
|
||||
requires :id
|
||||
data = connection.disable_availability_zones_for_load_balancer(zones, id).body['DisableAvailabilityZonesForLoadBalancerResult']
|
||||
data = service.disable_availability_zones_for_load_balancer(zones, id).body['DisableAvailabilityZonesForLoadBalancerResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
|
||||
def attach_subnets(subnet_ids)
|
||||
requires :id
|
||||
data = connection.attach_load_balancer_to_subnets(subnet_ids, id).body['AttachLoadBalancerToSubnetsResult']
|
||||
data = service.attach_load_balancer_to_subnets(subnet_ids, id).body['AttachLoadBalancerToSubnetsResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def detach_subnets(subnet_ids)
|
||||
requires :id
|
||||
data = connection.detach_load_balancer_from_subnets(subnet_ids, id).body['DetachLoadBalancerFromSubnetsResult']
|
||||
data = service.detach_load_balancer_from_subnets(subnet_ids, id).body['DetachLoadBalancerFromSubnetsResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
|
||||
def apply_security_groups(security_groups)
|
||||
requires :id
|
||||
data = connection.apply_security_groups_to_load_balancer(security_groups, id).body['ApplySecurityGroupsToLoadBalancerResult']
|
||||
data = service.apply_security_groups_to_load_balancer(security_groups, id).body['ApplySecurityGroupsToLoadBalancerResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def instance_health
|
||||
requires :id
|
||||
@instance_health ||= connection.describe_instance_health(id).body['DescribeInstanceHealthResult']['InstanceStates']
|
||||
@instance_health ||= service.describe_instance_health(id).body['DescribeInstanceHealthResult']['InstanceStates']
|
||||
end
|
||||
|
||||
def instances_in_service
|
||||
|
@ -95,14 +95,14 @@ module Fog
|
|||
|
||||
def configure_health_check(health_check)
|
||||
requires :id
|
||||
data = connection.configure_health_check(id, health_check).body['ConfigureHealthCheckResult']['HealthCheck']
|
||||
data = service.configure_health_check(id, health_check).body['ConfigureHealthCheckResult']['HealthCheck']
|
||||
merge_attributes(:health_check => data)
|
||||
end
|
||||
|
||||
def listeners
|
||||
Fog::AWS::ELB::Listeners.new({
|
||||
:data => attributes['ListenerDescriptions'],
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
:load_balancer => self
|
||||
})
|
||||
end
|
||||
|
@ -110,7 +110,7 @@ module Fog
|
|||
def policies
|
||||
Fog::AWS::ELB::Policies.new({
|
||||
:data => attributes['Policies'],
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
:load_balancer => self
|
||||
})
|
||||
end
|
||||
|
@ -118,13 +118,13 @@ module Fog
|
|||
def set_listener_policy(port, policy_name)
|
||||
requires :id
|
||||
policy_name = [policy_name].flatten
|
||||
connection.set_load_balancer_policies_of_listener(id, port, policy_name)
|
||||
service.set_load_balancer_policies_of_listener(id, port, policy_name)
|
||||
reload
|
||||
end
|
||||
|
||||
def set_listener_ssl_certificate(port, ssl_certificate_id)
|
||||
requires :id
|
||||
connection.set_load_balancer_listener_ssl_certificate(id, port, ssl_certificate_id)
|
||||
service.set_load_balancer_listener_ssl_certificate(id, port, ssl_certificate_id)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -144,8 +144,8 @@ module Fog
|
|||
# if both are specified, the availability zones have preference
|
||||
#requires :availability_zones
|
||||
if (availability_zones || subnet_ids)
|
||||
connection.create_load_balancer(availability_zones, id, listeners.map{|l| l.to_params}) if availability_zones
|
||||
connection.create_load_balancer(nil, id, listeners.map{|l| l.to_params}, {:subnet_ids => subnet_ids, :security_groups => security_groups, :scheme => scheme}) if subnet_ids && !availability_zones
|
||||
service.create_load_balancer(availability_zones, id, listeners.map{|l| l.to_params}) if availability_zones
|
||||
service.create_load_balancer(nil, id, listeners.map{|l| l.to_params}, {:subnet_ids => subnet_ids, :security_groups => security_groups, :scheme => scheme}) if subnet_ids && !availability_zones
|
||||
else
|
||||
throw Fog::Errors::Error.new("No availability zones or subnet ids specified")
|
||||
end
|
||||
|
@ -164,7 +164,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_load_balancer(id)
|
||||
service.delete_load_balancer(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
|||
marker = nil
|
||||
finished = false
|
||||
while !finished
|
||||
data = connection.describe_load_balancers('Marker' => marker).body
|
||||
data = service.describe_load_balancers('Marker' => marker).body
|
||||
result.concat(data['DescribeLoadBalancersResult']['LoadBalancerDescriptions'])
|
||||
marker = data['DescribeLoadBalancersResult']['NextMarker']
|
||||
finished = marker.nil?
|
||||
|
@ -25,7 +25,7 @@ module Fog
|
|||
|
||||
def get(identity)
|
||||
if identity
|
||||
data = connection.describe_load_balancers('LoadBalancerNames' => identity).body['DescribeLoadBalancersResult']['LoadBalancerDescriptions'].first
|
||||
data = service.describe_load_balancers('LoadBalancerNames' => identity).body['DescribeLoadBalancersResult']['LoadBalancerDescriptions'].first
|
||||
new(data)
|
||||
end
|
||||
rescue Fog::AWS::ELB::NotFound
|
||||
|
|
|
@ -13,7 +13,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :id, :load_balancer, :cookie_stickiness
|
||||
connection_method = nil
|
||||
service_method = nil
|
||||
args = [load_balancer.id, id]
|
||||
case cookie_stickiness
|
||||
when :app
|
||||
|
@ -27,13 +27,13 @@ module Fog
|
|||
raise ArgumentError.new('cookie_stickiness must be :app or :lb')
|
||||
end
|
||||
|
||||
connection.send(method, *args)
|
||||
service.send(method, *args)
|
||||
reload
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id, :load_balancer
|
||||
connection.delete_load_balancer_policy(load_balancer.id, id)
|
||||
service.delete_load_balancer_policy(load_balancer.id, id)
|
||||
reload
|
||||
end
|
||||
|
||||
|
|
|
@ -22,15 +22,15 @@ module Fog
|
|||
if multipart_chunk_size && body.respond_to?(:read)
|
||||
self.id = multipart_save
|
||||
else
|
||||
data = connection.create_archive(vault.id, body, 'description' => description)
|
||||
data = service.create_archive(vault.id, body, 'description' => description)
|
||||
self.id = data.headers['x-amz-archive-id']
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_archive(vault.id,id)
|
||||
service.delete_archive(vault.id,id)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -41,7 +41,7 @@ module Fog
|
|||
|
||||
def multipart_save
|
||||
# Initiate the upload
|
||||
res = connection.initiate_multipart_upload vault.id, multipart_chunk_size, 'description' => description
|
||||
res = service.initiate_multipart_upload vault.id, multipart_chunk_size, 'description' => description
|
||||
upload_id = res.headers["x-amz-multipart-upload-id"]
|
||||
|
||||
hash = Fog::AWS::Glacier::TreeHash.new
|
||||
|
@ -50,17 +50,17 @@ module Fog
|
|||
offset = 0
|
||||
while (chunk = body.read(multipart_chunk_size)) do
|
||||
part_hash = hash.add_part(chunk)
|
||||
part_upload = connection.upload_part(vault.id, upload_id, chunk, offset, part_hash )
|
||||
part_upload = service.upload_part(vault.id, upload_id, chunk, offset, part_hash )
|
||||
offset += chunk.bytesize
|
||||
end
|
||||
|
||||
rescue
|
||||
# Abort the upload & reraise
|
||||
connection.abort_multipart_upload(vault.id, upload_id) if upload_id
|
||||
service.abort_multipart_upload(vault.id, upload_id) if upload_id
|
||||
raise
|
||||
else
|
||||
# Complete the upload
|
||||
connection.complete_multipart_upload(vault.id, upload_id, offset, hash.hexdigest).headers['x-amz-archive-id']
|
||||
service.complete_multipart_upload(vault.id, upload_id, offset, hash.hexdigest).headers['x-amz-archive-id']
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ module Fog
|
|||
requires :vault, :type
|
||||
specification = {'Type' => type, 'ArchiveId' => archive_id, 'Format' => format, 'Description' => description, 'SNSTopic' => sns_topic}.reject{|k,v| v.nil?}
|
||||
|
||||
data = connection.initiate_job(vault.id, specification)
|
||||
data = service.initiate_job(vault.id, specification)
|
||||
self.id = data.headers['x-amz-job-id']
|
||||
reload
|
||||
end
|
||||
|
@ -51,7 +51,7 @@ module Fog
|
|||
options = options.merge :response_block => lambda {|chunk, remaining_bytes, total_bytes| io.write chunk}
|
||||
end
|
||||
options['Range'] = options.delete :range
|
||||
connection.get_job_output(vault.id, id, options)
|
||||
service.get_job_output(vault.id, id, options)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
model Fog::AWS::Glacier::Job
|
||||
attribute :vault
|
||||
attribute :filters
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters = {}
|
||||
super
|
||||
|
@ -21,12 +21,12 @@ module Fog
|
|||
# completed (true/false)
|
||||
def all(filters = self.filters)
|
||||
self.filters = filters
|
||||
data = connection.list_jobs(vault.id, self.filters).body['JobList']
|
||||
data = service.list_jobs(vault.id, self.filters).body['JobList']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(key)
|
||||
data = connection.describe_job(vault.id, key).body
|
||||
data = service.describe_job(vault.id, key).body
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
|
|
|
@ -21,30 +21,30 @@ module Fog
|
|||
end
|
||||
|
||||
def archives
|
||||
@archives ||= Fog::AWS::Glacier::Archives.new(:vault => self, :connection => connection)
|
||||
@archives ||= Fog::AWS::Glacier::Archives.new(:vault => self, :service => service)
|
||||
end
|
||||
|
||||
def jobs(filters={})
|
||||
Fog::AWS::Glacier::Jobs.new(:vault => self, :connection => connection, :filters => filters)
|
||||
Fog::AWS::Glacier::Jobs.new(:vault => self, :service => service, :filters => filters)
|
||||
end
|
||||
|
||||
def set_notification_configuration(topic, events)
|
||||
connection.set_vault_notification_configuration(id, topic, events)
|
||||
service.set_vault_notification_configuration(id, topic, events)
|
||||
end
|
||||
|
||||
def delete_notification_configuration
|
||||
connection.delete_vault_notification_configuration
|
||||
service.delete_vault_notification_configuration
|
||||
end
|
||||
|
||||
|
||||
def save
|
||||
requires :id
|
||||
connection.create_vault(id)
|
||||
service.create_vault(id)
|
||||
reload
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_vault(id)
|
||||
service.delete_vault(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,12 +10,12 @@ module Fog
|
|||
model Fog::AWS::Glacier::Vault
|
||||
|
||||
def all
|
||||
data = connection.list_vaults.body['VaultList']
|
||||
data = service.list_vaults.body['VaultList']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(key)
|
||||
data = connection.describe_vault(key).body
|
||||
data = service.describe_vault(key).body
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
|
|
|
@ -10,29 +10,29 @@ module Fog
|
|||
attribute :username, :aliases => 'UserName'
|
||||
attribute :secret_access_key, :aliases => 'SecretAccessKey'
|
||||
attribute :status, :aliases => 'Status'
|
||||
|
||||
|
||||
def save
|
||||
requires :username
|
||||
|
||||
data = connection.create_access_key('UserName'=> username).body["AccessKey"]
|
||||
data = service.create_access_key('UserName'=> username).body["AccessKey"]
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
requires :username
|
||||
|
||||
connection.delete_access_key(id,'UserName'=> username)
|
||||
service.delete_access_key(id,'UserName'=> username)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def user
|
||||
requires :username
|
||||
connection.users.get(username)
|
||||
service.users.get(username)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,17 +6,17 @@ module Fog
|
|||
class IAM
|
||||
|
||||
class AccessKeys < Fog::Collection
|
||||
|
||||
|
||||
model Fog::AWS::IAM::AccessKey
|
||||
|
||||
|
||||
def initialize(attributes = {})
|
||||
@username = attributes[:username]
|
||||
raise ArgumentError.new("Can't get an access_key's user without a username") unless @username
|
||||
super
|
||||
end
|
||||
|
||||
def all
|
||||
data = connection.list_access_keys('UserName'=> @username).body['AccessKeys']
|
||||
|
||||
def all
|
||||
data = service.list_access_keys('UserName'=> @username).body['AccessKeys']
|
||||
# AWS response doesn't contain the UserName, this injects it
|
||||
data.each {|access_key| access_key['UserName'] = @username }
|
||||
load(data)
|
||||
|
@ -25,7 +25,7 @@ module Fog
|
|||
def get(identity)
|
||||
self.all.select {|access_key| access_key.id == identity}.first
|
||||
end
|
||||
|
||||
|
||||
def new(attributes = {})
|
||||
super({ :username => @username }.merge!(attributes))
|
||||
end
|
||||
|
@ -33,4 +33,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,39 +6,39 @@ module Fog
|
|||
class IAM
|
||||
|
||||
class Policies < Fog::Collection
|
||||
|
||||
|
||||
model Fog::AWS::IAM::Policy
|
||||
|
||||
|
||||
def initialize(attributes = {})
|
||||
@username = attributes[:username]
|
||||
raise ArgumentError.new("Can't get a policy's user without a username") unless @username
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
|
||||
def all
|
||||
# AWS method get_user_policy only returns an array of policy names, this is kind of useless,
|
||||
# AWS method get_user_policy only returns an array of policy names, this is kind of useless,
|
||||
# that's why it has to loop through the list to get the details of each element. I don't like it because it makes this method slow
|
||||
policy_names = connection.list_user_policies(@username).body['PolicyNames'] # it returns an array
|
||||
policy_names = service.list_user_policies(@username).body['PolicyNames'] # it returns an array
|
||||
policies = []
|
||||
policy_names.each do |policy_name|
|
||||
policies << connection.get_user_policy(policy_name,@username).body['Policy']
|
||||
policies << service.get_user_policy(policy_name,@username).body['Policy']
|
||||
end
|
||||
load(policies) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.get_user_policy(identity,@username).body['Policy']
|
||||
data = service.get_user_policy(identity,@username).body['Policy']
|
||||
new(data) # data is an attribute hash
|
||||
rescue Fog::AWS::IAM::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
def new(attributes = {})
|
||||
super({ :username => @username }.merge!(attributes))
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,31 +9,31 @@ module Fog
|
|||
identity :id, :aliases => 'PolicyName'
|
||||
attribute :username, :aliases => 'UserName'
|
||||
attribute :document, :aliases => 'PolicyDocument'
|
||||
|
||||
|
||||
def save
|
||||
requires :id
|
||||
requires :username
|
||||
requires :document
|
||||
|
||||
data = connection.put_user_policy(username, id, document).body
|
||||
data = service.put_user_policy(username, id, document).body
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
requires :username
|
||||
|
||||
connection.delete_user_policy(username, id)
|
||||
service.delete_user_policy(username, id)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def user
|
||||
requires :username
|
||||
connection.users.get(username)
|
||||
service.users.get(username)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,31 +10,31 @@ module Fog
|
|||
attribute :path, :aliases => 'Path'
|
||||
attribute :arn, :aliases => 'Arn'
|
||||
attribute :user_id, :aliases => 'UserId'
|
||||
|
||||
|
||||
def save
|
||||
requires :id
|
||||
data = connection.create_user(id, path || '/').body['User']
|
||||
data = service.create_user(id, path || '/').body['User']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_user(id)
|
||||
service.delete_user(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def policies
|
||||
requires :id
|
||||
connection.policies(:username => id)
|
||||
service.policies(:username => id)
|
||||
end
|
||||
|
||||
|
||||
def access_keys
|
||||
requires :id
|
||||
connection.access_keys(:username => id)
|
||||
service.access_keys(:username => id)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,13 +14,13 @@ module Fog
|
|||
|
||||
def all(options = {})
|
||||
merge_attributes(options)
|
||||
data = connection.list_users(options).body
|
||||
data = service.list_users(options).body
|
||||
merge_attributes('IsTruncated' => data['IsTruncated'], 'Marker' => data['Marker'])
|
||||
load(data['Users']) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.get_user(identity).body['User']
|
||||
data = service.get_user(identity).body['User']
|
||||
new(data) # data is an attribute hash
|
||||
rescue Fog::AWS::IAM::NotFound
|
||||
nil
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module AWS
|
||||
class RDS
|
||||
|
||||
|
||||
class Parameter < Fog::Model
|
||||
|
||||
attribute :name, :aliases => ['ParameterName']
|
||||
|
@ -14,7 +14,7 @@ module Fog
|
|||
attribute :modifiable, :aliases => 'IsModifiable'
|
||||
attribute :apply_type, :aliases => 'ApplyType'
|
||||
attribute :value, :aliases => 'ParameterValue'
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,34 +3,34 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module AWS
|
||||
class RDS
|
||||
|
||||
|
||||
class ParameterGroup < Fog::Model
|
||||
|
||||
identity :id, :aliases => ['DBParameterGroupName', :name]
|
||||
attribute :family, :aliases => 'DBParameterGroupFamily'
|
||||
attribute :description, :aliases => 'Description'
|
||||
|
||||
|
||||
def save
|
||||
requires :family
|
||||
requires :description
|
||||
requires :id
|
||||
connection.create_db_parameter_group(id, family, description)
|
||||
service.create_db_parameter_group(id, family, description)
|
||||
end
|
||||
|
||||
|
||||
def modify(changes)
|
||||
connection.modify_db_parameter_group id, changes.collect {|c| {'ParameterName' => c[:name], 'ParameterValue' => c[:value], 'ApplyMethod' => c[:apply_method]}}
|
||||
service.modify_db_parameter_group id, changes.collect {|c| {'ParameterName' => c[:name], 'ParameterValue' => c[:value], 'ApplyMethod' => c[:apply_method]}}
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_db_parameter_group(id)
|
||||
service.delete_db_parameter_group(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def parameters(filters={})
|
||||
connection.parameters({:group => self}.merge(filters))
|
||||
service.parameters({:group => self}.merge(filters))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,12 +10,12 @@ module Fog
|
|||
model Fog::AWS::RDS::ParameterGroup
|
||||
|
||||
def all
|
||||
data = connection.describe_db_parameter_groups.body['DescribeDBParameterGroupsResult']['DBParameterGroups']
|
||||
data = service.describe_db_parameter_groups.body['DescribeDBParameterGroupsResult']['DBParameterGroups']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.describe_db_parameter_groups(identity).body['DescribeDBParameterGroupsResult']['DBParameterGroups'].first
|
||||
data = service.describe_db_parameter_groups(identity).body['DescribeDBParameterGroupsResult']['DBParameterGroups'].first
|
||||
new(data) # data is an attribute hash
|
||||
rescue Fog::AWS::RDS::NotFound
|
||||
nil
|
||||
|
@ -24,4 +24,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
marker = nil
|
||||
finished = false
|
||||
while !finished
|
||||
data = connection.describe_db_parameters(group.id, filters.merge(:marker => marker)).body
|
||||
data = service.describe_db_parameters(group.id, filters.merge(:marker => marker)).body
|
||||
result.concat(data['DescribeDBParametersResult']['Parameters'])
|
||||
marker = data['DescribeDBParametersResult']['Marker']
|
||||
finished = marker.nil?
|
||||
|
@ -34,4 +34,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_db_security_group(id)
|
||||
service.delete_db_security_group(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -27,7 +27,7 @@ module Fog
|
|||
requires :id
|
||||
requires :description
|
||||
|
||||
data = connection.create_db_security_group(id, description).body['CreateDBSecurityGroupResult']['DBSecurityGroup']
|
||||
data = service.create_db_security_group(id, description).body['CreateDBSecurityGroupResult']['DBSecurityGroup']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ module Fog
|
|||
end
|
||||
|
||||
def authorize_ingress(opts)
|
||||
data = connection.authorize_db_security_group_ingress(id, opts).body['AuthorizeDBSecurityGroupIngressResult']['DBSecurityGroup']
|
||||
data = service.authorize_db_security_group_ingress(id, opts).body['AuthorizeDBSecurityGroupIngressResult']['DBSecurityGroup']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
|
@ -72,7 +72,7 @@ module Fog
|
|||
end
|
||||
|
||||
def revoke_ingress(opts)
|
||||
data = connection.revoke_db_security_group_ingress(id, opts).body['RevokeDBSecurityGroupIngressResult']['DBSecurityGroup']
|
||||
data = service.revoke_db_security_group_ingress(id, opts).body['RevokeDBSecurityGroupIngressResult']['DBSecurityGroup']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_db_security_groups(filters).body['DescribeDBSecurityGroupsResult']['DBSecurityGroups']
|
||||
data = service.describe_db_security_groups(filters).body['DescribeDBSecurityGroupsResult']['DBSecurityGroups']
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
# Example:
|
||||
# get('my_db_security_group') # => model for my_db_security_group
|
||||
def get(identity)
|
||||
data = connection.describe_db_security_groups(identity).body['DescribeDBSecurityGroupsResult']['DBSecurityGroups'].first
|
||||
data = service.describe_db_security_groups(identity).body['DescribeDBSecurityGroupsResult']['DBSecurityGroups'].first
|
||||
new(data) # data is an attribute hash
|
||||
rescue Fog::AWS::RDS::NotFound
|
||||
nil
|
||||
|
|
|
@ -36,8 +36,8 @@ module Fog
|
|||
def create_read_replica(replica_id, options={})
|
||||
options[:security_group_names] ||= options['DBSecurityGroups']
|
||||
params = self.class.new(options).attributes_to_params
|
||||
connection.create_db_instance_read_replica(replica_id, id, params)
|
||||
connection.servers.get(replica_id)
|
||||
service.create_db_instance_read_replica(replica_id, id, params)
|
||||
service.servers.get(replica_id)
|
||||
end
|
||||
|
||||
def ready?
|
||||
|
@ -46,42 +46,42 @@ module Fog
|
|||
|
||||
def destroy(snapshot_identifier=nil)
|
||||
requires :id
|
||||
connection.delete_db_instance(id, snapshot_identifier, snapshot_identifier.nil?)
|
||||
service.delete_db_instance(id, snapshot_identifier, snapshot_identifier.nil?)
|
||||
true
|
||||
end
|
||||
|
||||
def reboot
|
||||
connection.reboot_db_instance(id)
|
||||
service.reboot_db_instance(id)
|
||||
true
|
||||
end
|
||||
|
||||
def snapshots
|
||||
requires :id
|
||||
connection.snapshots(:server => self)
|
||||
service.snapshots(:server => self)
|
||||
end
|
||||
|
||||
def tags
|
||||
requires :id
|
||||
connection.list_tags_for_resource(id).
|
||||
service.list_tags_for_resource(id).
|
||||
body['ListTagsForResourceResult']['TagList']
|
||||
end
|
||||
|
||||
def add_tags(new_tags)
|
||||
requires :id
|
||||
connection.add_tags_to_resource(id, new_tags)
|
||||
service.add_tags_to_resource(id, new_tags)
|
||||
tags
|
||||
end
|
||||
|
||||
def remove_tags(tag_keys)
|
||||
requires :id
|
||||
connection.remove_tags_from_resource(id, tag_keys)
|
||||
service.remove_tags_from_resource(id, tag_keys)
|
||||
tags
|
||||
end
|
||||
|
||||
def modify(immediately, options)
|
||||
options[:security_group_names] ||= options['DBSecurityGroups']
|
||||
params = self.class.new(options).attributes_to_params
|
||||
data = connection.modify_db_instance(id, immediately, params)
|
||||
data = service.modify_db_instance(id, immediately, params)
|
||||
merge_attributes(data.body['ModifyDBInstanceResult']['DBInstance'])
|
||||
true
|
||||
end
|
||||
|
@ -94,7 +94,7 @@ module Fog
|
|||
|
||||
self.flavor_id ||= 'db.m1.small'
|
||||
|
||||
data = connection.create_db_instance(id, attributes_to_params)
|
||||
data = service.create_db_instance(id, attributes_to_params)
|
||||
merge_attributes(data.body['CreateDBInstanceResult']['DBInstance'])
|
||||
true
|
||||
end
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue