Skip to content

Commit 5138963

Browse files
authored
Merge pull request #14 from displague/fix/privateIP-NetworkHelper
private ip option should enable network helper
2 parents 81ee7c2 + 314e29e commit 5138963

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pkg/drivers/linode/linode.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ func (d *Driver) Create() error {
388388
}
389389

390390
client := d.getClient()
391+
boolBooted := !d.CreatePrivateIP
391392

392393
// Create a linode
393394
createOpts := linodego.InstanceCreateOptions{
@@ -399,6 +400,7 @@ func (d *Driver) Create() error {
399400
Image: d.InstanceImage,
400401
SwapSize: &d.SwapSize,
401402
PrivateIP: d.CreatePrivateIP,
403+
Booted: &boolBooted,
402404
}
403405

404406
if len(d.AuthorizedUsers) > 0 {
@@ -453,6 +455,27 @@ func (d *Driver) Create() error {
453455
return err
454456
}
455457

458+
if d.CreatePrivateIP {
459+
log.Debugf("Enabling Network Helper for Private IP configuration...")
460+
461+
configs, err := client.ListInstanceConfigs(context.TODO(), linode.ID, nil)
462+
if err != nil {
463+
return err
464+
}
465+
if len(configs) == 0 {
466+
return fmt.Errorf("Linode Config was not found for Linode %d", linode.ID)
467+
}
468+
updateOpts := configs[0].GetUpdateOptions()
469+
updateOpts.Helpers.Network = true
470+
if _, err := client.UpdateInstanceConfig(context.TODO(), linode.ID, configs[0].ID, updateOpts); err != nil {
471+
return err
472+
}
473+
474+
if err := client.BootInstance(context.TODO(), linode.ID, configs[0].ID); err != nil {
475+
return err
476+
}
477+
}
478+
456479
log.Info("Waiting for Machine Running...")
457480
if _, err := client.WaitForInstanceStatus(context.TODO(), d.InstanceID, linodego.InstanceRunning, 180); err != nil {
458481
return fmt.Errorf("wait for machine running failed: %s", err)

0 commit comments

Comments
 (0)