【问题标题】:Launch Virtual Machine with Static ip in softlayer using rest api使用rest api在softlayer中启动具有静态ip的虚拟机
【发布时间】:2016-12-10 05:43:31
【问题描述】:

我需要一个解决方案,如何在 softlayer 中使用静态 ip 启动虚拟机,我在许多站点中搜索仍然无法得到任何答案 softlayer 支持静态 ip,我想知道在 softlayer 中订购静态 ip 的方法是什么以及如何干扰虚拟机

感谢您的回答...

【问题讨论】:

    标签: rest ibm-cloud-infrastructure


    【解决方案1】:

    为了订购具有任何规格的虚拟客人,您应该获得正确的商品价格 ID,为此您可以运行下一个请求:

    https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Package/46/getItemPrices.json
    Method: GET
    

    获得商品价格 ID 后,您可以使用它们来验证/下订单具有您想要的特征,这里是订购具有静态 IPv4 的 VSI 的示例:

    https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
    Method: POST
    Body:
    {
                    "parameters": [
                                    {
                                        "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
                                        "quantity": 1,
                                        "virtualGuests": [
                                            {"hostname": "test-template", "domain": "example.com"}
                                        ],
                                        "location": 168642,
                                        "packageId": 46,
                                        "prices": [
                                            {"id": 1640},
                                            {"id": 1644},
                                            {"id":  905},  
                                            {"id":  272},  
                                            {"id":50231}, 
                                            {"id":   21},  
                                            {"id": 2202},  
                                            {"id":13945},  
                                            {"id":   55},  
                                            {"id":   57},  
                                            {"id":   58},  
                                            {"id":  420},  
                                            {"id":  418},
                                            {"id":   22}
                                        ]
                                    }
                    ]
    }
    

    此外,您可以使用此 python 脚本,该脚本已记录并描述了静态 IPv4 的 REST 请求中使用的每个项目价格 ID: 注:脚本使用SL python客户端https://github.com/softlayer/softlayer-python

    """
    Order Virtual Guest with Static IPv4.
    
    Important manual pages:
    https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
    http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
    http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
    
    License: http://sldn.softlayer.com/article/License
    Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
    """
    import SoftLayer
    from pprint import pprint as pp
    
    USERNAME = 'set me
    API_KEY = 'set me
    
    client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
    
    order = {
        'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest',
        'quantity': 1,
        'virtualGuests': [
            {'hostname': 'test-template', 'domain': 'example.com'}
        ],
        'location': 168642,  # San Jose 1
        'packageId': 46,     # CCI Package
        'prices': [
            {'id': 1640},  # 1 x 2.0 GHz Core
            {'id': 1644},  # 1 GB RAM
            {'id':  905},  # Reboot / Remote Console
            {'id':  272},  # 10 Mbps Public & Private Networks
            {'id':50231},  # 1000 GB Bandwidth
            {'id':   21},  # 1 IP Address
            {'id': 2202},  # 25 GB (SAN)
            {'id':13945},  # CentOS 6.x - Minimal Install (64 bit)
            {'id':   55},  # Host Ping Monitoring
            {'id':   57},  # Email and Ticket Notifications
            {'id':   58},  # Automated Notification Response
            {'id':  420},  # Unlimited SSL VPN Users & 1 PPTP VPN User per account
            {'id':  418},  # Nessus Vulnerability Assessment & Reporting
            {'id':   22}   # 4 Public IP Addresses
        ]
    }
    
    try:
        # Replace verifyOrder for placeOrder
        result = client['SoftLayer_Product_Order'].verifyOrder(order)
        pp(result)
    except SoftLayer.SoftLayerAPIError as e:
        pp('Unable to verify/place order faultCode=%s, faultString=%s' 
        % (e.faultCode, e.faultString)) 
    

    这里是一个使用静态 IPv6 订购 VSI 的示例:

    https:// $username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
    Method: POST
    Body:
    {
                    "parameters": [
                                    {
                                        "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
                                        "quantity": 1,
                                        "virtualGuests": [
                                            {"hostname": "test-template", "domain": "example.com"}
                                        ],
                                        "location": 168642,
                                        "packageId": 46,
                                        "prices": [
                                            {"id": 1640},
                                            {"id": 1644},
                                            {"id":  905},  
                                            {"id":  272},  
                                            {"id":50231}, 
                                            {"id":   21},  
                                            {"id": 2202},  
                                            {"id":13945},  
                                            {"id":   55},  
                                            {"id":   57},  
                                            {"id":   58},  
                                            {"id":  420},  
                                            {"id":  418},
                                            {"id":  17129},
                                            {"id":  1481}
                                        ]
                                    }
                    ]
    }
    

    此外,您可以使用此 python 脚本,该脚本已记录并描述了静态 IPv6 的 REST 请求中使用的每个项目价格 ID: 注:脚本使用SL python客户端https://github.com/softlayer/softlayer-python

    """
    Order Virtual Guest with Static IPv6.
    
    Important manual pages:
    https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
    http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
    http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
    
    License: http://sldn.softlayer.com/article/License
    Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
    """
    import SoftLayer
    from pprint import pprint as pp
    
    USERNAME = 'set me
    API_KEY = 'set me
    
    client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
    
    order = {
        'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest',
        'quantity': 1,
        'virtualGuests': [
            {'hostname': 'test-template', 'domain': 'example.com'}
        ],
        'location': 168642,  # San Jose 1
        'packageId': 46,     # CCI Package
        'prices': [
            {'id': 1640},  # 1 x 2.0 GHz Core
            {'id': 1644},  # 1 GB RAM
            {'id':  905},  # Reboot / Remote Console
            {'id':  272},  # 10 Mbps Public & Private Networks
            {'id':50231},  # 1000 GB Bandwidth
            {'id':   21},  # 1 IP Address
            {'id': 2202},  # 25 GB (SAN)
            {'id':13945},  # CentOS 6.x - Minimal Install (64 bit)
            {'id':   55},  # Host Ping Monitoring
            {'id':   57},  # Email and Ticket Notifications
            {'id':   58},  # Automated Notification Response
            {'id':  420},  # Unlimited SSL VPN Users & 1 PPTP VPN User per account
            {'id':  418},  # Nessus Vulnerability Assessment & Reporting
            {'id':17129},  # 1_IPV6_ADDRESS
            {'id': 1481}   # 64_BLOCK_STATIC_PUBLIC_IPV6_ADDRESSES    ]
    }
    
    try:
        # Replace verifyOrder for placeOrder
        result = client['SoftLayer_Product_Order'].verifyOrder(order)
        pp(result)
    except SoftLayer.SoftLayerAPIError as e:
        pp('Unable to verify/place order faultCode=%s, faultString=%s' 
        % (e.faultCode, e.faultString)) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-30
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多