Merge pull request #2351 from dgageot/improve-google

Improve google driver
This commit is contained in:
David Gageot 2015-11-19 12:35:21 +01:00
commit 33c71d6a8f
2 changed files with 13 additions and 4 deletions

View File

@ -53,7 +53,7 @@ $ docker-machine create --driver google \
- `--google-tags`: Instance tags (comma-separated). - `--google-tags`: Instance tags (comma-separated).
- `--google-use-internal-ip`: When this option is used during create it will make docker-machine use internal rather than public NATed IPs. The flag is persistent in the sense that a machine created with it retains the IP. It's useful for managing docker machines from another machine on the same network e.g. while deploying swarm. - `--google-use-internal-ip`: When this option is used during create it will make docker-machine use internal rather than public NATed IPs. The flag is persistent in the sense that a machine created with it retains the IP. It's useful for managing docker machines from another machine on the same network e.g. while deploying swarm.
The GCE driver will use the `ubuntu-1404-trusty-v20150909a` instance image unless otherwise specified. To obtain a The GCE driver will use the `ubuntu-1404-trusty-v20151113` instance image unless otherwise specified. To obtain a
list of image URLs run: list of image URLs run:
``` ```
gcloud compute images list --uri gcloud compute images list --uri
@ -66,7 +66,7 @@ Environment variables and default values:
| **`--google-project`** | `GOOGLE_PROJECT` | - | | **`--google-project`** | `GOOGLE_PROJECT` | - |
| `--google-zone` | `GOOGLE_ZONE` | `us-central1-a` | | `--google-zone` | `GOOGLE_ZONE` | `us-central1-a` |
| `--google-machine-type` | `GOOGLE_MACHINE_TYPE` | `f1-standard-1` | | `--google-machine-type` | `GOOGLE_MACHINE_TYPE` | `f1-standard-1` |
| `--google-machine-image` | `GOOGLE_MACHINE_IMAGE` | `ubuntu-1404-trusty-v20150909a` | | `--google-machine-image` | `GOOGLE_MACHINE_IMAGE` | `ubuntu-1404-trusty-v20151113` |
| `--google-username` | `GOOGLE_USERNAME` | `docker-user` | | `--google-username` | `GOOGLE_USERNAME` | `docker-user` |
| `--google-scopes` | `GOOGLE_SCOPES` | `devstorage.read_only,logging.write` | | `--google-scopes` | `GOOGLE_SCOPES` | `devstorage.read_only,logging.write` |
| `--google-disk-size` | `GOOGLE_DISK_SIZE` | `10` | | `--google-disk-size` | `GOOGLE_DISK_SIZE` | `10` |

View File

@ -32,7 +32,7 @@ const (
defaultZone = "us-central1-a" defaultZone = "us-central1-a"
defaultUser = "docker-user" defaultUser = "docker-user"
defaultMachineType = "n1-standard-1" defaultMachineType = "n1-standard-1"
defaultImageName = "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1404-trusty-v20150909a" defaultImageName = "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1404-trusty-v20151113"
defaultScopes = "https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write" defaultScopes = "https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write"
defaultDiskType = "pd-standard" defaultDiskType = "pd-standard"
defaultDiskSize = 10 defaultDiskSize = 10
@ -181,7 +181,7 @@ func (d *Driver) PreCreateCheck() error {
return err return err
} }
// Check that the project exists. It will also check that credentials // Check that the project exists. It will also check the credentials
// at the same time. // at the same time.
log.Infof("Check that the project exists") log.Infof("Check that the project exists")
@ -229,10 +229,19 @@ func (d *Driver) GetURL() (string, error) {
// GetIP returns the IP address of the GCE instance. // GetIP returns the IP address of the GCE instance.
func (d *Driver) GetIP() (string, error) { func (d *Driver) GetIP() (string, error) {
machineState, err := d.GetState()
if err != nil {
return "", err
}
if machineState != state.Running {
return "", drivers.ErrHostIsNotRunning
}
c, err := newComputeUtil(d) c, err := newComputeUtil(d)
if err != nil { if err != nil {
return "", err return "", err
} }
return c.ip() return c.ip()
} }