内容简介:例如 选择这个:如何使用呢? 如下 ↓
获取accesskey
- 登录阿里云;
- 控制台;
- 右上角头像 –> accesskeys;
- 创建 accesskey (保存到文档,稍后用到);
基础Ali-api了解
例如 选择这个:
DescribeInstances 查询所有实例的详细信息。
如何使用呢? 如下 ↓
复制:“DescribeInstances” 到搜索框,出来二级选项框,选择一个区域就会出来咱们所对应不同语言的代码:
以 Python 为例:
#!/usr/bin/env python #coding=utf-8 from aliyunsdkcore.client import AcsClient from aliyunsdkcore.request import CommonRequest client = AcsClient('<accessKeyId>', '<accessSecret>', 'cn-hangzhou') request = CommonRequest() request.set_accept_format('json') request.set_domain('ecs.aliyuncs.com') request.set_method('POST') request.set_version('2014-05-26') request.set_action_name('DescribeInstances') request.add_query_param('RegionId', 'cn-hangzhou') response = client.do_action(request) # python2: print(response) print(str(response, encoding = 'utf-8'))
然后修改刚刚保存的accesskey信息即可;
sdk 安装
python2 pip install aliyun-python-sdk-core python3 pip install aliyun-python-sdk-core-v3 云产品 SDK 安装 pip install aliyun-python-sdk-ecs
运行:
{"PageNumber":1,"TotalCount":1,"PageSize":10,"RequestId":"BFE4F208-FB98-4156-A22D-3EE337A763B4","Instances":{"Instance":[{"ImageId":"centos_7_04_64_20G_alibase_201701015.vhd","VlanId":"","EipAddress":{"IpAddress":"","AllocationId":"","InternetChargeType":""},"ZoneId":"cn-hangzhou-b","IoOptimized":true,"SerialNumber":"bc1d494c-4cba-4e5b-b19f-eb6477f85f1b","Cpu":1,"Memory":2048,"DeviceAvailable":true,"SecurityGroupIds":{"SecurityGroupId":["sg-bp16sxv0bk2b9qcjisj3"]},"SaleCycle":"","AutoReleaseTime":"","OSType":"linux","ResourceGroupId":"","OSName":"CentOS 7.4 64位","InstanceNetworkType":"vpc","HostName":"iZbp1iidpxlqigcvrjz7mjZ","CreationTime":"2018-04-01T12:41Z","RegionId":"cn-hangzhou","DeletionProtection":false,"OperationLocks":{"LockReason":[]},"ExpiredTime":"2021-04-01T16:00Z","InnerIpAddress":{"IpAddress":[]},"InstanceTypeFamily":"ecs.t5","InstanceId":"i-bp1iidpxlqigcvrjz7mj","NetworkInterfaces":{"NetworkInterface":[{"MacAddress":"00:16:3e:11:97:f4","PrimaryIpAddress":"172.16.79.206","NetworkInterfaceId":"eni-bp16sxv0bk2b9qcnb35o"}]},"InternetMaxBandwidthIn":200,"CreditSpecification":"Standard","InternetChargeType":"PayByBandwidth","SpotStrategy":"NoSpot","StoppedMode":"Not-applicable","InternetMaxBandwidthOut":1,"VpcAttributes":{"NatIpAddress":"","PrivateIpAddress":{"IpAddress":["172.16.79.206"]},"VSwitchId":"vsw-bp1jt078ogsy2q1ypz7ys","VpcId":"vpc-bp1tnyrlkqsyqhi5n3cdj"},"SpotPriceLimit":0.0,"StartTime":"2019-01-21T13:14Z","InstanceName":"zdh_zz","Description":"","PublicIpAddress":{"IpAddress":["47.98.156.84"]},"InstanceType":"ecs.t5-lc1m2.small","Status":"Running","Recyclable":false,"ClusterId":"","GPUSpec":"","GPUAmount":0,"InstanceChargeType":"PrePaid","DedicatedHostAttribute":{"DedicatedHostId":"","DedicatedHostName":""},"DeploymentSetId":""}]}}
信息比较多,可以放在json页面解析下;
当然一个最重要的信息是, 阿里云区分不同的机器是根据实例id 也就是:
"InstanceId": "i-bp1iidpxlqigcvrjz7mj"
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
写给大家看的算法书
【日】杉浦 贤 / 绝云 / 电子工业出版社 / 2016-6 / 59.00元
算法这个词对于非计算机从业人士而言,似乎就是晦涩、神秘的代名词。其实,算法在日常生活中随处可见。做饭用的菜谱是一种算法、查字典的方法是一种算法、给期中考试分数排名也用到了算法。事实上,算法可以说是这个信息爆炸的时代所依存的重要基石之一。 《写给大家看的算法书》对于理解信息处理的基础——算法而言,是一本非常优秀的入门读物。作者采用大量生动的类比,配合简洁易懂的配图,深入浅出地讲解算法,极大地拉......一起来看看 《写给大家看的算法书》 这本书的介绍吧!