mirror of https://github.com/docker/docs.git
Set machine hostname
Signed-off-by: Guillaume Giamarchi <guillaume.giamarchi@gmail.com>
This commit is contained in:
parent
e44b840e3a
commit
9d91f458f5
|
@ -176,18 +176,20 @@ func GetCreateFlags() []cli.Flag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDriver(storePath string) (drivers.Driver, error) {
|
func NewDriver(machineName string, storePath string) (drivers.Driver, error) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"storePath": storePath,
|
"machineName": machineName,
|
||||||
|
"storePath": storePath,
|
||||||
}).Debug("Instantiating OpenStack driver...")
|
}).Debug("Instantiating OpenStack driver...")
|
||||||
|
|
||||||
return NewDerivedDriver(storePath, &GenericClient{})
|
return NewDerivedDriver(machineName, storePath, &GenericClient{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDerivedDriver(storePath string, client Client) (*Driver, error) {
|
func NewDerivedDriver(machineName string, storePath string, client Client) (*Driver, error) {
|
||||||
return &Driver{
|
return &Driver{
|
||||||
storePath: storePath,
|
MachineName: machineName,
|
||||||
client: client,
|
storePath: storePath,
|
||||||
|
client: client,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,8 +303,7 @@ func (d *Driver) GetState() (state.State, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Create() error {
|
func (d *Driver) Create() error {
|
||||||
d.setMachineNameIfNotSet()
|
d.KeyPairName = fmt.Sprintf("%s-%s", d.MachineName, utils.GenerateRandomID())
|
||||||
d.KeyPairName = d.MachineName
|
|
||||||
|
|
||||||
if err := d.resolveIds(); err != nil {
|
if err := d.resolveIds(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -745,9 +746,3 @@ func (d *Driver) sshKeyPath() string {
|
||||||
func (d *Driver) publicSSHKeyPath() string {
|
func (d *Driver) publicSSHKeyPath() string {
|
||||||
return d.sshKeyPath() + ".pub"
|
return d.sshKeyPath() + ".pub"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) setMachineNameIfNotSet() {
|
|
||||||
if d.MachineName == "" {
|
|
||||||
d.MachineName = fmt.Sprintf("docker-host-%s", utils.GenerateRandomID())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -93,13 +93,14 @@ func GetCreateFlags() []cli.Flag {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDriver instantiates a Rackspace driver.
|
// NewDriver instantiates a Rackspace driver.
|
||||||
func NewDriver(storePath string) (drivers.Driver, error) {
|
func NewDriver(machineName string, storePath string) (drivers.Driver, error) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"storePath": storePath,
|
"machineName": machineName,
|
||||||
|
"storePath": storePath,
|
||||||
}).Debug("Instantiating Rackspace driver.")
|
}).Debug("Instantiating Rackspace driver.")
|
||||||
|
|
||||||
client := &Client{}
|
client := &Client{}
|
||||||
inner, err := openstack.NewDerivedDriver(storePath, client)
|
inner, err := openstack.NewDerivedDriver(machineName, storePath, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue