UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

371 lines (155 loc) 27.1 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,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var fs = require("fs"); var generatorUtils = require("../../../util/generatorUtils"); var util = require("util"); var profile = require("../../../util/profile"); var utils = require("../../../util/utils"); var $ = utils.getLocaleString; exports.init = function(cli) { var network = cli.category("network").description($("Commands to manage network resources")); var networkWatchers = network.category("watcher").description($("Commands to manage network watchers")); var packetCaptures = networkWatchers.category("packet-capture").description($("Commands to manage packet captures")); packetCaptures.command("create [resource-group] [watcher-name] [name] [target]").description($("Create a packet capture")).usage("[options] <resource-group> <watcher-name> <name> <target>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --watcher-name <watcher-name>", $("the watcher name")).option("-n, --name <name>", $("the name of the packet capture")).option("-t, --target <target>", $(("the ID of the targeted resource, only" + "\n VM is currently supported"))).option("-b, --bytes-per-packet [bytes-per-packet]", $(("number of bytes captured per packet," + "\n the remaining bytes are truncated"))).option("-y, --bytes-per-session [bytes-per-session]", $("maximum size of the capture output")).option("-l, --time-limit [time-limit]", $(("maximum duration of the capture session" + "\n in seconds"))).option("-o, --storage-id [storage-id]", $(("the ID of the storage account to save" + "\n the packet capture session. Required if no local file path is provided"))).option("-p, --storage-path [storage-path]", $((("the URI of the storage path to save the" + "\n packet capture. Must be a well-formed URI describing the location to save the") + "\n packet capture"))).option("-e, --local-file-path [local-file-path]", $(((("a valid local path on the targeting VM." + "\n Must include the name of the capture file (*.cap). For linux virtual machine it") + "\n must start with /var/captures. Required if no storage ID is provided, otherwise") + "\n optional"))).option("-r, --filters-file [filters-file]", $("file cointaining JSON formatted Filters")).option("-f, --filters [filters]", $((((("filter that is applied to packet" + "\n capture request. Multiple filters can be applied. Should be in JSON format.") + "\n Supported properties: protocol, localIPAddress, remoteIPAddress localPort") + "\n remotePort. Argument format:\"[{\\\"protocol\\\":\\\"TCP\\\"},") + "\n {\\\"protocol\\\":\\\"UDP\\\"}]\""))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, watcherName, name, target, options, _) { var subscription, networkManagementClient, packetCapture, progress, parameters, data; var __frame = { name: "__1", line: 69 }; return __func(_, this, arguments, __1, 5, __frame, function __$__1() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("watcher name : "), watcherName, __cb(_, __frame, 2, 36, function ___(__0, __2) { watcherName = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __3) { name = __3; return cli.interaction.promptIfNotGiven($("target : "), target, __cb(_, __frame, 4, 39, function ___(__0, __4) { options.target = __4; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.packetCaptures.get(resourceGroup, watcherName, name, null, __cb(_, __frame, 12, 63, function ___(__0, __5) { packetCapture = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { if ((e.statusCode === 404)) { packetCapture = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() { _(null, null, 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() { if (packetCapture) { return _(new Error(util.format($("packet capture with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ; parameters = { }; if (options.target) { parameters.target = options.target; } ; if (options.bytesPerPacket) { parameters.bytesToCapturePerPacket = parseInt(options.bytesPerPacket, 10); } ; if (options.bytesPerSession) { parameters.totalBytesPerSession = parseInt(options.bytesPerSession, 10); } ; if (options.timeLimit) { parameters.timeLimitInSeconds = parseInt(options.timeLimit, 10); } ; if (!parameters.storageLocation) { parameters.storageLocation = { }; } ; if (options.storageId) { parameters.storageLocation.storageId = options.storageId; } ; if (options.storagePath) { parameters.storageLocation.storagePath = options.storagePath; } ; if (options.localFilePath) { parameters.storageLocation.filePath = options.localFilePath; } ; return (function __$__1(__then) { if (options.filtersFile) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { data = fs.readFileSync(options.filtersFile); parameters.filters = JSON.parse(data); __then(); }); })(function ___(err, __result) { __catch(function __$__1() { if (err) { return _(new Error(("Error in reading the provided file. Make sure that the file path is correct and it has correct content.\n" + util.inspect(err, { depth: null })))); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(function __$__1() { return (function __$__1(__then) { if ((options.filters && !options.filtersFile)) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { parameters.filters = JSON.parse(options.filters); __then(); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { return _(new Error(util.format($("Cannot parse --filters argument. It should be a valid JSON. Received input is:\n %s;\n Exception details: %s"), options.filters, e))); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(function __$__1() { generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Creating packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.packetCaptures.create(resourceGroup, watcherName, name, parameters, __cb(_, __frame, 81, 63, function ___(__0, __6) { packetCapture = __6; _(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(packetCapture, generatorUtils.traverse); _(); }); }); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }); }); packetCaptures.command("delete [resource-group] [watcher-name] [name]").description($("Delete a packet capture")).usage("[options] <resource-group> <watcher-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --watcher-name <watcher-name>", $("the watcher name")).option("-n, --name <name>", $("the name of the packet capture")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, watcherName, name, options, _) { var subscription, networkManagementClient, packetCapture, progress; var __frame = { name: "__2", line: 166 }; return __func(_, this, arguments, __2, 4, __frame, function __$__2() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __2) { resourceGroup = __2; return cli.interaction.promptIfNotGiven($("watcher name : "), watcherName, __cb(_, __frame, 2, 36, function ___(__0, __3) { watcherName = __3; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __4) { name = __4; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.packetCaptures.get(resourceGroup, watcherName, name, null, __cb(_, __frame, 11, 63, function ___(__0, __5) { packetCapture = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { if ((e.statusCode === 404)) { packetCapture = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, 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() { if (!packetCapture) { return _(new Error(util.format($("packet capture with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; return (function __$__2(_) { var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete packet capture \"%s\"? [y/n] "), name), __cb(_, __frame, 26, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -165, 17, function ___(__0, __6) { return (function __$__2(__then) { if (__6) { cli.output.info(util.format($("packet capture \"%s\" was not deleted and still exists in the resource group \"%s\""), name, resourceGroup)); return _(null); } else { __then(); } ; })(function __$__2() { progress = cli.interaction.progress(util.format($("Deleting packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.packetCaptures.deleteMethod(resourceGroup, watcherName, name, __cb(_, __frame, 33, 63, function ___(__0, __7) { packetCapture = __7; cli.output.info(util.format($("packet capture \"%s\" was successfully deleted from resource group \"%s\""), name, resourceGroup)); _(null, null, true); }, 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() { _(); }); }); }); }, true)); }); }); }, true)); }, true)); }, true)); }); }); packetCaptures.command("show [resource-group] [watcher-name] [name]").description($("Show a packet capture")).usage("[options] <resource-group> <watcher-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --watcher-name <watcher-name>", $("the watcher name")).option("-n, --name <name>", $("the name of the packet capture")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, watcherName, name, options, _) { var subscription, networkManagementClient, packetCapture, progress; var __frame = { name: "__3", line: 213 }; return __func(_, this, arguments, __3, 4, __frame, function __$__3() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("watcher name : "), watcherName, __cb(_, __frame, 2, 36, function ___(__0, __2) { watcherName = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __3) { name = __3; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.packetCaptures.get(resourceGroup, watcherName, name, null, __cb(_, __frame, 11, 63, function ___(__0, __4) { packetCapture = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { if ((e.statusCode === 404)) { packetCapture = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__3() { _(null, null, 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() { if (!packetCapture) { cli.output.warn(util.format($("packet capture with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ; cli.interaction.formatOutput(packetCapture, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }, true)); }); }); packetCaptures.command("list [resource-group] [watcher-name]").description($("List packet captures")).usage("[options] <resource-group> <watcher-name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --watcher-name <watcher-name>", $("the watcher name")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, watcherName, options, _) { var subscription, networkManagementClient, packetCapture, progress; var __frame = { name: "__4", line: 248 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() { options.resourceGroup = resourceGroup; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); packetCapture = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function __$__4(__then) { if ((typeof networkManagementClient.packetCaptures.listAll != "function")) { return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("network watcher : "), watcherName, __cb(_, __frame, 10, 40, function ___(__0, __2) { watcherName = __2; progress = cli.interaction.progress($("Getting the packet captures")); return networkManagementClient.packetCaptures.list(resourceGroup, watcherName, __cb(_, __frame, 12, 65, function ___(__0, __3) { packetCapture = __3; __then(); }, true)); }, true)); }, true)); } else { return (function __$__4(__then) { if (options.resourceGroup) { return cli.interaction.promptIfNotGiven($("network watcher : "), watcherName, __cb(_, __frame, 15, 42, function ___(__0, __4) { watcherName = __4; progress = cli.interaction.progress($("Getting the packet captures")); return networkManagementClient.packetCaptures.list(resourceGroup, watcherName, __cb(_, __frame, 17, 67, function ___(__0, __5) { packetCapture = __5; __then(); }, true)); }, true)); } else { return cli.interaction.promptIfNotGiven($("network watcher : "), watcherName, __cb(_, __frame, 19, 42, function ___(__0, __6) { watcherName = __6; progress = cli.interaction.progress($("Getting the packet captures")); return networkManagementClient.packetCaptures.listAll(watcherName, __cb(_, __frame, 21, 67, function ___(__0, __7) { packetCapture = __7; __then(); }, true)); }, true)); } ; })(__then); } ; })(function __$__4() { _(null, null, 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() { cli.interaction.formatOutput(packetCapture, function(packetCapture) { if ((!packetCapture || (packetCapture.length === 0))) { cli.output.warn($("No packet captures found")); } else { cli.output.table(packetCapture, function(row, item) { generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); }); packetCaptures.command("status [resource-group] [watcher-name] [name]").description($("Perform get status operation on a packet capture")).usage("[options] <resource-group> <watcher-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --watcher-name <watcher-name>", $("the watcher name")).option("-n, --name <name>", $("the name of the packet capture")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(resourceGroup, watcherName, name, options, _) { var subscription, networkManagementClient, packetCapture, progress; var __frame = { name: "__5", line: 294 }; return __func(_, this, arguments, __5, 4, __frame, function __$__5() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("watcher name : "), watcherName, __cb(_, __frame, 2, 36, function ___(__0, __2) { watcherName = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __3) { name = __3; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return networkManagementClient.packetCaptures.get(resourceGroup, watcherName, name, null, __cb(_, __frame, 12, 63, function ___(__0, __4) { packetCapture = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__5() { if (e) { if ((e.statusCode === 404)) { packetCapture = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__5() { _(null, null, 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() { if (!packetCapture) { return _(new Error(util.format($("a packet capture with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; progress = cli.interaction.progress(util.format($("Performing get status operation on a packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return networkManagementClient.packetCaptures.getStatus(resourceGroup, watcherName, name, __cb(_, __frame, 28, 63, function ___(__0, __5) { packetCapture = __5; _(null, null, 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(packetCapture, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }); }); packetCaptures.command("stop [resource-group] [watcher-name] [name]").description($("Perform stop operation on a packet capture")).usage("[options] <resource-group> <watcher-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --watcher-name <watcher-name>", $("the watcher name")).option("-n, --name <name>", $("the name of the packet capture")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __6(resourceGroup, watcherName, name, options, _) { var subscription, networkManagementClient, packetCapture, progress; var __frame = { name: "__6", line: 337 }; return __func(_, this, arguments, __6, 4, __frame, function __$__6() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("watcher name : "), watcherName, __cb(_, __frame, 2, 36, function ___(__0, __2) { watcherName = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __3) { name = __3; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() { return networkManagementClient.packetCaptures.get(resourceGroup, watcherName, name, null, __cb(_, __frame, 12, 63, function ___(__0, __4) { packetCapture = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__6() { if (e) { if ((e.statusCode === 404)) { packetCapture = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, 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() { if (!packetCapture) { return _(new Error(util.format($("a packet capture with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; progress = cli.interaction.progress(util.format($("Performing stop operation on a packet capture \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() { return networkManagementClient.packetCaptures.stop(resourceGroup, watcherName, name, __cb(_, __frame, 28, 63, function ___(__0, __5) { packetCapture = __5; _(null, null, true); }, 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(packetCapture, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }); });};