UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

474 lines (187 loc) 24.5 kB
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch; var util = require("util"); var profile = require("../../../util/profile"); var utils = require("../../../util/utils"); var help = require("./help"); var $ = utils.getLocaleString; var SMC = function SMC(options) { return utils.createServerManagementClient(profile.current.getSubscription(options.subscription));}; exports.init = function(cli) { var log = cli.output; var sm = cli.category("servermanagement").description($("Commands to manage Azure Server Managment resources")); var gateway = sm.category("gateway").description($("Commands to manage Azure Server Management Tools Gateway instances")); var node = sm.category("node").description($("Commands to manage Azure Server Management Tools Node instances")); var session = sm.category("session").description($("Commands to manage Azure Server Management Tools Sessions")); var powershell = sm.category("powershell").description($("Commands to invoke powershelll commands on a Azure Server Management Tools node")); gateway.command("create [resource-group] [location] [name]").description($("Create a server management gateway")).usage("[options] <resource-group> <location> <name>").option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.location.option, $(help.location.description)).option(help.gatewayName.option, $(help.gatewayName.description)).option(help.autoUpgrade.option, $(help.autoUpgrade.description)).option(help.subscription.option, $(help.subscription.description)).option(help.tags.option, $(help.tags.create)).execute(function __1(resourceGroup, location, gatewayName, options, _) { var result, progress; var __frame = { name: "__1", line: 54 }; return __func(_, this, arguments, __1, 4, __frame, function __$__1() { if (!resourceGroup) { return _(null, cli.missingArgument("resource-group")); } ; if (!location) { return _(null, cli.missingArgument("location")); } ; if (!gatewayName) { return _(null, cli.missingArgument("name")); } ; options = (options || { }); options.location = location; progress = cli.interaction.progress(util.format($("Creating server management gateway %s"), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return SMC(options).gateway.create(resourceGroup, gatewayName, options, __cb(_, __frame, 19, 19, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__1() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__1() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table([data,], formatGateway); } ; }); _(); }); }); }); }); gateway.command("list [resource-group]").description($("List registered gateways")).option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __2(resourceGroup, options, _) { var progress, result; var __frame = { name: "__2", line: 91 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() { progress = cli.interaction.progress($("Listing registered gateways")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function __$__2(__then) { if (resourceGroup) { return SMC(options).gateway.listForResourceGroup(resourceGroup, options, __cb(_, __frame, 6, 21, function ___(__0, __1) { result = __1; __then(); }, true)); } else { return SMC(options).gateway.list(options, __cb(_, __frame, 9, 21, function ___(__0, __2) { result = __2; __then(); }, true)); } ; })(function __$__2() { _(null, null, true); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__2() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__2() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table(data, formatGateway); } ; }); _(); }); }); }); }); gateway.command("show <resource-group> <name>").description($("Show detailed gateway information")).usage("[options] <resource-group> <name>").option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.gatewayName.option, $(help.gatewayName.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __3(resourceGroup, gatewayName, options, _) { var progress, result; var __frame = { name: "__3", line: 121 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() { progress = cli.interaction.progress($("Showing gateway details")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { options.expand = "status"; return SMC(options).gateway.get(resourceGroup, gatewayName, options, __cb(_, __frame, 6, 19, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__3() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__3() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table([data,], formatGatewayDetailed); } ; }); _(); }); }); }); }); gateway.command("delete <resource-group> <name>").description($("Delete a gateway")).option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.gatewayName.option, $(help.gatewayName.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __4(resourceGroup, gatewayName, options, _) { var progress, result; var __frame = { name: "__4", line: 146 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() { progress = cli.interaction.progress(util.format($("Deleting gateway %s"), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return SMC(options).gateway.deleteMethod(resourceGroup, gatewayName, options, __cb(_, __frame, 6, 19, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__4() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__4() { _(); }); }); }); }); node.command("create [resource-group] [location] [gateway-name] [name]").description($("Create a server management node")).usage("[options] <resource-group> <location> <gateway-name> <name>").option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.location.option, $(help.location.description)).option(help.gatewayName.option2, $(help.gatewayName.description)).option(help.nodeName.option, $(help.nodeName.description)).option(help.userName.option, $(help.userName.description)).option(help.password.option, $(help.password.description)).option(help.connection.option, $(help.connection.description)).option(help.tags.option, $(help.tags.create)).option(help.subscription.option, $(help.subscription.description)).execute(function __5(resourceGroup, location, gatewayName, nodeName, options, _) { var result, progress, gw; var __frame = { name: "__5", line: 170 }; return __func(_, this, arguments, __5, 5, __frame, function __$__5() { options = (options || { }); if (!resourceGroup) { return _(null, cli.missingArgument("resource-group")); } ; if (!location) { return _(null, cli.missingArgument("location")); } ; if (!gatewayName) { return _(null, cli.missingArgument("gateway-name")); } ; if (!nodeName) { return _(null, cli.missingArgument("name")); } ; if (!options.userName) { return _(null, cli.missingArgument("user-name")); } ; if (!options.connectionName) { options.connectionName = nodeName; } ; return cli.interaction.promptPasswordIfNotGiven($(help.password.description), options.password, __cb(_, __frame, 22, 41, function ___(__0, __1) { options.password = __1; options.location = location; progress = cli.interaction.progress(util.format($("Creating server management node %s"), nodeName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return SMC(options).gateway.get(resourceGroup, gatewayName, __cb(_, __frame, 31, 19, function ___(__0, __2) { gw = __2; options.gatewayId = gw.id; return SMC(options).node.create(resourceGroup, nodeName, options, __cb(_, __frame, 35, 16, function ___(__0, __3) { result = __3; _(null, null, true); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__5() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__5() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table([data,], formatNode); } ; }); _(); }); }); }, true)); }); }); node.command("list [resource-group]").description($("List registered nodes")).option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __6(resourceGroup, options, _) { var progress, result; var __frame = { name: "__6", line: 223 }; return __func(_, this, arguments, __6, 2, __frame, function __$__6() { progress = cli.interaction.progress($("Listing registered nodes")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() { return (function __$__6(__then) { if (resourceGroup) { return SMC(options).node.listForResourceGroup(resourceGroup, options, __cb(_, __frame, 6, 18, function ___(__0, __1) { result = __1; __then(); }, true)); } else { return SMC(options).node.list(options, __cb(_, __frame, 9, 18, function ___(__0, __2) { result = __2; __then(); }, true)); } ; })(function __$__6() { _(null, null, true); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__6() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__6() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table(data, formatNode); } ; }); _(); }); }); }); }); node.command("show <resource-group> <name>").description($("Show node information")).usage("[options] <resource-group> <name>").option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.nodeName.option, $(help.nodeName.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __7(resourceGroup, nodeName, options, _) { var progress, result; var __frame = { name: "__7", line: 253 }; return __func(_, this, arguments, __7, 3, __frame, function __$__7() { progress = cli.interaction.progress($("Showing node details")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() { return SMC(options).node.get(resourceGroup, nodeName, options, __cb(_, __frame, 5, 16, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__7() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__7() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table([data,], formatNode); } ; }); _(); }); }); }); }); node.command("delete <resource-group> <name>").description($("Delete a node")).option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.nodeName.option, $(help.nodeName.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __8(resourceGroup, nodeName, options, _) { var progress, result; var __frame = { name: "__8", line: 277 }; return __func(_, this, arguments, __8, 3, __frame, function __$__8() { progress = cli.interaction.progress(util.format($("Deleting node %s"), nodeName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() { return SMC(options).node.deleteMethod(resourceGroup, nodeName, options, __cb(_, __frame, 6, 16, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__8() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__8() { _(); }); }); }); }); session.command("create [resource-group] [node-name] [name]").description($("Create a server management session")).usage("[options] <resource-group> <node-name> <name>").option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.nodeName.option2, $(help.nodeName.description)).option(help.sessionName.option, $(help.sessionName.description)).option(help.userName.option, $(help.userName.description)).option(help.password.option, $(help.password.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __9(resourceGroup, nodeName, sessionName, options, _) { var result, progress; var __frame = { name: "__9", line: 298 }; return __func(_, this, arguments, __9, 4, __frame, function __$__9() { if (!resourceGroup) { return _(null, cli.missingArgument("resource-group")); } ; if (!nodeName) { return _(null, cli.missingArgument("node-name")); } ; if (!sessionName) { return _(null, cli.missingArgument("name")); } ; if (!options.userName) { return _(null, cli.missingArgument("user-name")); } ; return cli.interaction.promptPasswordIfNotGiven($(help.password.description), options.password, __cb(_, __frame, 15, 41, function ___(__0, __1) { options.password = __1; options = (options || { }); options.location = nodeName; progress = cli.interaction.progress(util.format($("Creating server management session %s"), sessionName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() { return SMC(options).session.create(resourceGroup, nodeName, sessionName, options, __cb(_, __frame, 24, 19, function ___(__0, __2) { result = __2; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__9() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__9() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table([data,], formatSession); } ; }); _(); }); }); }, true)); }); }); session.command("show <resource-group> <node-name> <name>").description($("Show detailed session information")).usage("[options] <resource-group> <node-name> <name>").option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.nodeName.option2, $(help.nodeName.description)).option(help.sessionName.option, $(help.sessionName.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __10(resourceGroup, nodeName, sessionName, options, _) { var progress, result; var __frame = { name: "__10", line: 343 }; return __func(_, this, arguments, __10, 4, __frame, function __$__10() { progress = cli.interaction.progress($("Showing session details")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__10() { options.expand = "status"; return SMC(options).session.get(resourceGroup, nodeName, sessionName, options, __cb(_, __frame, 6, 19, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__10() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__10() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table([data,], formatSession); } ; }); _(); }); }); }); }); session.command("delete <resource-group> <node-name> <name>").description($("Delete a session")).option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.nodeName.option2, $(help.nodeName.description)).option(help.sessionName.option, $(help.sessionName.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __11(resourceGroup, sessionName, options, _) { var progress, result; var __frame = { name: "__11", line: 369 }; return __func(_, this, arguments, __11, 3, __frame, function __$__11() { progress = cli.interaction.progress(util.format($("Deleting session %s"), sessionName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__11() { return SMC(options).session.deleteMethod(resourceGroup, sessionName, options, __cb(_, __frame, 6, 19, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__11() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__11() { _(); }); }); }); }); powershell.command("create <resource-group> <node-name> <session-name>").description($("Create a powershell session")).option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.nodeName.option2, $(help.nodeName.description)).option(help.sessionName.option2, $(help.sessionName.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __12(resourceGroup, nodeName, sessionName, options, _) { var progress, result; var __frame = { name: "__12", line: 387 }; return __func(_, this, arguments, __12, 4, __frame, function __$__12() { progress = cli.interaction.progress($("Creating powershell session")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__12() { return SMC(options).powerShell.createSession(resourceGroup, nodeName, sessionName, "00000000-0000-0000-0000-000000000000", __cb(_, __frame, 6, 22, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__12() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__12() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.table([data,], formatPsSession); } ; }); _(); }); }); }); }); powershell.command("invoke <resource-group> <node-name> <session-name> <powershell-sessionid>").description($("Invoke a powershell script on a session")).option(help.resourceGroup.option, $(help.resourceGroup.description)).option(help.nodeName.option2, $(help.nodeName.description)).option(help.sessionName.option2, $(help.sessionName.description)).option(help.powershellSessionId.option, $(help.powershellSessionId.description)).option(help.command.option, $(help.command.description)).option(help.subscription.option, $(help.subscription.description)).execute(function __13(resourceGroup, nodeName, sessionName, powershellSessionId, options, _) { var progress, result; var __frame = { name: "__13", line: 415 }; return __func(_, this, arguments, __13, 5, __frame, function __$__13() { progress = cli.interaction.progress($("Invoking powershell script")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__13() { return SMC(options).powerShell.invokeCommand(resourceGroup, nodeName, sessionName, powershellSessionId, options, __cb(_, __frame, 6, 22, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__13() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__13() { cli.interaction.formatOutput(result, function(data) { if (options.json) { log.json(data); } else { log.data(data.results[0].value); } ; }); _(); }); }); }); });}; function formatGateway(row, gateway) { var resourceGroup = gateway.id.match(/\/resourcegroups\/(.+?)\/(.*)/)[1]; row.cell($("Gateway"), gateway.name); row.cell($("Resource Group"), resourceGroup); row.cell($("Location"), gateway.location); row.cell($("Auto Upgrade"), gateway.autoUpgrade);}; function formatGatewayDetailed(row, gateway) { for (var each in gateway.instances) { row.cell($("Gateway"), gateway.name); row.cell($("Instance"), gateway.instances[each].name); row.cell($("Mem Avail (MB)"), gateway.instances[each].availableMemoryMByte); row.cell($("CPU (gateway)"), gateway.instances[each].gatewayCpuUtilizationPercent); row.cell($("CPU (total)"), gateway.instances[each].totalCpuUtilizationPercent); row.cell($("Version"), gateway.instances[each].gatewayVersion); row.cell($("CPUs"), gateway.instances[each].logicalProcessorCount); row.cell($("Working Set (MB)"), gateway.instances[each].gatewayWorkingSetMByte); };}; function formatNode(row, node) { var resourceGroup = node.id.match(/\/resourcegroups\/(.+?)\/(.*)/)[1]; var gatewayName = node.gatewayId.match(/\/gateways\/(.*)/)[1]; row.cell($("Node"), node.name); row.cell($("Connection"), node.connectionName); row.cell($("Resource Group"), resourceGroup); row.cell($("Gateway"), gatewayName); row.cell($("Location"), node.location);}; function formatSession(row, session) { row.cell($("Session"), session.name); row.cell($("User Name"), session.userName);}; function formatPsSession(row, session) { row.cell($("SessionId"), session.sessionId);};