Skip to content

Commit

Permalink
Handle special IPs names in run command / Help documentation lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ElNounch committed Feb 23, 2016
1 parent 980ce03 commit 51c1f93
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/cmd_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
cmdCreate.Flag.StringVar(&createBootscript, []string{"-bootscript"}, "", "Assign a bootscript")
cmdCreate.Flag.StringVar(&createEnv, []string{"e", "-env"}, "", "Provide metadata tags passed to initrd (i.e., boot=resue INITRD_DEBUG=1)")
cmdCreate.Flag.StringVar(&createVolume, []string{"v", "-volume"}, "", "Attach additional volume (i.e., 50G)")
cmdCreate.Flag.StringVar(&createIPAddress, []string{"-ip-address"}, "", "Assign an IP")
cmdCreate.Flag.StringVar(&createIPAddress, []string{"-ip-address"}, "dynamic", "Assign a reserved public IP, a 'dynamic' one or 'none'")
cmdCreate.Flag.BoolVar(&createHelp, []string{"h", "-help"}, false, "Print usage")
cmdCreate.Flag.BoolVar(&createTmpSSHKey, []string{"-tmp-ssh-key"}, false, "Access your server without uploading your SSH key to your account")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func init() {
cmdRun.Flag.StringVar(&runCreateVolume, []string{"v", "-volume"}, "", "Attach additional volume (i.e., 50G)")
cmdRun.Flag.BoolVar(&runHelpFlag, []string{"h", "-help"}, false, "Print usage")
cmdRun.Flag.Int64Var(&runTimeout, []string{"T", "-timeout"}, 0, "Set timeout value to seconds")
cmdRun.Flag.StringVar(&runIPAddress, []string{"-ip-address"}, "", "Assign an IP")
cmdRun.Flag.StringVar(&runIPAddress, []string{"-ip-address"}, "", "Assign a reserved public IP, a 'dynamic' one or 'none' (default to 'none' if gateway specified, 'dynamic' otherwise)")
cmdRun.Flag.BoolVar(&runAttachFlag, []string{"a", "-attach"}, false, "Attach to serial console")
cmdRun.Flag.BoolVar(&runDetachFlag, []string{"d", "-detach"}, false, "Run server in background and print server ID")
cmdRun.Flag.StringVar(&runGateway, []string{"g", "-gateway"}, "", "Use a SSH gateway")
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func RunCreate(ctx CommandContext, args CreateArgs) error {
DynamicIPRequired: false,
IP: args.IP,
}
if args.IP == "" || args.IP == "dynamic" {
if args.IP == "dynamic" || args.IP == "" {
config.DynamicIPRequired = true
config.IP = ""
} else if args.IP == "none" || args.IP == "no" {
Expand Down
13 changes: 10 additions & 3 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,22 @@ func Run(ctx CommandContext, args RunArgs) error {

// create IMAGE
logrus.Info("Server creation ...")
serverID, err := api.CreateServer(ctx.API, &api.ConfigCreateServer{
config := api.ConfigCreateServer{
ImageName: args.Image,
Name: args.Name,
Bootscript: args.Bootscript,
Env: env,
AdditionalVolumes: volume,
DynamicIPRequired: args.Gateway == "",
DynamicIPRequired: false,
IP: args.IP,
})
}
if args.IP == "dynamic" || (args.IP == "" && args.Gateway == "") {
config.DynamicIPRequired = true
config.IP = ""
} else if args.IP == "none" || args.IP == "no" || (args.IP == "" && args.Gateway != "") {
config.IP = ""
}
serverID, err := api.CreateServer(ctx.API, &config)
if err != nil {
return fmt.Errorf("failed to create server: %v", err)
}
Expand Down

0 comments on commit 51c1f93

Please sign in to comment.