azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
378 lines (177 loc) • 26.5 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 loadBalancers = network.category("lb").description($("Commands to manage load balancers"));
var frontendIPConfigurations = loadBalancers.category("frontend-ip").description($("Commands to manage frontend ip configurations"));
frontendIPConfigurations.command("create [resource-group] [lb-name] [name]").description($("Create a frontend ip configuration")).usage("[options] <resource-group> <lb-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-l, --lb-name <lb-name>", $("the lb name")).option("-n, --name <name>", $("the name of the frontend ip configuration")).option("-a, --private-ip-address [private-ip-address]", $(("the private IP address of the IP" + "\n configuration"))).option("-e, --subnet-name [subnet-name]", $(("sets subnet name. This option is" + "\n mutually exclusive with --subnet-id"))).option("-m, --subnet-vnet-name [subnet-vnet-name]", $("name of the virtual network that contains subnet")).option("-b, --subnet-id [subnet-id]", $(("sets subnet id. This option is mutually" + "\n exclusive with --subnet-name"))).option("-u, --public-ip-id [public-ip-id]", $(("sets public ip address id. This option" + "\n is mutually exclusive with --public-ip-name"))).option("-i, --public-ip-name [public-ip-name]", $(("sets public ip address name. This" + "\n option is mutually exclusive with --public-ip-id"))).option("-z, --zones [zones]", $(("a list of availability zones denoting" + "\n the IP allocated for the resource needs to come from"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, lbName, name, options, _) { var subscription, networkManagementClient, loadBalancer, progress, parentItem, frontendIPConfiguration, parameters, idContainerSubnet, idContainerPublicIPAddress; var __frame = { name: "__1", line: 59 }; 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($("lb name : "), lbName, __cb(_, __frame, 2, 31, function ___(__0, __2) { lbName = __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 load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.loadBalancers.get(resourceGroup, lbName, null, __cb(_, __frame, 11, 61, function ___(__0, __4) { loadBalancer = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
if ((e.statusCode === 404)) {
loadBalancer = 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() {
parentItem = loadBalancer;
if (!parentItem) {
return _(new Error(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroup))); } ;
frontendIPConfiguration = utils.findFirstCaseIgnore(parentItem.frontendIPConfigurations, { name: name });
if (frontendIPConfiguration) {
return _(new Error(util.format($("frontend ip configuration with name \"%s\" already exists in load balancer \"%s\""), name, lbName))); } ;
parameters = { };
if (options.privateIpAddress) {
parameters.privateIPAddress = options.privateIpAddress;
if ((!options.privateIpVersion || ((options.privateIpVersion && (options.privateIpVersion.toLowerCase() != "ipv6"))))) {
parameters.privateIPAllocationMethod = "Static"; } ; } ;
if (!parameters.subnet) {
parameters.subnet = { }; } ; return (function __$__1(__then) {
if (options.subnetId) {
if (options.subnetName) {
cli.output.warn($("--subnet-name parameter will be ignored because --subnet-id and --subnet-name are mutually exclusive")); } ;
parameters.subnet.id = options.subnetId; __then(); } else { return (function __$__1(__then) {
if (options.subnetName) {
return networkManagementClient.subnets.get(resourceGroup, options.subnetVnetName, options.subnetName, __cb(_, __frame, 50, 64, function ___(__0, __5) { idContainerSubnet = __5;
parameters.subnet.id = idContainerSubnet.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__1() {
if (!parameters.publicIPAddress) {
parameters.publicIPAddress = { }; } ; return (function __$__1(__then) {
if (options.publicIpId) {
if (options.publicIpName) {
cli.output.warn($("--public-ip-name parameter will be ignored because --public-ip-id and --public-ip-name are mutually exclusive")); } ;
parameters.publicIPAddress.id = options.publicIpId; __then(); } else { return (function __$__1(__then) {
if (options.publicIpName) {
return networkManagementClient.publicIPAddresses.get(resourceGroup, options.publicIpName, __cb(_, __frame, 63, 83, function ___(__0, __6) { idContainerPublicIPAddress = __6;
parameters.publicIPAddress.id = idContainerPublicIPAddress.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__1() {
if (options.zones) {
parameters.zones = generatorUtils.splitStringByCharacter(options.zones, ","); } ;
parameters.name = name;
parentItem.frontendIPConfigurations.push(parameters);
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Creating frontend ip configuration in load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.loadBalancers.createOrUpdate(resourceGroup, lbName, loadBalancer, __cb(_, __frame, 77, 61, function ___(__0, __7) { loadBalancer = __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() {
parentItem = loadBalancer;
cli.interaction.formatOutput(utils.findFirstCaseIgnore(parentItem.frontendIPConfigurations, { name: name }), generatorUtils.traverse); _(); }); }); }); }); }); }); }, true)); }, true)); }, true)); }); });
frontendIPConfigurations.command("set [resource-group] [lb-name] [name]").description($("Update a frontend ip configuration")).usage("[options] <resource-group> <lb-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-l, --lb-name <lb-name>", $("the lb name")).option("-n, --name <name>", $("the name of the frontend ip configuration")).option("-a, --private-ip-address [private-ip-address]", $(("the private IP address of the IP" + "\n configuration"))).option("-e, --subnet-name [subnet-name]", $(("sets subnet name. This option is" + "\n mutually exclusive with --subnet-id"))).option("-m, --subnet-vnet-name [subnet-vnet-name]", $("name of the virtual network that contains subnet")).option("-b, --subnet-id [subnet-id]", $(("sets subnet id. This option is mutually" + "\n exclusive with --subnet-name"))).option("-u, --public-ip-id [public-ip-id]", $(("sets public ip address id. This option" + "\n is mutually exclusive with --public-ip-name"))).option("-i, --public-ip-name [public-ip-name]", $(("sets public ip address name. This" + "\n option is mutually exclusive with --public-ip-id"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, lbName, name, options, _) { var subscription, networkManagementClient, loadBalancer, progress, parentItem, frontendIPConfiguration, parameters, idContainerSubnet, idContainerPublicIPAddress; var __frame = { name: "__2", line: 163 }; 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($("lb name : "), lbName, __cb(_, __frame, 2, 31, function ___(__0, __2) { lbName = __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 load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.loadBalancers.get(resourceGroup, lbName, null, __cb(_, __frame, 11, 61, function ___(__0, __4) { loadBalancer = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
if ((e.statusCode === 404)) {
loadBalancer = 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() {
parentItem = loadBalancer;
if (!parentItem) {
return _(new Error(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroup))); } ;
frontendIPConfiguration = utils.findFirstCaseIgnore(parentItem.frontendIPConfigurations, { name: name });
if (!frontendIPConfiguration) {
return _(new Error(util.format($("frontend ip configuration with name \"%s\" not found in load balancer \"%s\""), name, lbName))); } ;
parameters = frontendIPConfiguration;
if (options.privateIpAddress) {
if (!utils.argHasValue(options.privateIpAddress)) {
delete parameters.privateIPAddress;
parameters.privateIPAllocationMethod = "Dynamic"; }
else {
parameters.privateIPAddress = options.privateIpAddress;
if ((!options.privateIpVersion || ((options.privateIpVersion && (options.privateIpVersion.toLowerCase() != "ipv6"))))) {
parameters.privateIPAllocationMethod = "Static"; } ; } ; } ;
if (!parameters.subnet) {
parameters.subnet = { }; } ; return (function __$__2(__then) {
if (options.subnetId) {
if (options.subnetName) {
cli.output.warn($("--subnet-name parameter will be ignored because --subnet-id and --subnet-name are mutually exclusive")); } ;
parameters.subnet.id = options.subnetId; __then(); } else { return (function __$__2(__then) {
if (options.subnetName) {
return networkManagementClient.subnets.get(resourceGroup, options.subnetVnetName, options.subnetName, __cb(_, __frame, 55, 64, function ___(__0, __5) { idContainerSubnet = __5;
parameters.subnet.id = idContainerSubnet.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__2() {
if (!parameters.publicIPAddress) {
parameters.publicIPAddress = { }; } ; return (function __$__2(__then) {
if (options.publicIpId) {
if (options.publicIpName) {
cli.output.warn($("--public-ip-name parameter will be ignored because --public-ip-id and --public-ip-name are mutually exclusive")); } ;
parameters.publicIPAddress.id = options.publicIpId; __then(); } else { return (function __$__2(__then) {
if (options.publicIpName) {
return networkManagementClient.publicIPAddresses.get(resourceGroup, options.publicIpName, __cb(_, __frame, 68, 83, function ___(__0, __6) { idContainerPublicIPAddress = __6;
parameters.publicIPAddress.id = idContainerPublicIPAddress.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__2() {
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Updating frontend ip configuration in \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.loadBalancers.createOrUpdate(resourceGroup, lbName, loadBalancer, __cb(_, __frame, 75, 61, function ___(__0, __7) { loadBalancer = __7; _(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() {
parentItem = loadBalancer;
cli.interaction.formatOutput(utils.findFirstCaseIgnore(parentItem.frontendIPConfigurations, { name: name }), generatorUtils.traverse); _(); }); }); }); }); }); }); }, true)); }, true)); }, true)); }); });
frontendIPConfigurations.command("delete [resource-group] [lb-name] [name]").description($("Delete a frontend ip configuration")).usage("[options] <resource-group> <lb-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-l, --lb-name <lb-name>", $("the lb name")).option("-n, --name <name>", $("the name of the frontend ip configuration")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, lbName, name, options, _) { var subscription, networkManagementClient, loadBalancer, progress, parentItem, index; var __frame = { name: "__3", line: 255 }; 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($("lb name : "), lbName, __cb(_, __frame, 2, 31, function ___(__0, __3) { lbName = __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 load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.loadBalancers.get(resourceGroup, lbName, null, __cb(_, __frame, 11, 61, function ___(__0, __5) { loadBalancer = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) {
if ((e.statusCode === 404)) {
loadBalancer = 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() {
parentItem = loadBalancer;
if (!parentItem) {
return _(new Error(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroup))); } ;
index = utils.indexOfCaseIgnore(parentItem.frontendIPConfigurations, { name: name });
if ((index === -1)) {
return _(new Error(util.format($("frontend ip configuration \"%s\" not found in load balancer \"%s\""), name, lbName))); } ; return (function __$__3(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete frontend ip configuration with name \"%s\" from load balancer \"%s\"? [y/n] "), name, lbName), __cb(_, __frame, 32, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -254, 17, function ___(__0, __6) { return (function __$__3(__then) { if (__6) { return _(null); } else { __then(); } ; })(function __$__3() {
parentItem.frontendIPConfigurations.splice(index, 1);
progress = cli.interaction.progress("Deleting frontend ip configuration"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.loadBalancers.createOrUpdate(resourceGroup, lbName, loadBalancer, __cb(_, __frame, 40, 61, function ___(__0, __7) { loadBalancer = __7; _(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)); }); });
frontendIPConfigurations.command("show [resource-group] [lb-name] [name]").description($("Show a frontend ip configuration")).usage("[options] <resource-group> <lb-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-l, --lb-name <lb-name>", $("the lb name")).option("-n, --name <name>", $("the name of the frontend ip configuration")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, lbName, name, options, _) { var subscription, networkManagementClient, loadBalancer, progress, parentItem, frontendIPConfiguration; var __frame = { name: "__4", line: 308 }; 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($("lb name : "), lbName, __cb(_, __frame, 2, 31, function ___(__0, __2) { lbName = __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 load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return networkManagementClient.loadBalancers.get(resourceGroup, lbName, null, __cb(_, __frame, 11, 61, function ___(__0, __4) { loadBalancer = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) {
if ((e.statusCode === 404)) {
loadBalancer = 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() {
parentItem = loadBalancer;
if (!parentItem) {
return _(new Error(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroup))); } ;
frontendIPConfiguration = utils.findFirstCaseIgnore(parentItem.frontendIPConfigurations, { name: name });
if (!frontendIPConfiguration) {
cli.output.warn(util.format($("frontend ip configuration with name \"%s\" not found in the load balancer \"%s\""), name, lbName)); } ;
cli.interaction.formatOutput(frontendIPConfiguration, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }, true)); }); });
frontendIPConfigurations.command("list [resource-group] [lb-name]").description($("List frontend ip configurations")).usage("[options] <resource-group> <lb-name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-l, --lb-name <lb-name>", $("the lb name")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(resourceGroup, lbName, options, _) { var subscription, networkManagementClient, loadBalancer, progress, parentItem; var __frame = { name: "__5", line: 349 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() {
subscription = profile.current.getSubscription(options.subscription);
networkManagementClient = utils.createNetworkManagementClient(subscription);
loadBalancer = null;
progress = cli.interaction.progress(util.format($("Looking up the load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() {
return networkManagementClient.loadBalancers.get(resourceGroup, lbName, null, __cb(_, __frame, 7, 61, function ___(__0, __1) { loadBalancer = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__5() { if (e) {
if ((e.statusCode === 404)) {
loadBalancer = 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() {
parentItem = loadBalancer;
if (!parentItem) {
return _(new Error(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroup))); } ;
cli.interaction.formatOutput(parentItem.frontendIPConfigurations, function(items) {
if ((!items || (items.length === 0))) {
cli.output.warn($("No frontend ip configurations found")); }
else {
cli.output.table(items, function(row, item) {
generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};