阿里云SDK-python修改阿里云ecs密码

python修改阿里云ecs密码

# pip
# pip install aliyun-python-sdk-core        # 安装阿里云SDK核心库
pip install aliyun-python-sdk-core-v3   # Python3.X 阿里云SDK核心库
pip install aliyun-python-sdk-ecs
pip install aliyun-python-sdk-alimt     # 安装机器翻译
#!/usr/bin/env python
#coding=utf-8
from aliyunsdkcore import client
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
#from aliyunsdkecs.request.v20140526 import ModifyInstanceAttribute
from aliyunsdkecs.request.v20140526 import ModifyInstanceAttributeRequest
import json
list = ['要改密码的ecs id1','要改密码的ecs id2']
 
clt = client.AcsClient('AccessKeyId','AccessKeySecret','地域名')
 
for i in list:
    #request = ModifyInstanceAttribute.ModifyInstanceAttribute()
    request = ModifyInstanceAttributeRequest.ModifyInstanceAttributeRequest()
    request.set_accept_format('json')
    request.set_InstanceName("实例名")
    request.set_Password("密码")
    request.set_InstanceId(i)
    action = clt.do_action_with_exception(request)
    print action
posted @ 2021-05-30 14:07  SRE运维充电站  阅读(178)  评论(0编辑  收藏  举报