2016-08-04 28 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