Softlayer API使用Python获取帐户备份历史时出现SoftLayer_Exception_Public错误

2024-06-16 11:13:12 发布

您现在位置:Python中文网/ 问答频道 /正文


首先,我想说的是,我对云计算和Python非常陌生。 我希望你们比软层服务台更有帮助。在

目前我很难理解那里的Python API。 我有几个服务器在运行,每台服务器都有evault代理在运行。代理定期创建我的服务器的备份。逃逸探员已经运行了几个月了,所以我有一些历史数据。在

我想要的是创建一个Python脚本,每天检查备份是否成功。但不幸的是,我无法从“Account”服务访问“getAccountBackupHistory”方法。在

“getAccountBackupHistory”需要3个参数,但我不知道添加到哪里。在

我还搜索了那里的论坛,希望能找到一些类似的东西,但我没有找到任何有用的东西。在

  • 软层论坛通用
  • 软层论坛实现

这是我目前为止的剧本:

import SoftLayer
import datetime,time
from SoftLayer import utils
import pprint

usr_name="my_username"
api="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

client = SoftLayer.create_client_from_env(username=usr_name, api_key=api)

dt_now=datetime.datetime.now()
dt_end=str(dt_now.strftime('%Y-%m-%d'))
dt_start=str((dt_now-datetime.timedelta(days=2)).strftime('%Y-%m-%d'))

#First attempt
obj=client.call("Account","getAccountBackupHistory",dt_start,dt_end,"success")


#Second attempt
obj=client["Account"]
webcc=obj.getAccountBackupHistory(dt_start,dt_end,"success")

这给了我以下例外:

^{pr2}$

注:我使用的帐户具有管理员权限
欢迎
干杯,
埃雷贾尔


Tags: import服务器clientapiobjdatetimedtaccount
1条回答
网友
1楼 · 发布于 2024-06-16 11:13:12

显然,SoftLayer_Account::getAccountBackupHistory有问题。在

但是,如果要检查备份是否已从其代理成功创建,则可以尝试以下Python脚本:

"""
This script retrieves an account's associated EVault storage volumes.
Also it retrieves the "agentStatuses" and "backupJobDetails" information from them.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getEvaultNetworkStorage
http://sldn.softlayer.com/article/object-masks

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer
import pprint

# Your SoftLayer username and apiKey
usr_name = "set me"
api = "set me"

# Declare the API client.
client = SoftLayer.create_client_from_env(username=usr_name, api_key=api)

# Declare an object mask, to get agentStatuses and backupJobDetails information
object_mask = "mask(SoftLayer_Network_Storage_Backup_Evault_Version6)[agentStatuses, backupJobDetails]"

try:
    obj = client["SoftLayer_Account"].getEvaultNetworkStorage(mask=object_mask)
    pprint.pprint(obj)
except SoftLayer.SoftLayerAPIError as e:
    print("Error: faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))

相关问题 更多 >