Authored by root

fix Nonce type bug

... ... @@ -48,7 +48,7 @@ class QcloudApi:
params['Signature'] = sign
response_dict = requests.post("https://" + req_url, data=params).json()
elif api_version == 3:
public_params = {'Region': QcloudApi.Region, 'Timestamp': int(time.time()), 'Nonce': QcloudApi.generate_nonce(), 'Version': '2017-03-12', 'SecretId': self.secretId, 'SignatureMethod':'HmacSHA1'}
public_params = {'Region': QcloudApi.Region, 'Timestamp': int(time.time()), 'Nonce': int(QcloudApi.generate_nonce()), 'Version': '2017-03-12', 'SecretId': self.secretId, 'SignatureMethod':'HmacSHA1'}
# merge params
params = dict(params, **public_params)
# signature
... ...
... ... @@ -55,7 +55,7 @@ class consoleRobot(object):
"Action":"TerminateInstances",
"InstanceIds.0":instanceId
}
result = self.client.do_query(params,"cvm.ap-beijing.tencentcloudapi.com")
result = self.client.do_query(params,"cvm.ap-beijing.tencentcloudapi.com",api_version=3)
return result
def ReturnInstanceByIp(self,privateIp):
... ... @@ -67,11 +67,16 @@ class consoleRobot(object):
feedBack = str(raw_input('确认?(Y/N): ')).upper()
if feedBack == 'Y':
print '开始退还实例...{0}'.format(instanceId)
self.ReturnInstanceById(instanceId)
print '实例退还成功!'
print '开始注销zabbix host...'
delete_host_by_ip(privateIp)
return 0
rsp = self.ReturnInstanceById(instanceId)['Response']
if rsp.has_key('Error'):
print json.dumps(rsp['Error'],indent=4)
print '实例退还失败'
return 1
else:
print '实例退还成功!'
print '开始注销zabbix host...'
delete_host_by_ip(privateIp)
return 0
else:
print '任务取消'
return 0
... ...