azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
349 lines (150 loc) • 26 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 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 virtualNetworks = network.category("vnet").description($("Commands to manage virtual networks"));
var virtualNetworkPeerings = virtualNetworks.category("peering").description($("Commands to manage virtual network peerings"));
virtualNetworkPeerings.command("create [resource-group] [vnet-name] [name]").description($("Create a virtual network peering")).usage("[options] <resource-group> <vnet-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the virtual network peering")).option("-a, --allow-vnet-access [allow-vnet-access]", $((("whether the VMs in the linked virtual" + "\n network space would be able to access all the VMs in local Virtual network") + "\n space"))).option("-f, --allow-forwarded-traffic [allow-forwarded-traffic]", $(("whether the forwarded traffic from the" + "\n VMs in the remote virtual network will be allowed/disallowed"))).option("-y, --allow-gateway-transit [allow-gateway-transit]", $(("if gateway links can be used in remote" + "\n virtual networking to link to this virtual network"))).option("-w, --use-remote-gateways [use-remote-gateways]", $((((("if remote gateways can be used on this" + "\n virtual network. If the flag is set to true, and allowGatewayTransit on remote") + "\n peering is also true, virtual network will use gateways of remote virtual") + "\n network for transit. Only one peering can have this flag set to true. This flag") + "\n cannot be set if virtual network already has a gateway"))).option("-m, --remote-vnet-name [remote-vnet-name]", $(("sets remote virtual network. This" + "\n option is mutually exclusive with --remote-vnet-id"))).option("-r, --remote-vnet-id [remote-vnet-id]", $(("sets remote virtual network. This" + "\n option is mutually exclusive with --remote-vnet-name"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, vnetName, name, options, _) { var subscription, networkManagementClient, virtualNetworkPeering, progress, parameters, idContainerRemoteVirtualNetwork; var __frame = { name: "__1", line: 62 }; return __func(_, this, arguments, __1, 4, __frame, function __$__1() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __2) { vnetName = __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 virtual network peering \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.virtualNetworkPeerings.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 11, 79, function ___(__0, __4) { virtualNetworkPeering = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
if ((e.statusCode === 404)) {
virtualNetworkPeering = 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 (virtualNetworkPeering) {
return _(new Error(util.format($("virtual network peering with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = { };
if (options.allowVnetAccess) {
parameters.allowVirtualNetworkAccess = utils.parseBool(options.allowVnetAccess); } ;
if (options.allowForwardedTraffic) {
parameters.allowForwardedTraffic = utils.parseBool(options.allowForwardedTraffic); } ;
if (options.allowGatewayTransit) {
parameters.allowGatewayTransit = utils.parseBool(options.allowGatewayTransit); } ;
if (options.useRemoteGateways) {
parameters.useRemoteGateways = utils.parseBool(options.useRemoteGateways); } ;
if (!parameters.remoteVirtualNetwork) {
parameters.remoteVirtualNetwork = { }; } ; return (function __$__1(__then) {
if (options.remoteVnetId) {
if (options.remoteVnetName) {
cli.output.warn($("--remote-vnet-name parameter will be ignored because --remote-vnet-id and --remote-vnet-name are mutually exclusive")); } ;
parameters.remoteVirtualNetwork.id = options.remoteVnetId; __then(); } else { return (function __$__1(__then) {
if (options.remoteVnetName) {
return networkManagementClient.virtualNetworks.get(resourceGroup, options.remoteVnetName, __cb(_, __frame, 52, 86, function ___(__0, __5) { idContainerRemoteVirtualNetwork = __5;
if (!idContainerRemoteVirtualNetwork) {
return _(new Error(util.format($("A virtual network with name \"%s\" not found in the resource group \"%s\""), options.remoteVnetName, resourceGroup))); } ;
parameters.remoteVirtualNetwork.id = idContainerRemoteVirtualNetwork.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__1() {
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Creating virtual network peering \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.virtualNetworkPeerings.createOrUpdate(resourceGroup, vnetName, name, parameters, __cb(_, __frame, 62, 79, function ___(__0, __6) { virtualNetworkPeering = __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(virtualNetworkPeering, generatorUtils.traverse); _(); }); }); }); }); }); }, true)); }, true)); }, true)); }); });
virtualNetworkPeerings.command("set [resource-group] [vnet-name] [name]").description($("Update a virtual network peering")).usage("[options] <resource-group> <vnet-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the virtual network peering")).option("-a, --allow-vnet-access [allow-vnet-access]", $((("whether the VMs in the linked virtual" + "\n network space would be able to access all the VMs in local Virtual network") + "\n space"))).option("-f, --allow-forwarded-traffic [allow-forwarded-traffic]", $(("whether the forwarded traffic from the" + "\n VMs in the remote virtual network will be allowed/disallowed"))).option("-y, --allow-gateway-transit [allow-gateway-transit]", $(("if gateway links can be used in remote" + "\n virtual networking to link to this virtual network"))).option("-w, --use-remote-gateways [use-remote-gateways]", $((((("if remote gateways can be used on this" + "\n virtual network. If the flag is set to true, and allowGatewayTransit on remote") + "\n peering is also true, virtual network will use gateways of remote virtual") + "\n network for transit. Only one peering can have this flag set to true. This flag") + "\n cannot be set if virtual network already has a gateway"))).option("-m, --remote-vnet-name [remote-vnet-name]", $(("sets remote virtual network. This" + "\n option is mutually exclusive with --remote-vnet-id"))).option("-r, --remote-vnet-id [remote-vnet-id]", $(("sets remote virtual network. This" + "\n option is mutually exclusive with --remote-vnet-name"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, vnetName, name, options, _) { var subscription, networkManagementClient, virtualNetworkPeering, progress, parameters, idContainerRemoteVirtualNetwork; var __frame = { name: "__2", line: 155 }; 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($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __2) { vnetName = __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 virtual network peering \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.virtualNetworkPeerings.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 11, 79, function ___(__0, __4) { virtualNetworkPeering = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
if ((e.statusCode === 404)) {
virtualNetworkPeering = 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 (!virtualNetworkPeering) {
return _(new Error(util.format($("virtual network peering with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = virtualNetworkPeering;
if (options.allowVnetAccess) {
parameters.allowVirtualNetworkAccess = utils.parseBool(options.allowVnetAccess); } ;
if (options.allowForwardedTraffic) {
parameters.allowForwardedTraffic = utils.parseBool(options.allowForwardedTraffic); } ;
if (options.allowGatewayTransit) {
parameters.allowGatewayTransit = utils.parseBool(options.allowGatewayTransit); } ;
if (options.useRemoteGateways) {
parameters.useRemoteGateways = utils.parseBool(options.useRemoteGateways); } ;
if (!parameters.remoteVirtualNetwork) {
parameters.remoteVirtualNetwork = { }; } ; return (function __$__2(__then) {
if (options.remoteVnetId) {
if (options.remoteVnetName) {
cli.output.warn($("--remote-vnet-name parameter will be ignored because --remote-vnet-id and --remote-vnet-name are mutually exclusive")); } ;
parameters.remoteVirtualNetwork.id = options.remoteVnetId; __then(); } else { return (function __$__2(__then) {
if (options.remoteVnetName) {
return networkManagementClient.virtualNetworks.get(resourceGroup, options.remoteVnetName, __cb(_, __frame, 52, 86, function ___(__0, __5) { idContainerRemoteVirtualNetwork = __5;
if (!idContainerRemoteVirtualNetwork) {
return _(new Error(util.format($("A virtual network with name \"%s\" not found in the resource group \"%s\""), options.remoteVnetName, resourceGroup))); } ;
parameters.remoteVirtualNetwork.id = idContainerRemoteVirtualNetwork.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__2() {
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Updating virtual network peering \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.virtualNetworkPeerings.createOrUpdate(resourceGroup, vnetName, name, parameters, __cb(_, __frame, 62, 79, function ___(__0, __6) { virtualNetworkPeering = __6; _(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(virtualNetworkPeering, generatorUtils.traverse); _(); }); }); }); }); }); }, true)); }, true)); }, true)); }); });
virtualNetworkPeerings.command("delete [resource-group] [vnet-name] [name]").description($("Delete a virtual network peering")).usage("[options] <resource-group> <vnet-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the virtual network peering")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, vnetName, name, options, _) { var subscription, networkManagementClient, virtualNetworkPeering, progress; var __frame = { name: "__3", line: 233 }; 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($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __3) { vnetName = __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 virtual network peering \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.virtualNetworkPeerings.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 11, 79, function ___(__0, __5) { virtualNetworkPeering = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) {
if ((e.statusCode === 404)) {
virtualNetworkPeering = 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 (!virtualNetworkPeering) {
return _(new Error(util.format($("virtual network peering 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 virtual network peering \"%s\"? [y/n] "), name), __cb(_, __frame, 26, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -232, 17, function ___(__0, __6) { return (function __$__3(__then) { if (__6) {
cli.output.info(util.format($("virtual network peering \"%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 virtual network peering \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.virtualNetworkPeerings.deleteMethod(resourceGroup, vnetName, name, __cb(_, __frame, 33, 79, function ___(__0, __7) { virtualNetworkPeering = __7;
cli.output.info(util.format($("virtual network peering \"%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)); }); });
virtualNetworkPeerings.command("show [resource-group] [vnet-name] [name]").description($("Show a virtual network peering")).usage("[options] <resource-group> <vnet-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the virtual network peering")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, vnetName, name, options, _) { var subscription, networkManagementClient, virtualNetworkPeering, progress; var __frame = { name: "__4", line: 280 }; 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($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __2) { vnetName = __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 virtual network peering \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return networkManagementClient.virtualNetworkPeerings.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 11, 79, function ___(__0, __4) { virtualNetworkPeering = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) {
if ((e.statusCode === 404)) {
virtualNetworkPeering = 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 (!virtualNetworkPeering) {
cli.output.warn(util.format($("virtual network peering with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ;
cli.interaction.formatOutput(virtualNetworkPeering, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }, true)); }); });
virtualNetworkPeerings.command("list [resource-group] [vnet-name]").description($("List virtual network peerings")).usage("[options] <resource-group> <vnet-name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(resourceGroup, vnetName, options, _) { var subscription, networkManagementClient, virtualNetworkPeering, progress; var __frame = { name: "__5", line: 315 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() {
options.resourceGroup = resourceGroup;
subscription = profile.current.getSubscription(options.subscription);
networkManagementClient = utils.createNetworkManagementClient(subscription);
virtualNetworkPeering = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function __$__5(__then) {
if ((typeof networkManagementClient.virtualNetworkPeerings.listAll != "function")) {
return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("virtual network : "), vnetName, __cb(_, __frame, 10, 37, function ___(__0, __2) { vnetName = __2;
progress = cli.interaction.progress($("Getting the virtual network peerings"));
return networkManagementClient.virtualNetworkPeerings.list(resourceGroup, vnetName, __cb(_, __frame, 12, 81, function ___(__0, __3) { virtualNetworkPeering = __3; __then(); }, true)); }, true)); }, true)); } else { return (function __$__5(__then) {
if (options.resourceGroup) {
return cli.interaction.promptIfNotGiven($("virtual network : "), vnetName, __cb(_, __frame, 15, 39, function ___(__0, __4) { vnetName = __4;
progress = cli.interaction.progress($("Getting the virtual network peerings"));
return networkManagementClient.virtualNetworkPeerings.list(resourceGroup, vnetName, __cb(_, __frame, 17, 83, function ___(__0, __5) { virtualNetworkPeering = __5; __then(); }, true)); }, true)); } else {
return cli.interaction.promptIfNotGiven($("virtual network : "), vnetName, __cb(_, __frame, 19, 39, function ___(__0, __6) { vnetName = __6;
progress = cli.interaction.progress($("Getting the virtual network peerings"));
return networkManagementClient.virtualNetworkPeerings.listAll(vnetName, __cb(_, __frame, 21, 83, function ___(__0, __7) { virtualNetworkPeering = __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(virtualNetworkPeering, function(virtualNetworkPeering) {
if ((!virtualNetworkPeering || (virtualNetworkPeering.length === 0))) {
cli.output.warn($("No virtual network peerings found")); }
else {
cli.output.table(virtualNetworkPeering, function(row, item) {
generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};