SoftLayer:如何获得imageId?

时间:2017-12-13 04:43:35

标签: image import operating-system ibm-cloud-infrastructure ssh-keys

我需要从SoftLayer中的以下代码中获取ImageId:

import SoftLayer
from pprint import pprint as pp

class example():

def __init__(self):
    self.client = SoftLayer.Client()

def main(self):
    """
    Will reload the operating system with a new imageTemplate, 
    along with a set of sshKeys. This will erease all data.
    """
    # Change these IDs
    imageId = 1234567
    sshKey1 = 123
    sshKey2 = 456
    serverId = 102938
    config = {
        'imageTemplateId': imageId, 
        'sshKeyIds': [sshKey1, sshKey2]
    }

    output = self.client['Hardware_Server'].reloadOperatingSystem('FORCE', config, id=serverId)

    pp(config)
    print "RESULT\n"
    pp(output)

if __name__ == "__main__":
main = example()
main.main()

有人知道如何获取imageId吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

您可以通过控制门户页面获取图片ID,只需在此处查看所有私有图片https://control.softlayer.com/devices/images

通过API,您可以使用方法SoftLayer_Account :: getPrivateBlockDeviceTemplateGroups

GET https://[userName]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Account/getPrivateBlockDeviceTemplateGroups

使用python应该是这样的:

 images = client['SoftLayer_Account'].getPrivateBlockDeviceTemplateGroups()