mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
ccf8a41870
26 changed files with 753 additions and 22 deletions
|
@ -15,6 +15,9 @@ module Fog
|
|||
request :describe_pipelines
|
||||
request :list_pipelines
|
||||
request :put_pipeline_definition
|
||||
request :get_pipeline_definition
|
||||
request :query_objects
|
||||
request :describe_objects
|
||||
|
||||
model_path 'fog/aws/models/data_pipeline'
|
||||
model :pipeline
|
||||
|
|
|
@ -43,7 +43,9 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :vpc_id, :cidr_block
|
||||
data = service.create_subnet(vpc_id, cidr_block).body['subnetSet'].first
|
||||
options = {}
|
||||
options['AvailabilityZone'] = availability_zone if availability_zone
|
||||
data = service.create_subnet(vpc_id, cidr_block, options).body['subnetSet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -29,6 +29,8 @@ module Fog
|
|||
attribute :notification_config,
|
||||
:aliases => 'NotificationConfiguration', :type => :hash
|
||||
|
||||
attr_accessor :parameter_group_name
|
||||
|
||||
def ready?
|
||||
status == 'available'
|
||||
end
|
||||
|
@ -57,7 +59,7 @@ module Fog
|
|||
:port => port,
|
||||
:preferred_availablility_zone => zone,
|
||||
:preferred_maintenance_window => maintenance_window,
|
||||
:parameter_group_name => parameter_group['CacheParameterGroupName'],
|
||||
:parameter_group_name => parameter_group_name || parameter_group['CacheParameterGroupName'],
|
||||
}
|
||||
)
|
||||
end
|
||||
|
|
41
lib/fog/aws/requests/data_pipeline/describe_objects.rb
Normal file
41
lib/fog/aws/requests/data_pipeline/describe_objects.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class DataPipeline
|
||||
|
||||
class Real
|
||||
|
||||
# Queries a pipeline for the names of objects that match a specified set of conditions.
|
||||
# http://docs.aws.amazon.com/datapipeline/latest/APIReference/API_DescribeObjects.html
|
||||
# ==== Parameters
|
||||
# * PipelineId <~String> - The ID of the pipeline
|
||||
# * ObjectIds <~Array> - Identifiers of the pipeline objects that contain the definitions
|
||||
# to be described. You can pass as many as 25 identifiers in a
|
||||
# single call to DescribeObjects.
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def describe_objects(id, objectIds)
|
||||
params = {
|
||||
'pipelineId' => id,
|
||||
'objectIds' => objectIds,
|
||||
}
|
||||
|
||||
response = request({
|
||||
:body => Fog::JSON.encode(params),
|
||||
:headers => { 'X-Amz-Target' => 'DataPipeline.DescribeObjects' },
|
||||
})
|
||||
|
||||
Fog::JSON.decode(response.body)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def describe_objects(id, objects)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class DataPipeline
|
||||
|
||||
class Real
|
||||
|
||||
# Get pipeline definition JSON
|
||||
# http://docs.aws.amazon.com/datapipeline/latest/APIReference/API_GetPipelineDefinition.html
|
||||
# ==== Parameters
|
||||
# * PipelineId <~String> - The ID of the pipeline
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def get_pipeline_definition(id)
|
||||
params = {
|
||||
'pipelineId' => id,
|
||||
}
|
||||
|
||||
response = request({
|
||||
:body => Fog::JSON.encode(params),
|
||||
:headers => { 'X-Amz-Target' => 'DataPipeline.GetPipelineDefinition' },
|
||||
})
|
||||
|
||||
Fog::JSON.decode(response.body)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_pipeline_definition(id, objects)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
41
lib/fog/aws/requests/data_pipeline/query_objects.rb
Normal file
41
lib/fog/aws/requests/data_pipeline/query_objects.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class DataPipeline
|
||||
|
||||
class Real
|
||||
|
||||
# Queries a pipeline for the names of objects that match a specified set of conditions.
|
||||
# http://docs.aws.amazon.com/datapipeline/latest/APIReference/API_QueryObjects.html
|
||||
# ==== Parameters
|
||||
# * PipelineId <~String> - The ID of the pipeline
|
||||
# * Sphere <~String> - Specifies whether the query applies to components or instances.
|
||||
# Allowable values: COMPONENT, INSTANCE, ATTEMPT.
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def query_objects(id, sphere)
|
||||
params = {
|
||||
'pipelineId' => id,
|
||||
'sphere' => sphere,
|
||||
}
|
||||
|
||||
response = request({
|
||||
:body => Fog::JSON.encode(params),
|
||||
:headers => { 'X-Amz-Target' => 'DataPipeline.QueryObjects' },
|
||||
})
|
||||
|
||||
Fog::JSON.decode(response.body)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def query_objects(id, objects)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -17,6 +17,8 @@ class OpenStack < Fog::Bin
|
|||
Fog::Volume::OpenStack
|
||||
when :metering
|
||||
Fog::Metering::OpenStack
|
||||
when :orchestration
|
||||
Fog::Orchestration::OpenStack
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key}"
|
||||
end
|
||||
|
@ -46,6 +48,9 @@ class OpenStack < Fog::Bin
|
|||
when :metering
|
||||
Fog::Logger.warning("OpenStack[:metering] is not recommended, use Metering[:openstack] for portability")
|
||||
Fog::Metering.new(:provider => 'OpenStack')
|
||||
when :orchestration
|
||||
Fog::Logger.warning("OpenStack[:orchestration] is not recommended, use Orchestration[:openstack] for portability")
|
||||
Fog::Orchestration.new(:provider => 'OpenStack')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
|
|
|
@ -47,3 +47,4 @@ require 'fog/cdn'
|
|||
require 'fog/dns'
|
||||
require 'fog/network'
|
||||
require 'fog/storage'
|
||||
require 'fog/orchestration'
|
||||
|
|
|
@ -48,6 +48,7 @@ module Fog
|
|||
service(:storage, 'openstack/storage', 'Storage')
|
||||
service(:volume, 'openstack/volume', 'Volume')
|
||||
service(:metering, 'openstack/metering', 'Metering')
|
||||
service(:orchestration, 'openstack/orchestration', 'Orchestration')
|
||||
|
||||
def self.authenticate(options, connection_options = {})
|
||||
case options[:openstack_auth_uri].path
|
||||
|
|
|
@ -7,12 +7,20 @@ module Fog
|
|||
|
||||
class Images < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Compute::OpenStack::Image
|
||||
|
||||
attribute :server
|
||||
|
||||
def all
|
||||
data = service.list_images_detail.body['images']
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = service.list_images_detail(filters).body['images']
|
||||
images = load(data)
|
||||
if server
|
||||
self.replace(self.select {|image| image.server_id == server.id})
|
||||
|
|
52
lib/fog/openstack/models/orchestration/stack.rb
Normal file
52
lib/fog/openstack/models/orchestration/stack.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Orchestration
|
||||
class OpenStack
|
||||
class Stack < Fog::Model
|
||||
identity :id
|
||||
|
||||
attribute :stack_name
|
||||
attribute :stack_status
|
||||
attribute :stack_status_reason
|
||||
attribute :creation_time
|
||||
attribute :updated_time
|
||||
attribute :id
|
||||
|
||||
attribute :template_url
|
||||
attribute :template
|
||||
attribute :parameters
|
||||
attribute :timeout_in_minutes
|
||||
|
||||
def initialize(attributes)
|
||||
# Old 'connection' is renamed as service and should be used instead
|
||||
prepare_service_value(attributes)
|
||||
super
|
||||
end
|
||||
|
||||
def save
|
||||
requires :stack_name
|
||||
identity ? update : create
|
||||
end
|
||||
|
||||
def create
|
||||
requires :stack_name
|
||||
service.create_stack(stack_name, self.attributes)
|
||||
self
|
||||
end
|
||||
|
||||
def update
|
||||
requires :stack_name
|
||||
service.update_stack(stack_name, self.attributes)
|
||||
self
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
service.delete_stack(self.stack_name, self.id)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/openstack/models/orchestration/stacks.rb
Normal file
21
lib/fog/openstack/models/orchestration/stacks.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/openstack/models/orchestration/stack'
|
||||
|
||||
module Fog
|
||||
module Orchestration
|
||||
class OpenStack
|
||||
class Stacks < Fog::Collection
|
||||
model Fog::Orchestration::OpenStack::Stack
|
||||
|
||||
def all
|
||||
load(service.list_stacks.body['stacks'])
|
||||
end
|
||||
|
||||
def find_by_id(id)
|
||||
self.find {|stack| stack.id == id}
|
||||
end
|
||||
alias_method :get, :find_by_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
227
lib/fog/openstack/orchestration.rb
Normal file
227
lib/fog/openstack/orchestration.rb
Normal file
|
@ -0,0 +1,227 @@
|
|||
require 'fog/aws/cloud_formation'
|
||||
|
||||
module Fog
|
||||
module Orchestration
|
||||
class OpenStack < Fog::Service
|
||||
requires :openstack_auth_url
|
||||
recognizes :openstack_auth_token, :openstack_management_url,
|
||||
:persistent, :openstack_service_type, :openstack_service_name,
|
||||
:openstack_tenant,
|
||||
:openstack_api_key, :openstack_username, :openstack_identity_endpoint,
|
||||
:current_user, :current_tenant, :openstack_region,
|
||||
:openstack_endpoint_type
|
||||
|
||||
model_path 'fog/openstack/models/orchestration'
|
||||
model :stack
|
||||
collection :stacks
|
||||
|
||||
request_path 'fog/openstack/requests/orchestration'
|
||||
request :create_stack
|
||||
request :update_stack
|
||||
request :delete_stack
|
||||
request :list_stacks
|
||||
|
||||
class Mock
|
||||
attr_reader :auth_token
|
||||
attr_reader :auth_token_expiration
|
||||
attr_reader :current_user
|
||||
attr_reader :current_tenant
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
hash[key] = {
|
||||
:stacks => {}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset
|
||||
@data = nil
|
||||
end
|
||||
|
||||
def initialize(options={})
|
||||
@openstack_username = options[:openstack_username]
|
||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||
|
||||
@current_tenant = options[:openstack_tenant]
|
||||
|
||||
@auth_token = Fog::Mock.random_base64(64)
|
||||
@auth_token_expiration = (Time.now.utc + 86400).iso8601
|
||||
|
||||
management_url = URI.parse(options[:openstack_auth_url])
|
||||
management_url.port = 8774
|
||||
management_url.path = '/v1'
|
||||
@openstack_management_url = management_url.to_s
|
||||
|
||||
identity_public_endpoint = URI.parse(options[:openstack_auth_url])
|
||||
identity_public_endpoint.port = 5000
|
||||
@openstack_identity_public_endpoint = identity_public_endpoint.to_s
|
||||
end
|
||||
|
||||
def data
|
||||
self.class.data["#{@openstack_username}-#{@current_tenant}"]
|
||||
end
|
||||
|
||||
def reset_data
|
||||
self.class.data.delete("#{@openstack_username}-#{@current_tenant}")
|
||||
end
|
||||
|
||||
def credentials
|
||||
{ :provider => 'openstack',
|
||||
:openstack_auth_url => @openstack_auth_uri.to_s,
|
||||
:openstack_auth_token => @auth_token,
|
||||
:openstack_management_url => @openstack_management_url,
|
||||
:openstack_identity_endpoint => @openstack_identity_public_endpoint }
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
attr_reader :auth_token
|
||||
attr_reader :auth_token_expiration
|
||||
attr_reader :current_user
|
||||
attr_reader :current_tenant
|
||||
|
||||
def initialize(options={})
|
||||
@openstack_auth_token = options[:openstack_auth_token]
|
||||
@auth_token = options[:openstack_auth_token]
|
||||
@openstack_identity_public_endpoint = options[:openstack_identity_endpoint]
|
||||
|
||||
unless @auth_token
|
||||
missing_credentials = Array.new
|
||||
@openstack_api_key = options[:openstack_api_key]
|
||||
@openstack_username = options[:openstack_username]
|
||||
|
||||
missing_credentials << :openstack_api_key unless @openstack_api_key
|
||||
missing_credentials << :openstack_username unless @openstack_username
|
||||
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
||||
end
|
||||
|
||||
@openstack_tenant = options[:openstack_tenant]
|
||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||
@openstack_management_url = options[:openstack_management_url]
|
||||
@openstack_must_reauthenticate = false
|
||||
@openstack_service_type = options[:openstack_service_type] || ['orchestration']
|
||||
@openstack_service_name = options[:openstack_service_name]
|
||||
@openstack_identity_service_type = options[:openstack_identity_service_type] || 'identity'
|
||||
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'publicURL'
|
||||
@openstack_region = options[:openstack_region]
|
||||
|
||||
@connection_options = options[:connection_options] || {}
|
||||
|
||||
@current_user = options[:current_user]
|
||||
@current_tenant = options[:current_tenant]
|
||||
|
||||
authenticate
|
||||
|
||||
@persistent = options[:persistent] || false
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
||||
end
|
||||
|
||||
def credentials
|
||||
{ :provider => 'openstack',
|
||||
:openstack_auth_url => @openstack_auth_uri.to_s,
|
||||
:openstack_auth_token => @auth_token,
|
||||
:openstack_management_url => @openstack_management_url,
|
||||
:openstack_identity_endpoint => @openstack_identity_public_endpoint,
|
||||
:openstack_region => @openstack_region,
|
||||
:current_user => @current_user,
|
||||
:current_tenant => @current_tenant }
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
begin
|
||||
response = @connection.request(params.merge({
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
'X-Auth-Token' => @auth_token
|
||||
}.merge!(params[:headers] || {}),
|
||||
:host => @host,
|
||||
:path => "#{@path}/#{@tenant_id}/#{params[:path]}",
|
||||
:query => params[:query]
|
||||
}))
|
||||
rescue Excon::Errors::Unauthorized => error
|
||||
if error.response.body != 'Bad username or password' # token expiration
|
||||
@openstack_must_reauthenticate = true
|
||||
authenticate
|
||||
retry
|
||||
else # Bad Credentials
|
||||
raise error
|
||||
end
|
||||
rescue Excon::Errors::HTTPStatusError => error
|
||||
raise case error
|
||||
when Excon::Errors::NotFound
|
||||
Fog::Compute::OpenStack::NotFound.slurp(error)
|
||||
else
|
||||
error
|
||||
end
|
||||
end
|
||||
|
||||
if response.status == 200 && !response.body.empty?
|
||||
response.body = Fog::JSON.decode(response.body)
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authenticate
|
||||
if !@openstack_management_url || @openstack_must_reauthenticate
|
||||
options = {
|
||||
:openstack_api_key => @openstack_api_key,
|
||||
:openstack_username => @openstack_username,
|
||||
:openstack_auth_token => @auth_token,
|
||||
:openstack_auth_uri => @openstack_auth_uri,
|
||||
:openstack_region => @openstack_region,
|
||||
:openstack_tenant => @openstack_tenant,
|
||||
:openstack_service_type => @openstack_service_type,
|
||||
:openstack_service_name => @openstack_service_name,
|
||||
:openstack_identity_service_type => @openstack_identity_service_type,
|
||||
:openstack_endpoint_type => @openstack_endpoint_type
|
||||
}
|
||||
|
||||
if @openstack_auth_uri.path =~ /\/v2.0\//
|
||||
|
||||
credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
|
||||
else
|
||||
credentials = Fog::OpenStack.authenticate_v1(options, @connection_options)
|
||||
end
|
||||
|
||||
@current_user = credentials[:user]
|
||||
@current_tenant = credentials[:tenant]
|
||||
|
||||
@openstack_must_reauthenticate = false
|
||||
@auth_token = credentials[:token]
|
||||
@auth_token_expiration = credentials[:expires]
|
||||
@openstack_management_url = credentials[:server_management_url]
|
||||
@openstack_identity_public_endpoint = credentials[:identity_public_endpoint]
|
||||
end
|
||||
|
||||
uri = URI.parse(@openstack_management_url)
|
||||
@host = uri.host
|
||||
@path, @tenant_id = uri.path.scan(/(\/.*)\/(.*)/).flatten
|
||||
|
||||
@path.sub!(/\/$/, '')
|
||||
|
||||
@port = uri.port
|
||||
@scheme = uri.scheme
|
||||
|
||||
# Not all implementations have identity service in the catalog
|
||||
if @openstack_identity_public_endpoint || @openstack_management_url
|
||||
@identity_connection = Fog::Connection.new(
|
||||
@openstack_identity_public_endpoint || @openstack_management_url,
|
||||
false, @connection_options)
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,11 +3,12 @@ module Fog
|
|||
class OpenStack
|
||||
class Real
|
||||
|
||||
def list_images_detail
|
||||
def list_images_detail(filters = {})
|
||||
request(
|
||||
:expects => [200, 203],
|
||||
:method => 'GET',
|
||||
:path => 'images/detail.json'
|
||||
:path => 'images/detail.json',
|
||||
:query => filters
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -15,7 +16,7 @@ module Fog
|
|||
|
||||
class Mock
|
||||
|
||||
def list_images_detail
|
||||
def list_images_detail(filters = {})
|
||||
response = Excon::Response.new
|
||||
|
||||
images = self.data[:images].values
|
||||
|
|
55
lib/fog/openstack/requests/orchestration/create_stack.rb
Normal file
55
lib/fog/openstack/requests/orchestration/create_stack.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
module Fog
|
||||
module Orchestration
|
||||
class OpenStack
|
||||
class Real
|
||||
|
||||
# Create a stack.
|
||||
#
|
||||
# * stack_name [String] Name of the stack to create.
|
||||
# * options [Hash]:
|
||||
# * :template_body [String] Structure containing the template body.
|
||||
# or (one of the two Template parameters is required)
|
||||
# * :template_url [String] URL of file containing the template body.
|
||||
# * :disable_rollback [Boolean] Controls rollback on stack creation failure, defaults to false.
|
||||
# * :parameters [Hash] Hash of providers to supply to template
|
||||
# * :timeout_in_minutes [Integer] Minutes to wait before status is set to CREATE_FAILED
|
||||
#
|
||||
# @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html
|
||||
|
||||
def create_stack(stack_name, options = {})
|
||||
params = {
|
||||
:stack_name => stack_name
|
||||
}.merge(options)
|
||||
|
||||
request(
|
||||
:path => 'stacks',
|
||||
:method => 'POST',
|
||||
:body => MultiJson.encode(params)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_stack(stack_name, options = {})
|
||||
stack_id = Fog::Mock.random_hex(32)
|
||||
stack = self.data[:stacks][stack_id] = {
|
||||
'id' => stack_id,
|
||||
'stack_name' => stack_name,
|
||||
'links' => [],
|
||||
'description' => options[:description],
|
||||
'stack_status' => 'CREATE_COMPLETE',
|
||||
'stack_status_reason' => 'Stack successfully created',
|
||||
'creation_time' => Time.now,
|
||||
'updated_time' => Time.now
|
||||
}
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 202
|
||||
response.body = {}
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
36
lib/fog/openstack/requests/orchestration/delete_stack.rb
Normal file
36
lib/fog/openstack/requests/orchestration/delete_stack.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
module Fog
|
||||
module Orchestration
|
||||
class OpenStack
|
||||
class Real
|
||||
|
||||
# Delete a stack.
|
||||
#
|
||||
# @param stack_name [String] Name of the stack to delete.
|
||||
# @param stack_id [String] ID of the stack to delete.
|
||||
#
|
||||
# @return [Excon::Response]
|
||||
#
|
||||
# @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DeleteStack.html
|
||||
|
||||
def delete_stack(stack_name, stack_id)
|
||||
request(
|
||||
:path => "stacks/#{stack_name}/#{stack_id}",
|
||||
:method => 'DELETE'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def delete_stack(stack_name, stack_id)
|
||||
self.data[:stacks].delete(stack_id)
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 202
|
||||
response.body = {}
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
48
lib/fog/openstack/requests/orchestration/list_stacks.rb
Normal file
48
lib/fog/openstack/requests/orchestration/list_stacks.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
module Fog
|
||||
module Orchestration
|
||||
class OpenStack
|
||||
class Real
|
||||
|
||||
# List stacks.
|
||||
#
|
||||
# @param options [Hash]
|
||||
#
|
||||
# @return [Excon::Response]
|
||||
# * body [Hash]:
|
||||
# * stacks [Array] - Matching stacks
|
||||
# * stack [Hash]:
|
||||
# * id [String] -
|
||||
# * stack_name [String] -
|
||||
# * description [String]
|
||||
# * links [Array]
|
||||
# * stack_status [String] -
|
||||
# * stack_status_reason [String]
|
||||
# * creation_time [Time] -
|
||||
# * updated_time [Time] -
|
||||
#
|
||||
#
|
||||
# @see http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ListStacks.html
|
||||
|
||||
def list_stacks(options = {})
|
||||
request(
|
||||
:path => 'stacks',
|
||||
:method => 'GET',
|
||||
:query => options
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def list_stacks(options = {})
|
||||
stacks = self.data[:stacks].values
|
||||
|
||||
Excon::Response.new(
|
||||
:body => { 'stacks' => stacks },
|
||||
:status => 200
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
41
lib/fog/openstack/requests/orchestration/update_stack.rb
Normal file
41
lib/fog/openstack/requests/orchestration/update_stack.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Fog
|
||||
module Orchestration
|
||||
class OpenStack
|
||||
class Real
|
||||
|
||||
# Update a stack.
|
||||
#
|
||||
# @param [String] stack_name Name of the stack to update.
|
||||
# @param [Hash] options
|
||||
# * :template_body [String] Structure containing the template body.
|
||||
# or (one of the two Template parameters is required)
|
||||
# * :template_url [String] URL of file containing the template body.
|
||||
# * :parameters [Hash] Hash of providers to supply to template.
|
||||
#
|
||||
# @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html
|
||||
#
|
||||
def update_stack(stack_name, options = {})
|
||||
params = {
|
||||
:stack_name => stack_name
|
||||
}.merge(options)
|
||||
|
||||
request(
|
||||
:path => 'stacks',
|
||||
:method => 'PUT',
|
||||
:body => MultiJson.encode(params)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def update_stack(stack_name, options = {})
|
||||
response = Excon::Response.new
|
||||
response.status = 202
|
||||
response.body = {}
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/orchestration.rb
Normal file
25
lib/fog/orchestration.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Fog
|
||||
module Orchestration
|
||||
|
||||
def self.[](provider)
|
||||
self.new(:provider => provider)
|
||||
end
|
||||
|
||||
def self.new(attributes)
|
||||
attributes = attributes.dup # Prevent delete from having side effects
|
||||
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||
|
||||
if self.providers.include?(provider)
|
||||
require "fog/#{provider}/network"
|
||||
return Fog::Orchestration.const_get(Fog.providers[provider]).new(attributes)
|
||||
end
|
||||
|
||||
raise ArgumentError.new("#{provider} has no orchestration service")
|
||||
end
|
||||
|
||||
def self.providers
|
||||
Fog.services[:orchestration]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -20,12 +20,12 @@ module Fog
|
|||
|
||||
def item_list
|
||||
data = service.get_organizations.body
|
||||
org = data[:Org] # there is only a single Org
|
||||
service.add_id_from_href!(org)
|
||||
[org]
|
||||
orgs = data[:Org].is_a?(Hash) ? [data[:Org]] : data[:Org]
|
||||
orgs.each {|org| service.add_id_from_href!(org)}
|
||||
orgs
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
#
|
||||
# === Returns
|
||||
# * response<~Excon::Response>
|
||||
# # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/2012-03-01/APIReference/ApiReference-query-DeleteNetworkInterface.html]
|
||||
#
|
||||
def post_task_cancel(task_id)
|
||||
request(
|
||||
:expects => 204,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Shindo.tests("Fog::Compute[:aws] | subnet", ['aws']) do
|
||||
@vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24')
|
||||
model_tests(Fog::Compute[:aws].subnets, {:vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28'}, true)
|
||||
model_tests(Fog::Compute[:aws].subnets, {:vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28', :availability_zone => 'us-east-1b'}, true)
|
||||
@vpc.destroy
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Shindo.tests("Fog::Compute[:aws] | subnets", ['aws']) do
|
||||
@vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/28')
|
||||
collection_tests(Fog::Compute[:aws].subnets, { :vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28'}, true)
|
||||
collection_tests(Fog::Compute[:aws].subnets, { :vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28', :availability_zone => 'us-east-1c'}, true)
|
||||
@vpc.destroy
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,14 @@ class AWS
|
|||
'pipelineId' => String,
|
||||
}
|
||||
|
||||
FIELDS = [
|
||||
{
|
||||
"key" => String,
|
||||
"refValue" => Fog::Nullable::String,
|
||||
"stringValue" => Fog::Nullable::String,
|
||||
}
|
||||
]
|
||||
|
||||
LIST_PIPELINES = {
|
||||
"hasMoreResults" => Fog::Nullable::Boolean,
|
||||
"marker" => Fog::Nullable::String,
|
||||
|
@ -17,19 +25,31 @@ class AWS
|
|||
]
|
||||
}
|
||||
|
||||
QUERY_OBJECTS = {
|
||||
"hasMoreResults" => Fog::Nullable::Boolean,
|
||||
"marker" => Fog::Nullable::String,
|
||||
"ids" => Fog::Nullable::Array,
|
||||
}
|
||||
|
||||
DESCRIBE_OBJECTS = {
|
||||
"hasMoreResults" => Fog::Nullable::Boolean,
|
||||
"marker" => Fog::Nullable::String,
|
||||
"pipelineObjects" => [
|
||||
{
|
||||
'id' => String,
|
||||
'name' => String,
|
||||
'fields' => FIELDS,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
DESCRIBE_PIPELINES = {
|
||||
"pipelineDescriptionList" => [
|
||||
{
|
||||
"description" => Fog::Nullable::String,
|
||||
"name" => String,
|
||||
"pipelineId" => String,
|
||||
"fields" => [
|
||||
{
|
||||
"key" => String,
|
||||
"refValue" => Fog::Nullable::String,
|
||||
"stringValue" => Fog::Nullable::String,
|
||||
}
|
||||
]
|
||||
"fields" => FIELDS,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -38,7 +58,17 @@ class AWS
|
|||
"errored" => Fog::Boolean,
|
||||
"validationErrors" => Fog::Nullable::Array,
|
||||
}
|
||||
|
||||
|
||||
GET_PIPELINE_DEFINITION = {
|
||||
"pipelineObjects" => [
|
||||
{
|
||||
"id" => String,
|
||||
"name" => String,
|
||||
"fields" => FIELDS,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,6 +46,30 @@ Shindo.tests('AWS::DataPipeline | pipeline_tests', ['aws', 'data_pipeline']) do
|
|||
Fog::AWS[:data_pipeline].activate_pipeline(@pipeline_id)
|
||||
end
|
||||
|
||||
tests("#get_pipeline_definition").formats(AWS::DataPipeline::Formats::GET_PIPELINE_DEFINITION) do
|
||||
Fog::AWS[:data_pipeline].get_pipeline_definition(@pipeline_id)
|
||||
end
|
||||
|
||||
tests("#query_objects") do
|
||||
tests("for COMPONENTs").formats(AWS::DataPipeline::Formats::QUERY_OBJECTS) do
|
||||
Fog::AWS[:data_pipeline].query_objects(@pipeline_id, 'COMPONENT')
|
||||
end
|
||||
|
||||
tests("for INSTANCEs").formats(AWS::DataPipeline::Formats::QUERY_OBJECTS) do
|
||||
Fog::AWS[:data_pipeline].query_objects(@pipeline_id, 'INSTANCE')
|
||||
end
|
||||
|
||||
tests("for ATTEMPTs").formats(AWS::DataPipeline::Formats::QUERY_OBJECTS) do
|
||||
Fog::AWS[:data_pipeline].query_objects(@pipeline_id, 'ATTEMPT')
|
||||
end
|
||||
end
|
||||
|
||||
tests('#describe_objects').formats(AWS::DataPipeline::Formats::DESCRIBE_OBJECTS) do
|
||||
attempts = Fog::AWS[:data_pipeline].query_objects(@pipeline_id, 'ATTEMPT')
|
||||
object_ids = attempts['ids'][0..5]
|
||||
Fog::AWS[:data_pipeline].describe_objects(@pipeline_id, object_ids)
|
||||
end
|
||||
|
||||
tests("#delete_pipeline").returns(true) do
|
||||
Fog::AWS[:data_pipeline].delete_pipeline(@pipeline_id)
|
||||
end
|
||||
|
|
30
tests/openstack/requests/orchestration/stack_tests.rb
Normal file
30
tests/openstack/requests/orchestration/stack_tests.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
Shindo.tests('Fog::Orchestration[:openstack] | stack requests', ['openstack']) do
|
||||
@stack_format = {
|
||||
'links' => Array,
|
||||
'id' => String,
|
||||
'stack_name' => String,
|
||||
'description' => Fog::Nullable::String,
|
||||
'stack_status' => String,
|
||||
'stack_status_reason' => String,
|
||||
'creation_time' => Time,
|
||||
'updated_time' => Time
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
tests('#create_stack("teststack")').formats({}) do
|
||||
Fog::Orchestration[:openstack].create_stack("teststack").body
|
||||
end
|
||||
|
||||
tests('#list_stacks').formats({'stacks' => [@stack_format]}) do
|
||||
Fog::Orchestration[:openstack].list_stacks.body
|
||||
end
|
||||
|
||||
tests('#update_stack("teststack")').formats({}) do
|
||||
Fog::Orchestration[:openstack].update_stack("teststack").body
|
||||
end
|
||||
|
||||
tests('#delete_stack("teststack", "id")').formats({}) do
|
||||
Fog::Orchestration[:openstack].delete_stack("teststack", "id").body
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue