var hyperv = require("../HyperVShellExecute");
/*
 * GET home page.
 */

exports.getvms = function(req, res){
  hyperv.getAllVms(function (json) { 
      res.send('{"aaData": '+json+'}'); });
  //res.send('{"aaData": [ { "Name": "142176B8-EAD9-4509-9F2A-7877FB567BB3", "DisplayName": "eYouVoBoxDev", "State": 3, "StateText": "Stopped", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "32238C48-34CB-47F7-A8AF-C2BB917DEFF5", "DisplayName": "VM XP petits logiciels", "State": 2, "StateText": "Running", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "48B51107-537B-4493-8652-867F38E4BF0C", "DisplayName": "Newsgroups", "State": 2, "StateText": "Running", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "4E3F9344-5286-4C2E-AFA7-0C3DCB12B317", "DisplayName": "Win81NodeJS", "State": 2, "StateText": "Running", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "7907F2A5-00B5-4F1D-8541-7BB688E2034C", "DisplayName": "DevWin7VS2010", "State": 3, "StateText": "Stopped", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "A8503E7E-52E5-424A-955C-3FBCFFCA68A4", "DisplayName": "Win81VS2013", "State": 3, "StateText": "Stopped", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "B83A4B91-1765-4DAE-9060-A0F4674FE366", "DisplayName": "Automate", "State": 2, "StateText": "Running", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "BAF92D09-F403-4296-A4CA-F54D2750E315", "DisplayName": "Win8VS2012", "State": 3, "StateText": "Stopped", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "BE3FCCAC-050C-45A1-8040-608B3A3021B2", "DisplayName": "Desktop", "State": 2, "StateText": "Running", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ,{ "Name": "F4A69941-5BF7-4E39-A8D0-D31B7430C9D6", "DisplayName": "VMWorkExpertime", "State": 2, "StateText": "Running", "HealthState": 5, "HealthStateText": "OK", "StartupStateText": "Enabled"} ]}');
};

exports.setvmstate = function(req, res) {
    var id = req.query.id;
    var state = req.query.state;

    hyperv.setvmstate(id, state, function (restxt) { 
        res.send(restxt); });
}




