How to order a softlayer network gateway with ssh configured for Gateway and its member
package main
import (
"fmt"
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/services"
"github.com/softlayer/softlayer-go/session"
"github.com/softlayer/softlayer-go/sl"
"encoding/json"
)
func main() {
// SoftLayer API username and key
username := "set me"
apikey := "set me"
// Build a Container_Product_Order_Virtual_Disk_Image object containing the order
// you wish to place
order := datatypes.Container_Product_Order{
ContainerIdentifier: sl.String(d.Get("hostname").(string)),
Quantity: sl.Int(1),
Hardware: []datatypes.Hardware{
{
Hostname: sl.String(d.Get("hostname").(string)),
Domain: sl.String(d.Get("domain").(string)),
},
},
Location: sl.String(strconv.Itoa(*dc.Id)),
PackageId: pkg.Id,
Prices: []datatypes.Product_Item_Price{
server,
os,
ram,
portSpeed,
priIpAddress,
remoteManagement,
vpnManagement,
monitoring,
notification,
response,
vulnerabilityScanner,
},
}
// Set SSH Key on main order
ssh_key_ids := members[0].Get("ssh_key_ids").([]interface{})
sshKeyP := make([]int, len(ssh_key_ids))
for i, ssh_key_id := range ssh_key_ids {
sshKeyP[i] = ssh_key_id.(int)
}
order.SshKeys = make([]datatypes.Container_Product_Order_SshKeys, len(members))
order.SshKeys[0] = datatypes.Container_Product_Order_SshKeys{
SshKeyIds: sshKeyP,
}
// Create a session
sess := session.New(username, apikey)
// Get SoftLayer_Product_Order service
service := services.GetProductOrderService(sess)
// Use verifyOrder() method to check for errors. Replace this with placeOrder() when
// you are ready to order.
receipt, err := service.VerifyOrder(&templateObject)
if err != nil {
fmt.Printf("
Unable to place order:
- %s
", err)
return
}
// Following helps to print the result in json format.
jsonFormat, jsonErr := json.MarshalIndent(receipt, ""," ")
if jsonErr != nil {
fmt.Println(jsonErr)
return
}
fmt.Println(string(jsonFormat))
}
This is the script I am using to order, but it configures the ssh keys only for the gateway member but not the gateway. could you please help me on how to configure the ssh key for gateway and its member. It would be great if you could update the same script and share it.