欢迎光临
我们一直在努力

01: 腾讯云API-云服务器

#! /usr/bin/env python # -*- coding: utf-8 -*- from tencentcloud.common import credential from tencentcloud.common.profile.client_profile import ClientProfile from tencentcloud.common.profile.http_profile import httpprofile from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException from tencentcloud.cvm.v20170312 import cvm_client, models from day04.settings import secretKey,secretId # 导入腾讯云账户secretId,secretKey值 # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey def instantiates_auth_obj(): cred = credential.Credential(secretId=secretId, secretKey=secretKey) return cred # 查询指定地域可用区列表(查询北京地域所有主机信息 InstanceId机器唯一ID) def zero_hosts_list(zones): try: cred = instantiates_auth_obj() httpProfile = HttpProfile() httpProfile.endpoint = "cvm.tencentcloudapi.com" clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = cvm_client.CvmClient(cred, zones, clientProfile) req = models.DescribeInstancesRequest() params = '{}' req.from_json_string(params) resp = client.DescribeInstances(req) return resp except TencentCloudSDKException as err: print(err) return {} print zero_hosts_list('ap-beijing') d = { "InstanceSet": [{ "RenewFlag": "NOTIFY_AND_AUTO_RENEW", "InstanceState": "RUNNING", "LoginSettings": { "KeyIds": none, "Password": None, "KeepImageLogin": None }, "RestrictState": "NORMAL", "ExpiredTime": "2019-04-11T07:25:00Z", "Memory": 1, "CreatedTime": "2019-03-11T07:25:00Z", "CPU": 1, "PublicIpAddresses": ["118.89.245.148"], "Tags": [{ "Key": "costcenter", "Value": "devops" }, { "Key": "负责人", "Value": "zihe.feng" }], "InstanceId": "ins-3n9jqe9x", "ImageId": "img-qp03e2j7", "StopChargingMode": "NOT_APPLICABLE", "InstanceChargeType": "PREPAID", "InstanceType": "S2.SMALL1", "SystemDisk": { "DiskSize": 100, "DiskId": "disk-bxp7e5c1", "DiskType": "CLOUD_SSD" }, "Placement": { "ProjectId": 0, "HostIds": None, "Zone": "ap-beijing-1" }, "PrivateIpAddresses": ["172.20.0.10"], "OsName": "CentOS 7.3 64位", "SecurityGroupIds": ["sg-od0hrpvh"], "InstanceName": "bj-test-common-ss-1", "DataDisks": None, "VirtualPrivateCloud": { "SubnetId": "subnet-qebil5dp", "AsVpcGateway": False, "VpcId": "vpc-fbv2dybq", "PrivateIpAddresses": None }, "InternetAccessible": { "PublicIpAssigned": None, "InternetChargeType": "TRAFFIC_POSTPAID_BY_HOUR", "BandwidthPackageId": None, "InternetMaxBandwidthOut": 200 } }, { "RenewFlag": "NOTIFY_AND_AUTO_RENEW", "InstanceState": "RUNNING", "LoginSettings": { "KeyIds": ["skey-h64mpzpz"], "Password": None, "KeepImageLogin": None }, "RestrictState": "NORMAL", "ExpiredTime": "2019-04-07T11:11:42Z", "Memory": 56, "CreatedTime": "2019-03-07T11:11:42Z", "CPU": 28, "PublicIpAddresses": ["154.8.155.101"], "Tags": [], "InstanceId": "ins-33hru7oj", "ImageId": "img-qp03e2j7", "StopChargingMode": "NOT_APPLICABLE", "InstanceChargeType": "PREPAID", "InstanceType": "GN2.7XLARGE56", "SystemDisk": { "DiskSize": 50, "DiskId": "ldisk-czzwc94e", "DiskType": "LOCAL_SSD" }, "Placement": { "ProjectId": 0, "HostIds": None, "Zone": "ap-beijing-2" }, "PrivateIpAddresses": ["172.21.0.15"], "OsName": "CentOS 7.3 64位", "SecurityGroupIds": ["sg-od0hrpvh"], "InstanceName": "bj-prod-research-gpu-2", "DataDisks": [{ "DeleteWithInstance": None, "DiskSize": 1650, "DiskId": "ldisk-1xfm3yi6", "DiskType": "LOCAL_SSD" }], "VirtualPrivateCloud": { "SubnetId": "subnet-iyhhdfun", "AsVpcGateway": False, "VpcId": "vpc-pmccgax8", "PrivateIpAddresses": None }, "InternetAccessible": { "PublicIpAssigned": None, "InternetChargeType": "TRAFFIC_POSTPAID_BY_HOUR", "BandwidthPackageId": None, "InternetMaxBandwidthOut": 200 } }], "TotalCount": 11, "RequestId": "b68ed268-d528-48e8-aa29-416b126d7489" }

  • 海报
海报图正在生成中...
赞(0) 打赏
声明:
1、本博客不从事任何主机及服务器租赁业务,不参与任何交易,也绝非中介。博客内容仅记录博主个人感兴趣的服务器测评结果及一些服务器相关的优惠活动,信息均摘自网络或来自服务商主动提供;所以对本博客提及的内容不作直接、间接、法定、约定的保证,博客内容也不具备任何参考价值及引导作用,访问者需自行甄别。
2、访问本博客请务必遵守有关互联网的相关法律、规定与规则;不能利用本博客所提及的内容从事任何违法、违规操作;否则造成的一切后果由访问者自行承担。
3、未成年人及不能独立承担法律责任的个人及群体请勿访问本博客。
4、一旦您访问本博客,即表示您已经知晓并接受了以上声明通告。
文章名称:《01: 腾讯云API-云服务器》
文章链接:https://www.456zj.com/4473.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址