Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DestroyCmd = &cobra.Command{ Use: "destroy", Short: "VPSインスタンスの削除", Long: "destroy in ConoHa API(required logged in)", Run: func(cmd *cobra.Command, args []string) { try := util.Try try(conoha.Refresh()) confSpec := &spec.Config{} try(spec.Read(confSpec)) name := confSpec.Name config := &conoha.Config{} try(conoha.Read(config)) tenantId := config.Auth.TenantId tokenId := config.Token.Id servers := &[]endpoint.Server{} try(endpoint.Get(tenantId, tokenId, servers)) var id string for _, it := range *servers { if it.Metadata.Instance_name_tag == name { id = it.Id } } if id == "" { fmt.Println("not found server.") return } try(endpoint.Delete(tenantId, tokenId, id)) fmt.Println("delete succesful.") }, }
View Source
var InfoCmd = &cobra.Command{ Use: "info", Short: "APIからプランやイメージ一覧情報を取得", Long: "get Infomation from ConoHa API (require logged in).", Run: func(cmd *cobra.Command, args []string) {}, }
View Source
var InfoFlavorsCmd = &cobra.Command{ Use: "flavors", Short: "get flavors ConoHa API.", Long: "get flavors ConoHa API (require logged in).", Run: func(cmd *cobra.Command, args []string) { try := util.Try try(conoha.Refresh()) config := &conoha.Config{} try(conoha.Read(config)) tenantId := config.Auth.TenantId tokenId := config.Token.Id flavors := &[]endpoint.Flavor{} try(endpoint.Get(tenantId, tokenId, flavors)) for _, item := range *flavors { fmt.Println(item.Name) } }, }
View Source
var InfoImagesCmd = &cobra.Command{ Use: "images", Short: "get images ConoHa API.", Long: "get images ConoHa API (require logged in).", Run: func(cmd *cobra.Command, args []string) { try := util.Try try(conoha.Refresh()) config := &conoha.Config{} try(conoha.Read(config)) tokenId := config.Token.Id images := &[]endpoint.Image{} try(endpoint.Get(tokenId, images)) for _, item := range *images { fmt.Println(item.Name) } }, }
View Source
var InfoSshCmd = &cobra.Command{ Use: "ssh", Short: "get registed ssh keypair-name ConoHa API.", Long: "get registed ssh keypair-name API (require logged in).", Run: func(cmd *cobra.Command, args []string) { try := util.Try try(conoha.Refresh()) config := &conoha.Config{} try(conoha.Read(config)) keypairs := &[]endpoint.Keypair{} try(endpoint.Get(config.Auth.TenantId, config.Token.Id, keypairs)) for _, item := range *keypairs { fmt.Println(item.Name) } }, }
View Source
var LoginCmd = &cobra.Command{ Use: "login", Short: "ConoHa APIへのログイン", Long: "login to ConoHa API.", Run: func(cmd *cobra.Command, args []string) { try := util.Try config := &conoha.Config{} try(conoha.Read(config)) config.Auth = *findAuth() fmt.Printf("auth: %T, %s\n", config.Auth, config.Auth) try(conoha.Login(&config.Auth, &config.Token)) try(conoha.Write(config)) fmt.Println("login successful.") }, }
View Source
var RootCmd = &cobra.Command{ Use: "conoha", Short: "This tool is conoha cli.", Long: "This tool is a conoha cli.", Run: func(cmd *cobra.Command, args []string) {}, }
View Source
var SshCmd = &cobra.Command{ Use: "ssh", Short: "VPSインスタンスへのSSH接続", Run: func(cmd *cobra.Command, args []string) { if isMosh { sshClient.Mosh() } else if exec.Command("ssh", "-V").Run() == nil { sshClient.OpenSSH() } else { sshClient.Origin() } }, }
View Source
var SshConfigCmd = &cobra.Command{ Use: "ssh-config", Short: "SSH接続情報の表示", Long: "Show SSH config.", Run: func(cmd *cobra.Command, args []string) { try := util.Try config := &conoha.Config{} try(conoha.Read(config)) sshConf := &status.SshConfig{} try(status.Load(sshConf)) format := `Host %s HostName %s User %s IdentityFile %s` fmt.Printf(format, sshConf.Name, sshConf.HostName, sshConf.User, sshConf.IdentityFile) }, }
View Source
var SshSetCmd = &cobra.Command{ Use: "set <name> <path>", Short: "ConoHaに登録済みのSSH Keyと秘密鍵ファイルパスの紐付け", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { name := args[0] path := args[1] if !util.IsExist(path) { fmt.Println("存在しないファイルパスです。") return } try := util.Try try(conoha.SshAdd(name, path)) }, }
View Source
var SshSetCmdHelp = `` /* 266-byte string literal not displayed */
View Source
var StatusCmd = &cobra.Command{ Use: "status", Short: "VPSインスタンスの状態を調べる", Long: "status in ConoHa API(required logged in)", Run: func(cmd *cobra.Command, args []string) { try := util.Try try(conoha.Refresh()) config := &conoha.Config{} try(conoha.Read(config)) tenantId := config.Auth.TenantId tokenId := config.Token.Id confSpec := &spec.Config{} try(spec.Read(confSpec)) name := confSpec.Name server := &endpoint.Server{} try(endpoint.Show(tenantId, tokenId, name, server)) state := server.Status if state == "" { state = "NONE" } else { try(status.Save(server)) } data := [][]string{ []string{server.Metadata.Instance_name_tag, state}, } if isAll { table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Name", "State"}) table.SetBorder(false) table.AppendBulk(data) table.Render() } else { fmt.Println(state) } }, }
View Source
var UpCmd = &cobra.Command{ Use: "up", Short: "VPSインスタンスの起動", Long: "up in ConoHa API(required logged in)", Run: func(cmd *cobra.Command, args []string) { try := util.Try try(conoha.Refresh()) confSpec := &spec.Config{} try(spec.Read(confSpec)) name := confSpec.Name config := &conoha.Config{} try(conoha.Read(config)) tenantId := config.Auth.TenantId tokenId := config.Token.Id server := &servers.Server{} try(servers.Show(tenantId, tokenId, name, server)) serverName := server.Metadata.Instance_name_tag if serverName != "" { fmt.Printf("%s server is alive.\n", name) return } image := &images.Image{} try(images.Show(tokenId, confSpec.Image, image)) if image.Id == "" { fmt.Printf("image %s is not found.\n", confSpec.Image) return } flavor := &flavors.Flavor{} try(flavors.Show(tenantId, tokenId, confSpec.Flavor, flavor)) if flavor.Id == "" { fmt.Printf("flavor %s is not found.\n", confSpec.Flavor) return } try(servers.Post(tenantId, tokenId, name, image.Id, flavor.Id, confSpec.SSHKey)) fmt.Println("up successful.") }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.