Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

Commit

Permalink
v. 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vahaah committed Aug 11, 2016
1 parent 46f8055 commit 01a5ec8
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 48 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-machine-driver-vscale
*.log
.idea/
.idea/
devel/
Godeps/_workspace/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.0 (2016-08-11)

Official Go api

## 1.0.3 (2016-07-18)

Fixed ssh
Expand Down
49 changes: 41 additions & 8 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
This is a plugin for [Docker Machine](https://docs.docker.com/machine/) allowing
to create Docker hosts on [Vscale]( http://vscale.io ) cloud services.

This is refactored version of [github.com/evrone/docker-machine-vscale](https://github.com/evrone/docker-machine-vscale)

## Installation

To install this plugin manually, download the binary `docker-machine-driver-vscale`
and make it available by `$PATH`, for example by putting it to `/usr/local/bin/`:

```console
$ curl -L https://github.com/vahaah/docker-machine-driver-vscale/releases/download/1.0.3/docker-machine-driver-vscale > /usr/local/bin/docker-machine-driver-vscale
$ curl -L https://github.com/vahaah/docker-machine-driver-vscale/releases/download/1.1.0/docker-machine-driver-vscale > /usr/local/bin/docker-machine-driver-vscale

$ chmod +x /usr/local/bin/docker-machine-driver-vscale
```
Expand All @@ -22,7 +20,7 @@ the ["Releases"](https://github.com/vahaah/docker-machine-driver-vscale/releases
For Ubuntu 16.04:

```console
$ sudo curl -L https://github.com/vahaah/docker-machine-driver-vscale/releases/download/1.0.3/docker-machine-driver-vscale.ubuntu.16.04.x64 > /usr/local/bin/docker-machine-driver-vscale
$ sudo curl -L https://github.com/vahaah/docker-machine-driver-vscale/releases/download/1.1.0/docker-machine-driver-vscale.ubuntu.16.04.x64 > /usr/local/bin/docker-machine-driver-vscale

$ sudo chmod +x /usr/local/bin/docker-machine-driver-vscale
```
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "fmt"
var GitCommit string

// Version number that is being run at the moment.
const Version = "1.0.3"
const Version = "1.1.0"

// FullVersion formats the version to be printed.
func FullVersion() string {
Expand Down
52 changes: 18 additions & 34 deletions vscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import (
"github.com/docker/machine/libmachine/mcnflag"
"github.com/docker/machine/libmachine/state"
"github.com/docker/machine/libmachine/ssh"
api "github.com/evrone/vscale_api"
api "github.com/vscale/go-vscale"
)

type Driver struct {
*drivers.BaseDriver
AccessToken string
ScaletID int
ScaletID int64
ScaletName string
Rplan string
MadeFrom string
Location string
SSHKeyID int
SSHKeyID int64
SwapFile int
}

Expand Down Expand Up @@ -103,12 +103,7 @@ func (d *Driver) createSSHKey() (*api.SSHKey, error) {
return nil, err
}

createRequest := &api.SSHKeyCreateRequest{
Name: d.MachineName,
Key: string(publicKey),
}

key, _, err := d.getClient().SSHKey.Create(createRequest)
key, _, err := d.getClient().SSHKey.Create(string(publicKey), d.MachineName)
return key, err
}

Expand All @@ -131,8 +126,8 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return nil
}

func (d *Driver) getClient() *api.Client {
return api.New(d.AccessToken)
func (d *Driver) getClient() *api.WebClient {
return api.NewClient(d.AccessToken)
}

func (d *Driver) PreCreateCheck() error {
Expand All @@ -155,16 +150,8 @@ func (d *Driver) Create() error {
log.Infof("Creating Vscale scalet...")

client := d.getClient()
createRequest := &api.ScaletCreateRequest{
MakeFrom: d.MadeFrom,
Rplan: d.Rplan,
DoStart: true,
Name: d.MachineName,
Keys: []int{d.SSHKeyID},
Location: d.Location,
}
newScalet, _, err := client.Scalet.CreateWithoutPassword(d.MadeFrom, d.Rplan, d.MachineName, d.Location, true, []int64{d.SSHKeyID}, true)

newScalet, _, err := client.Scalet.Create(createRequest)
if err != nil {
return err
}
Expand All @@ -174,13 +161,13 @@ func (d *Driver) Create() error {
log.Info("Waiting for IP address to be assigned to the Scalet...")

for {
newScalet, _, err = client.Scalet.GetByID(d.ScaletID)
newScalet, _, err = client.Scalet.Get(d.ScaletID)
if err != nil {
return err
}

if newScalet.PublicAddress != nil {
d.IPAddress = newScalet.PublicAddress.Address
if newScalet.Active == true {
d.IPAddress = newScalet.PublicAddresses.Address
}

if d.IPAddress != "" {
Expand All @@ -190,7 +177,7 @@ func (d *Driver) Create() error {
time.Sleep(1 * time.Second)
}

log.Info(fmt.Sprintf("Creating scalet with ID: %v, IPAddress: %v", d.ScaletID, d.IPAddress))
log.Info(fmt.Sprintf("Scalet created! ID: %v, IPAddress: %v", d.ScaletID, d.IPAddress))
if d.SwapFile > 0 {
for {
ssh := drivers.WaitForSSH(d)
Expand Down Expand Up @@ -226,7 +213,7 @@ func (d *Driver) GetURL() (string, error) {
}

func (d *Driver) GetState() (state.State, error) {
scalet, _, err := d.getClient().Scalet.GetByID(d.ScaletID)
scalet, _, err := d.getClient().Scalet.Get(d.ScaletID)
if err != nil {
return state.Error, err
}
Expand All @@ -243,36 +230,33 @@ func (d *Driver) GetState() (state.State, error) {
}

func (d *Driver) Start() error {
_, _, err := d.getClient().Scalet.Start(d.ScaletID)
_, _, err := d.getClient().Scalet.Start(d.ScaletID, true)
return err
}

func (d *Driver) Stop() error {
_, _, err := d.getClient().Scalet.Halt(d.ScaletID)
_, _, err := d.getClient().Scalet.Stop(d.ScaletID, true)
return err
}

func (d *Driver) Remove() error {
client := d.getClient()
_, _, err := client.Scalet.Delete(d.ScaletID)
_, _, err := client.Scalet.Remove(d.ScaletID, true)
if err != nil {
return err
}

_, err = client.SSHKey.Delete(d.SSHKeyID)
if err != nil {
return err
}
_, _ , _ = client.SSHKey.Remove(d.SSHKeyID)

return nil
}

func (d *Driver) Restart() error {
_, _, err := d.getClient().Scalet.Restart(d.ScaletID)
_, _, err := d.getClient().Scalet.Restart(d.ScaletID, true)
return err
}

func (d *Driver) Kill() error {
_, _, err := d.getClient().Scalet.Halt(d.ScaletID)
_, _, err := d.getClient().Scalet.Remove(d.ScaletID, true)
return err
}

0 comments on commit 01a5ec8

Please sign in to comment.