/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var fs = require("fs");
















var ss = require("streamline/lib/streams/streams");
var util = require("util");
var batchUtil = require("./batch.util");
var batchShowUtil = require("./batch.showUtil");
var utils = require("../../util/utils");
var startProgress = batchUtil.startProgress;
var endProgress = batchUtil.endProgress;

var $ = utils.getLocaleString;




exports.init = function(cli) {


  batchUtil.init(cli);




  var batch = cli.category("batch").description($("Commands to manage your Batch objects"));


  var logger = cli.output;

  var interaction = cli.interaction;

  var node = batch.category("node").description($("Commands to manage your Batch compute nodes"));


  var nodeUser = batch.category("node-user").description($("Commands to manage your Batch compute node users"));


  var remoteLoginSettings = node.category("remote-login-settings").description($("The remote login settings for a Batch compute node"));


  var remoteDesktop = node.category("remote-desktop").description($("The remote desktop protocol for a Batch compute node"));


  var nodeSchedulingSettings = node.category("scheduling").description($("The scheduling property for a Batch compute node"));


  nodeUser.command("create [pool-id] [node-id] [user-name]").description($("Adds a user account to the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the machine on which you want to create a user account")).option("-n, --user-name <user-name>", $("the name of the user account to be created")).option("-w, --user-password [user-password]", $("the password of the user account")).option("--ssh-public-key [ssh-public-key]", $("the ssh public key that can be used for remote login to the compute node; can only be specified for Linux nodes")).option("--admin", $("whether the account should be an administrator on the compute node")).option("--expiry-time [expiry-time]", $("the time at which the account should expire")).appendBatchAccountOption().execute(addUser);











  nodeUser.command("delete [pool-id] [node-id] [user-name]").description($("Deletes a user account from the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the machine on which you want to delete a user account")).option("-n, --user-name <user-name>", $("the name of user account to delete")).option("-q, --quiet", $("remove the specified user without confirmation")).appendBatchAccountOption().execute(deleteUser);








  nodeUser.command("set [pool-id] [node-id] [user-name]").description($("Update the properties of a user account on the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the machine on which you want to update a user account")).option("-n, --user-name <user-name>", $("the name of the user account to update")).option("-w, --user-password [user-password]", $("the password of the user account")).option("--ssh-public-key [ssh-public-key]", $("the ssh public key that can be used for remote login to the compute node; can only be specified for Linux nodes")).option("--expiry-time [expiry-time]", $("the time at which the account should expire")).appendBatchAccountOption().execute(updateUser);










  node.command("show [pool-id] [node-id]").description($("Show information about the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node that you want to get information about")).appendODataFilterOption(true, false, false).appendBatchAccountOption().execute(showNode);







  node.command("list [pool-id]").description($("Lists the compute nodes in the specified pool")).option("-p, --pool-id <pool-Id>", $("the id of the pool from which you want to list nodes")).appendODataFilterOption(true, true, false).appendBatchAccountOption().execute(listNode);






  node.command("reboot [pool-id] [node-id]").description($("Restarts the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node that you want to restart")).option("-o, --reboot-option <reboot-option>", $("when to reboot the compute node and what to do with currently running tasks")).option("-q, --quiet", $("reboot the specified compute node without confirmation")).appendBatchAccountOption().execute(rebootNode);








  node.command("reimage [pool-id] [node-id]").description($("Reinstalls the operating system on the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node that you want to reimage")).option("-o, --reimage-option <reimage-option>", $("when to reimage the compute node and what to do with currently running tasks")).option("-q, --quiet", $("reimage the specified compute node without confirmation")).appendBatchAccountOption().execute(reimageNode);








  nodeSchedulingSettings.command("disable [pool-id] [node-id]").description($("Disable scheduling on the Batch compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node that you want to disable scheduling")).option("-o, --disable-option <disable-option>", $("option of what to do with currently running tasks when to disable scheduling on the compute node")).appendBatchAccountOption().execute(disableSchedulingNode);







  nodeSchedulingSettings.command("enable [pool-id] [node-id]").description($("Enable scheduling on the Batch compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node that you want to enable scheduling")).appendBatchAccountOption().execute(enableSchedulingNode);






  remoteDesktop.command("show [pool-id] [node-id] [rdp-file]").description($("Gets the Remote Desktop Protocol file for the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node for which you want to get the Remote Desktop Protocol file")).option("-f, --rdp-file <rdp-file>", $("the path where you would like to save the Remote Desktop Protocol file")).option("-q, --quiet", $("overwrite the destination Remote Desktop Protocol file without confirmation")).appendBatchAccountOption().execute(getRemoteDesktop);








  remoteLoginSettings.command("show [pool-id] [node-id]").description($("Gets the remote login settings for the specified node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node for which you want to get the remote login settings")).appendBatchAccountOption().execute(getRemoteLoginSettings);


















  function addUser(poolId, nodeId, userName, options, _) { var client, tips, batchOptions, param; var __frame = { name: "addUser", line: 169 }; return __func(_, this, arguments, addUser, 4, __frame, function __$addUser() {
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 8, 25, function ___(__0, __2) { nodeId = __2;
          if (!userName) {
            userName = options.userName; } ;

          return interaction.promptIfNotGiven($("User name: "), userName, __cb(_, __frame, 12, 27, function ___(__0, __3) { userName = __3;

            client = batchUtil.createBatchServiceClient(options);
            tips = util.format($("Adding node user %s"), userName);
            batchOptions = { };
            batchOptions.computeNodeAddUserOptions = batchUtil.getBatchOperationDefaultOption();

            param = { };
            param.name = userName;
            if (options.userPassword) {
              param.password = options.userPassword; } ;

            if (options.admin) {
              param.isAdmin = true; } ;

            if (options.expiryTime) {
              param.expiryTime = options.expiryTime; } ;

            if (options.sshPublicKey) {
              param.sshPublicKey = options.sshPublicKey; } ;


            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$addUser() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$addUser() {

                        return client.computeNodeOperations.addUser(poolId, nodeId, param, batchOptions, __cb(_, __frame, 36, 35, __then, true)); }); })(function ___(err, __result) { __catch(function __$addUser() { if (err) {

                          if (batchUtil.isNotFoundException(err)) {
                            return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                           else {
                            if (err.message) {
                              if ((typeof err.message === "object")) {
                                err.message = err.message.value; } ; } ;



                            return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$addUser() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$addUser() {



                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$addUser() {


                logger.verbose(util.format($("User %s has been added to node %s successfully"), userName, nodeId)); _(); }); }); }, true)); }, true)); }, true)); }); };










  function deleteUser(poolId, nodeId, userName, options, _) { var client, tips, batchOptions; var __frame = { name: "deleteUser", line: 234 }; return __func(_, this, arguments, deleteUser, 4, __frame, function __$deleteUser() {
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 8, 25, function ___(__0, __2) { nodeId = __2;
          if (!userName) {
            userName = options.userName; } ;

          return interaction.promptIfNotGiven($("User name: "), userName, __cb(_, __frame, 12, 27, function ___(__0, __3) { userName = __3;

            client = batchUtil.createBatchServiceClient(options);
            tips = util.format($("Deleting user %s"), userName);
            batchOptions = { };
            batchOptions.computeNodeDeleteUserOptions = batchUtil.getBatchOperationDefaultOption(); return (function __$deleteUser(__then) {

              if (!options.quiet) {
                return interaction.confirm(util.format($("Do you want to delete user %s? "), userName), __cb(_, __frame, 20, 23, function ___(__0, __5) { var __4 = !__5; return (function __$deleteUser(__then) { if (__4) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$deleteUser() {




              startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteUser() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteUser() {


                          return client.computeNodeOperations.deleteUser(poolId, nodeId, userName, batchOptions, __cb(_, __frame, 28, 35, __then, true)); }); })(function ___(err, __result) { __catch(function __$deleteUser() { if (err) {

                            if (batchUtil.isNotFoundException(err)) {
                              return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                             else {
                              if (err.message) {
                                if ((typeof err.message === "object")) {
                                  err.message = err.message.value; } ; } ;



                              return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deleteUser() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deleteUser() {


                      endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deleteUser() {


                  logger.info(util.format($("User %s has been deleted successfully"), userName)); _(); }); }); }); }, true)); }, true)); }, true)); }); };










  function updateUser(poolId, nodeId, userName, options, _) { var client, tips, batchOptions, param; var __frame = { name: "updateUser", line: 290 }; return __func(_, this, arguments, updateUser, 4, __frame, function __$updateUser() {
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 8, 25, function ___(__0, __2) { nodeId = __2;
          if (!userName) {
            userName = options.userName; } ;

          return interaction.promptIfNotGiven($("User name: "), userName, __cb(_, __frame, 12, 27, function ___(__0, __3) { userName = __3;

            client = batchUtil.createBatchServiceClient(options);
            tips = util.format($("Updating node user %s"), userName);
            batchOptions = { };
            batchOptions.computeNodeUpdateUserOptions = batchUtil.getBatchOperationDefaultOption();

            param = { };
            if (options.userPassword) {
              param.password = options.userPassword; } ;

            if (options.expiryTime) {
              param.expiryTime = options.expiryTime; } ;

            if (options.sshPublicKey) {
              param.sshPublicKey = options.sshPublicKey; } ;


            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$updateUser() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$updateUser() {

                        return client.computeNodeOperations.updateUser(poolId, nodeId, userName, param, batchOptions, __cb(_, __frame, 32, 35, __then, true)); }); })(function ___(err, __result) { __catch(function __$updateUser() { if (err) {

                          if (batchUtil.isNotFoundException(err)) {
                            return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                           else {
                            if (err.message) {
                              if ((typeof err.message === "object")) {
                                err.message = err.message.value; } ; } ;



                            return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$updateUser() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$updateUser() {



                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$updateUser() {


                logger.verbose(util.format($("User %s has been updated on node %s successfully"), userName, nodeId)); _(); }); }); }, true)); }, true)); }, true)); }); };









  function showNode(poolId, nodeId, options, _) { var client, tips, batchOptions, node; var __frame = { name: "showNode", line: 350 }; return __func(_, this, arguments, showNode, 3, __frame, function __$showNode() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 9, 25, function ___(__0, __2) { nodeId = __2;
          tips = $("Getting Batch node information");
          batchOptions = { };
          batchOptions.computeNodeGetOptions = batchUtil.getBatchOperationDefaultOption();

          if (options.selectClause) {
            batchOptions.computeNodeGetOptions.select = options.selectClause; } ;


          node = null;
          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showNode() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showNode() {


                      return client.computeNodeOperations.get(poolId, nodeId, batchOptions, __cb(_, __frame, 22, 42, function ___(__0, __3) { node = __3; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$showNode() { if (err) {

                        if (batchUtil.isNotFoundException(err)) {
                          return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                         else {
                          if (err.message) {
                            if ((typeof err.message === "object")) {
                              err.message = err.message.value; } ; } ;



                          return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$showNode() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showNode() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$showNode() {


              batchShowUtil.showComputeNode(node, cli.output); _(); }); }); }, true)); }, true)); }); };








  function listNode(poolId, options, _) { var client, tips, batchOptions, nodes, result, nextLink; var __frame = { name: "listNode", line: 398 }; return __func(_, this, arguments, listNode, 2, __frame, function __$listNode() {
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;

        client = batchUtil.createBatchServiceClient(options);
        tips = $("Listing Batch nodes");
        batchOptions = { };
        batchOptions.computeNodeListOptions = batchUtil.getBatchOperationDefaultOption();

        if (options.selectClause) {
          batchOptions.computeNodeListOptions.select = options.selectClause; } ;

        if (options.filterClause) {
          batchOptions.computeNodeListOptions.filter = options.filterClause; } ;


        nodes = [];
        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listNode() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listNode() {


                    return client.computeNodeOperations.list(poolId, batchOptions, __cb(_, __frame, 22, 48, function ___(__0, __2) { result = __2;
                      result.forEach(function(node) {
                        nodes.push(node); });

                      nextLink = result.odatanextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$listNode() { __more = false;

                          var __6 = nextLink; if (__6) {
                            batchOptions.computeNodeListOptions = batchUtil.getBatchOperationDefaultOption();
                            return client.computeNodeOperations.listNext(nextLink, batchOptions, __cb(_, __frame, 30, 46, function ___(__0, __3) { result = __3;
                              result.forEach(function(node) {
                                nodes.push(node); });

                              nextLink = result.odatanextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }, true)); }); })(function ___(err, __result) { __catch(function __$listNode() { if (err) {


                      if (err.message) {
                        if ((typeof err.message === "object")) {
                          err.message = err.message.value; } ; } ;



                      return _(err); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$listNode() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listNode() {

                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listNode() {


            cli.interaction.formatOutput(nodes, function(outputData) {
              if ((outputData.length === 0)) {
                logger.info($("No node found")); }
               else {
                logger.table(outputData, function(row, item) {
                  row.cell($("Id"), item.id);
                  row.cell($("State"), item.state);
                  row.cell($("VM Size"), item.vmSize);
                  row.cell($("IP Address"), item.ipAddress); }); } ; }); _(); }); }); }, true)); }); };












  function rebootNode(poolId, nodeId, options, _) { var client, tips, batchOptions; var __frame = { name: "rebootNode", line: 467 }; return __func(_, this, arguments, rebootNode, 3, __frame, function __$rebootNode() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 9, 25, function ___(__0, __2) { nodeId = __2;

          tips = util.format($("Rebooting compute node %s"), nodeId);
          batchOptions = { };
          batchOptions.computeNodeRebootOptions = batchUtil.getBatchOperationDefaultOption(); return (function __$rebootNode(__then) {

            if (!options.quiet) {
              return interaction.confirm(util.format($("Do you want to reboot node %s? "), nodeId), __cb(_, __frame, 16, 23, function ___(__0, __4) { var __3 = !__4; return (function __$rebootNode(__then) { if (__3) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$rebootNode() {




            if (options.rebootOption) {
              batchOptions.nodeRebootOption = options.rebootOption; } ;


            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$rebootNode() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$rebootNode() {


                        return client.computeNodeOperations.reboot(poolId, nodeId, batchOptions, __cb(_, __frame, 28, 35, __then, true)); }); })(function ___(err, __result) { __catch(function __$rebootNode() { if (err) {

                          if (batchUtil.isNotFoundException(err)) {
                            return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                           else {
                            if (err.message) {
                              if ((typeof err.message === "object")) {
                                err.message = err.message.value; } ; } ;



                            return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$rebootNode() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$rebootNode() {


                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$rebootNode() {


                logger.info(util.format($("Node %s has been rebooted successfully"), nodeId)); _(); }); }); }); }, true)); }, true)); }); };









  function reimageNode(poolId, nodeId, options, _) { var client, tips, batchOptions; var __frame = { name: "reimageNode", line: 522 }; return __func(_, this, arguments, reimageNode, 3, __frame, function __$reimageNode() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 9, 25, function ___(__0, __2) { nodeId = __2;
          tips = util.format($("Reimaging compute node %s"), nodeId);
          batchOptions = { };
          batchOptions.computeNodeReimageOptions = batchUtil.getBatchOperationDefaultOption(); return (function __$reimageNode(__then) {

            if (!options.quiet) {
              return interaction.confirm(util.format($("Do you want to reimage node %s? "), nodeId), __cb(_, __frame, 15, 23, function ___(__0, __4) { var __3 = !__4; return (function __$reimageNode(__then) { if (__3) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$reimageNode() {




            if (options.reimageOption) {
              batchOptions.nodeReimageOption = options.reimageOption; } ;


            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$reimageNode() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$reimageNode() {


                        return client.computeNodeOperations.reimage(poolId, nodeId, batchOptions, __cb(_, __frame, 27, 35, __then, true)); }); })(function ___(err, __result) { __catch(function __$reimageNode() { if (err) {

                          if (batchUtil.isNotFoundException(err)) {
                            return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                           else {
                            if (err.message) {
                              if ((typeof err.message === "object")) {
                                err.message = err.message.value; } ; } ;



                            return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$reimageNode() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$reimageNode() {


                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$reimageNode() {


                logger.info(util.format($("Node %s has been reimaged successfully"), nodeId)); _(); }); }); }); }, true)); }, true)); }); };









  function disableSchedulingNode(poolId, nodeId, options, _) { var client, tips, batchOptions; var __frame = { name: "disableSchedulingNode", line: 576 }; return __func(_, this, arguments, disableSchedulingNode, 3, __frame, function __$disableSchedulingNode() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 9, 25, function ___(__0, __2) { nodeId = __2;
          tips = util.format($("Disabling scheduling at compute node %s"), nodeId);
          batchOptions = { };
          batchOptions.computeNodeDisableSchedulingOptions = batchUtil.getBatchOperationDefaultOption();

          if (options.disableOption) {
            batchOptions.nodeDisableSchedulingOption = options.disableOption; } ;


          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$disableSchedulingNode() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$disableSchedulingNode() {


                      return client.computeNodeOperations.disableScheduling(poolId, nodeId, batchOptions, __cb(_, __frame, 21, 35, __then, true)); }); })(function ___(err, __result) { __catch(function __$disableSchedulingNode() { if (err) {

                        if (batchUtil.isNotFoundException(err)) {
                          return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                         else {
                          if (err.message) {
                            if ((typeof err.message === "object")) {
                              err.message = err.message.value; } ; } ;



                          return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$disableSchedulingNode() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$disableSchedulingNode() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$disableSchedulingNode() {


              logger.info(util.format($("Node %s has been disabled scheduling successfully"), nodeId)); _(); }); }); }, true)); }, true)); }); };









  function enableSchedulingNode(poolId, nodeId, options, _) { var client, tips, batchOptions; var __frame = { name: "enableSchedulingNode", line: 624 }; return __func(_, this, arguments, enableSchedulingNode, 3, __frame, function __$enableSchedulingNode() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 9, 25, function ___(__0, __2) { nodeId = __2;
          tips = util.format($("Enabling scheduling at compute node %s"), nodeId);
          batchOptions = { };
          batchOptions.computeNodeEnableSchedulingOptions = batchUtil.getBatchOperationDefaultOption();

          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$enableSchedulingNode() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$enableSchedulingNode() {


                      return client.computeNodeOperations.enableScheduling(poolId, nodeId, batchOptions, __cb(_, __frame, 17, 35, __then, true)); }); })(function ___(err, __result) { __catch(function __$enableSchedulingNode() { if (err) {

                        if (batchUtil.isNotFoundException(err)) {
                          return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                         else {
                          if (err.message) {
                            if ((typeof err.message === "object")) {
                              err.message = err.message.value; } ; } ;



                          return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$enableSchedulingNode() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$enableSchedulingNode() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$enableSchedulingNode() {


              logger.info(util.format($("Node %s has been enabled scheduling successfully"), nodeId)); _(); }); }); }, true)); }, true)); }); };










  function getRemoteDesktop(poolId, nodeId, rdpFile, options, _) { var client, force, tips, batchOptions, stream, reader, data, fd; var __frame = { name: "getRemoteDesktop", line: 669 }; return __func(_, this, arguments, getRemoteDesktop, 4, __frame, function __$getRemoteDesktop() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 9, 25, function ___(__0, __2) { nodeId = __2;
          if (!rdpFile) {
            rdpFile = options.autoscaleFormula; } ;

          return interaction.promptIfNotGiven($("RDP file: "), rdpFile, __cb(_, __frame, 13, 26, function ___(__0, __3) { rdpFile = __3;



            force = !!options.quiet;
            return utils.fileExists(rdpFile, __cb(_, __frame, 18, 14, function ___(__0, __4) { return (function __$getRemoteDesktop(__then) { if (__4) { return (function __$getRemoteDesktop(__then) {
                    if ((force !== true)) {
                      return interaction.confirm(util.format($("Do you want to overwrite file %s? "), rdpFile), __cb(_, __frame, 20, 28, function ___(__0, __5) { force = __5;
                        if ((force !== true)) { return _(null); } ; __then(); }, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$getRemoteDesktop() {





                tips = util.format($("Getting RDP at node %s"), nodeId);
                batchOptions = { };
                batchOptions.computeNodeGetRemoteDesktopOptions = batchUtil.getBatchOperationDefaultOption();

                startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getRemoteDesktop() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getRemoteDesktop() {



                            return client.computeNodeOperations.getRemoteDesktop(poolId, nodeId, batchOptions, __cb(_, __frame, 35, 44, function ___(__0, __6) { stream = __6; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$getRemoteDesktop() { if (err) {

                              if (batchUtil.isNotFoundException(err)) {
                                return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                               else {
                                if (err.message) {
                                  if ((typeof err.message === "object")) {
                                    err.message = err.message.value; } ; } ;



                                return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$getRemoteDesktop() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getRemoteDesktop() {


                        endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getRemoteDesktop() {


                    reader = new ss.ReadableStream(stream);
                    return reader.read(__cb(_, __frame, 53, 22, function ___(__0, __7) { data = __7;
                      fd = fs.openSync(rdpFile, "w");
                      return fs.write(fd, data, 0, data.length, 0, __cb(_, __frame, 55, 7, function __$getRemoteDesktop() {
                        fs.close(fd); _(); }, true)); }, true)); }); }); }); }, true)); }, true)); }, true)); }, true)); }); };









  function getRemoteLoginSettings(poolId, nodeId, options, _) { var client, tips, batchOptions; var __frame = { name: "getRemoteLoginSettings", line: 735 }; return __func(_, this, arguments, getRemoteLoginSettings, 3, __frame, function __$getRemoteLoginSettings() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.poolId; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeId) {
          nodeId = options.nodeId; } ;

        return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 9, 25, function ___(__0, __2) { nodeId = __2;

          tips = util.format($("Getting remote login settings for node %s"), nodeId);
          batchOptions = { };
          batchOptions.computeNodeGetRemoteLoginSettingsOptions = batchUtil.getBatchOperationDefaultOption();

          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getRemoteLoginSettings() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getRemoteLoginSettings() {


                      return client.computeNodeOperations.getRemoteLoginSettings(poolId, nodeId, batchOptions, __cb(_, __frame, 18, 46, function ___(__0, __3) { settings = __3; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$getRemoteLoginSettings() { if (err) {

                        if (batchUtil.isNotFoundException(err)) {
                          return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
                         else {
                          if (err.message) {
                            if ((typeof err.message === "object")) {
                              err.message = err.message.value; } ; } ;



                          return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$getRemoteLoginSettings() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getRemoteLoginSettings() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getRemoteLoginSettings() {


              batchShowUtil.showRemoteLoginSettings(settings, cli.output); _(); }); }); }, true)); }, true)); }); };};
