Skip to content

Instantly share code, notes, and snippets.

@mattburch
Created July 1, 2014 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattburch/b424a27a9e9ca811d763 to your computer and use it in GitHub Desktop.
Save mattburch/b424a27a9e9ca811d763 to your computer and use it in GitHub Desktop.
var portServiceToColor = function(portnum, product, color) {
// Changes the status of provided port to provided color by Array of hosts
// for lair-blue, lair-orange, lair-red; Host status is updated to COLOR also
//
// Created by: Matt Burch
// Usage: portServiceToColor(47001, 'Microsoft HTTPAPI httpd 2.0', 'lair-green');
// Supported Colors: console.log(STATUS_MAP)
//
// Requires client-side updates: false
var PROJECT_ID = Session.get('projectId');
var MODIFIED_BY = Meteor.user().emails[0].address;
var COUNT = 0;
if (STATUS_MAP.indexOf(color) === -1) {
console.log("Lair Supported colors: " + STATUS_MAP);
throw {name : "Wrong Color", message : "Provided COLOR: \"" + color + "\" is not Lair compliant"};
}
var ports = Ports.find({project_id : PROJECT_ID, 'port' : portnum, 'product' : product}).fetch();
ports.forEach( function(port) {
Meteor.call("setPortStatus", PROJECT_ID, port._id, color)
COUNT ++;
});
console.log(COUNT + " port(s) updated");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment