Merge pull request #2489 from jeanlaurent/logrus
Replace custom logging system by logrus
This commit is contained in:
commit
a3eb02897c
|
@ -477,7 +477,7 @@ func (c *GenericClient) Authenticate(d *Driver) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.Debug("Authenticating...", map[string]interface{}{
|
||||||
"AuthUrl": d.AuthUrl,
|
"AuthUrl": d.AuthUrl,
|
||||||
"Insecure": d.Insecure,
|
"Insecure": d.Insecure,
|
||||||
"DomainID": d.DomainID,
|
"DomainID": d.DomainID,
|
||||||
|
@ -485,7 +485,7 @@ func (c *GenericClient) Authenticate(d *Driver) error {
|
||||||
"Username": d.Username,
|
"Username": d.Username,
|
||||||
"TenantName": d.TenantName,
|
"TenantName": d.TenantName,
|
||||||
"TenantID": d.TenantId,
|
"TenantID": d.TenantId,
|
||||||
}).Debug("Authenticating...")
|
})
|
||||||
|
|
||||||
opts := gophercloud.AuthOptions{
|
opts := gophercloud.AuthOptions{
|
||||||
IdentityEndpoint: d.AuthUrl,
|
IdentityEndpoint: d.AuthUrl,
|
||||||
|
|
|
@ -278,7 +278,7 @@ func (d *Driver) GetIP() (string, error) {
|
||||||
return d.IPAddress, nil
|
return d.IPAddress, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithField("MachineId", d.MachineId).Debug("Looking for the IP address...")
|
log.Debug("Looking for the IP address...", map[string]string{"MachineId": d.MachineId})
|
||||||
|
|
||||||
if err := d.initCompute(); err != nil {
|
if err := d.initCompute(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -306,7 +306,7 @@ func (d *Driver) GetIP() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) GetState() (state.State, error) {
|
func (d *Driver) GetState() (state.State, error) {
|
||||||
log.WithField("MachineId", d.MachineId).Debug("Get status for OpenStack instance...")
|
log.Debug("Get status for OpenStack instance...", map[string]string{"MachineId": d.MachineId})
|
||||||
if err := d.initCompute(); err != nil {
|
if err := d.initCompute(); err != nil {
|
||||||
return state.None, err
|
return state.None, err
|
||||||
}
|
}
|
||||||
|
@ -316,10 +316,10 @@ func (d *Driver) GetState() (state.State, error) {
|
||||||
return state.None, err
|
return state.None, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.Debug("State for OpenStack instance", map[string]string{
|
||||||
"MachineId": d.MachineId,
|
"MachineId": d.MachineId,
|
||||||
"State": s,
|
"State": s,
|
||||||
}).Debug("State for OpenStack instance")
|
})
|
||||||
|
|
||||||
switch s {
|
switch s {
|
||||||
case "ACTIVE":
|
case "ACTIVE":
|
||||||
|
@ -365,7 +365,7 @@ func (d *Driver) Create() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Start() error {
|
func (d *Driver) Start() error {
|
||||||
log.WithField("MachineId", d.MachineId).Info("Starting OpenStack instance...")
|
log.Debug("Starting OpenStack instance...", map[string]string{"MachineId": d.MachineId})
|
||||||
if err := d.initCompute(); err != nil {
|
if err := d.initCompute(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -376,7 +376,7 @@ func (d *Driver) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Stop() error {
|
func (d *Driver) Stop() error {
|
||||||
log.WithField("MachineId", d.MachineId).Info("Stopping OpenStack instance...")
|
log.Debug("Stopping OpenStack instance...", map[string]string{"MachineId": d.MachineId})
|
||||||
if err := d.initCompute(); err != nil {
|
if err := d.initCompute(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ func (d *Driver) Stop() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Remove() error {
|
func (d *Driver) Remove() error {
|
||||||
log.WithField("MachineId", d.MachineId).Debug("deleting instance...")
|
log.Debug("deleting instance...", map[string]string{"MachineId": d.MachineId})
|
||||||
log.Info("Deleting OpenStack instance...")
|
log.Info("Deleting OpenStack instance...")
|
||||||
if err := d.initCompute(); err != nil {
|
if err := d.initCompute(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -396,7 +396,7 @@ func (d *Driver) Remove() error {
|
||||||
if err := d.client.DeleteInstance(d); err != nil {
|
if err := d.client.DeleteInstance(d); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.WithField("Name", d.KeyPairName).Debug("deleting key pair...")
|
log.Debug("deleting key pair...", map[string]string{"Name": d.KeyPairName})
|
||||||
if err := d.client.DeleteKeyPair(d, d.KeyPairName); err != nil {
|
if err := d.client.DeleteKeyPair(d, d.KeyPairName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ func (d *Driver) Remove() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Restart() error {
|
func (d *Driver) Restart() error {
|
||||||
log.WithField("MachineId", d.MachineId).Info("Restarting OpenStack instance...")
|
log.Info("Restarting OpenStack instance...", map[string]string{"MachineId": d.MachineId})
|
||||||
if err := d.initCompute(); err != nil {
|
if err := d.initCompute(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -483,10 +483,10 @@ func (d *Driver) resolveIds() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
d.NetworkId = networkID
|
d.NetworkId = networkID
|
||||||
log.WithFields(log.Fields{
|
log.Debug("Found network id using its name", map[string]string{
|
||||||
"Name": d.NetworkName,
|
"Name": d.NetworkName,
|
||||||
"ID": d.NetworkId,
|
"ID": d.NetworkId,
|
||||||
}).Debug("Found network id using its name")
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.FlavorName != "" {
|
if d.FlavorName != "" {
|
||||||
|
@ -504,10 +504,10 @@ func (d *Driver) resolveIds() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
d.FlavorId = flavorID
|
d.FlavorId = flavorID
|
||||||
log.WithFields(log.Fields{
|
log.Debug("Found flavor id using its name", map[string]string{
|
||||||
"Name": d.FlavorName,
|
"Name": d.FlavorName,
|
||||||
"ID": d.FlavorId,
|
"ID": d.FlavorId,
|
||||||
}).Debug("Found flavor id using its name")
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.ImageName != "" {
|
if d.ImageName != "" {
|
||||||
|
@ -525,10 +525,10 @@ func (d *Driver) resolveIds() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
d.ImageId = imageID
|
d.ImageId = imageID
|
||||||
log.WithFields(log.Fields{
|
log.Debug("Found image id using its name", map[string]string{
|
||||||
"Name": d.ImageName,
|
"Name": d.ImageName,
|
||||||
"ID": d.ImageId,
|
"ID": d.ImageId,
|
||||||
}).Debug("Found image id using its name")
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.FloatingIpPool != "" && !d.ComputeNetwork {
|
if d.FloatingIpPool != "" && !d.ComputeNetwork {
|
||||||
|
@ -546,10 +546,10 @@ func (d *Driver) resolveIds() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
d.FloatingIpPoolId = f
|
d.FloatingIpPoolId = f
|
||||||
log.WithFields(log.Fields{
|
log.Debug("Found floating IP pool id using its name", map[string]string{
|
||||||
"Name": d.FloatingIpPool,
|
"Name": d.FloatingIpPool,
|
||||||
"ID": d.FloatingIpPoolId,
|
"ID": d.FloatingIpPoolId,
|
||||||
}).Debug("Found floating IP pool id using its name")
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -577,7 +577,7 @@ func (d *Driver) initNetwork() error {
|
||||||
|
|
||||||
func (d *Driver) createSSHKey() error {
|
func (d *Driver) createSSHKey() error {
|
||||||
sanitizeKeyPairName(&d.KeyPairName)
|
sanitizeKeyPairName(&d.KeyPairName)
|
||||||
log.WithField("Name", d.KeyPairName).Debug("Creating Key Pair...")
|
log.Debug("Creating Key Pair...", map[string]string{"Name": d.KeyPairName})
|
||||||
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
|
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -596,10 +596,10 @@ func (d *Driver) createSSHKey() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) createMachine() error {
|
func (d *Driver) createMachine() error {
|
||||||
log.WithFields(log.Fields{
|
log.Debug("Creating OpenStack instance...", map[string]string{
|
||||||
"FlavorId": d.FlavorId,
|
"FlavorId": d.FlavorId,
|
||||||
"ImageId": d.ImageId,
|
"ImageId": d.ImageId,
|
||||||
}).Debug("Creating OpenStack instance...")
|
})
|
||||||
|
|
||||||
if err := d.initCompute(); err != nil {
|
if err := d.initCompute(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -632,17 +632,17 @@ func (d *Driver) assignFloatingIP() error {
|
||||||
|
|
||||||
var floatingIP *FloatingIP
|
var floatingIP *FloatingIP
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.Debugf("Looking for an available floating IP", map[string]string{
|
||||||
"MachineId": d.MachineId,
|
"MachineId": d.MachineId,
|
||||||
"Pool": d.FloatingIpPool,
|
"Pool": d.FloatingIpPool,
|
||||||
}).Debugf("Looking for an available floating IP")
|
})
|
||||||
|
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
if ip.PortId == "" {
|
if ip.PortId == "" {
|
||||||
log.WithFields(log.Fields{
|
log.Debug("Available floating IP found", map[string]string{
|
||||||
"MachineId": d.MachineId,
|
"MachineId": d.MachineId,
|
||||||
"IP": ip.Ip,
|
"IP": ip.Ip,
|
||||||
}).Debugf("Available floating IP found")
|
})
|
||||||
floatingIP = &ip
|
floatingIP = &ip
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -650,9 +650,9 @@ func (d *Driver) assignFloatingIP() error {
|
||||||
|
|
||||||
if floatingIP == nil {
|
if floatingIP == nil {
|
||||||
floatingIP = &FloatingIP{}
|
floatingIP = &FloatingIP{}
|
||||||
log.WithField("MachineId", d.MachineId).Debugf("No available floating IP found. Allocating a new one...")
|
log.Debug("No available floating IP found. Allocating a new one...", map[string]string{"MachineId": d.MachineId})
|
||||||
} else {
|
} else {
|
||||||
log.WithField("MachineId", d.MachineId).Debugf("Assigning floating IP to the instance")
|
log.Debug("Assigning floating IP to the instance", map[string]string{"MachineId": d.MachineId})
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := d.client.AssignFloatingIP(d, floatingIP); err != nil {
|
if err := d.client.AssignFloatingIP(d, floatingIP); err != nil {
|
||||||
|
@ -663,7 +663,7 @@ func (d *Driver) assignFloatingIP() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) waitForInstanceActive() error {
|
func (d *Driver) waitForInstanceActive() error {
|
||||||
log.WithField("MachineId", d.MachineId).Debug("Waiting for the OpenStack instance to be ACTIVE...")
|
log.Debug("Waiting for the OpenStack instance to be ACTIVE...", map[string]string{"MachineId": d.MachineId})
|
||||||
if err := d.client.WaitForInstanceStatus(d, "ACTIVE"); err != nil {
|
if err := d.client.WaitForInstanceStatus(d, "ACTIVE"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -676,10 +676,10 @@ func (d *Driver) lookForIPAddress() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.IPAddress = ip
|
d.IPAddress = ip
|
||||||
log.WithFields(log.Fields{
|
log.Debug("IP address found", map[string]string{
|
||||||
"IP": ip,
|
"IP": ip,
|
||||||
"MachineId": d.MachineId,
|
"MachineId": d.MachineId,
|
||||||
}).Debug("IP address found")
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue