Skip to content

Commit

Permalink
private ip option should enable network helper
Browse files Browse the repository at this point in the history
Instances provisioned on accounts with the global network helper option
disabled will not automatically configure their private ip addresses.

Enable Network Helper in the Instance Config before booting the
instance when `--linode-create-private-ip` is used.

Closes #13
  • Loading branch information
displague committed Apr 11, 2019
1 parent 81ee7c2 commit 314e29e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/drivers/linode/linode.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ func (d *Driver) Create() error {
}

client := d.getClient()
boolBooted := !d.CreatePrivateIP

// Create a linode
createOpts := linodego.InstanceCreateOptions{
Expand All @@ -399,6 +400,7 @@ func (d *Driver) Create() error {
Image: d.InstanceImage,
SwapSize: &d.SwapSize,
PrivateIP: d.CreatePrivateIP,
Booted: &boolBooted,
}

if len(d.AuthorizedUsers) > 0 {
Expand Down Expand Up @@ -453,6 +455,27 @@ func (d *Driver) Create() error {
return err
}

if d.CreatePrivateIP {
log.Debugf("Enabling Network Helper for Private IP configuration...")

configs, err := client.ListInstanceConfigs(context.TODO(), linode.ID, nil)
if err != nil {
return err
}
if len(configs) == 0 {
return fmt.Errorf("Linode Config was not found for Linode %d", linode.ID)
}
updateOpts := configs[0].GetUpdateOptions()
updateOpts.Helpers.Network = true
if _, err := client.UpdateInstanceConfig(context.TODO(), linode.ID, configs[0].ID, updateOpts); err != nil {
return err
}

if err := client.BootInstance(context.TODO(), linode.ID, configs[0].ID); err != nil {
return err
}
}

log.Info("Waiting for Machine Running...")
if _, err := client.WaitForInstanceStatus(context.TODO(), d.InstanceID, linodego.InstanceRunning, 180); err != nil {
return fmt.Errorf("wait for machine running failed: %s", err)
Expand Down

0 comments on commit 314e29e

Please sign in to comment.