fix node equal check (location)

This commit is contained in:
Martin/Geno 2018-07-27 13:40:04 +02:00
parent 21c398ca42
commit 9fbdd5a798
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
2 changed files with 16 additions and 12 deletions

View File

@ -1,6 +1,7 @@
package runtime
import (
"fmt"
"net"
"strings"
@ -80,9 +81,11 @@ func (n *Node) IsEqual(node *Node) bool {
if n.NodeID != node.NodeID {
return false
}
if n.Address != node.Address {
return false
}
/*
if n.Address != node.Address {
return false
}
*/
if n.Hostname != node.Hostname {
return false
}
@ -98,16 +101,20 @@ func (n *Node) IsEqual(node *Node) bool {
return true
}
const LOCATION_EQUAL_FORMAT_STRING = "%.6f"
func locationEqual(a, b yanicData.Location) bool {
if a.Latitude != b.Latitude {
if fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, a.Latitude) != fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, b.Latitude) {
return false
}
if a.Longitude != b.Longitude {
if fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, a.Longitude) != fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, b.Longitude) {
return false
}
if a.Altitude != b.Altitude {
return false
}
return true
}

View File

@ -49,16 +49,17 @@ func (conn *YanicDB) InsertNode(n *runtimeYanic.Node) {
//"StatsClients": node.StatsClients,
"Address": node.Address,
})
conn.sendNode(node, false)
if lNode.Blacklist {
logger.Debug("on blacklist")
return
}
conn.sendNode(node, false)
if !node.IsEqual(&lNode) {
lNode.SSHUpdate(conn.ssh, node)
logger.Debug("run sshupdate again")
logger.Debug("yanic trigger sshupdate again")
} else {
logger.Debug("yanic update")
}
logger.Debug("yanic update")
return
}
@ -71,10 +72,6 @@ func (conn *YanicDB) InsertNode(n *runtimeYanic.Node) {
}
conn.db.Create(&node)
conn.sendNode(node, true)
if err == nil {
lNode.SSHUpdate(conn.ssh, node)
logger.Debug("run sshupdate")
}
}
func (conn *YanicDB) InsertLink(link *runtimeYanic.Link, time time.Time) {