开发者社区 问答 正文

如何查询ECS所有实例的详细信息



描述


查询所有实例的详细信息。

  • 此接口不会校验参数之间的依赖关系,而是作为 Filter 进行使用,为逻辑与(AND)关系。
  • 如果参数为空,则过滤器不起作用,但是 InstanceIds 如果是一个空 Json Array(即 []),则视为该过滤器有效,且返回空。


请求参数


名称类型是否必须描述
ActionString系统规定参数。取值:DescribeInstances
RegionIdString地域 ID。
VpcIdString专有网络 ID。
VSwitchIdString交换机 ID。
ZoneIdString可用区 ID。
InstanceIdsString实例的编号列表。参数为一个带有格式的 Json Array:[“i-xxxxxxxxx”, ”i-yyyyyyyyy”, … “i-zzzzzzzzz”],最多 100 个 ID,用半角逗号字符隔开。
InstanceTypeString实例的规格。
InstanceTypeFamilyString实例的规格族。
InstanceNetworkTypeString实例网络类型。
PrivateIpAddressesStringVPC 网络类型实例的私有 IP 列表。当 NetworkType 为 VPC 时,这个参数生效.参数为一个带有格式的 Json Array:[“172.16.1.1”, “172.16.2.1”, … “172.16.10.1”],最多 100 个 IP,用半角逗号字符隔开。
InnerIpAddressesString经典网络类型实例的内网 IP 列表。当 NetworkType 为 Classic 时,这个参数生效。参数为一个带有格式的 Json Array:[“10.1.1.1”, ”10.1.2.1”, … “10.1.10.1”],最多 100 个 IP,用半角逗号字符隔开。
PublicIpAddressesString经典网络类型实例的公网 IP 列表。当 NetworkType 为 Classic 时,这个参数生效。参数为一个带有格式的 Json Array:[“42.1.1.1”, ”42.1.2.1”, … “42.1.10.1”],最多 100 个 IP,用半角逗号字符隔开。
SecurityGroupIdString实例所属的安全组。
InstanceChargeTypeString实例的付费方式。取值范围:
  • PrePaid:预付费,即包年包月
  • PostPaid:后付费,即按量付费
SpotStrategyString后付费实例的竞价策略 当InstanceChargeType为PostPay时为生效,可选取值为: NoSpot,正常按量付费实例; SpotWithPriceLimit,设置上限价格的竞价实例; SpotAsPriceGo 系统自动出价,最高按量付费价格。默认值为NoSpot
InternetChargeTypeString网络计费类型。取值范围:
  • PayByTraffic:按流量计费
  • PayByBandwidth:按带宽计费
InstanceNameString实例名称。
ImageIdString镜像 ID。
DeploymentSetIdString部署集 ID。
StatusString实例状态。取值范围:
  • Running
  • Starting
  • Stopping
  • Stopped
IoOptimizedString是否是 I/O 优化型实例。取值范围:
  • True:是 I/O 优化型实例
  • False:不是 I/O 优化型实例
Tag.n.KeyString标签 key。n 的取值范围:[1, 5]不允许为空字符串。
Tag.n.ValueString标签 value。n 的取值范围:[1, 5]允许为空字符串。
PageNumberInteger实例状态列表的页码,起始值为 1。默认值:1
PageSizeInteger分页查询时设置的每页行数,最大值为 100 行。默认值:10


返回参数


名称类型描述
TotalCountInteger实例总个数
PageNumberInteger实例列表的页码
PageSizeInteger输入时设置的每页行数
InstancesInstanceAttributesType由 InstanceAttributesType 组成的数组格式,返回实例的信息


错误码


错误代码描述Http 状态码语义
InvalidInstanceChargeType.NotFoundThe InstanceChargeType does not exist in our records.404指定的 InstanceChargeType 不存在。
InvalidInternetChargeType.ValueNotSupportedThe specified InternetChargeType is not valid404指定的 InternetChargeType 不存在。
InvalidNetworkType.NotFoundThe specified InstanceNetworkType is not found404指定的 InstanceNetworkType 不存在。
InvalidStatus.NotFoundThe specified Status is not found404指定的 Status 不存在。
InvalidTag.MismatchThe specified Tag.n.Key and Tag.n.Value are not match.400指定的 Tag.n.Key 和 Tag.n.Value 不匹配。
InvalidTagCountThe specified tags are beyond the permitted range.400指定的 Tag 数超过了 5 个。


