Skip to content

Commit

Permalink
update to v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesClonk committed Jul 29, 2016
1 parent fc683af commit 42d4701
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $ export VULTR_API_KEY=87dFbC91rJjkL/18zJEQxS
* Run it
```sh
$ vultr version
Client version: v1.8
Client version: v1.9
Vultr API endpoint: https://api.vultr.com/
Vultr API version: v1
OS/Arch (client): linux/amd64
Expand All @@ -46,7 +46,7 @@ $ export VULTR_API_KEY=89dFbb91rGjkL/12zJEQxS
* Run it
```sh
$ vultr version
Client version: v1.8
Client version: v1.9
Vultr API endpoint: https://api.vultr.com/
Vultr API version: v1
OS/Arch (client): linux/amd64
Expand Down
12 changes: 5 additions & 7 deletions cmd/commands_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func serversChangeOS(cmd *cli.Cmd) {
func serversAttachISO(cmd *cli.Cmd) {
cmd.Spec = "SUBID -i"
id := cmd.StringArg("SUBID", "", "SUBID of virtual machine (see <servers>)")
isoID := cmd.IntOpt("i iso", 0, "ISO ID (ISOID)")
isoID := cmd.IntOpt("i iso", 0, "ISOID of ISO image")
cmd.Action = func() {
if err := GetClient().AttachISOtoServer(*id, *isoID); err != nil {
log.Fatal(err)
Expand All @@ -152,20 +152,18 @@ func serversStatusISO(cmd *cli.Cmd) {
id := cmd.StringArg("SUBID", "", "SUBID of virtual machine (see <servers>)")
cmd.Action = func() {
iso, err := GetClient().GetISOStatusofServer(*id)

if err != nil {
log.Fatal(err)
}

if iso.State == "" {
fmt.Printf("Couldn't determine ISO state of virtual machine on SUBID %v!\n", *id)
fmt.Printf("Could not determine ISO state of virtual machine with SUBID %v!\n", *id)
return
}

lengths := []int{24, 64}
tabsPrint(Columns{"Id (SUBID):", *id}, lengths)
tabsPrint(Columns{"State:", iso.State}, lengths)
tabsPrint(Columns{"Iso (ISOID):", iso.ISOID}, lengths)
lengths := []int{12, 8, 24}
tabsPrint(Columns{"SUBID", "ISOID", "STATE"}, lengths)
tabsPrint(Columns{*id, iso.ISOID, iso.State}, lengths)
tabsFlush()
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

const (
// Version of this libary
Version = "v1.8"
Version = "v1.9"

// APIVersion of Vultr
APIVersion = "v1"
Expand Down
10 changes: 5 additions & 5 deletions lib/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ type V6Network struct {
NetworkSize string `json:"v6_network_size"`
}

// ISOStatus represents an ISO image attached to a Vultr server
type ISOStatus struct {
State string `json:"state"`
ISOID string `json:"ISOID"`
State string `json:"state"`
ISOID string `json:"ISOID"`
}

// UnmarshalJSON implements json.Unmarshaller on Server.
Expand Down Expand Up @@ -343,7 +344,7 @@ func (c *Client) ChangeOSofServer(id string, osID int) error {
func (c *Client) AttachISOtoServer(id string, isoID int) error {
values := url.Values{
"SUBID": {id},
"ISOID": {fmt.Sprintf("%v", isoID)},
"ISOID": {fmt.Sprintf("%v", isoID)},
}

if err := c.post(`server/iso_attach`, values, nil); err != nil {
Expand All @@ -363,11 +364,10 @@ func (c *Client) DetachISOfromServer(id string) error {
return nil
}

func (c *Client) GetISOStatusofServer(id string)(isoStatus ISOStatus, err error) {
func (c *Client) GetISOStatusofServer(id string) (isoStatus ISOStatus, err error) {
if err := c.get(`server/iso_status?SUBID=`+id, &isoStatus); err != nil {
return ISOStatus{}, err
}

return isoStatus, nil
}

Expand Down

0 comments on commit 42d4701

Please sign in to comment.