2016-08-04 66 views
1

我已经尝试了下面的方法,以获取softlayer上的iscsi存储凭据(我在softlayer上有耐力块存储)但无法检索密码。如何获得softlayer上的卷存储凭据

SoftLayer_Network_Storage_Iscsi::getCredentials 
eg. res = client['SoftLayer_Network_Storage_Iscsi'].getCredentials(id=***) 
SoftLayer_Network_Storage_Iscsi::getObjectsByCredential 
SoftLayer_Network_Storage_Iscsi::getObject 
SoftLayer_Network_Storage_Iscsi::getAllowedVirtualGuests 

我想检索授权主机到特定卷的用户名,密码和iqn。是否有任何的API来获取这些信息,或者任何其他方式来获取这些信息

回答

1

你可以使用一个对象屏蔽来获取这样的信息:

面具[allowedHardware [allowedHost [凭证],allowedVirtualGuests [allowedHost [凭证]]]

这将是一个REST请求用法:

https://$username:[email protected]/rest/v3/SoftLayer_Network_Storage_Iscsi/$iscsiId/getObject.json?objectMask=mask[allowedHardware[allowedHost[credential]],allowedVirtualGuests[allowedHost[credential]]] 

这里一个使用样本Python客户端:

""" 
Get credentials for a authorized hosts of a SoftLayer_Network_Storage_Iscsi 

Important manual pages 
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi 

License: http://sldn.softlayer.com/article/License 
Author: SoftLayer Technologies, Inc. <[email protected]> 
""" 

import SoftLayer 
import json 

USERNAME = 'set me' 
API_KEY = 'set me' 

iscsiStorageId = 1234567 

client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY) 
networkStorageIscsiService = client['SoftLayer_Network_Storage_Iscsi'] 

objectMask = 'mask[allowedHardware[allowedHost[credential]],allowedVirtualGuests[allowedHost[credential]]]' 

try: 
    iscsiStorage = networkStorageIscsiService.getObject(mask=objectMask, id=iscsiStorageId) 
    print(json.dumps(iscsiStorage, sort_keys=True, indent=2, separators=(',', ': '))) 
except SoftLayer.SoftLayerAPIError as e: 
    print("Unable to retrieve the Network Storage Iscsi. faultCode=%s, faultString=%s" 
     % (e.faultCode, e.faultString)) 

下一个环节可能会为您提供进一步的信息:

https://sldn.softlayer.com/article/object-masks

+0

嗨大卫......我能与上述步骤感谢您检索凭据 – Ajay