11package ipmanager
22
33import (
4- "log"
54 "net"
65 "os/exec"
76 "time"
@@ -22,11 +21,11 @@ var (
2221func (c * BasicConfigurer ) configureAddress () bool {
2322 if c .arpClient == nil {
2423 if err := c .createArpClient (); err != nil {
25- log .Printf ("Couldn't create an Arp client: %s " , err )
24+ log .Error ("Couldn't create an Arp client:" , err )
2625 }
2726 }
2827
29- log .Printf ("Configuring address %s on %s" , c .getCIDR (), c .Iface .Name )
28+ log .Infof ("Configuring address %s on %s" , c .getCIDR (), c .Iface .Name )
3029
3130 result := c .runAddressConfiguration ("add" )
3231
@@ -42,7 +41,7 @@ func (c *BasicConfigurer) configureAddress() bool {
4241
4342// deconfigureAddress drops virtual IP address
4443func (c * BasicConfigurer ) deconfigureAddress () bool {
45- log .Printf ("Removing address %s on %s" , c .getCIDR (), c .Iface .Name )
44+ log .Infof ("Removing address %s on %s" , c .getCIDR (), c .Iface .Name )
4645 return c .runAddressConfiguration ("delete" )
4746}
4847
@@ -54,12 +53,12 @@ func (c *BasicConfigurer) runAddressConfiguration(action string) bool {
5453
5554 switch err .(type ) {
5655 case * exec.ExitError :
57- log .Printf ("Got error %s" , output )
56+ log .Infof ("Got error %s" , output )
5857
5958 return false
6059 }
6160 if err != nil {
62- log .Printf ("Error running ip address %s %s on %s: %s" ,
61+ log .Infof ("Error running ip address %s %s on %s: %s" ,
6362 action , c .VIP , c .Iface .Name , err )
6463 return false
6564 }
@@ -71,7 +70,7 @@ func (c *BasicConfigurer) createArpClient() (err error) {
7170 if c .arpClient , err = arp .Dial (& c .Iface ); err == nil {
7271 return
7372 }
74- log .Printf ("Problems with producing the arp client: %s" , err )
73+ log .Infof ("Problems with producing the arp client: %s" , err )
7574 time .Sleep (time .Duration (c .RetryAfter ) * time .Millisecond )
7675 }
7776 return
@@ -86,7 +85,7 @@ func (c *BasicConfigurer) arpSendGratuitous() error {
8685 * https://support.citrix.com/article/CTX112701
8786 */
8887 if c .arpClient == nil {
89- log .Println ("No arp client available, skip send gratuitous ARP" )
88+ log .Info ("No arp client available, skip send gratuitous ARP" )
9089 return nil
9190 }
9291 gratuitousReplyPackage , err := arp .NewPacket (
@@ -97,7 +96,7 @@ func (c *BasicConfigurer) arpSendGratuitous() error {
9796 c .VIP ,
9897 )
9998 if err != nil {
100- log .Printf ("Gratuitous arp reply package is malformed: %s" , err )
99+ log .Infof ("Gratuitous arp reply package is malformed: %s" , err )
101100 return err
102101 }
103102
@@ -121,23 +120,23 @@ func (c *BasicConfigurer) arpSendGratuitous() error {
121120 c .VIP ,
122121 )
123122 if err != nil {
124- log .Printf ("Gratuitous arp request package is malformed: %s" , err )
123+ log .Infof ("Gratuitous arp request package is malformed: %s" , err )
125124 return err
126125 }
127126
128127 for i := 0 ; i < c .RetryNum ; i ++ {
129128 errReply := c .arpClient .WriteTo (gratuitousReplyPackage , ethernetBroadcast )
130129 if err != nil {
131- log .Printf ("Couldn't write to the arpClient: %s " , errReply )
130+ log .Error ("Couldn't write to the arpClient:" , errReply )
132131 } else {
133- log .Println ("Sent gratuitous ARP reply" )
132+ log .Info ("Sent gratuitous ARP reply" )
134133 }
135134
136135 errRequest := c .arpClient .WriteTo (gratuitousRequestPackage , ethernetBroadcast )
137136 if err != nil {
138- log .Printf ("Couldn't write to the arpClient: %s " , errRequest )
137+ log .Error ("Couldn't write to the arpClient:" , errRequest )
139138 } else {
140- log .Println ("Sent gratuitous ARP request" )
139+ log .Info ("Sent gratuitous ARP request" )
141140 }
142141
143142 if errReply != nil || errRequest != nil {
@@ -152,7 +151,7 @@ func (c *BasicConfigurer) arpSendGratuitous() error {
152151 time .Sleep (time .Duration (c .RetryAfter ) * time .Millisecond )
153152 }
154153 if err != nil {
155- log .Print ("too many retries" )
154+ log .Error ("too many retries" , err )
156155 return err
157156 }
158157
0 commit comments