mplane_http_transport.js
function registerSpecification(specification, remoteDN , options , callback){
    // Serialize the capability Object
    var post_data = {};
    post_data[remoteDN] = JSON.parse(specification.to_dict());
    post_data = JSON.stringify(post_data);

    var proto = https;
    var post_options = {
        path: SUPERVISOR_PATH_REGISTER_SPECIFICATION,
        method: 'POST',
        host: options.host,
        port: options.port,
        followRedirect:false,
        headers: {
            'Content-Type': MIME_TYPE,
            'Content-Length': Buffer.byteLength(post_data)
        } ,
        key: ssl_files.readFileContent(options.keyFile)
        ,cert: ssl_files.readFileContent(options.certFile)
        ,ca: ssl_files.readCaChain(options.caFile)
    };
    // Set up the request
    var post_req = proto.request(post_options, function(res) {
        var body = "";
        res.setEncoding('utf8');
        res.on('data', function (chunk) {
            if (chunk)
                body +=chunk;
        });
        res.on('end', function (chunk) {
            if (chunk)
                body +=chunk;
            if (res.statusCode == 200){
                // Send back the receipt
                callback(null, body);
            }else{
                callback(new Error(res.statusCode), null);
            }
        });
    });
    // post the data
    post_req.write(post_data);
    post_req.end();
}
function registerSpecification(specification, remoteDN , options , callback){
    // Serialize the capability Object
    var post_data = {};
    post_data[remoteDN] = JSON.parse(specification.to_dict());
    post_data = JSON.stringify(post_data);

    var proto = https;
    var post_options = {
        path: SUPERVISOR_PATH_REGISTER_SPECIFICATION,
        method: 'POST',
        host: options.host,
        port: options.port,
        followRedirect:false,
        headers: {
            'Content-Type': MIME_TYPE,
            'Content-Length': Buffer.byteLength(post_data)
        } ,
        key: ssl_files.readFileContent(options.keyFile)
        ,cert: ssl_files.readFileContent(options.certFile)
        ,ca: ssl_files.readCaChain(options.caFile)
    };
    // Set up the request
    var post_req = proto.request(post_options, function(res) {
        var body = "";
        res.setEncoding('utf8');
        res.on('data', function (chunk) {
            if (chunk)
                body +=chunk;
        });
        res.on('end', function (chunk) {
            if (chunk)
                body +=chunk;
            if (res.statusCode == 200){
                // Send back the receipt
                callback(null, body);
            }else{
                callback(new Error(res.statusCode), null);
            }
        });
    });
    // post the data
    post_req.write(post_data);
    post_req.end();
}
function registerSpecification ( specification , remoteDN , options , callback ) { // Serialize the capability Object var post_data = { } ; post_data [ remoteDN ] = JSON . parse ( specification . to_dict ( ) ) ; post_data = JSON . stringify ( post_data ) ; var proto = https ; var post_options = { path : SUPERVISOR_PATH_REGISTER_SPECIFICATION , method : 'POST' , host : options . host , port : options . port , followRedirect : false , headers : { 'Content-Type' : MIME_TYPE , 'Content-Length' : Buffer . byteLength ( post_data ) } , key : ssl_files . readFileContent ( options . keyFile ) , cert : ssl_files . readFileContent ( options . certFile ) , ca : ssl_files . readCaChain ( options . caFile ) } ; // Set up the request var post_req = proto . request ( post_options , function ( res ) { var body = "" ; res . setEncoding ( 'utf8' ) ; res . on ( 'data' , function ( chunk ) { if ( chunk ) body += chunk ; } ) ; res . on ( 'end' , function ( chunk ) { if ( chunk ) body += chunk ; if ( res . statusCode == 200 ) { // Send back the receipt callback ( null , body ) ; } else { callback ( new Error ( res . statusCode ) , null ) ; } } ) ; } ) ; // post the data post_req . write ( post_data ) ; post_req . end ( ) ; }
Register with a POST a specification to the supervisor
@param specification an mPlane Spcification
options MUST include (or an INVALID parameters error is thrown):
- options.host
- options.port
- options.caFile
- options.keyFile
- options.certFile
Register with a POST a specification to the supervisor