Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ElasticIP optional and expose PrivateIP when not allocated (#12 and #13) #22

Merged
merged 6 commits into from
Aug 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions otc/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type Driver struct {
JobId string

//network
ElasticIpBool int
ElasticIPId string
ElasticIP string
SecurityGroupName string
Expand Down Expand Up @@ -197,6 +198,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Value: "",
EnvVar: "SSH_USER",
},
mcnflag.IntFlag{
Name: "otc-elastic-ip",
Usage: "Set it to 1 to allocate ElasticIP",
Value: 0,
EnvVar: "ELASTIC_IP",
},
}
}

Expand All @@ -219,6 +226,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.BandwidthType = flags.String("otc-bandwidth-type")
d.ElasticIpType = flags.String("otc-elasticip-type")
d.SSHUser = flags.String("otc-ssh-user")
d.ElasticIpBool = flags.Int("otc-elastic-ip")
//fmt.Printf("test for region: %s\n", d.Region)
return d.checkConfig()
}
Expand Down Expand Up @@ -633,6 +641,13 @@ func (d *Driver) checkJobStatus(jobid string) error {
}

func (d *Driver) configureNetwork() error {

// Exit if ElasticIp is set to false
if d.ElasticIpBool == 0 {
log.Infof("%s | An ElasticIp won't be allocated", d.MachineName)
return nil
}

log.Debugf("%s | Allocate elastic ip ...", d.MachineName)

elasticIpCreate := &vpcModules.PublicipCreate{}
Expand Down