如何在softlayer

时间:2016-08-04 13:32:46

标签: ibm-cloud-infrastructure

我已尝试过以下方法,在softlayer上获取iscsi存储的凭据(我在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 个答案:

答案 0 :(得分:1)

您可以使用对象蒙版来检索此类信息:

  

掩模[allowedHardware [allowedHost [凭证],allowedVirtualGuests [allowedHost [凭证]]]

这将是REST请求的用法:

https://$username:$apiKey@api.softlayer.com/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. <sldn@softlayer.com>
"""

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