// Implementation of the Cloud interface
Implementation of the Cloud interface
// Implementation of the Cloud interface
func (cloud GCECloud) CreateInstance(name string, zone string) (string, error) {
	rootDisk, err := cloud.getOrCreateRootDisk(*gceDiskName, zone)
	if err != nil {
		log.Printf("failed to create root disk: %v", err)
		return "", err
	}
	prefix := "https://www.googleapis.com/compute/v1/projects/" + cloud.projectId
	instance := &compute.Instance{
		Name:        name,
		Description: "Docker on GCE",
		MachineType: prefix + *gceInstanceType,
		Disks: []*compute.AttachedDisk{
			{
				Boot:   true,
				Type:   "PERSISTENT",
				Mode:   "READ_WRITE",
				Source: rootDisk,
			},
		},
		NetworkInterfaces: []*compute.NetworkInterface{
			{
				AccessConfigs: []*compute.AccessConfig{
					&compute.AccessConfig{Type: "ONE_TO_ONE_NAT"},
				},
				Network: prefix + "/global/networks/default",
			},
		},
	}
	log.Printf("starting instance: %q", name)
	op, err := cloud.service.Instances.Insert(cloud.projectId, zone, instance).Do()
	if err != nil {
		log.Printf("instance insert api call failed: %v", err)
		return "", err
	}
	err = cloud.waitForOp(op, zone)
	if err != nil {
		log.Printf("instance insert operation failed: %v", err)
		return "", err
	}
	time.Sleep(60 * time.Second)
	log.Printf("instance started: %q", instance.NetworkInterfaces[0].AccessConfigs[0].NatIP)
	return instance.NetworkInterfaces[0].AccessConfigs[0].NatIP, err
}
func ( cloud GCECloud ) CreateInstance ( name string , zone string ) ( string , error ) { rootDisk , err := cloud . getOrCreateRootDisk ( * gceDiskName , zone ) if err != nil { log . Printf ( " " , err ) return " " , err } prefix := " " + cloud . projectId instance := & compute . Instance { Name : name , Description : " " , MachineType : prefix + * gceInstanceType , Disks : [ ] * compute . AttachedDisk { { Boot : true , Type : " " , Mode : " " , Source : rootDisk , } , } , NetworkInterfaces : [ ] * compute . NetworkInterface { { AccessConfigs : [ ] * compute . AccessConfig { & compute . AccessConfig { Type : " " } , } , Network : prefix + " " , } , } , } log . Printf ( " " , name ) op , err := cloud . service . Instances . Insert ( cloud . projectId , zone , instance ) . Do ( ) if err != nil { log . Printf ( " " , err ) return " " , err } err = cloud . waitForOp ( op , zone ) if err != nil { log . Printf ( " " , err ) return " " , err } time . Sleep ( 60 * time . Second ) log . Printf ( " " , instance . NetworkInterfaces [ 0 ] . AccessConfigs [ 0 ] . NatIP ) return instance . NetworkInterfaces [ 0 ] . AccessConfigs [ 0 ] . NatIP , err }
Implementation of the Cloud interface
Implementation of the Cloud interface
// Wait for docker to come up // TODO(bburns) : Use metadata instead to signal that docker is up and read.