示例



请求示例


https://ecs.aliyuncs.com/?Action=DescribeInstances
&RegionId=cn-hangzhou
&<公共请求参数>
返回示例

XML格式
<DescribeInstancesResponse>
    <CreationTime>2014-09-21T01:12:35Z</CreationTime>
    <DeviceAvailable>true</DeviceAvailable>
    <Description></Description>
    <EipAddress>
          <AllocationId></AllocationId>
        <InternetChargeType></InternetChargeType>
        <IpAddress></IpAddress>
    </EipAddress>
    <ExpiredTime>2011-09-08T16:00Z</ExpiredTime>
    <HostName>iZ25skktcp4Z</HostName>
       <ImageId>ubuntu1404_64_20G_aliaegis_20140703.vhd</ImageId>
    <InnerIpAddress></InnerIpAddress>
    <InstanceChargeType>PostPaid</InstanceChargeType>
    <IpAddress></IpAddress>
    <InstanceId>i-25skktcp4</InstanceId>
    <InstanceName>iZ25skktcp4Z</InstanceName>
    <InstanceNetworkType>vpc</InstanceNetworkType>
    <InstanceType>ecs.t1.xsmall</InstanceType>
    <InternetChargeType></InternetChargeType>
    <InternetMaxBandwidthIn>-1</InternetMaxBandwidthIn>
    <InternetMaxBandwidthOut></InternetMaxBandwidthOut>
    <IoOptimized>false</IoOptimized>
    <OperationLocks>
           <LockReason></LockReason>
    </OperationLocks>
    <PublicIpAddress>
        <IpAddress></IpAddress>
    </PublicIpAddress>
    <RegionId>cn-beijing</RegionId>
    <SecurityGroupIds>
           <SecurityGroupId>sg-25am0n4q0</SecurityGroupId>
    </SecurityGroupIds>
    <SerialNumber>51d1353b-22bf-4567-a176-8b3e12e43135</SerialNumber>
    <Status>Running</Status>
    <VlanId></VlanId>
    <VpcAttributes>
        <NatIpAddress>10.175.68.212</NatIpAddress>
        <PrivateIpAddress>
            <IpAddress>192.168.2.3</IpAddress>
           </PrivateIpAddress>
        <VSwitchId>vsw-25gbsqby3</VSwitchId>
        <VpcId>vpc-25onv3oi4</VpcId>
    </VpcAttributes>
    <ZoneId>cn-beijing-a</ZoneId>
</DescribeInstancesResponse>
JSON格式
{
  "Instances": {
    "Instance": [
      {
        "CreationTime": "2015-07-27T07:08Z",
        "DeviceAvailable": true,
        "EipAddress": {},
        "ExpiredTime": "2011-09-08T16:00Z",
        "HostName": "iZ94t3s0jxkZ",
        "ImageId": "centos6u5_64_20G_aliaegis_20150130.vhd",
        "InnerIpAddress": {
          "IpAddress": [
            "10.170.106.80"
          ]
        },
        "InstanceChargeType": "PostPaid",
        "InstanceId": "i-94t3s0jxk",
        "InstanceName": "dd\u6027\u80fd\u6d4b\u8bd5",
        "InstanceNetworkType": "classic",
        "InstanceType": "ecs.s2.large",
        "InternetChargeType": "PayByTraffic",
        "InternetMaxBandwidthIn": -1,
        "InternetMaxBandwidthOut": 1,
        "IoOptimized": false,
        "OperationLocks": {
          "LockReason": []
        },
        "PublicIpAddress": {
          "IpAddress": [
            "120.25.13.106"
          ]
        },
        "RegionId": "cn-shenzhen",
        "SecurityGroupIds": {
          "SecurityGroupId": [
            "sg-94kd0cyg0"
          ]
        },
        "SerialNumber": "51d1353b-22bf-4567-a176-8b3e12e43135",
        "Status": "Running",
        "VpcAttributes": {
          "PrivateIpAddress": {
            "IpAddress": []
          }
        },
        "ZoneId": "cn-shenzhen-a"
      }
    ]
  },
  "PageNumber": 1,
  "PageSize": 10,
  "RequestId": "14A07460-EBE7-47CA-9757-12CC4761D47A",
  "TotalCount": 1
}


展开
收起
boxti 2017-10-19 14:11:59 2364 分享
分享
版权
举报
0 条回答
写回答
取消 提交回答
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等