【问题标题】:Importing an AWS image into softlayer将 AWS 映像导入 softlayer
【发布时间】:2017-03-03 21:34:12
【问题描述】:

是否可以直接将 AWS 映像导入到 softlayer 中?我知道我们可以下载 AWS 映像并导入到 softlayer,但正在寻找一些自动化的解决方案。

【问题讨论】:

    标签: amazon-web-services ibm-cloud-infrastructure


    【解决方案1】:

    没有任何 Softlayer 的 API 方法可以自动完成所有过程,图像必须上传到您的任何对象存储帐户中,您可以使用 API 上传图像,这里有一些参考:

    http://sldn.softlayer.com/blog/waelriac/Managing-SoftLayer-Object-Storage-Through-REST-APIs

    并查看有关如何处理大文件的文档

    https://docs.openstack.org/developer/swift/overview_large_objects.html

    上传文件后,您可以使用 API 将其导入:

    这里是使用 SOftlayer 的 Python 客户端的示例:

    """
    Create Image Template from external source
    
    This script creates a transaction to import a disk image from an external source and create 
    a standard image template
    
    Important manual pages:
    http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest_Block_Device_Template_Group/createFromExternalSource
    http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Virtual_Guest_Block_Device_Template_Configuration
    http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Block_Device_Template_Group
    
    License: http://sldn.softlayer.com/article/License
    Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
    """
    import SoftLayer
    
    # Your SoftLayer username and apiKey
    USERNAME = 'set me'
    API_KEY = 'set me'
    
    # Declare the group name to be applied to the imported template
    name = 'imageTemplateTest'
    # Declare the note to be applied to the imported template
    note = 'This is for test Rcv'
    
    '''
    Declare referenceCode of the operating system software description for the imported VHD
    available options: CENTOS_6_32, CENTOS_6_64, CENTOS_7_64, REDHAT_6_32, REDHAT_6_64, REDHAT_7_64, 
    UBUNTU_12_32, UBUNTU_12_64, UBUNTU_14_32, UBUNTU_14_64, WIN_2003-STD-SP2-5_32, WIN_2003-STD-SP2-5_64, 
    WIN_2008-STD-R2-SP1_64, WIN_2012-STD_64.
    '''
    operatingSystemReferenceCode = 'CENTOS_6_64'
    
    '''
    Define the parameters below, which refers to object storage where the image template is stored. 
    It will help to build the uri.
    '''
    # Declare the object storage account name
    objectStorageAccountName = 'SLOS307608-10'
    # Declare the cluster name where the image is stored
    clusterName = 'dal05'
    # Declare the container name where the image is stored
    containerName = 'OS'
    # Declare the file name of the image stored in the object storage, it should be .vhd or 
    fileName = 'testImage2.vhd-0.vhd'
    
    """
    Creating an SoftLayer_Container_Virtual_Guest_block_Device_Template_Configuration Skeleton
    which contains the information from external source
    """
    configuration = {
        'name': name,
        'note': note,
        'operatingSystemReferenceCode': operatingSystemReferenceCode,
        'uri': 'swift://'+ objectStorageAccountName + '@' + clusterName + '/' + containerName + '/' + fileName
    }
    
    # Declare the API client
    client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
    groupService = client['SoftLayer_Virtual_Guest_Block_Device_Template_Group']
    
    try:
        result = groupService.createFromExternalSource(configuration)
        print(result)
    except SoftLayer.SoftLayerAPIError as e:
        print("Unable to create the image template from external source. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
        exit(1)
    

    问候

    【讨论】:

    • 好的,但是没有办法直接从 Softlayer 帐户引用亚马逊 AMI 并将它们导入 Softlayer?
    • 正如我在回答中感到难过的那样“没有任何 Softlayer 的 API 方法可以自动完成所有进程”。
    猜你喜欢
    • 2020-05-08
    • 1970-01-01
    • 1970-01-01
    • 2016-12-21
    • 2017-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多