Created
December 22, 2015 13:03
-
-
Save mattburch/7c23a7272fd26f9e8143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hostValidation(title1, title2) { | |
// Usage: | |
function checklist(l1, l2) { | |
var list = [] | |
var list2 = [] | |
l1.forEach( function(h1) { | |
var check = false | |
l2.forEach( function(h2) { | |
if ([h1.ipv4, h1.port, h1.protocol].join(":") == [h2.ipv4, h2.port, h2.protocol].join(":") ) { | |
check = true | |
list2.push([h2.ipv4, h2.port, h2.protocol].join(":")) | |
} | |
}) | |
if (check == false) { | |
list.push([h1.ipv4, h1.port, h1.protocol].join(":")) | |
} | |
}) | |
return [list, list2] | |
} | |
var projectId = Session.get('projectId') | |
var issue1 = Issues.findOne({ | |
projectId: projectId, | |
title: title1, | |
}) | |
if (typeof issue1 == null) { | |
return console.log("No hosts detected for '" + title1 + "'") | |
} | |
var issue2 = Issues.findOne({ | |
projectId: projectId, | |
title: title2, | |
}) | |
if (typeof issue2 == null) { | |
return console.log("No hosts detected for '" + title2 + "'") | |
} | |
console.log(title1 + " - hosts: " + issue1.hosts.length) | |
console.log(title2 + " - hosts: " + issue2.hosts.length) | |
var list = checklist(issue1.hosts, issue2.hosts) | |
if (list.length > 0) { | |
console.log(title2 + " - Missing " + list[0].length + " Hosts") | |
list[0].forEach( function(h) { | |
console.log(h) | |
}) | |
console.log(title1 + " - Matched " + list[1].length + " Hosts") | |
list[1].forEach( function(h) { | |
console.log(h) | |
}) | |
} else { | |
console.log ("Host Match") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment