我可以确认restoreFromSnapshot API调用确实已被破坏。我把机密信息留空了。另外,我想要注意的是,我已经遵循了正确的程序,并在发出恢复之前在我配置的机器上卸载了Endurance卷。
/home/scripts > ./snapshot.py list 12193217
VOLUM ID: 12193217
+---+-------------------+----------+----------+---------------------------+
| # | username | id | nasType | createDate |
+---+-------------------+----------+----------+---------------------------+
| 7 | *** | 13020991 | SNAPSHOT | *** |
/home/scripts > ./snapshot.py restore 12193217 13020991
iscsi id: 12193217
iscsi snapshot ID: 13020991
True
def restore_from_snapshot(sl_config, volume_id, snapshot_id):
""" Restore drive from specified snapshot """
if snapshot_id and volume_id:
volume_id = volume_id[0]
snapshot_id = snapshot_id[0]
#print "snapshot_id = %s :: volume_id = %s" % snapshot_id % volume_id
iscsi_mgr = SoftLayer.ISCSIManager(SL.instance(sl_config).client)
iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids, volume_id,'iSCSI')
print "iscsi id: %i" % iscsi_id
iscsi_snapshot_id = helpers.resolve_id(iscsi_mgr.resolve_ids, snapshot_id,'Snapshot')
print "iscsi snapshot ID: %i " % iscsi_snapshot_id
iscsi = SL.instance(sl_config).client['Network_Storage_Iscsi']
snapshot_output = iscsi.restoreFromSnapshot(iscsi_snapshot_id, id=iscsi_id)
print snapshot_output
在此之后没有任何事情发生。只有通过Web API才能进行还原。 SLCLI也被破坏(它使用相同的服务)。
答案 0 :(得分:0)
目前在ISCSIManager中使用该服务存在问题。我已经开了一个关于它的问题:
可能需要一些时间来修复。同时我可以提供一个Python脚本来从快照恢复存储:
"""
This script restores the volume from a snapshot that was previously taken.
See below references for more details.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage/restoreFromSnapshot
@License: http://sldn.softlayer.com/article/License
@Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer
from pprint import pprint as pp
# Your SoftLayer username and apiKey
user = 'set me'
api = 'set me'
# Connect to SoftLayer
client = SoftLayer.create_client_from_env(username=user, api_key=api)
# Define the storage Id
storageId = 5805966
# Define the snapshot Id
snapshotId = 13431999
try:
result = client['SoftLayer_Network_Storage'].restoreFromSnapshot(snapshotId, id=storageId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
print('Error: faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
exit(1)
<强>参考强>