gpt4 book ai didi

go - 如何订购为网关及其成员配置 ssh 的软层网络网关

转载 作者:数据小太阳 更新时间:2023-10-29 03:23:12 24 4
gpt4 key购买 nike

如何订购为网关及其成员配置ssh的软层网络网关

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("\n Unable to place order:\n - %s\n", 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))
}

这是我用来订购的脚本,但它只为网关成员而不是网关配置 ssh key 。您能帮我了解如何为网关及其成员配置 ssh key 吗?如果您可以更新相同的脚本并共享它,那就太好了。

最佳答案

SoftLayer Network Gateway 是一个由一个成员(独立)或 2 个成员(高可用性)组成的对象。当您通过 ssh 访问网关时,它实际上与网关成员之一建立了 ssh session 。所以只能为网关成员配置ssh key,不能为网关本身配置。

关于go - 如何订购为网关及其成员配置 ssh 的软层网络网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49503461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com