dongxiao0449 2018-03-27 02:26
浏览 82

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

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.

  • 写回答

1条回答 默认 最新

  • dongmeijian1716 2018-04-12 22:19
    关注

    SoftLayer Network Gateway is an object which consists of either one member (standalone) or 2 members (High Availability). When you accessing a gateway via ssh, it actually establishes ssh session with one of gateway member. So you can only configure ssh key for gateway members, not gateway itself.

    评论

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试