Browse Source

Remove withFields

Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
Jean-Laurent de Morlhon 3 years ago
parent
commit
bae895ef81
2 changed files with 31 additions and 31 deletions
  1. 2
    2
      drivers/openstack/client.go
  2. 29
    29
      drivers/openstack/openstack.go

+ 2
- 2
drivers/openstack/client.go View File

@@ -477,7 +477,7 @@ func (c *GenericClient) Authenticate(d *Driver) error {
477 477
 		return nil
478 478
 	}
479 479
 
480
-	log.WithFields(log.Fields{
480
+	log.Debug("Authenticating...", map[string]interface{}{
481 481
 		"AuthUrl":    d.AuthUrl,
482 482
 		"Insecure":   d.Insecure,
483 483
 		"DomainID":   d.DomainID,
@@ -485,7 +485,7 @@ func (c *GenericClient) Authenticate(d *Driver) error {
485 485
 		"Username":   d.Username,
486 486
 		"TenantName": d.TenantName,
487 487
 		"TenantID":   d.TenantId,
488
-	}).Debug("Authenticating...")
488
+	})
489 489
 
490 490
 	opts := gophercloud.AuthOptions{
491 491
 		IdentityEndpoint: d.AuthUrl,

+ 29
- 29
drivers/openstack/openstack.go View File

@@ -278,7 +278,7 @@ func (d *Driver) GetIP() (string, error) {
278 278
 		return d.IPAddress, nil
279 279
 	}
280 280
 
281
-	log.WithField("MachineId", d.MachineId).Debug("Looking for the IP address...")
281
+	log.Debug("Looking for the IP address...", map[string]string{"MachineId": d.MachineId})
282 282
 
283 283
 	if err := d.initCompute(); err != nil {
284 284
 		return "", err
@@ -306,7 +306,7 @@ func (d *Driver) GetIP() (string, error) {
306 306
 }
307 307
 
308 308
 func (d *Driver) GetState() (state.State, error) {
309
-	log.WithField("MachineId", d.MachineId).Debug("Get status for OpenStack instance...")
309
+	log.Debug("Get status for OpenStack instance...", map[string]string{"MachineId": d.MachineId})
310 310
 	if err := d.initCompute(); err != nil {
311 311
 		return state.None, err
312 312
 	}
@@ -316,10 +316,10 @@ func (d *Driver) GetState() (state.State, error) {
316 316
 		return state.None, err
317 317
 	}
318 318
 
319
-	log.WithFields(log.Fields{
319
+	log.Debug("State for OpenStack instance", map[string]string{
320 320
 		"MachineId": d.MachineId,
321 321
 		"State":     s,
322
-	}).Debug("State for OpenStack instance")
322
+	})
323 323
 
324 324
 	switch s {
325 325
 	case "ACTIVE":
@@ -365,7 +365,7 @@ func (d *Driver) Create() error {
365 365
 }
366 366
 
367 367
 func (d *Driver) Start() error {
368
-	log.WithField("MachineId", d.MachineId).Info("Starting OpenStack instance...")
368
+	log.Debug("Starting OpenStack instance...", map[string]string{"MachineId": d.MachineId})
369 369
 	if err := d.initCompute(); err != nil {
370 370
 		return err
371 371
 	}
@@ -376,7 +376,7 @@ func (d *Driver) Start() error {
376 376
 }
377 377
 
378 378
 func (d *Driver) Stop() error {
379
-	log.WithField("MachineId", d.MachineId).Info("Stopping OpenStack instance...")
379
+	log.Debug("Stopping OpenStack instance...", map[string]string{"MachineId": d.MachineId})
380 380
 	if err := d.initCompute(); err != nil {
381 381
 		return err
382 382
 	}
@@ -388,7 +388,7 @@ func (d *Driver) Stop() error {
388 388
 }
389 389
 
390 390
 func (d *Driver) Remove() error {
391
-	log.WithField("MachineId", d.MachineId).Debug("deleting instance...")
391
+	log.Debug("deleting instance...", map[string]string{"MachineId": d.MachineId})
392 392
 	log.Info("Deleting OpenStack instance...")
393 393
 	if err := d.initCompute(); err != nil {
394 394
 		return err
@@ -396,7 +396,7 @@ func (d *Driver) Remove() error {
396 396
 	if err := d.client.DeleteInstance(d); err != nil {
397 397
 		return err
398 398
 	}
399
-	log.WithField("Name", d.KeyPairName).Debug("deleting key pair...")
399
+	log.Debug("deleting key pair...", map[string]string{"Name": d.KeyPairName})
400 400
 	if err := d.client.DeleteKeyPair(d, d.KeyPairName); err != nil {
401 401
 		return err
402 402
 	}
@@ -404,7 +404,7 @@ func (d *Driver) Remove() error {
404 404
 }
405 405
 
406 406
 func (d *Driver) Restart() error {
407
-	log.WithField("MachineId", d.MachineId).Info("Restarting OpenStack instance...")
407
+	log.Info("Restarting OpenStack instance...", map[string]string{"MachineId": d.MachineId})
408 408
 	if err := d.initCompute(); err != nil {
409 409
 		return err
410 410
 	}
@@ -483,10 +483,10 @@ func (d *Driver) resolveIds() error {
483 483
 		}
484 484
 
485 485
 		d.NetworkId = networkID
486
-		log.WithFields(log.Fields{
486
+		log.Debug("Found network id using its name", map[string]string{
487 487
 			"Name": d.NetworkName,
488 488
 			"ID":   d.NetworkId,
489
-		}).Debug("Found network id using its name")
489
+		})
490 490
 	}
491 491
 
492 492
 	if d.FlavorName != "" {
@@ -504,10 +504,10 @@ func (d *Driver) resolveIds() error {
504 504
 		}
505 505
 
506 506
 		d.FlavorId = flavorID
507
-		log.WithFields(log.Fields{
507
+		log.Debug("Found flavor id using its name", map[string]string{
508 508
 			"Name": d.FlavorName,
509 509
 			"ID":   d.FlavorId,
510
-		}).Debug("Found flavor id using its name")
510
+		})
511 511
 	}
512 512
 
513 513
 	if d.ImageName != "" {
@@ -525,10 +525,10 @@ func (d *Driver) resolveIds() error {
525 525
 		}
526 526
 
527 527
 		d.ImageId = imageID
528
-		log.WithFields(log.Fields{
528
+		log.Debug("Found image id using its name", map[string]string{
529 529
 			"Name": d.ImageName,
530 530
 			"ID":   d.ImageId,
531
-		}).Debug("Found image id using its name")
531
+		})
532 532
 	}
533 533
 
534 534
 	if d.FloatingIpPool != "" && !d.ComputeNetwork {
@@ -546,10 +546,10 @@ func (d *Driver) resolveIds() error {
546 546
 		}
547 547
 
548 548
 		d.FloatingIpPoolId = f
549
-		log.WithFields(log.Fields{
549
+		log.Debug("Found floating IP pool id using its name", map[string]string{
550 550
 			"Name": d.FloatingIpPool,
551 551
 			"ID":   d.FloatingIpPoolId,
552
-		}).Debug("Found floating IP pool id using its name")
552
+		})
553 553
 	}
554 554
 
555 555
 	return nil
@@ -577,7 +577,7 @@ func (d *Driver) initNetwork() error {
577 577
 
578 578
 func (d *Driver) createSSHKey() error {
579 579
 	sanitizeKeyPairName(&d.KeyPairName)
580
-	log.WithField("Name", d.KeyPairName).Debug("Creating Key Pair...")
580
+	log.Debug("Creating Key Pair...", map[string]string{"Name": d.KeyPairName})
581 581
 	if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
582 582
 		return err
583 583
 	}
@@ -596,10 +596,10 @@ func (d *Driver) createSSHKey() error {
596 596
 }
597 597
 
598 598
 func (d *Driver) createMachine() error {
599
-	log.WithFields(log.Fields{
599
+	log.Debug("Creating OpenStack instance...", map[string]string{
600 600
 		"FlavorId": d.FlavorId,
601 601
 		"ImageId":  d.ImageId,
602
-	}).Debug("Creating OpenStack instance...")
602
+	})
603 603
 
604 604
 	if err := d.initCompute(); err != nil {
605 605
 		return err
@@ -632,17 +632,17 @@ func (d *Driver) assignFloatingIP() error {
632 632
 
633 633
 	var floatingIP *FloatingIP
634 634
 
635
-	log.WithFields(log.Fields{
635
+	log.Debugf("Looking for an available floating IP", map[string]string{
636 636
 		"MachineId": d.MachineId,
637 637
 		"Pool":      d.FloatingIpPool,
638
-	}).Debugf("Looking for an available floating IP")
638
+	})
639 639
 
640 640
 	for _, ip := range ips {
641 641
 		if ip.PortId == "" {
642
-			log.WithFields(log.Fields{
642
+			log.Debug("Available floating IP found", map[string]string{
643 643
 				"MachineId": d.MachineId,
644 644
 				"IP":        ip.Ip,
645
-			}).Debugf("Available floating IP found")
645
+			})
646 646
 			floatingIP = &ip
647 647
 			break
648 648
 		}
@@ -650,9 +650,9 @@ func (d *Driver) assignFloatingIP() error {
650 650
 
651 651
 	if floatingIP == nil {
652 652
 		floatingIP = &FloatingIP{}
653
-		log.WithField("MachineId", d.MachineId).Debugf("No available floating IP found. Allocating a new one...")
653
+		log.Debug("No available floating IP found. Allocating a new one...", map[string]string{"MachineId": d.MachineId})
654 654
 	} else {
655
-		log.WithField("MachineId", d.MachineId).Debugf("Assigning floating IP to the instance")
655
+		log.Debug("Assigning floating IP to the instance", map[string]string{"MachineId": d.MachineId})
656 656
 	}
657 657
 
658 658
 	if err := d.client.AssignFloatingIP(d, floatingIP); err != nil {
@@ -663,7 +663,7 @@ func (d *Driver) assignFloatingIP() error {
663 663
 }
664 664
 
665 665
 func (d *Driver) waitForInstanceActive() error {
666
-	log.WithField("MachineId", d.MachineId).Debug("Waiting for the OpenStack instance to be ACTIVE...")
666
+	log.Debug("Waiting for the OpenStack instance to be ACTIVE...", map[string]string{"MachineId": d.MachineId})
667 667
 	if err := d.client.WaitForInstanceStatus(d, "ACTIVE"); err != nil {
668 668
 		return err
669 669
 	}
@@ -676,10 +676,10 @@ func (d *Driver) lookForIPAddress() error {
676 676
 		return err
677 677
 	}
678 678
 	d.IPAddress = ip
679
-	log.WithFields(log.Fields{
679
+	log.Debug("IP address found", map[string]string{
680 680
 		"IP":        ip,
681 681
 		"MachineId": d.MachineId,
682
-	}).Debug("IP address found")
682
+	})
683 683
 	return nil
684 684
 }
685 685
 

Loading…
Cancel
Save