Skip to content

Commit

Permalink
Merge pull request #22 from hvpareja/hector/make-elastic-ip-optional
Browse files Browse the repository at this point in the history
Make ElasticIP optional and expose PrivateIP when not allocated (#12 and #13)
  • Loading branch information
zzhaoy authored Aug 27, 2019
2 parents 141fbab + e80fe1c commit 7cdb19a
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit 7cdb19a

Please sign in to comment.