mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
refactoring common parser code. cluster requests tests
This commit is contained in:
parent
f83629550b
commit
fad43b8694
11 changed files with 213 additions and 268 deletions
29
lib/fog/aws/parsers/redshift/cluster.rb
Normal file
29
lib/fog/aws/parsers/redshift/cluster.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
module Fog
|
||||||
|
module Parsers
|
||||||
|
module Redshift
|
||||||
|
module AWS
|
||||||
|
require 'fog/aws/parsers/redshift/cluster_parser'
|
||||||
|
|
||||||
|
class Cluster < ClusterParser
|
||||||
|
def reset
|
||||||
|
super
|
||||||
|
@response = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_element(name, attrs = [])
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_element(name)
|
||||||
|
super
|
||||||
|
case name
|
||||||
|
when 'Cluster'
|
||||||
|
@response = @cluster
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -4,53 +4,57 @@ module Fog
|
||||||
module AWS
|
module AWS
|
||||||
|
|
||||||
class ClusterParser < Fog::Parsers::Base
|
class ClusterParser < Fog::Parsers::Base
|
||||||
# :allow_version_upgrade` - (Boolean) z
|
# :cluster_identifier - (String)
|
||||||
# :automated_snapshot_retention_period` - (Integer) w
|
# :node_type - (String)
|
||||||
# :availability_zone` - (String) x
|
# :cluster_status - (String)
|
||||||
# :cluster_create_time` - (Time) y
|
# :modify_status - (String)
|
||||||
# :cluster_identifier` - (String) x
|
# :master_username - (String)
|
||||||
# :cluster_parameter_groups` - (Array<Hash>)
|
# :db_name - (String)
|
||||||
# :parameter_group_name` - (String)
|
# :endpoint - (Hash)
|
||||||
# :parameter_apply_status` - (String)
|
# :address - (String)
|
||||||
# :cluster_security_groups` - (Array<Hash>)
|
# :port - (Integer)
|
||||||
# :cluster_security_group_name` - (String)
|
# :cluster_create_time - (Time)
|
||||||
# :status` - (String)
|
# :automated_snapshot_retention_period - (Integer)
|
||||||
# :cluster_status` - (String) x
|
# :cluster_security_groups - (Array)
|
||||||
# :cluster_subnet_group_name` - (String) x
|
# :cluster_security_group_name - (String)
|
||||||
# :cluster_version` - (String) x
|
# :status - (String)
|
||||||
# :db_name` - (String) x
|
# :vpc_security_groups - (Array)
|
||||||
# :encrypted` - (Boolean) z
|
# :vpc_security_group_id - (String)
|
||||||
# :endpoint` - (Hash)
|
# :status - (String)
|
||||||
# :address` - (String)
|
# :cluster_parameter_groups - (Array)
|
||||||
# :port` - (Integer)
|
# :parameter_group_name - (String)
|
||||||
# :master_username` - (String) x
|
# :parameter_apply_status - (String)
|
||||||
# :modify_status` - (String) x
|
# :cluster_subnet_group_name - (String)
|
||||||
# :node_type` - (String) x
|
# :vpc_id - (String)
|
||||||
# :number_of_nodes` - (Integer) w
|
# :availability_zone - (String)
|
||||||
# :pending_modified_values` - (Hash)
|
# :preferred_maintenance_window - (String)
|
||||||
# :master_user_password` - (String)
|
# :pending_modified_values - (Hash)
|
||||||
# :node_type` - (String)
|
# :master_user_password - (String)
|
||||||
# :number_of_nodes` - (Integer)
|
# :node_type - (String)
|
||||||
# :cluster_type` - (String)
|
# :number_of_nodes - (Integer)
|
||||||
# :cluster_version` - (String)
|
# :cluster_type - (String)
|
||||||
# :automated_snapshot_retention_period` - (Integer)
|
# :cluster_version - (String)
|
||||||
# :preferred_maintenance_window` - (String) x
|
# :automated_snapshot_retention_period - (Integer)
|
||||||
# :publicly_accessible` - (Boolean) z
|
# :cluster_version - (String)
|
||||||
# :restore_status` - (Hash)
|
# :allow_version_upgrade - (Boolean)
|
||||||
# :status` - (String)
|
# :number_of_nodes - (Integer)
|
||||||
# :current_restore_rate_in_mega_bytes_per_second` - (Numeric)
|
# :publicly_accessible - (Boolean)
|
||||||
# :snapshot_size_in_mega_bytes` - (Integer)
|
# :encrypted - (Boolean)
|
||||||
# :progress_in_mega_bytes` - (Integer)
|
# :restore_status - (Hash)
|
||||||
# :elapsed_time_in_seconds` - (Integer)
|
# :status - (String)
|
||||||
# :estimated_time_to_completion_in_seconds` - (Integer)
|
# :current_restore_rate_in_mega_bytes_per_second - (Numeric)
|
||||||
# :vpc_id` - (String) x
|
# :snapshot_size_in_mega_bytes - (Integer)
|
||||||
# :vpc_security_groups` - (Array<Hash>)
|
# :progress_in_mega_bytes - (Integer)
|
||||||
# :vpc_security_group_id` - (String)
|
# :elapsed_time_in_seconds - (Integer)
|
||||||
# :status` - (String)
|
# :estimated_time_to_completion_in_seconds - (Integer)
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@response = { 'ClusterParameterGroups' => [], 'ClusterSecurityGroups' => [], 'VpcSecurityGroups' => [],
|
@cluster = fresh_cluster
|
||||||
'EndPoint' => {}, 'PendingModifiedValues'=> {}, 'RestoreStatus' => {}}
|
end
|
||||||
|
|
||||||
|
def fresh_cluster
|
||||||
|
{ 'ClusterParameterGroups' => [], 'ClusterSecurityGroups' => [], 'VpcSecurityGroups' => [],
|
||||||
|
'EndPoint' => {}, 'PendingModifiedValues'=> {}, 'RestoreStatus' => {}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_element(name, attrs = [])
|
def start_element(name, attrs = [])
|
||||||
|
@ -73,36 +77,36 @@ module Fog
|
||||||
case name
|
case name
|
||||||
when 'AvailabilityZone', 'ClusterIdentifier', 'ClusterStatus', 'ClusterSubnetGroupName', 'DBName',
|
when 'AvailabilityZone', 'ClusterIdentifier', 'ClusterStatus', 'ClusterSubnetGroupName', 'DBName',
|
||||||
'MasterUsername', 'ModifyStatus', 'PreferredMaintenanceWindow', 'VpcId'
|
'MasterUsername', 'ModifyStatus', 'PreferredMaintenanceWindow', 'VpcId'
|
||||||
@response[name] = value
|
@cluster[name] = value
|
||||||
when 'ClusterCreateTime'
|
when 'ClusterCreateTime'
|
||||||
@response[name] = Time.parse(value)
|
@cluster[name] = Time.parse(value)
|
||||||
when 'AllowVersionUpgrade', 'Encrypted', 'PubliclyAccessible'
|
when 'AllowVersionUpgrade', 'Encrypted', 'PubliclyAccessible'
|
||||||
@response[name] = (value == true)
|
@cluster[name] = (value == true)
|
||||||
when 'Address'
|
when 'Address'
|
||||||
@response['EndPoint'][name] = value
|
@cluster['EndPoint'][name] = value
|
||||||
when 'Port'
|
when 'Port'
|
||||||
@response['EndPoint'][name] = value.to_i
|
@cluster['EndPoint'][name] = value.to_i
|
||||||
when 'NodeType', 'ClusterVersion'
|
when 'NodeType', 'ClusterVersion'
|
||||||
if @in_pending_modified_values
|
if @in_pending_modified_values
|
||||||
@response['PendingModifiedValues'][name] = value
|
@cluster['PendingModifiedValues'][name] = value
|
||||||
else
|
else
|
||||||
@response[name] = value
|
@cluster[name] = value
|
||||||
end
|
end
|
||||||
when 'NumberOfNodes', 'AutomatedSnapshotRetentionPeriod'
|
when 'NumberOfNodes', 'AutomatedSnapshotRetentionPeriod'
|
||||||
if @in_pending_modified_values
|
if @in_pending_modified_values
|
||||||
@response['PendingModifiedValues'][name] = value.to_i
|
@cluster['PendingModifiedValues'][name] = value.to_i
|
||||||
else
|
else
|
||||||
@response[name] = value.to_i
|
@cluster[name] = value.to_i
|
||||||
end
|
end
|
||||||
when 'MasterUserPassword', 'ClusterType'
|
when 'MasterUserPassword', 'ClusterType'
|
||||||
@response['PendingModifiedValues'][name] = value
|
@cluster['PendingModifiedValues'][name] = value
|
||||||
when 'Status'
|
when 'Status'
|
||||||
if @in_vpc_security_groups
|
if @in_vpc_security_groups
|
||||||
@vpc_security_group[name] = value
|
@vpc_security_group[name] = value
|
||||||
elsif @in_cluster_security_groups
|
elsif @in_cluster_security_groups
|
||||||
@cluster_security_group[name] = value
|
@cluster_security_group[name] = value
|
||||||
else
|
else
|
||||||
@response['RestoreStatus'][name] = value
|
@cluster['RestoreStatus'][name] = value
|
||||||
end
|
end
|
||||||
when 'ParameterGroupName', 'ParameterApplyStatus'
|
when 'ParameterGroupName', 'ParameterApplyStatus'
|
||||||
@cluster_parameter_group[name] = value
|
@cluster_parameter_group[name] = value
|
||||||
|
@ -111,9 +115,9 @@ module Fog
|
||||||
when 'VpcSecurityGroupId'
|
when 'VpcSecurityGroupId'
|
||||||
@vpc_security_group[name] = value
|
@vpc_security_group[name] = value
|
||||||
when 'SnapshotSizeInMegaBytes', 'ProgressInMegaBytes', 'ElapsedTimeInSeconds', 'EstimatedTimeToCompletionInSeconds'
|
when 'SnapshotSizeInMegaBytes', 'ProgressInMegaBytes', 'ElapsedTimeInSeconds', 'EstimatedTimeToCompletionInSeconds'
|
||||||
@response['RestoreStatus'][name] = value.to_i
|
@cluster['RestoreStatus'][name] = value.to_i
|
||||||
when 'CurrentRestoreRateInMegaBytesPerSecond'
|
when 'CurrentRestoreRateInMegaBytesPerSecond'
|
||||||
@response['RestoreStatus'][name] = value.to_f
|
@cluster['RestoreStatus'][name] = value.to_f
|
||||||
|
|
||||||
when 'ClusterSecurityGroups'
|
when 'ClusterSecurityGroups'
|
||||||
@in_cluster_security_groups = false
|
@in_cluster_security_groups = false
|
||||||
|
@ -123,15 +127,14 @@ module Fog
|
||||||
@in_pending_modified_values = false
|
@in_pending_modified_values = false
|
||||||
|
|
||||||
when 'ClusterParameterGroup'
|
when 'ClusterParameterGroup'
|
||||||
@response['ClusterParameterGroups'] << @cluster_parameter_group
|
@cluster['ClusterParameterGroups'] << @cluster_parameter_group
|
||||||
@cluster_parameter_group = {}
|
@cluster_parameter_group = {}
|
||||||
when 'ClusterSecurityGroup'
|
when 'ClusterSecurityGroup'
|
||||||
@response['ClusterSecurityGroups'] << @cluster_security_group
|
@cluster['ClusterSecurityGroups'] << @cluster_security_group
|
||||||
@cluster_security_group = {}
|
@cluster_security_group = {}
|
||||||
when 'VpcSecurityGroup'
|
when 'VpcSecurityGroup'
|
||||||
@response['VpcSecurityGroups'] << @vpc_security_group
|
@cluster['VpcSecurityGroups'] << @vpc_security_group
|
||||||
@vpc_security_group = {}
|
@vpc_security_group = {}
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
module Fog
|
|
||||||
module Parsers
|
|
||||||
module Redshift
|
|
||||||
module AWS
|
|
||||||
|
|
||||||
class ClusterSubnetGroupParser < Fog::Parsers::Base
|
|
||||||
# :cluster_subnet_group_name - (String)
|
|
||||||
# :description - (String)
|
|
||||||
# :vpc_id - (String)
|
|
||||||
# :subnet_group_status - (String)
|
|
||||||
# :subnets - (Array)
|
|
||||||
# :subnet_identifier - (String)
|
|
||||||
# :subnet_availability_zone - (Hash)
|
|
||||||
# :name - (String)
|
|
||||||
# :subnet_status - (String)
|
|
||||||
|
|
||||||
def reset
|
|
||||||
@response = { 'Subnets' => [] }
|
|
||||||
end
|
|
||||||
|
|
||||||
def fresh_subnet
|
|
||||||
{'SubnetAvailabilityZone'=>{}}
|
|
||||||
end
|
|
||||||
|
|
||||||
def start_element(name, attrs = [])
|
|
||||||
super
|
|
||||||
case name
|
|
||||||
when 'Subnets'
|
|
||||||
@subnet = fresh_subnet
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def end_element(name)
|
|
||||||
super
|
|
||||||
case name
|
|
||||||
when 'ClusterSubnetGroupName', 'Desciption', 'VpcId', 'SubnetGroupStatus'
|
|
||||||
@response[name] = value
|
|
||||||
when 'SubnetIdentifier', 'SubnetStatus'
|
|
||||||
@subnet[name] = value
|
|
||||||
when 'Name'
|
|
||||||
@subnet['SubnetAvailabilityZone'][name] = value
|
|
||||||
when 'Subnet'
|
|
||||||
@response['Subnets'] << @subnet
|
|
||||||
@subnet = fresh_subnet
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -2,114 +2,25 @@ module Fog
|
||||||
module Parsers
|
module Parsers
|
||||||
module Redshift
|
module Redshift
|
||||||
module AWS
|
module AWS
|
||||||
|
require 'fog/aws/parsers/redshift/cluster_parser'
|
||||||
|
|
||||||
class DescribeClusters < Fog::Parsers::Base
|
class DescribeClusters < ClusterParser
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@response = { 'ClusterSet' => [] }
|
super
|
||||||
@cluster = fresh_cluster
|
@response = {"ClusterSet" => []}
|
||||||
@context = []
|
|
||||||
@contexts = ['EndPoint', 'ClusterSecurityGroups', 'VpcSecurityGroups', 'ClusterParameterGroups', 'PendingModifiedValues', 'RestoreStatus']
|
|
||||||
end
|
|
||||||
|
|
||||||
def fresh_cluster
|
|
||||||
{
|
|
||||||
'EndPoint' => {},
|
|
||||||
'ClusterSecurityGroups' => [],
|
|
||||||
'VpcSecurityGroups' => [],
|
|
||||||
'ClusterParameterGroups' => [],
|
|
||||||
'PendingModifiedValues' => {},
|
|
||||||
'RestoreStatus' => {}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_element(name, attrs = [])
|
def start_element(name, attrs = [])
|
||||||
super
|
super
|
||||||
@context.push(name) if @contexts.include?(name)
|
|
||||||
case name
|
|
||||||
when 'ClusterSecurityGroups'
|
|
||||||
@in_cluster_security_groups = true
|
|
||||||
@cluster_security_groups = []
|
|
||||||
when 'ClusterSecurityGroup'
|
|
||||||
@cluster_security_group = {}
|
|
||||||
when 'VpcSecurityGroups'
|
|
||||||
@in_vpc_security_groups = true
|
|
||||||
@vpc_security_groups = []
|
|
||||||
when 'VpcSecurityGroup'
|
|
||||||
@vpc_security_group = {}
|
|
||||||
when 'ClusterParameterGroups'
|
|
||||||
@cluster_parameter_groups = []
|
|
||||||
when 'ClusterParameterGroup'
|
|
||||||
@cluster_parameter_group = {}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def end_element(name)
|
def end_element(name)
|
||||||
super
|
super
|
||||||
case name
|
case name
|
||||||
when 'Marker'
|
|
||||||
@response[name] = value
|
|
||||||
when 'ClusterIdentifier', 'NodeType', 'ClusterStatus', 'ModifyStatus', 'MasterUsername', 'DBName',
|
|
||||||
'ClusterSubnetGroupName', 'VpcId', 'AvailabilityZone', 'PreferredMaintenanceWindow', 'ClusterVersion'
|
|
||||||
@cluster[name] = value
|
|
||||||
when 'Address'
|
|
||||||
@cluster['EndPoint'][name] = value
|
|
||||||
when 'Port','AutomatedSnapshotRetentionPeriod'
|
|
||||||
@cluster['EndPoint'][name] = value.to_i
|
|
||||||
when 'ClusterCreateTime'
|
|
||||||
@cluster['EndPoint'][name] = Time.parse(value)
|
|
||||||
when 'VpcSecurityGroups'
|
|
||||||
@in_vpc_security_groups = false
|
|
||||||
@cluster['VpcSecurityGroups'] = @vpc_security_groups
|
|
||||||
when 'VpcSecurityGroup'
|
|
||||||
@vpc_security_groups << @vpc_security_group
|
|
||||||
@vpc_security_group = {}
|
|
||||||
when 'VpcSecurityGroupId'
|
|
||||||
@vpc_security_group[name]=value
|
|
||||||
when 'ClusterSecurityGroups'
|
|
||||||
@in_cluster_security_groups = false
|
|
||||||
@cluster['ClusterSecurityGroups'] = @cluster_security_groups
|
|
||||||
when 'ClusterSecurityGroup'
|
|
||||||
@cluster_security_groups << @cluster_security_group
|
|
||||||
@cluster_security_group = {}
|
|
||||||
when 'ClusterSecurityGroupName'
|
|
||||||
@cluster_security_group[name] = value
|
|
||||||
when 'ClusterParameterGroups'
|
|
||||||
@cluster['ClusterParameterGroups'] = @cluster_parameter_groups
|
|
||||||
when 'ClusterParameterGroup'
|
|
||||||
@cluster_parameter_groups << @cluster_parameter_group
|
|
||||||
@cluster_parameter_group = {}
|
|
||||||
when 'ParameterGroupName', 'ParameterApplyStatus'
|
|
||||||
@cluster_parameter_group[name] = value
|
|
||||||
when 'Status'
|
|
||||||
if @in_vpc_security_groups
|
|
||||||
@vpc_security_group[name] = value
|
|
||||||
elsif @in_cluster_security_groups
|
|
||||||
@cluster_security_group[name] = value
|
|
||||||
else
|
|
||||||
@cluster['RestoreStatus'][name] = value
|
|
||||||
end
|
|
||||||
when 'MasterUserPassword', 'NodeType', 'ClusterType', 'ClusterVersion'
|
|
||||||
@cluster['PendingModifiedValues'][name] = value
|
|
||||||
when 'AutomatedSnapshotRetentionPeriod'
|
|
||||||
@cluster['PendingModifiedValues'][name] = value
|
|
||||||
when 'NumberOfNodes'
|
|
||||||
if @context.last == 'PendingModifiedValues'
|
|
||||||
@cluster['PendingModifiedValues'][name] = value.to_i
|
|
||||||
else
|
|
||||||
@cluster[name] = value.to_i
|
|
||||||
end
|
|
||||||
when 'AllowVersionUpgrade', 'PubliclyAccessible', 'Encrypted'
|
|
||||||
@cluster[name] = (value == true)
|
|
||||||
when 'SnapshotSizeInMegaBytes', 'ProgressInMegaBytes', 'ElapsedTimeInSeconds', 'EstimatedTimeToCompletionInSeconds'
|
|
||||||
@cluster['RestoreStatus'] = value.to_i
|
|
||||||
when 'CurrentRestoreRateInMegaBytesPerSecond'
|
|
||||||
@cluster['RestoreStatus'] = value.to_f
|
|
||||||
when 'Cluster'
|
when 'Cluster'
|
||||||
@response['ClusterSet'] << @cluster
|
@response["ClusterSet"] << @cluster
|
||||||
@cluster = fresh_cluster
|
@cluster = fresh_cluster
|
||||||
end
|
end
|
||||||
@context.pop if @contexts.include?(name)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -117,4 +28,3 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ module Fog
|
||||||
# request :authorize_snapshot_access
|
# request :authorize_snapshot_access
|
||||||
# request :copy_cluster_snapshot
|
# request :copy_cluster_snapshot
|
||||||
# request :purchase_reserved_node_offering
|
# request :purchase_reserved_node_offering
|
||||||
# request :reboot_cluster
|
request :reboot_cluster
|
||||||
# request :reset_cluster_parameter_group
|
# request :reset_cluster_parameter_group
|
||||||
# request :restore_from_cluster_snapshot
|
# request :restore_from_cluster_snapshot
|
||||||
# request :revoke_cluster_security_group_ingress
|
# request :revoke_cluster_security_group_ingress
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
||||||
module AWS
|
module AWS
|
||||||
class Redshift
|
class Redshift
|
||||||
class Real
|
class Real
|
||||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
require 'fog/aws/parsers/redshift/cluster'
|
||||||
|
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
#
|
#
|
||||||
|
@ -108,7 +108,7 @@ module Fog
|
||||||
:path => path,
|
:path => path,
|
||||||
:method => :put,
|
:method => :put,
|
||||||
:query => {},
|
:query => {},
|
||||||
:parser => Fog::Parsers::Redshift::AWS::ClusterParser.new
|
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||||
}
|
}
|
||||||
|
|
||||||
if cluster_security_groups = options.delete(:ClusterSecurityGroups)
|
if cluster_security_groups = options.delete(:ClusterSecurityGroups)
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
||||||
module AWS
|
module AWS
|
||||||
class Redshift
|
class Redshift
|
||||||
class Real
|
class Real
|
||||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
require 'fog/aws/parsers/redshift/cluster'
|
||||||
|
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
#
|
#
|
||||||
|
@ -35,7 +35,7 @@ module Fog
|
||||||
:path => path,
|
:path => path,
|
||||||
:method => :put,
|
:method => :put,
|
||||||
:query => {},
|
:query => {},
|
||||||
:parser => Fog::Parsers::Redshift::AWS::ClusterParser.new
|
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||||
}
|
}
|
||||||
|
|
||||||
params[:query]['Action'] = 'DeleteCluster'
|
params[:query]['Action'] = 'DeleteCluster'
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
||||||
module AWS
|
module AWS
|
||||||
class Redshift
|
class Redshift
|
||||||
class Real
|
class Real
|
||||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
require 'fog/aws/parsers/redshift/cluster'
|
||||||
|
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
#
|
#
|
||||||
|
@ -76,7 +76,7 @@ module Fog
|
||||||
:path => path,
|
:path => path,
|
||||||
:method => :put,
|
:method => :put,
|
||||||
:query => {},
|
:query => {},
|
||||||
:parser => Fog::Parsers::Redshift::AWS::ClusterParser.new
|
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||||
}
|
}
|
||||||
|
|
||||||
if cluster_security_groups = options.delete(:ClusterSecurityGroups)
|
if cluster_security_groups = options.delete(:ClusterSecurityGroups)
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
||||||
#
|
#
|
||||||
# ==== See Also
|
# ==== See Also
|
||||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_ModifyClusterSubnetGroup.html
|
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_ModifyClusterSubnetGroup.html
|
||||||
def create_cluster_subnet_group(options = {})
|
def modify_cluster_subnet_group(options = {})
|
||||||
cluster_subnet_group_name = options[:cluster_subnet_group_name]
|
cluster_subnet_group_name = options[:cluster_subnet_group_name]
|
||||||
description = options[:description]
|
description = options[:description]
|
||||||
|
|
||||||
|
|
36
lib/fog/aws/requests/redshift/reboot_cluster.rb
Normal file
36
lib/fog/aws/requests/redshift/reboot_cluster.rb
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class Redshift
|
||||||
|
class Real
|
||||||
|
require 'fog/aws/parsers/redshift/cluster'
|
||||||
|
|
||||||
|
# ==== Parameters
|
||||||
|
#
|
||||||
|
# @param [Hash] options
|
||||||
|
# * :cluster_identifier - required - (String)
|
||||||
|
# A unique identifier for the cluster. You use this identifier to refer to the cluster
|
||||||
|
# for any subsequent cluster operations such as deleting or modifying. Must be unique
|
||||||
|
# for all clusters within an AWS account. Example: myexamplecluster
|
||||||
|
#
|
||||||
|
# ==== See Also
|
||||||
|
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_DeleteCluster.html
|
||||||
|
def reboot_cluster(options = {})
|
||||||
|
cluster_identifier = options[:cluster_identifier]
|
||||||
|
|
||||||
|
path = "/"
|
||||||
|
params = {
|
||||||
|
:headers => {},
|
||||||
|
:path => path,
|
||||||
|
:method => :put,
|
||||||
|
:query => {},
|
||||||
|
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||||
|
}
|
||||||
|
|
||||||
|
params[:query]['Action'] = 'RebootCluster'
|
||||||
|
params[:query]['ClusterIdentifier'] = cluster_identifier if cluster_identifier
|
||||||
|
request(params)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,64 +1,82 @@
|
||||||
Shindo.tests('Fog::Redshift[:aws] | cluster requests', ['aws']) do
|
Shindo.tests('Fog::Redshift[:aws] | cluster requests', ['aws']) do
|
||||||
|
|
||||||
@describe_clusters_format = {
|
identifier = "test-cluster-#{rand(65536).to_s(16)}"
|
||||||
"ClusterSet" => [{
|
|
||||||
"EndPoint" => {
|
@cluster_format = {
|
||||||
"Port" => Integer,
|
"ClusterParameterGroups" => [{
|
||||||
"Address" => String,
|
"ParameterApplyStatus" => String,
|
||||||
"AutomatedSnapshotRetentionPeriod" => Integer,
|
"ParameterGroupName" => String
|
||||||
"ClusterCreateTime" => Time
|
}],
|
||||||
},
|
"ClusterSecurityGroups" => [{
|
||||||
"ClusterSecurityGroups" => [{
|
"Status" => String,
|
||||||
"Status" => String,
|
"ClusterSecurityGroupName" => String
|
||||||
"ClusterSecurityGroupName" => String
|
}],
|
||||||
}],
|
"VpcSecurityGroups" => Fog::Nullable::Array,
|
||||||
"VpcSecurityGroups" => Fog::Nullable::Array,
|
"EndPoint" => Fog::Nullable::Hash,
|
||||||
"ClusterParameterGroups" => [{
|
"PendingModifiedValues" => Fog::Nullable::Hash, #{"MasterUserPassword" => String},
|
||||||
"ParameterApplyStatus" => String,
|
"RestoreStatus" => Fog::Nullable::Hash,
|
||||||
"ParameterGroupName" => String
|
"ClusterVersion" => String,
|
||||||
}],
|
"ClusterStatus" => String,
|
||||||
"PendingModifiedValues" => Fog::Nullable::Hash,
|
"Encrypted" => Fog::Boolean,
|
||||||
"RestoreStatus" => Fog::Nullable::Hash,
|
"NumberOfNodes" => Integer,
|
||||||
"ClusterVersion" => String,
|
"PubliclyAccessible" => Fog::Boolean,
|
||||||
"ClusterStatus" => String,
|
"AutomatedSnapshotRetentionPeriod" => Integer,
|
||||||
"Encrypted" => Fog::Boolean,
|
"DBName" => String,
|
||||||
"NumberOfNodes" => Integer,
|
"PreferredMaintenanceWindow" => String,
|
||||||
"PubliclyAccessible" => Fog::Boolean,
|
"NodeType" => String,
|
||||||
"DBName" => String,
|
"ClusterIdentifier" => String,
|
||||||
"PreferredMaintenanceWindow" => String,
|
"AllowVersionUpgrade" => Fog::Boolean,
|
||||||
"AvailabilityZone" => String,
|
"MasterUsername" => String
|
||||||
"NodeType" => String,
|
|
||||||
"ClusterIdentifier" => String,
|
|
||||||
"AllowVersionUpgrade" => Fog::Boolean,
|
|
||||||
"MasterUsername" => String
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@describe_clusters_format = {
|
||||||
|
"ClusterSet" => [
|
||||||
|
@cluster_format.merge({"ClusterCreateTime"=>Time, "AvailabilityZone"=>String, "EndPoint"=>{"Port"=>Integer, "Address"=>String}})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
tests('success') do
|
tests('success') do
|
||||||
tests("#describe_clusters").formats(@describe_clusters_format) do
|
tests("create_cluster").formats(@cluster_format) do
|
||||||
body = Fog::AWS[:redshift].describe_clusters.body
|
body = Fog::AWS[:redshift].create_cluster(:cluster_identifier => identifier,
|
||||||
|
:master_user_password => 'Password1234',
|
||||||
|
:master_username => 'testuser',
|
||||||
|
:node_type => 'dw.hs1.xlarge',
|
||||||
|
:cluster_type => 'single-node').body
|
||||||
|
Fog.wait_for do
|
||||||
|
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['ClusterStatus']
|
||||||
|
end
|
||||||
body
|
body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
tests("#describe_clusters").formats(@describe_clusters_format["ClusterSet"]) do
|
||||||
|
body = Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body["ClusterSet"]
|
||||||
|
body
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
tests("#reboot_cluster") do
|
||||||
|
sleep 30
|
||||||
|
body = Fog::AWS[:redshift].reboot_cluster(:cluster_identifier=>identifier).body
|
||||||
|
tests("verify reboot").returns("rebooting") { body['ClusterStatus']}
|
||||||
|
Fog.wait_for do
|
||||||
|
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['ClusterStatus']
|
||||||
|
end
|
||||||
|
body
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
tests("#delete_cluster") do
|
||||||
|
sleep 30
|
||||||
|
body = Fog::AWS[:redshift].delete_cluster(:cluster_identifier=>identifier, :skip_final_cluster_snapshot=>true).body
|
||||||
|
tests("verify delete").returns("deleting") { body['ClusterStatus']}
|
||||||
|
body
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# tests('failure') do
|
# tests('failure') do
|
||||||
|
|
||||||
# tests("#get_console_output('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
|
||||||
# Fog::Compute[:aws].get_console_output('i-00000000')
|
|
||||||
# end
|
|
||||||
|
|
||||||
# tests("#get_password_data('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
|
||||||
# Fog::Compute[:aws].get_password_data('i-00000000')
|
|
||||||
# end
|
|
||||||
|
|
||||||
# tests("#reboot_instances('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
|
||||||
# Fog::Compute[:aws].reboot_instances('i-00000000')
|
|
||||||
# end
|
|
||||||
|
|
||||||
# tests("#terminate_instances('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
|
||||||
# Fog::Compute[:aws].terminate_instances('i-00000000')
|
|
||||||
# end
|
|
||||||
|
|
||||||
# end
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue