0


首先,我想提一下,我对云计算和 Python 还是很陌生。我希望你们比softlayer服务台更有帮助。

目前我很难理解 Python API。我有几台服务器正在运行,每台服务器都在运行 evault 代理。代理会定期创建我的服务器的备份。电子仓库代理现在已经运行了几个月,所以我有一些历史数据。

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

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

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

  • Softlayer 论坛一般
  • Softlayer 论坛实施

到目前为止,这是我的脚本:

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")

这给了我以下例外:

SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_Public): Error Occured. Unable to get account backup history.

PS:我使用的帐户具有管理员权限
欢迎任何建议
干杯,
Eredjar

4

1 回答 1

0

显然,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))
于 2016-01-19T14:19:53.920 回答