mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Added a new request - describe_instance_attribute for AWS
This commit is contained in:
parent
818c8e14ce
commit
d34c7ced1f
3 changed files with 242 additions and 0 deletions
|
@ -99,6 +99,7 @@ module Fog
|
|||
request :describe_dhcp_options
|
||||
request :describe_images
|
||||
request :describe_instances
|
||||
request :describe_instance_attribute
|
||||
request :describe_internet_gateways
|
||||
request :describe_reserved_instances
|
||||
request :describe_instance_status
|
||||
|
|
180
lib/fog/aws/parsers/compute/describe_instance_attribute.rb
Normal file
180
lib/fog/aws/parsers/compute/describe_instance_attribute.rb
Normal file
|
@ -0,0 +1,180 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
class DescribeInstanceAttribute < Fog::Parsers::Base
|
||||
def reset
|
||||
@response = { }
|
||||
@in_instanceType = false
|
||||
@in_kernelId = false
|
||||
@in_ramdiskId = false
|
||||
@in_userData = false
|
||||
@in_disableApiTermination = false
|
||||
@in_instanceInitiatedShutdownBehavior = false
|
||||
@in_rootDeviceName = false
|
||||
@in_blockDeviceMapping = false
|
||||
@in_productCodes = false
|
||||
@in_ebsOptimized = false
|
||||
@in_sriovNetSupport = false
|
||||
@in_sourceDestCheck = false
|
||||
@in_groupSet = false
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
when 'instanceType'
|
||||
@in_instanceType = true
|
||||
when 'kernel'
|
||||
@in_kernel = true
|
||||
when 'ramdisk'
|
||||
@in_ramdisk = true
|
||||
when 'userData'
|
||||
@in_userData = true
|
||||
when 'disableApiTermination'
|
||||
@in_disableApiTermination = true
|
||||
when 'instanceInitiatedShutdownBehavior'
|
||||
@in_instanceInitiatedShutdownBehavior = true
|
||||
when 'rootDeviceName'
|
||||
@in_rootDeviceName = true
|
||||
when 'blockDeviceMapping'
|
||||
@in_blockDeviceMapping = true
|
||||
@block_device_mapping = {}
|
||||
unless @response.key?('blockDeviceMapping')
|
||||
@response['blockDeviceMapping'] = []
|
||||
end
|
||||
when 'productCodes'
|
||||
@in_productCodes = true
|
||||
unless @response.key?('productCodes')
|
||||
@response['productCodes'] = []
|
||||
end
|
||||
when 'ebsOptimized'
|
||||
@in_ebsOptimized = true
|
||||
when 'sriovNetSupport'
|
||||
@in_sriovNetSupport = true
|
||||
when 'sourceDestCheck'
|
||||
@in_sourceDestCheck = true
|
||||
when 'groupSet'
|
||||
@in_groupSet = true
|
||||
@group = {}
|
||||
unless @response.key?('groupSet')
|
||||
@response['groupSet'] = []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if @in_instanceType
|
||||
case name
|
||||
when 'value'
|
||||
@response['instanceType'] = value
|
||||
when 'instanceType'
|
||||
@in_instanceType = false
|
||||
end
|
||||
elsif @in_kernel
|
||||
case name
|
||||
when 'value'
|
||||
@response['kernelId'] = value
|
||||
when 'kernel'
|
||||
@in_kernelId = false
|
||||
end
|
||||
elsif @in_ramdisk
|
||||
case name
|
||||
when 'value'
|
||||
@response['ramdiskId'] = value
|
||||
when 'ramdisk'
|
||||
@in_ramdiskId = false
|
||||
end
|
||||
elsif @in_userData
|
||||
case name
|
||||
when 'value'
|
||||
@response['userData'] = value
|
||||
when 'userData'
|
||||
@in_userData = false
|
||||
end
|
||||
elsif @in_disableApiTermination
|
||||
case name
|
||||
when 'value'
|
||||
@response['disableApiTermination'] = (value == 'true')
|
||||
when 'disableApiTermination'
|
||||
@in_disableApiTermination = false
|
||||
end
|
||||
elsif @in_instanceInitiatedShutdownBehavior
|
||||
case name
|
||||
when 'value'
|
||||
@response['instanceInitiatedShutdownBehavior'] = value
|
||||
when 'instanceInitiatedShutdownBehavior'
|
||||
@in_instanceInitiatedShutdownBehavior = false
|
||||
end
|
||||
elsif @in_rootDeviceName
|
||||
case name
|
||||
when 'value'
|
||||
@response['rootDeviceName'] = value
|
||||
when 'rootDeviceName'
|
||||
@in_rootDeviceName = false
|
||||
end
|
||||
elsif @in_blockDeviceMapping
|
||||
case name
|
||||
when 'item'
|
||||
@response["blockDeviceMapping"] << @block_device_mapping
|
||||
@block_device_mapping = {}
|
||||
when 'deviceName'
|
||||
@block_device_mapping['deviceName'] = value
|
||||
when 'volumeId', 'status'
|
||||
@block_device_mapping[name] = value
|
||||
when 'attachTime'
|
||||
@block_device_mapping['attachTime'] = Time.parse(value)
|
||||
when 'deleteOnTermination'
|
||||
@block_device_mapping['deleteOnTermination'] = (value == 'true')
|
||||
when 'blockDeviceMapping'
|
||||
@in_blockDeviceMapping = false
|
||||
end
|
||||
elsif @in_productCodes
|
||||
@response['productCodes'] << value
|
||||
case name
|
||||
when 'productCodes'
|
||||
@in_productCodes = false
|
||||
end
|
||||
elsif @in_ebsOptimized
|
||||
case name
|
||||
when 'value'
|
||||
@response['ebsOptimized'] = (value == 'true')
|
||||
when 'ebsOptimized'
|
||||
@in_ebsOptimized = false
|
||||
end
|
||||
elsif @in_sriovNetSupport
|
||||
case name
|
||||
when 'value'
|
||||
@response["sriovNetSupport"] = value
|
||||
when "sriovNetSupport"
|
||||
@in_sriovNetSupport = false
|
||||
end
|
||||
elsif @in_sourceDestCheck
|
||||
case name
|
||||
when 'value'
|
||||
@response['sourceDestCheck'] = (value == 'true')
|
||||
when 'sourceDestCheck'
|
||||
@in_sourceDestCheck = false
|
||||
end
|
||||
elsif @in_groupSet
|
||||
case name
|
||||
when 'item'
|
||||
@response['groupSet'] << @group
|
||||
@group = {}
|
||||
when 'groupId'
|
||||
@group["groupId"] = value
|
||||
when 'groupSet'
|
||||
@in_groupSet = false
|
||||
end
|
||||
else
|
||||
case name
|
||||
when 'requestId', 'instanceId'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
61
lib/fog/aws/requests/compute/describe_instance_attribute.rb
Normal file
61
lib/fog/aws/requests/compute/describe_instance_attribute.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
require 'fog/aws/parsers/compute/describe_instance_attribute'
|
||||
# Describes an instance attribute value
|
||||
#
|
||||
# ==== Parameters
|
||||
# * instance_id<~String> - The ID of the instance you want to describe an attribute of
|
||||
# * attribute<~String> - The attribute to describe, must be one of the following:
|
||||
# -'instanceType'
|
||||
# -'kernel'
|
||||
# -'ramdisk'
|
||||
# -'userData'
|
||||
# -'disableApiTermination'
|
||||
# -'instanceInitiatedShutdownBehavior'
|
||||
# -'rootDeviceName'
|
||||
# -'blockDeviceMapping'
|
||||
# -'productCodes'
|
||||
# -'sourceDestCheck'
|
||||
# -'groupSet'
|
||||
# -'ebsOptimized'
|
||||
# -'sriovNetSupport'
|
||||
#
|
||||
# === Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'instanceId'<~String> - The ID of the instance
|
||||
# * 'instanceType'<~String> - Instance type
|
||||
# * 'kernelId'<~String> - The kernel ID
|
||||
# * 'ramdiskId'<~String> - The RAM disk ID
|
||||
# * 'userData'<~String> - The Base64-encoded MIME user data
|
||||
# * 'disableApiTermination'<~Boolean> - If the value is true , you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.
|
||||
# * 'instanceInitiatedShutdownBehavior'<~String> - Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown)
|
||||
# * 'rootDeviceName'<~String> - The name of the root device (for example, /dev/sda1 or /dev/xvda )
|
||||
# * 'blockDeviceMapping'<~List> - The block device mapping of the instance
|
||||
# * 'productCodes'<~List> - A list of product codes
|
||||
# * 'ebsOptimized'<~Boolean> - Indicates whether the instance is optimized for EBS I/O
|
||||
# * 'sriovNetSupport'<~String> - The value to use for a resource attribute
|
||||
# * 'sourceDestCheck'<~Boolean> - Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT
|
||||
# * 'groupSet'<~List> - The security groups associated with the instance
|
||||
# (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstanceAttribute.html]
|
||||
def describe_instance_attribute(instance_id, attribute)
|
||||
request(
|
||||
'Action' => 'DescribeInstanceAttribute',
|
||||
'InstanceId' => instance_id,
|
||||
'Attribute' => attribute,
|
||||
:parser => Fog::Parsers::Compute::AWS::DescribeInstanceAttribute.new
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def describe_instance_attribute(instance_id, attribute)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue