@@ -30,6 +30,7 @@ func CreateCommand() commands.Command {
3030 "create" ,
3131 "Create a server" ,
3232 "upctl server create --title myapp --zone fi-hel1 --hostname myapp --password-delivery email" ,
33+ "upctl server create --wait --title myapp --zone fi-hel1 --hostname myapp --password-delivery email" ,
3334 "upctl server create --title \" My Server\" --zone fi-hel1 --hostname myapp --password-delivery email" ,
3435 "upctl server create --zone fi-hel1 --hostname myapp --password-delivery email --plan 2xCPU-4GB" ,
3536 "upctl server create --zone fi-hel1 --hostname myapp --password-delivery email --plan custom --cores 2 --memory 4096" ,
@@ -243,6 +244,7 @@ type createCommand struct {
243244 metadata config.OptionalBoolean
244245 remoteAccess config.OptionalBoolean
245246 createPassword config.OptionalBoolean
247+ wait config.OptionalBoolean
246248}
247249
248250// InitCommand implements Command.InitCommand
@@ -275,6 +277,7 @@ func (s *createCommand) InitCommand() {
275277 fs .StringVar (& s .params .UserData , "user-data" , def .UserData , "Defines URL for a server setup script, or the script body itself." )
276278 fs .StringVar (& s .params .username , "username" , def .username , "Admin account username." )
277279 fs .StringVar (& s .params .VideoModel , "video-model" , def .VideoModel , "Video interface model of the server. Available: vga, cirrus" )
280+ config .AddToggleFlag (fs , & s .wait , "wait" , false , "Wait for server to be in started state before returning." )
278281 fs .StringVar (& s .params .Zone , "zone" , def .Zone , "Zone where to create the server." )
279282 // fs.BoolVar(&s.params.firewall, "firewall", def.firewall, "Enables the firewall. You can manage firewall rules with the firewall command.")
280283 // fs.BoolVar(&s.params.metadata, "metadata", def.metadata, "Enable metadata service.")
@@ -369,6 +372,13 @@ func (s *createCommand) ExecuteWithoutArguments(exec commands.Executor) (output.
369372 logline .SetMessage (fmt .Sprintf ("%s: request sent" , msg ))
370373 logline .MarkDone ()
371374
375+ if s .wait .Value () {
376+ logline := exec .NewLogEntry (msg )
377+ if err := waitForServerState (res .UUID , upcloud .ServerStateStarted , serverSvc , logline ); err != nil {
378+ return nil , err
379+ }
380+ }
381+
372382 return output.MarshaledWithHumanDetails {Value : res , Details : []output.DetailRow {
373383 {Title : "UUID" , Value : res .UUID , Colour : ui .DefaultUUUIDColours },
374384 {Title : "IP Addresses" , Value : res , Format : formatIPAddresses },
0 commit comments