Skip to content

Commit

Permalink
Merge pull request #185 from subutai-io/clean-logs
Browse files Browse the repository at this point in the history
Clean logs
  • Loading branch information
crioto authored Jul 26, 2016
2 parents a5adeda + 39acea0 commit a45aa31
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,34 @@ func (p *Procedures) Show(args *RunArgs, resp *Response) error {
resp.ExitCode = 0
if exists {
if args.IP != "" {
swarm.PTP.PeersLock.Lock()
for _, peer := range swarm.PTP.NetworkPeers {
if peer.PeerLocalIP.String() == args.IP {
if peer.State == ptp.P_CONNECTED {
resp.ExitCode = 0
resp.Output = "Integrated with " + args.IP
swarm.PTP.PeersLock.Unlock()
runtime.Gosched()
return nil
}
}
}
swarm.PTP.PeersLock.Unlock()
runtime.Gosched()
resp.ExitCode = 1
resp.Output = "Not yet integrated with " + args.IP
return nil
} else {
resp.Output = "< Peer ID >\t< IP >\t< Endpoint >\t< HW >\n"
swarm.PTP.PeersLock.Lock()
for _, peer := range swarm.PTP.NetworkPeers {
resp.Output = resp.Output + peer.ID + "\t"
resp.Output = resp.Output + peer.PeerLocalIP.String() + "\t"
resp.Output = resp.Output + peer.Endpoint.String() + "\t"
resp.Output = resp.Output + peer.PeerHW.String() + "\n"
}
swarm.PTP.PeersLock.Unlock()
runtime.Gosched()
}
} else {
resp.Output = "Specified environment was not found: " + args.Hash
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (c Crypto) EnrichKeyValues(ckey CryptoKey, key, datetime string) CryptoKey
// Default value is +1 hour
ckey.Until = ckey.Until.Add(60 * time.Minute)
if err != nil {
Log(ERROR, "Failed to parse TTL. Falling back to default value of 1 hour")
Log(WARNING, "Failed to parse TTL. Falling back to default value of 1 hour")
} else {
ckey.Until = time.Unix(i, 0)
}
Expand Down
6 changes: 3 additions & 3 deletions lib/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (np *NetworkPeer) Run(ptpc *PTPCloud) {
}
err := callback(ptpc)
if err != nil {
Log(ERROR, "Peer %s: %v", np.ID, err)
Log(WARNING, "Peer %s: %v", np.ID, err)
}
time.Sleep(time.Millisecond * 500)
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func (np *NetworkPeer) TestConnection(ptpc *PTPCloud, endpoint *net.UDPAddr) boo
msg := CreateTestP2PMessage(ptpc.Crypter, "TEST", 0)
conn, err := net.DialUDP("udp4", nil, endpoint)
if err != nil {
Log(ERROR, "%v", err)
Log(DEBUG, "%v", err)
return false
}
ser := msg.Serialize()
Expand All @@ -340,7 +340,7 @@ func (np *NetworkPeer) TestConnection(ptpc *PTPCloud, endpoint *net.UDPAddr) boo
var buf [4096]byte
s, _, err := conn.ReadFromUDP(buf[0:])
if err != nil {
Log(ERROR, "%v", err)
Log(DEBUG, "%v", err)
conn.Close()
return false
}
Expand Down

0 comments on commit a45aa31

Please sign in to comment.