Skip to content

Enable creation of public IP-less servers via special IP address names #283

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

Merged
merged 2 commits into from
Feb 25, 2016
Merged
Show file tree
Hide file tree
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
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
13 changes: 10 additions & 3 deletions pkg/commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ func RunCreate(ctx CommandContext, args CreateArgs) error {

env := strings.Join(args.Tags, " ")
volume := strings.Join(args.Volumes, " ")
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.IP == "",
DynamicIPRequired: false,
IP: args.IP,
})
}
if args.IP == "dynamic" || args.IP == "" {
config.DynamicIPRequired = true
config.IP = ""
} else if args.IP == "none" || args.IP == "no" {
config.IP = ""
}
serverID, err := api.CreateServer(ctx.API, &config)
if err != nil {
return err
}
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