在SoftLayer上添加服务组(虚拟服务)的正确方法是什么?

时间:2016-08-11 16:55:30

标签: ibm-cloud-infrastructure

我正在尝试创建一个Auto Scale Group。此新Auto Scale组需要指向现有本地负载均衡器虚拟IP地址上的新(服务组,服务端口)条目。

从网站上,我可以选择“添加组”并输入(GroupType,方法,虚拟端口,分配),它们似乎是SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualServer上的字段 (似乎还有一个名为SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_Service_Group的类型,但它没有正确的字段名称。)

我尝试使用以下POST Web请求在现有本地负载均衡器上创建新的VirtualServer(服务组?),并返回404错误代码。

https://api.softlayer.com/rest/v3/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualServer.json

{
  "parameters": 
  [
    {
      "allocation": 12,
      "port": 1290,
      "routingMethodId": null,
      "virtualIpAddressId": 157345
    }
  ]
}

=== EDITED ===

根据您的建议,我尝试了以下方法:

GET

https://api.softlayer.com/rest/v3/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/157345/getObject.json?objectMask=mask[virtualServers[serviceGroups]]

RESPONSE

{
   "accountId": 940999,
   "connectionLimit": 250,
   "connectionLimitUnits": "connections\/second",
   "dedicatedFlag": false,
   "id": 157345,
   "ipAddressId": 11112844,
   "notes": "CaffeLoadBalancer",
   "securityCertificateId": null,
   "sslActiveFlag": false,
   "sslEnabledFlag": false,
   "highAvailabilityFlag": false,
   "managedResourceFlag": false,
   "virtualServers": [{
      "allocation": 12,
      "id": 274353,
      "port": 1201,
      "routingMethodId": null,
      "virtualIpAddressId": 157345,
      "serviceGroups": [{
         "id": 270313,
         "routingMethodId": 3,
         "routingTypeId": 3,
         "timeout": null
      }],
      "virtualIpAddress": {
         "accountId": 940999,
         "connectionLimit": 250,
         "connectionLimitUnits": "connections\/second",
         "dedicatedFlag": false,
         "id": 157345,
         "ipAddressId": 11112844,
         "notes": "CaffeLoadBalancer",
         "securityCertificateId": null,
         "sslActiveFlag": false,
         "sslEnabledFlag": false,
         "highAvailabilityFlag": false,
         "managedResourceFlag": false,
         "virtualServers": null
      }
   }]
}

然后我修改了对此的回复:

{
"parameters": 
[

 {
  "accountId": 940999,
  "connectionLimit": 250,
  "connectionLimitUnits": "connections\/second",
  "dedicatedFlag": false,
  "id": 157345,
  "ipAddressId": 11112844,
  "notes": "CaffeLoadBalancer",
  "securityCertificateId": null,
  "sslActiveFlag": false,
  "sslEnabledFlag": false,
  "highAvailabilityFlag": false,
  "managedResourceFlag": false,
  "virtualServers": 
   [
   {
    "allocation": 12,
    "id": 274353,
    "port": 1201,
    "routingMethodId": null,
    "virtualIpAddressId": 157345,
    "serviceGroups": [{
      "id": 270313,
      "routingMethodId": 3,
      "routingTypeId": 3,
      "timeout": null
    }],
    "virtualIpAddress": {
      "accountId": 940999,
      "connectionLimit": 250,
      "connectionLimitUnits": "connections\/second",
      "dedicatedFlag": false,
      "id": 157345,
      "ipAddressId": 11112844,
      "notes": "CaffeLoadBalancer",
      "securityCertificateId": null,
      "sslActiveFlag": false,
      "sslEnabledFlag": false,
      "highAvailabilityFlag": false,
      "managedResourceFlag": false,
      "virtualServers": null
    }
  },
   {
    "allocation": 12,
    "port": 1290,
    "routingMethodId": null,
    "virtualIpAddressId": 157345,
    "serviceGroups": [{
      "id": 270313,
      "routingMethodId": 3,
      "routingTypeId": 3,
      "timeout": null
    }],
    "virtualIpAddress": {
      "accountId": 940999,
      "connectionLimit": 250,
      "connectionLimitUnits": "connections\/second",
      "dedicatedFlag": false,
      "id": 157345,
      "ipAddressId": 11112844,
      "notes": "CaffeLoadBalancer",
      "securityCertificateId": null,
      "sslActiveFlag": false,
      "sslEnabledFlag": false,
      "highAvailabilityFlag": false,
      "managedResourceFlag": false,
      "virtualServers": null
    }
  }
  ]
}

]
}

并将其发布到:

https://api.softlayer.com/rest/v3.1/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/157345/editObject.json

我收到以下错误:

  

远程服务器返回错误:(500)内部服务器错误。

1 个答案:

答案 0 :(得分:0)

您需要编辑调用方法的加载balnacer并不是那么容易:

http://sldn.softlayer.com/reference/services/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/e

基本上你需要通过添加新的virtual server object来编辑负载均衡器中包含的virtualServer的配置

请求将看起来像这样:

POST https://api.softlayer.com/rest/v3.1/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/$LOADBALANCERID/editObject
    {
    "parameters": [{
        "connectionLimit": 500,
        "connectionLimitUnits": "connections/second",
        "dedicatedFlag": false,
        "id": 79945,
        "ipAddressId": 25132124,
        "notes": "This is for test",
        "sslActiveFlag": false,
        "sslEnabledFlag": false,
        "highAvailabilityFlag": false,
        "managedResourceFlag": false,
        "virtualServers": [{
            "allocation": 40,
            "id": 192913,
            "port": 70,
            "virtualIpAddressId": 79945,
            "serviceGroups": [{
                "id": 188753,
                "notes": "group 2",
                "routingMethodId": 11,
                "routingTypeId": 3
            }],
            "virtualIpAddress": {
                "connectionLimit": 500,
                "connectionLimitUnits": "connections/second",
                "dedicatedFlag": false,
                "id": 79945,
                "ipAddressId": 25132124,
                "notes": "This is for test",
                "sslActiveFlag": false,
                "sslEnabledFlag": false,
                "highAvailabilityFlag": false,
                "managedResourceFlag": false
            }
        }, {
            "allocation": 10,
            "id": 140553,
            "port": 80,
            "virtualIpAddressId": 79945,
            "serviceGroups": [{
                "id": 138193,
                "notes": "group note 2",
                "routingMethodId": 2,
                "routingTypeId": 2
            }],
            "virtualIpAddress": {
                "connectionLimit": 500,
                "connectionLimitUnits": "connections/second",
                "dedicatedFlag": false,
                "id": 79945,
                "ipAddressId": 25132124,
                "notes": "This is for test",
                "sslActiveFlag": false,
                "sslEnabledFlag": false,
                "highAvailabilityFlag": false,
                "managedResourceFlag": false
            }
        },{
            "port": 81,
            "allocation": 10,
            "serviceGroups": [{
                "notes": "group note 2",
                "routingMethodId": 2,
                "routingTypeId": 2
            }]
        }]
    }]

}

我建议您先使用下面的请求获取负载均衡器的配置,然后添加新的虚拟服务器对象并调用编辑对象方法:

GET https://api.softlayer.com/rest/v3/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/$LOADBALANCERID/getObject?objectMask=mask[virtualServers[serviceGroups]]