azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
304 lines (132 loc) • 21.7 kB
JavaScript
/*** 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 generatorUtils = require("../../../util/generatorUtils");
var util = require("util");
var validation = require("../../../util/validation");
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 routeTables = network.category("route-table").description($("Commands to manage route tables"));
var routes = routeTables.category("route").description($("Commands to manage routes"));
var nextHopTypeVirtualAppliance = "VirtualAppliance";
routes.command("create [resource-group] [route-table-name] [name] [address-prefix] [next-hop-type]").description($("Create a route")).usage("[options] <resource-group> <route-table-name> <name> <address-prefix> <next-hop-type>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-r, --route-table-name <route-table-name>", $("the route table name")).option("-n, --name <name>", $("the name of the route")).option("-a, --address-prefix <address-prefix>", $(("the destination CIDR to which the route" + "\n applies"))).option("-p, --next-hop-ip-address [next-hop-ip-address]", $((("the IP address packets should be" + "\n forwarded to. Next hop values are only allowed in routes where the next hop") + "\n type is VirtualAppliance"))).option("-y, --next-hop-type <next-hop-type>", $((("the type of Azure hop the packet should" + "\n be sent to. Possible values are: 'VirtualNetworkGateway', 'VnetLocal',") + "\n 'Internet', 'VirtualAppliance', and 'None'"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, routeTableName, name, addressPrefix, nextHopType, options, _) { var subscription, networkManagementClient, route, progress, parameters; var __frame = { name: "__1", line: 57 }; return __func(_, this, arguments, __1, 6, __frame, function __$__1() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("route table name : "), routeTableName, __cb(_, __frame, 2, 39, function ___(__0, __2) { routeTableName = __2;
return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __3) { name = __3;
return cli.interaction.promptIfNotGiven($("address prefix : "), addressPrefix, __cb(_, __frame, 4, 46, function ___(__0, __4) { options.addressPrefix = __4;
return cli.interaction.promptIfNotGiven($("next hop type : "), nextHopType, __cb(_, __frame, 5, 44, function ___(__0, __5) { options.nextHopType = __5;
subscription = profile.current.getSubscription(options.subscription);
networkManagementClient = utils.createNetworkManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Looking up the route \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.routes.get(resourceGroup, routeTableName, name, null, __cb(_, __frame, 13, 47, function ___(__0, __6) { route = __6; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
if ((e.statusCode === 404)) {
route = 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 (route) {
return _(new Error(util.format($("route with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = { };
if (options.addressPrefix) {
parameters.addressPrefix = options.addressPrefix; } ;
if (options.nextHopIpAddress) {
parameters.nextHopIpAddress = options.nextHopIpAddress; } ;
if (options.nextHopType) {
parameters.nextHopType = validation.isIn(options.nextHopType, ["VirtualNetworkGateway","VnetLocal","Internet","VirtualAppliance","None",], "--next-hop-type");
if ((options.nextHopType.toLowerCase() != nextHopTypeVirtualAppliance.toLowerCase())) {
delete parameters.nextHopIpAddress; } ; } ;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Creating route \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.routes.createOrUpdate(resourceGroup, routeTableName, name, parameters, __cb(_, __frame, 47, 47, function ___(__0, __7) { route = __7; _(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(route, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }, true)); }); });
routes.command("set [resource-group] [route-table-name] [name]").description($("Update a route")).usage("[options] <resource-group> <route-table-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-r, --route-table-name <route-table-name>", $("the route table name")).option("-n, --name <name>", $("the name of the route")).option("-a, --address-prefix [address-prefix]", $(("the destination CIDR to which the route" + "\n applies"))).option("-p, --next-hop-ip-address [next-hop-ip-address]", $((("the IP address packets should be" + "\n forwarded to. Next hop values are only allowed in routes where the next hop") + "\n type is VirtualAppliance"))).option("-y, --next-hop-type [next-hop-type]", $((("the type of Azure hop the packet should" + "\n be sent to. Possible values are: 'VirtualNetworkGateway', 'VnetLocal',") + "\n 'Internet', 'VirtualAppliance', and 'None'"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, routeTableName, name, options, _) { var subscription, networkManagementClient, route, progress, parameters; var __frame = { name: "__2", line: 127 }; return __func(_, this, arguments, __2, 4, __frame, function __$__2() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("route table name : "), routeTableName, __cb(_, __frame, 2, 39, function ___(__0, __2) { routeTableName = __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 route \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.routes.get(resourceGroup, routeTableName, name, null, __cb(_, __frame, 11, 47, function ___(__0, __4) { route = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
if ((e.statusCode === 404)) {
route = 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 (!route) {
return _(new Error(util.format($("route with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = route;
if (options.addressPrefix) {
parameters.addressPrefix = options.addressPrefix; } ;
if (options.nextHopIpAddress) {
parameters.nextHopIpAddress = options.nextHopIpAddress; } ;
if (options.nextHopType) {
parameters.nextHopType = validation.isIn(options.nextHopType, ["VirtualNetworkGateway","VnetLocal","Internet","VirtualAppliance","None",], "--next-hop-type");
if ((options.nextHopType.toLowerCase() != nextHopTypeVirtualAppliance.toLowerCase())) {
delete parameters.nextHopIpAddress; } ; } ;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Updating route \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.routes.createOrUpdate(resourceGroup, routeTableName, name, parameters, __cb(_, __frame, 45, 47, function ___(__0, __5) { route = __5; _(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() {
cli.interaction.formatOutput(route, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }); });
routes.command("delete [resource-group] [route-table-name] [name]").description($("Delete a route")).usage("[options] <resource-group> <route-table-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-r, --route-table-name <route-table-name>", $("the route table name")).option("-n, --name <name>", $("the name of the route")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, routeTableName, name, options, _) { var subscription, networkManagementClient, route, progress; var __frame = { name: "__3", line: 188 }; return __func(_, this, arguments, __3, 4, __frame, function __$__3() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __2) { resourceGroup = __2;
return cli.interaction.promptIfNotGiven($("route table name : "), routeTableName, __cb(_, __frame, 2, 39, function ___(__0, __3) { routeTableName = __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 route \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.routes.get(resourceGroup, routeTableName, name, null, __cb(_, __frame, 11, 47, function ___(__0, __5) { route = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) {
if ((e.statusCode === 404)) {
route = 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 (!route) {
return _(new Error(util.format($("route with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; return (function __$__3(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete route \"%s\"? [y/n] "), name), __cb(_, __frame, 26, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -187, 17, function ___(__0, __6) { return (function __$__3(__then) { if (__6) {
cli.output.info(util.format($("route \"%s\" was not deleted and still exists in the resource group \"%s\""), name, resourceGroup)); return _(null); } else { __then(); } ; })(function __$__3() {
progress = cli.interaction.progress(util.format($("Deleting route \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.routes.deleteMethod(resourceGroup, routeTableName, name, __cb(_, __frame, 33, 47, function ___(__0, __7) { route = __7;
cli.output.info(util.format($("route \"%s\" was successfully deleted from resource group \"%s\""), name, resourceGroup)); _(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() { _(); }); }); }); }, true)); }); }); }, true)); }, true)); }, true)); }); });
routes.command("show [resource-group] [route-table-name] [name]").description($("Show a route")).usage("[options] <resource-group> <route-table-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-r, --route-table-name <route-table-name>", $("the route table name")).option("-n, --name <name>", $("the name of the route")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, routeTableName, name, options, _) { var subscription, networkManagementClient, route, progress; var __frame = { name: "__4", line: 235 }; return __func(_, this, arguments, __4, 4, __frame, function __$__4() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("route table name : "), routeTableName, __cb(_, __frame, 2, 39, function ___(__0, __2) { routeTableName = __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 route \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return networkManagementClient.routes.get(resourceGroup, routeTableName, name, null, __cb(_, __frame, 11, 47, function ___(__0, __4) { route = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) {
if ((e.statusCode === 404)) {
route = null; }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, 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() {
if (!route) {
cli.output.warn(util.format($("route with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ;
cli.interaction.formatOutput(route, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }, true)); }); });
routes.command("list [resource-group] [route-table-name]").description($("List routes")).usage("[options] <resource-group> <route-table-name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-r, --route-table-name <route-table-name>", $("the route table name")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(resourceGroup, routeTableName, options, _) { var subscription, networkManagementClient, route, progress; var __frame = { name: "__5", line: 270 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() {
options.resourceGroup = resourceGroup;
subscription = profile.current.getSubscription(options.subscription);
networkManagementClient = utils.createNetworkManagementClient(subscription);
route = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function __$__5(__then) {
if ((typeof networkManagementClient.routes.listAll != "function")) {
return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("route table : "), routeTableName, __cb(_, __frame, 10, 43, function ___(__0, __2) { routeTableName = __2;
progress = cli.interaction.progress($("Getting the routes"));
return networkManagementClient.routes.list(resourceGroup, routeTableName, __cb(_, __frame, 12, 49, function ___(__0, __3) { route = __3; __then(); }, true)); }, true)); }, true)); } else { return (function __$__5(__then) {
if (options.resourceGroup) {
return cli.interaction.promptIfNotGiven($("route table : "), routeTableName, __cb(_, __frame, 15, 45, function ___(__0, __4) { routeTableName = __4;
progress = cli.interaction.progress($("Getting the routes"));
return networkManagementClient.routes.list(resourceGroup, routeTableName, __cb(_, __frame, 17, 51, function ___(__0, __5) { route = __5; __then(); }, true)); }, true)); } else {
return cli.interaction.promptIfNotGiven($("route table : "), routeTableName, __cb(_, __frame, 19, 45, function ___(__0, __6) { routeTableName = __6;
progress = cli.interaction.progress($("Getting the routes"));
return networkManagementClient.routes.listAll(routeTableName, __cb(_, __frame, 21, 51, function ___(__0, __7) { route = __7; __then(); }, true)); }, true)); } ; })(__then); } ; })(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() {
cli.interaction.formatOutput(route, function(route) {
if ((!route || (route.length === 0))) {
cli.output.warn($("No routes found")); }
else {
cli.output.table(route, function(row, item) {
generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};