Browse Source

Merge pull request #2732 from dgageot/better-logs

Improve Start/Stop/Kill/Restart lifecycle/logs
David Gageot 3 years ago
parent
commit
db63c28917
1 changed files with 13 additions and 23 deletions
  1. 13
    23
      drivers/openstack/openstack.go

+ 13
- 23
drivers/openstack/openstack.go View File

@@ -383,26 +383,31 @@ func (d *Driver) Create() error {
383 383
 }
384 384
 
385 385
 func (d *Driver) Start() error {
386
-	log.Debug("Starting OpenStack instance...", map[string]string{"MachineId": d.MachineId})
387 386
 	if err := d.initCompute(); err != nil {
388 387
 		return err
389 388
 	}
390
-	if err := d.client.StartInstance(d); err != nil {
391
-		return err
392
-	}
393
-	return nil
389
+
390
+	return d.client.StartInstance(d)
394 391
 }
395 392
 
396 393
 func (d *Driver) Stop() error {
397
-	log.Debug("Stopping OpenStack instance...", map[string]string{"MachineId": d.MachineId})
398 394
 	if err := d.initCompute(); err != nil {
399 395
 		return err
400 396
 	}
401
-	if err := d.client.StopInstance(d); err != nil {
397
+
398
+	return d.client.StopInstance(d)
399
+}
400
+
401
+func (d *Driver) Restart() error {
402
+	if err := d.initCompute(); err != nil {
402 403
 		return err
403 404
 	}
404 405
 
405
-	return nil
406
+	return d.client.RestartInstance(d)
407
+}
408
+
409
+func (d *Driver) Kill() error {
410
+	return d.Stop()
406 411
 }
407 412
 
408 413
 func (d *Driver) Remove() error {
@@ -422,21 +427,6 @@ func (d *Driver) Remove() error {
422 427
 	return nil
423 428
 }
424 429
 
425
-func (d *Driver) Restart() error {
426
-	log.Info("Restarting OpenStack instance...", map[string]string{"MachineId": d.MachineId})
427
-	if err := d.initCompute(); err != nil {
428
-		return err
429
-	}
430
-	if err := d.client.RestartInstance(d); err != nil {
431
-		return err
432
-	}
433
-	return nil
434
-}
435
-
436
-func (d *Driver) Kill() error {
437
-	return d.Stop()
438
-}
439
-
440 430
 const (
441 431
 	errorMandatoryEnvOrOption    string = "%s must be specified either using the environment variable %s or the CLI option %s"
442 432
 	errorMandatoryOption         string = "%s must be specified using the CLI option %s"

Loading…
Cancel
Save