func (d *DockerMachine) RegisterMachine(opts RegisterMachineOpts) (*Machine, error) {
	if !d.temp {
		return nil, errors.New("register is only available without user defined StorePath")
	}
	if opts.Base.CustomData == nil {
		return nil, errors.New("custom data is required")
	}
	opts.Base.CustomData["SSHKeyPath"] = filepath.Join(d.client.GetMachinesDir(), opts.Base.Id, "id_rsa")
	rawDriver, err := json.Marshal(opts.Base.CustomData)
	if err != nil {
		return nil, errors.WithMessage(err, "failed to marshal driver data")
	}
	h, err := d.client.NewHost(opts.DriverName, rawDriver)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.Driver.GetSSHKeyPath(), opts.SSHPrivateKey, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.AuthOptions().CaCertPath, opts.Base.CaCert, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.AuthOptions().ClientCertPath, opts.Base.ClientCert, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.AuthOptions().ClientKeyPath, opts.Base.ClientKey, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = d.client.Save(h)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	savedHost, err := d.client.Load(h.Name)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	return &Machine{
		Base: opts.Base,
		Host: savedHost,
	}, nil
}
func (d *DockerMachine) RegisterMachine(opts RegisterMachineOpts) (*Machine, error) {
	if !d.temp {
		return nil, errors.New("register is only available without user defined StorePath")
	}
	if opts.Base.CustomData == nil {
		return nil, errors.New("custom data is required")
	}
	opts.Base.CustomData["SSHKeyPath"] = filepath.Join(d.client.GetMachinesDir(), opts.Base.Id, "id_rsa")
	rawDriver, err := json.Marshal(opts.Base.CustomData)
	if err != nil {
		return nil, errors.WithMessage(err, "failed to marshal driver data")
	}
	h, err := d.client.NewHost(opts.DriverName, rawDriver)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.Driver.GetSSHKeyPath(), opts.SSHPrivateKey, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.AuthOptions().CaCertPath, opts.Base.CaCert, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.AuthOptions().ClientCertPath, opts.Base.ClientCert, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(h.AuthOptions().ClientKeyPath, opts.Base.ClientKey, 0700)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = d.client.Save(h)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	savedHost, err := d.client.Load(h.Name)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	return &Machine{
		Base: opts.Base,
		Host: savedHost,
	}, nil
}
func ( d * DockerMachine ) RegisterMachine ( opts RegisterMachineOpts ) ( * Machine , error ) { if ! d . temp { return nil , errors . New ( " " ) } if opts . Base . CustomData == nil { return nil , errors . New ( " " ) } opts . Base . CustomData [ " " ] = filepath . Join ( d . client . GetMachinesDir ( ) , opts . Base . Id , " " ) rawDriver , err := json . Marshal ( opts . Base . CustomData ) if err != nil { return nil , errors . WithMessage ( err , " " ) } h , err := d . client . NewHost ( opts . DriverName , rawDriver ) if err != nil { return nil , errors . WithStack ( err ) } err = ioutil . WriteFile ( h . Driver . GetSSHKeyPath ( ) , opts . SSHPrivateKey , 0700 ) if err != nil { return nil , errors . WithStack ( err ) } err = ioutil . WriteFile ( h . AuthOptions ( ) . CaCertPath , opts . Base . CaCert , 0700 ) if err != nil { return nil , errors . WithStack ( err ) } err = ioutil . WriteFile ( h . AuthOptions ( ) . ClientCertPath , opts . Base . ClientCert , 0700 ) if err != nil { return nil , errors . WithStack ( err ) } err = ioutil . WriteFile ( h . AuthOptions ( ) . ClientKeyPath , opts . Base . ClientKey , 0700 ) if err != nil { return nil , errors . WithStack ( err ) } err = d . client . Save ( h ) if err != nil { return nil , errors . WithStack ( err ) } savedHost , err := d . client . Load ( h . Name ) if err != nil { return nil , errors . WithStack ( err ) } return & Machine { Base : opts . Base , Host : savedHost , } , nil }
// RegisterMachine registers an iaas.Machine as an Machine and a host on
// the current running DockerMachine. It expects all data needed to Marshal
// the host/driver to be available on CustomData.
RegisterMachine registers an iaas . Machine as an Machine and a host on the current running DockerMachine . It expects all data needed to Marshal the host / driver to be available on CustomData .