softlayer-go icon indicating copy to clipboard operation
softlayer-go copied to clipboard

Softlayer network gateway order

Open Praveengostu opened this issue 7 years ago • 3 comments

As part of network gateway order we need to send two orders which has a different container each other.To order the network gateway with configured sshkeys for gateway and its members we need to create a payload as below

{  
   "parameters":[  
      {  
         "orderContainers":[  
            {  
               "complexType":"SoftLayer_Container_Product_Order_Hardware_Server_Gateway_Appliance",
               "hardware":[  
                  {  
                     "hostname":"hostHA1test",
                     "userData":[  
                        {  
                           "value":"hardware member 1 "
                        }
                     ]
                  },
                  {  
                     "hostname":"hostHA2test",
                     "domain":"domain.com",
                     "userData":[  
                        {  
                           "value":"hardware member 2 "
                        }
                     ]
                  }
               ],
               "location":"LONDON02",
               "packageId":236,
               "quantity":2,
               "prices":[  
                  {  
                     "id":177619
                  },
                  {  
                     "id":72927
                  },
                  {  
                     "id":420
                  },
                  {  
                     "id":418
                  },
                  {  
                     "id":21
                  },
                  {  
                     "id":57
                  },
                  {  
                     "id":906
                  },
                  {  
                     "id":201189
                  },
                  {  
                     "id":876
                  },
                  {  
                     "id":14031
                  },
                  {  
                     "id":342
                  },
                  {  
                     "id":273
                  },
                  {  
                     "id":792
                  },
                  {  
                     "id":55
                  },
                  {  
                     "id":58
                  }
               ],
               "sshKeys":[  
                  {  
                     "sshKeyIds":[  
                        94228
                     ]
                  },
                  {  
                     "sshKeyIds":[  
                        94228,
                        94206,
                        63668
                     ]
                  }
               ],
               "clusterIdentifier":"praveenCluster"
            },
            {  
               "complexType":"SoftLayer_Container_Product_Order_Gateway_Appliance_Cluster",
               "packageId":196,
               "quantity":1,
               "prices":[  
                  {  
                     "id":37110
                  }
               ],
               "clusterIdentifier":"praveenCluster",
               "sshKeys":[  
                  {  
                     "sshKeyIds":[  
                        94228,
                        94206,
                        63668,
                        76146,
                        38390
                     ]
                  }
               ]
            }
         ]
      }
   ]
}

With the existing softlayer go client we tried

orderTemplate:= datatypes.Container_Product_Order{}
       OrderContainers: []datatypes.Container_Product_Order{
              {   ComplexType: sl.String("SoftLayer_Container_Product_Order_Hardware_Server_Gateway_Appliance"),
                     Quantity: sl.Int(quantity),
                     PackageId: sl.Int(packageId),
                     Prices: prices,
                     Hardware: hardware,
                     Location:  sl.String(location),
                     ClusterIdentifier:=datatypes.Container_Product_Order_Virtual_Guest{
                           sl.String("test")
              }
              },
              {
                     ComplexType: sl.String("SoftLayer_Container_Product_Order_Gateway_Appliance_Cluster"),
                     Quantity: sl.Int(1),
                     PackageId: sl.Int(196),
                     Prices: []datatypes.Product_Item_Price{
                           {Id: sl.Int(37110)},
                     },
                     ClusterIdentifier:=datatypes.Container_Product_Order_Virtual_Guest{
                     sl.String("test")
              },
              },
       },
}

here you can see that each order has an specific container (See the ComplexType attribute), however the code has an error, the “ClusterIdentifier” attribute is not recognized, because this attribute does not exists into the datatype “Container_Product_Order” and we cannot change it either :(.

Another way we tried is this:

orderTemplate2 := datatypes.Container_Product_Order_Gateway_Appliance_Cluster{}
orderTemplate2.ClusterIdentifier = sl.String("test")
orderTemplate2.Quantity = sl.Int(quantity)
orderTemplate2.PackageId = sl.Int(196)
orderTemplate2.Prices = pricesCluster

orderTemplate1:= datatypes.Container_Product_Order_Hardware_Server_Gateway_Appliance{}
orderTemplate1.PackageId = sl.Int(packageId)
orderTemplate1.Location = sl.String(location)
orderTemplate1.Prices = prices
orderTemplate1.Quantity = sl.Int(quantity)
orderTemplate1.Hardware = hardware
orderTemplate1.ClusterIdentifier = sl.String("test")



var orderData1 [2]datatypes.Container_Product_Order
orderData1 = append(orderData1, orderTemplate1)
fmt.Println(orderData1))

We created each order and then we tried to put them together in an “Container_Product_Order” Array, but this code did not work, because GO does not allow appending different objects from “Container_Product_Order” datatype.

Could you please help us the correct way of doing this

Praveengostu avatar Mar 27 '18 19:03 Praveengostu

@Praveengostu Hi. Take a look at tools/loadmeta.go to see how we can move/add the ClusterIdentifier field up to the Container_Product_Order as they are being read from the api metadata endpoint.

renier avatar Mar 28 '18 00:03 renier

@renier I was checking the softlayer datatype https://softlayer.github.io/reference/datatypes/SoftLayer_Container_Product_Order/ and I see there is no clusterIdentifier on it. So I think we can add this. API team Says I have to create the payload as stated above. But with the current softlayer-go could not understand how to create the same

Praveengostu avatar Mar 28 '18 10:03 Praveengostu

@renier Is there any fix or work around for this issue?. I am also facing that same issue and not able to order the VSRX gateway using orderContainers. It throws error that SoftLayer_Exception_Public: No cluster identifier set. (HTTP 500)"

srimuvva avatar Dec 13 '18 04:12 srimuvva