diff --git a/drivers/openstack/openstack.go b/drivers/openstack/openstack.go index bdc217a234..49e502f8fa 100644 --- a/drivers/openstack/openstack.go +++ b/drivers/openstack/openstack.go @@ -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{ - "storePath": storePath, + "machineName": machineName, + "storePath": storePath, }).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{ - storePath: storePath, - client: client, + MachineName: machineName, + storePath: storePath, + client: client, }, nil } @@ -301,8 +303,7 @@ func (d *Driver) GetState() (state.State, error) { } func (d *Driver) Create() error { - d.setMachineNameIfNotSet() - d.KeyPairName = d.MachineName + d.KeyPairName = fmt.Sprintf("%s-%s", d.MachineName, utils.GenerateRandomID()) if err := d.resolveIds(); err != nil { return err @@ -745,9 +746,3 @@ func (d *Driver) sshKeyPath() string { func (d *Driver) publicSSHKeyPath() string { return d.sshKeyPath() + ".pub" } - -func (d *Driver) setMachineNameIfNotSet() { - if d.MachineName == "" { - d.MachineName = fmt.Sprintf("docker-host-%s", utils.GenerateRandomID()) - } -} diff --git a/drivers/rackspace/rackspace.go b/drivers/rackspace/rackspace.go index 73bc51768c..0365e47cb7 100644 --- a/drivers/rackspace/rackspace.go +++ b/drivers/rackspace/rackspace.go @@ -93,13 +93,14 @@ func GetCreateFlags() []cli.Flag { } // 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{ - "storePath": storePath, + "machineName": machineName, + "storePath": storePath, }).Debug("Instantiating Rackspace driver.") client := &Client{} - inner, err := openstack.NewDerivedDriver(storePath, client) + inner, err := openstack.NewDerivedDriver(machineName, storePath, client) if err != nil { return nil, err }