Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RegisterSelfCommand = cli.Command{ Name: "register-self", Usage: "register-self [options]", Description: "Registers virtual instance that calls this script to iCE.", Flags: []cli.Flag{ cli.StringFlag{ Name: "api-endpoint", Usage: "The iCE REST API endpoint URL", }, cli.StringFlag{ Name: "session-id", Usage: "The session id", }, }, Action: func(ctx *cli.Context) error { apiEndpoint := ctx.String("api-endpoint") sessionID := ctx.String("session-id") inst := ice.Instance{ SessionID: sessionID, } // SSH var err error inst.SSHUsername, err = ssh.Username(context.TODO()) if err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } inst.SSHAuthorizedFingerprint, err = ssh.AuthorizedFingerprint( context.TODO(), inst.SSHUsername, ) if err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } iceClient := ice.NewClient(apiEndpoint) inst.Networks, err = network.Networks(context.TODO()) if err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } inst.PublicIPAddr, err = iceClient.MyIP(context.TODO()) if err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } inst.PublicReverseDNS, err = network.ReverseDNS( context.TODO(), inst.PublicIPAddr.String(), ) if err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } instID, err := iceClient.StoreInstance(context.TODO(), inst) if err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } if err := state.WriteInstanceID(context.TODO(), instID); err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } inst.ID = instID if err := json.NewEncoder(os.Stdout).Encode(inst); err != nil { return cli.NewExitError(fmt.Sprintf("ERROR: %s", err), 1) } return nil }, }
RegisterSelfCommand implements the register-self subcommand of the agent.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.