azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
932 lines (499 loc) • 62 kB
JavaScript
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var __ = require("underscore");
var util = require("util");
var utils = require("../../../util/utils");
var validation = require("../../../util/validation");
var $ = utils.getLocaleString;
var constants = require("./constants");
var resourceUtils = require("../resource/resourceUtils");
var tagUtils = require("../tag/tagUtils");
var PublicIp = require("./publicIp");
var Subnet = require("./subnet");
function LoadBalancer(cli, networkManagementClient) {
this.networkManagementClient = networkManagementClient;
this.publicIpCrud = new PublicIp(cli, networkManagementClient);
this.subnetCrud = new Subnet(cli, networkManagementClient);
this.output = cli.output;
this.interaction = cli.interaction;};
__.extend(LoadBalancer.prototype, {
create: function create__1(resourceGroupName, lbName, options, _) { var self, parameters, lb, progress, __this = this; var __frame = { name: "create__1", line: 39 }; return __func(_, this, arguments, create__1, 3, __frame, function __$create__1() { self = __this;
parameters = {
location: options.location };
parameters = self._parseLoadBalancer(parameters, options);
return self.get(resourceGroupName, lbName, __cb(_, __frame, 9, 18, function ___(__0, __1) { lb = __1;
if (lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" already exists in the resource group \"%s\""), lbName, resourceGroupName))); } ;
progress = self.interaction.progress(util.format($("Creating load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$create__1() {
return self.networkManagementClient.loadBalancers.createOrUpdate(resourceGroupName, lbName, parameters, __cb(_, __frame, 16, 54, function ___(__0, __2) { lb = __2; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$create__1() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$create__1() {
self._showLoadBalancer(lb, resourceGroupName, lbName); _(); }); }); }, true)); }); },
set: function set__2(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "set__2", line: 62 }; return __func(_, this, arguments, set__2, 3, __frame, function __$set__2() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
lb = self._parseLoadBalancer(lb, options);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 10, 14, function ___(__0, __2) { lb = __2;
self._showLoadBalancer(lb, resourceGroupName, lbName); _(); }, true)); }, true)); }); },
list: function list__3(options, _) { var self, progress, lbs, __this = this; var __frame = { name: "list__3", line: 76 }; return __func(_, this, arguments, list__3, 1, __frame, function __$list__3() { self = __this;
progress = self.interaction.progress($("Looking up load balancers"));
lbs = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$list__3() { return (function __$list__3(__then) {
if (options.resourceGroup) {
return self.networkManagementClient.loadBalancers.list(options.resourceGroup, __cb(_, __frame, 8, 57, function ___(__0, __1) { lbs = __1; __then(); }, true)); } else {
return self.networkManagementClient.loadBalancers.listAll(__cb(_, __frame, 10, 57, function ___(__0, __2) { lbs = __2; __then(); }, true)); } ; })(function __$list__3() { _(null, null, true); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$list__3() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$list__3() {
self.interaction.formatOutput(lbs, function(lbs) {
if ((lbs.length === 0)) {
self.output.warn($("No load balancers found")); }
else {
self.output.table(lbs, function(row, lb) {
row.cell($("Name"), lb.name);
row.cell($("Location"), lb.location);
var resInfo = resourceUtils.getResourceInformation(lb.id);
row.cell($("Resource group"), resInfo.resourceGroup);
row.cell($("Provisioning state"), lb.provisioningState);
row.cell($("Probe"), lb.probes.length);
row.cell($("FIP"), lb.frontendIPConfigurations.length);
row.cell($("Backend pool"), lb.backendAddressPools.length);
row.cell($("Rule"), lb.loadBalancingRules.length);
row.cell($("Inbound NAT rule"), lb.inboundNatRules.length);
row.cell($("Inbound NAT pool"), lb.inboundNatPools.length);
row.cell($("Outbound NAT rule"), lb.outboundNatRules.length); }); } ; }); _(); }); }); }); },
show: function show__4(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "show__4", line: 114 }; return __func(_, this, arguments, show__4, 3, __frame, function __$show__4() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 2, 18, function ___(__0, __1) { lb = __1;
self._showLoadBalancer(lb, resourceGroupName, lbName); _(); }, true)); }); },
get: function get__5(resourceGroupName, lbName, _) { var self, progress, lb, __this = this; var __frame = { name: "get__5", line: 121 }; return __func(_, this, arguments, get__5, 2, __frame, function __$get__5() { self = __this;
progress = self.interaction.progress(util.format($("Looking up the load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__5() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__5() {
return self.networkManagementClient.loadBalancers.get(resourceGroupName, lbName, __cb(_, __frame, 4, 58, function ___(__0, __1) { lb = __1;
return _(null, lb); }, true)); }); })(function ___(e, __result) { __catch(function __$get__5() { if (e) {
if ((e.statusCode === 404)) {
return _(null, null); } ;
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$get__5() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$get__5() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$get__5() { _(); }); }); }); },
delete: function delete__6(resourceGroupName, lbName, options, _) { var self, lb, progress, __this = this; var __frame = { name: "delete__6", line: 137 }; return __func(_, this, arguments, delete__6, 3, __frame, function __$delete__6() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __2) { lb = __2;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ; return (function __$delete__6(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete load balancer \"%s\"? [y/n] "), lbName), __cb(_, __frame, 8, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -136, 17, function ___(__0, __3) { return (function __$delete__6(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$delete__6() {
progress = self.interaction.progress(util.format($("Deleting load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$delete__6() {
return self.networkManagementClient.loadBalancers.deleteMethod(resourceGroupName, lbName, __cb(_, __frame, 14, 49, function __$delete__6() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$delete__6() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$delete__6() { _(); }); }); }); }, true)); }, true)); }); },
update: function update__7(resourceGroupName, lbName, parameters, _) { var self, progress, lb, __this = this; var __frame = { name: "update__7", line: 157 }; return __func(_, this, arguments, update__7, 3, __frame, function __$update__7() { self = __this;
progress = self.interaction.progress(util.format($("Updating load balancer \"%s\""), lbName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$update__7() {
return self.networkManagementClient.loadBalancers.createOrUpdate(resourceGroupName, lbName, parameters, __cb(_, __frame, 4, 58, function ___(__0, __1) { lb = __1;
return _(null, lb); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$update__7() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$update__7() { _(); }); }); }); },
createFrontendIP: function createFrontendIP__8(resourceGroupName, lbName, fipName, options, _) { var self, lb, fip, __this = this; var __frame = { name: "createFrontendIP__8", line: 171 }; return __func(_, this, arguments, createFrontendIP__8, 4, __frame, function __$createFrontendIP__8() { self = __this;
if (((((!options.publicIpName && !options.publicIpId) && !options.subnetId) && !options.subnetName) && !options.subnetVnetName)) {
return _(new Error($("You must specify --public-ip-id, --public-ip-name or --subnet-id, --subnet-name, --subnet-vnet-name"), lbName, resourceGroupName)); } ;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 7, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
fip = {
name: fipName,
privateIPAllocationMethod: "Dynamic" };
return self._parseFrontendIP(resourceGroupName, fip, options, __cb(_, __frame, 17, 15, function ___(__0, __2) { fip = __2;
if (utils.findFirstCaseIgnore(lb.frontendIPConfigurations, { name: fipName })) {
return _(new Error(util.format($("Frontend IP configuration with name \"%s\" already exists in the load balancer \"%s\""), fipName, lbName))); } ;
lb.frontendIPConfigurations.push(fip);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 25, 14, function ___(__0, __3) { lb = __3;
fip = utils.findFirstCaseIgnore(lb.frontendIPConfigurations, { name: fipName });
self._showFrontendIP(fip); _(); }, true)); }, true)); }, true)); }); },
setFrontendIP: function setFrontendIP__9(resourceGroupName, lbName, fipName, options, _) { var self, lb, fip, __this = this; var __frame = { name: "setFrontendIP__9", line: 202 }; return __func(_, this, arguments, setFrontendIP__9, 4, __frame, function __$setFrontendIP__9() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 2, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
fip = utils.findFirstCaseIgnore(lb.frontendIPConfigurations, { name: fipName });
if (!fip) {
return _(new Error(util.format($("Frontend IP configuration with name \"%s\" not found in the load balancer \"%s\""), fipName, lbName))); } ;
return self._parseFrontendIP(resourceGroupName, fip, options, __cb(_, __frame, 13, 9, function __$setFrontendIP__9() {
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 15, 14, function ___(__0, __2) { lb = __2;
fip = utils.findFirstCaseIgnore(lb.frontendIPConfigurations, { name: fipName });
self._showFrontendIP(fip); _(); }, true)); }, true)); }, true)); }); },
listFrontendIPs: function listFrontendIPs__10(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "listFrontendIPs__10", line: 223 }; return __func(_, this, arguments, listFrontendIPs__10, 3, __frame, function __$listFrontendIPs__10() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
self.interaction.formatOutput(lb.frontendIPConfigurations, function(fips) {
if ((fips.length === 0)) {
self.output.warn($("No frontend IP configurations found")); }
else {
self._listFrontendIP(fips); } ; }); _(); }, true)); }); },
deleteFrontendIP: function deleteFrontendIP__11(resourceGroupName, lbName, fipName, options, _) { var self, lb, index, __this = this; var __frame = { name: "deleteFrontendIP__11", line: 240 }; return __func(_, this, arguments, deleteFrontendIP__11, 4, __frame, function __$deleteFrontendIP__11() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __2) { lb = __2;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
index = utils.indexOfCaseIgnore(lb.frontendIPConfigurations, { name: fipName });
if ((index === -1)) {
return _(new Error(util.format($("Frontend IP configuration with name \"%s\" not found in the load balancer \"%s\""), fipName, lbName))); } ; return (function __$deleteFrontendIP__11(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete frontend IP configuration \"%s\" ? [y/n] "), fipName), __cb(_, __frame, 13, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -239, 17, function ___(__0, __3) { return (function __$deleteFrontendIP__11(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$deleteFrontendIP__11() {
lb.frontendIPConfigurations.splice(index, 1);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 18, 9, function __$deleteFrontendIP__11() { _(); }, true)); }); }, true)); }, true)); }); },
createProbe: function createProbe__12(resourceGroupName, lbName, probeName, options, _) { var self, probe, lb, __this = this; var __frame = { name: "createProbe__12", line: 264 }; return __func(_, this, arguments, createProbe__12, 4, __frame, function __$createProbe__12() { self = __this;
probe = {
name: probeName };
probe = self._parseProbe(probe, options, true);
return self.get(resourceGroupName, lbName, __cb(_, __frame, 9, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
if (utils.findFirstCaseIgnore(lb.probes, { name: probeName })) {
return _(new Error(util.format($("A probe with name \"%s\" already exists in the load balancer \"%s\""), probeName, lbName))); } ;
lb.probes.push(probe);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 19, 14, function ___(__0, __2) { lb = __2;
probe = utils.findFirstCaseIgnore(lb.probes, { name: probeName });
self._showProbe(probe); _(); }, true)); }, true)); }); },
setProbe: function setProbe__13(resourceGroupName, lbName, probeName, options, _) { var self, lb, probe, __this = this; var __frame = { name: "setProbe__13", line: 289 }; return __func(_, this, arguments, setProbe__13, 4, __frame, function __$setProbe__13() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
probe = utils.findFirstCaseIgnore(lb.probes, {
name: probeName });
if (!probe) {
return _(new Error(util.format($("A probe with name \"%s\" not found in the load balancer \"%s\""), probeName, lbName))); } ;
self._parseProbe(probe, options, false);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 17, 14, function ___(__0, __2) { lb = __2;
probe = utils.findFirstCaseIgnore(lb.probes, { name: probeName });
self._showProbe(probe); _(); }, true)); }, true)); }); },
listProbes: function listProbes__14(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "listProbes__14", line: 312 }; return __func(_, this, arguments, listProbes__14, 3, __frame, function __$listProbes__14() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
self.interaction.formatOutput(lb.probes, function(probes) {
if ((probes.length === 0)) {
self.output.warn($("No probes found")); }
else {
self._listProbes(probes); } ; }); _(); }, true)); }); },
deleteProbe: function deleteProbe__15(resourceGroupName, lbName, probeName, options, _) { var self, lb, index, __this = this; var __frame = { name: "deleteProbe__15", line: 329 }; return __func(_, this, arguments, deleteProbe__15, 4, __frame, function __$deleteProbe__15() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __2) { lb = __2;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
index = utils.indexOfCaseIgnore(lb.probes, { name: probeName });
if ((index === -1)) {
return _(new Error(util.format($("A probe with name with name \"%s\" not found in the load balancer \"%s\""), probeName, lbName))); } ; return (function __$deleteProbe__15(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete probe \"%s\" ? [y/n] "), probeName), __cb(_, __frame, 13, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -328, 17, function ___(__0, __3) { return (function __$deleteProbe__15(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$deleteProbe__15() {
lb.probes.splice(index, 1);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 18, 9, function __$deleteProbe__15() { _(); }, true)); }); }, true)); }, true)); }); },
createBackendAddressPool: function createBackendAddressPool__16(resourceGroupName, lbName, poolName, options, _) { var self, pool, lb, __this = this; var __frame = { name: "createBackendAddressPool__16", line: 353 }; return __func(_, this, arguments, createBackendAddressPool__16, 4, __frame, function __$createBackendAddressPool__16() { self = __this;
pool = {
name: poolName,
properties: { } };
return self.get(resourceGroupName, lbName, __cb(_, __frame, 8, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
if (utils.findFirstCaseIgnore(lb.backendAddressPools, { name: poolName })) {
return _(new Error(util.format($("A backend address pool with name \"%s\" already exists in the load balancer \"%s\""), poolName, lbName))); } ;
lb.backendAddressPools.push(pool);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 18, 14, function ___(__0, __2) { lb = __2;
pool = utils.findFirstCaseIgnore(lb.backendAddressPools, { name: poolName });
self._showBackendAddressPool(pool); _(); }, true)); }, true)); }); },
listBackendAddressPools: function listBackendAddressPools__17(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "listBackendAddressPools__17", line: 377 }; return __func(_, this, arguments, listBackendAddressPools__17, 3, __frame, function __$listBackendAddressPools__17() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
self.interaction.formatOutput(lb.backendAddressPools, function(pools) {
if ((pools.length === 0)) {
self.output.warn($("No backend address pools found")); }
else {
self._listBackendAddressPools(pools); } ; }); _(); }, true)); }); },
deleteBackendAddressPool: function deleteBackendAddressPool__18(resourceGroupName, lbName, poolName, options, _) { var self, lb, index, __this = this; var __frame = { name: "deleteBackendAddressPool__18", line: 394 }; return __func(_, this, arguments, deleteBackendAddressPool__18, 4, __frame, function __$deleteBackendAddressPool__18() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __2) { lb = __2;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
index = utils.indexOfCaseIgnore(lb.backendAddressPools, { name: poolName });
if ((index === -1)) {
return _(new Error(util.format($("A backend address pool with name with name \"%s\" not found in the load balancer \"%s\""), poolName, lbName))); } ; return (function __$deleteBackendAddressPool__18(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete backend address pool \"%s\" ? [y/n] "), poolName), __cb(_, __frame, 13, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -393, 17, function ___(__0, __3) { return (function __$deleteBackendAddressPool__18(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$deleteBackendAddressPool__18() {
lb.backendAddressPools.splice(index, 1);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 18, 9, function __$deleteBackendAddressPool__18() { _(); }, true)); }); }, true)); }, true)); }); },
createBalancingRule: function createBalancingRule__19(resourceGroupName, lbName, ruleName, options, _) { var self, rule, lb, __this = this; var __frame = { name: "createBalancingRule__19", line: 418 }; return __func(_, this, arguments, createBalancingRule__19, 4, __frame, function __$createBalancingRule__19() { self = __this;
rule = {
name: ruleName };
return self.get(resourceGroupName, lbName, __cb(_, __frame, 7, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
rule = self._parseBalancingRule(lb, rule, options, true);
if (utils.findFirstCaseIgnore(lb.loadBalancingRules, { name: ruleName })) {
return _(new Error(util.format($("Load balancing rule with name \"%s\" already exists in the load balancer \"%s\""), ruleName, lbName))); } ;
lb.loadBalancingRules.push(rule);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 19, 14, function ___(__0, __2) { lb = __2;
rule = utils.findFirstCaseIgnore(lb.loadBalancingRules, { name: ruleName });
self._showBalancingRule(rule); _(); }, true)); }, true)); }); },
setBalancingRule: function setBalancingRule__20(resourceGroupName, lbName, ruleName, options, _) { var self, lb, rule, __this = this; var __frame = { name: "setBalancingRule__20", line: 443 }; return __func(_, this, arguments, setBalancingRule__20, 4, __frame, function __$setBalancingRule__20() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
rule = utils.findFirstCaseIgnore(lb.loadBalancingRules, { name: ruleName });
if (!rule) {
return _(new Error(util.format($("Load balancing rule with the name \"%s\" not found in load balancer \"%s\""), ruleName, lbName))); } ;
self._parseBalancingRule(lb, rule, options, false);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 14, 14, function ___(__0, __2) { lb = __2;
rule = utils.findFirstCaseIgnore(lb.loadBalancingRules, { name: ruleName });
self._showBalancingRule(rule); _(); }, true)); }, true)); }); },
listBalancingRules: function listBalancingRules__21(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "listBalancingRules__21", line: 463 }; return __func(_, this, arguments, listBalancingRules__21, 3, __frame, function __$listBalancingRules__21() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
self.interaction.formatOutput(lb.loadBalancingRules, function(rules) {
if ((rules.length === 0)) {
self.output.warn($("No load balancing rules found")); }
else {
self._listBalancingRules(rules); } ; }); _(); }, true)); }); },
deleteBalancingRule: function deleteBalancingRule__22(resourceGroupName, lbName, ruleName, options, _) { var self, lb, index, __this = this; var __frame = { name: "deleteBalancingRule__22", line: 480 }; return __func(_, this, arguments, deleteBalancingRule__22, 4, __frame, function __$deleteBalancingRule__22() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __2) { lb = __2;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
index = utils.indexOfCaseIgnore(lb.loadBalancingRules, { name: ruleName });
if ((index === -1)) {
return _(new Error(util.format($("A load balancing rule with name \"%s\" not found in the load balancer \"%s\""), ruleName, lbName))); } ; return (function __$deleteBalancingRule__22(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete load balancing rule \"%s\" ? [y/n] "), ruleName), __cb(_, __frame, 13, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -479, 17, function ___(__0, __3) { return (function __$deleteBalancingRule__22(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$deleteBalancingRule__22() {
lb.loadBalancingRules.splice(index, 1);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 18, 9, function __$deleteBalancingRule__22() { _(); }, true)); }); }, true)); }, true)); }); },
createInboundNatRule: function createInboundNatRule__23(resourceGroupName, lbName, ruleName, options, _) { var self, lb, rule, __this = this; var __frame = { name: "createInboundNatRule__23", line: 504 }; return __func(_, this, arguments, createInboundNatRule__23, 4, __frame, function __$createInboundNatRule__23() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
rule = {
name: ruleName };
rule = self._parseInboundNatRule(lb, rule, options, true);
if (utils.findFirstCaseIgnore(lb.inboundNatRules, { name: ruleName })) {
return _(new Error(util.format($("An inbound NAT rule with name \"%s\" already exists in the load balancer \"%s\""), ruleName, lbName))); } ;
lb.inboundNatRules.push(rule);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 19, 14, function ___(__0, __2) { lb = __2;
rule = utils.findFirstCaseIgnore(lb.inboundNatRules, { name: ruleName });
self._showInboundNatRule(rule); _(); }, true)); }, true)); }); },
setInboundNatRule: function setInboundNatRule__24(resourceGroupName, lbName, ruleName, options, _) { var self, lb, rule, __this = this; var __frame = { name: "setInboundNatRule__24", line: 529 }; return __func(_, this, arguments, setInboundNatRule__24, 4, __frame, function __$setInboundNatRule__24() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
rule = utils.findFirstCaseIgnore(lb.inboundNatRules, { name: ruleName });
if (!rule) {
return _(new Error(util.format($("An inbound NAT rule with name \"%s\" not found in the load balancer \"%s\""), ruleName, lbName))); } ;
self._parseInboundNatRule(lb, rule, options, false);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 14, 14, function ___(__0, __2) { lb = __2;
rule = utils.findFirstCaseIgnore(lb.inboundNatRules, { name: ruleName });
self._showInboundNatRule(rule); _(); }, true)); }, true)); }); },
listInboundNatRules: function listInboundNatRules__25(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "listInboundNatRules__25", line: 549 }; return __func(_, this, arguments, listInboundNatRules__25, 3, __frame, function __$listInboundNatRules__25() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
self.interaction.formatOutput(lb.inboundNatRules, function(inboundNatRules) {
if ((inboundNatRules.length === 0)) {
self.output.warn($("No inbound NAT rules found")); }
else {
self._listInboundNatRules(inboundNatRules); } ; }); _(); }, true)); }); },
deleteInboundNatRule: function deleteInboundNatRule__26(resourceGroupName, lbName, ruleName, options, _) { var self, lb, ruleIndex, __this = this; var __frame = { name: "deleteInboundNatRule__26", line: 566 }; return __func(_, this, arguments, deleteInboundNatRule__26, 4, __frame, function __$deleteInboundNatRule__26() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 2, 18, function ___(__0, __2) { lb = __2;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
ruleIndex = utils.indexOfCaseIgnore(lb.inboundNatRules, { name: ruleName });
if ((ruleIndex === -1)) {
return _(new Error(util.format($("An inbound NAT rule with name \"%s\" not found in the load balancer \"%s\""), ruleName, lbName))); } ; return (function __$deleteInboundNatRule__26(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete inbound NAT rule \"%s\" ? [y/n] "), ruleName), __cb(_, __frame, 13, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -565, 17, function ___(__0, __3) { return (function __$deleteInboundNatRule__26(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$deleteInboundNatRule__26() {
lb.inboundNatRules.splice(ruleIndex, 1);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 18, 9, function __$deleteInboundNatRule__26() { _(); }, true)); }); }, true)); }, true)); }); },
createInboundNatPool: function createInboundNatPool__27(resourceGroupName, lbName, poolName, options, _) { var self, lb, pool, __this = this; var __frame = { name: "createInboundNatPool__27", line: 590 }; return __func(_, this, arguments, createInboundNatPool__27, 4, __frame, function __$createInboundNatPool__27() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
pool = {
name: poolName };
pool = self._parseInboundNatPool(lb, pool, options, true);
if (utils.findFirstCaseIgnore(lb.inboundNatPools, { name: poolName })) {
return _(new Error(util.format($("An inbound NAT pool with name \"%s\" already exists in the load balancer \"%s\""), poolName, lbName))); } ;
lb.inboundNatPools.push(pool);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 19, 14, function ___(__0, __2) { lb = __2;
pool = utils.findFirstCaseIgnore(lb.inboundNatPools, { name: poolName });
self._showInboundNatPool(pool); _(); }, true)); }, true)); }); },
setInboundNatPool: function setInboundNatPool__28(resourceGroupName, lbName, poolName, options, _) { var self, lb, pool, __this = this; var __frame = { name: "setInboundNatPool__28", line: 615 }; return __func(_, this, arguments, setInboundNatPool__28, 4, __frame, function __$setInboundNatPool__28() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
pool = utils.findFirstCaseIgnore(lb.inboundNatPools, { name: poolName });
if (!pool) {
return _(new Error(util.format($("An inbound NAT pool with name \"%s\" not found in the load balancer \"%s\""), poolName, lbName))); } ;
self._parseInboundNatPool(lb, pool, options, false);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 14, 14, function ___(__0, __2) { lb = __2;
pool = utils.findFirstCaseIgnore(lb.inboundNatPools, { name: poolName });
self._showInboundNatPool(pool); _(); }, true)); }, true)); }); },
listInboundNatPools: function listInboundNatPools__29(resourceGroupName, lbName, options, _) { var self, lb, __this = this; var __frame = { name: "listInboundNatPools__29", line: 635 }; return __func(_, this, arguments, listInboundNatPools__29, 3, __frame, function __$listInboundNatPools__29() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __1) { lb = __1;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
self.interaction.formatOutput(lb.inboundNatPools, function(inboundNatPools) {
if ((inboundNatPools.length === 0)) {
self.output.warn($("No inbound NAT pools found")); }
else {
self._listInboundNatPools(inboundNatPools); } ; }); _(); }, true)); }); },
deleteInboundNatPool: function deleteInboundNatPool__30(resourceGroupName, lbName, poolName, options, _) { var self, lb, index, __this = this; var __frame = { name: "deleteInboundNatPool__30", line: 652 }; return __func(_, this, arguments, deleteInboundNatPool__30, 4, __frame, function __$deleteInboundNatPool__30() { self = __this;
return self.get(resourceGroupName, lbName, __cb(_, __frame, 3, 18, function ___(__0, __2) { lb = __2;
if (!lb) {
return _(new Error(util.format($("A load balancer with name \"%s\" not found in the resource group \"%s\""), lbName, resourceGroupName))); } ;
index = utils.indexOfCaseIgnore(lb.inboundNatPools, { name: poolName });
if ((index === -1)) {
return _(new Error(util.format($("An inbound NAT pool with name \"%s\" not found in the load balancer \"%s\""), poolName, lbName))); } ; return (function __$deleteInboundNatPool__30(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete inbound NAT pool \"%s\" ? [y/n] "), poolName), __cb(_, __frame, 13, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -651, 17, function ___(__0, __3) { return (function __$deleteInboundNatPool__30(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$deleteInboundNatPool__30() {
lb.inboundNatPools.splice(index, 1);
return self.update(resourceGroupName, lbName, lb, __cb(_, __frame, 18, 9, function __$deleteInboundNatPool__30() { _(); }, true)); }); }, true)); }, true)); }); },
_parseLoadBalancer: function(lb, options) {
if (options.tags) {
if (utils.argHasValue(options.tags)) {
tagUtils.appendTags(lb, options); }
else {
lb.tags = { }; } ; } ;
return lb; },
_parseFrontendIP: function _parseFrontendIP__31(resourceGroupName, fip, options, _) { var self, publicip, subnet, __this = this; var __frame = { name: "_parseFrontendIP__31", line: 688 }; return __func(_, this, arguments, _parseFrontendIP__31, 3, __frame, function __$_parseFrontendIP__31() { self = __this;
if (options.privateIpAddress) {
if (utils.argHasValue(options.privateIpAddress)) {
fip.privateIPAddress = validation.isIP(options.privateIpAddress, "--private-ip-address");
fip.privateIPAllocationMethod = "Static"; }
else {
delete fip.privateIPAddress;
fip.privateIPAllocationMethod = "Dynamic"; } ; } ; return (function __$_parseFrontendIP__31(__then) {
if (options.publicIpId) {
if (options.publicIpName) { self.output.warn($("--public-ip-name parameter will be ignored because --public-ip-id and --public-ip-name are mutually exclusive")); } ;
fip.publicIPAddress = {
id: options.publicIpId };
delete fip.subnet; __then(); } else { return (function __$_parseFrontendIP__31(__then) {
if (options.publicIpName) {
return self.publicIpCrud.get(resourceGroupName, options.publicIpName, __cb(_, __frame, 20, 39, function ___(__0, __1) { publicip = __1;
if (!publicip) {
return _(new Error(util.format($("A public ip address with name \"%s\" not found in the resource group \"%s\""), options.publicIpName, resourceGroupName))); } ;
fip.publicIPAddress = {
id: publicip.id };
delete fip.subnet; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$_parseFrontendIP__31() { return (function __$_parseFrontendIP__31(__then) {
if (options.subnetId) {
if ((options.subnetName || options.subnetVnetName)) { self.output.warn($("--subnet-name, --subnet-vnet-name parameter will be ignored because --subnet-name, --subnet-vnet-name and --subnet-id are mutually exclusive")); } ;
fip.subnet = {
id: options.subnetId };
delete fip.publicIPAddress; __then(); } else { return (function __$_parseFrontendIP__31(__then) {
if ((options.subnetName && options.subnetVnetName)) {
return self.subnetCrud.get(resourceGroupName, options.subnetVnetName, options.subnetName, __cb(_, __frame, 37, 35, function ___(__0, __2) { subnet = __2;
if (!subnet) {
return _(new Error(util.format($("A subnet with name \"%s\" not found in the resource group \"%s\""), options.subnetName, resourceGroupName))); } ;
fip.subnet = {
id: subnet.id };
delete fip.publicIPAddress; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$_parseFrontendIP__31() {
return _(null, fip); }); }); }); },
_parseProbe: function(probe, options, useDefaults) {
var self = this;
if (options.path) {
if (utils.stringIsNullOrEmpty(options.path)) {
throw new Error($("--path must not be null or empty string")); } ;
probe.requestPath = options.path; } ;
if (options.protocol) {
validation.isIn(options.protocol, constants.lb.probe.protocols, "--protocol");
if (utils.ignoreCaseEquals(options.protocol, "tcp")) {
if (options.path) {
self.output.warn($("--path will be ignored when probe protocol is TCP")); } ;
delete probe.requestPath; } ;
if ((utils.ignoreCaseEquals(options.protocol, "http") && !options.path)) {
throw new Error($("--path is required when probe protocol is HTTP")); } ;
probe.protocol = options.protocol; }
else if (useDefaults) {
probe.protocol = utils.takeDefault(self.output, constants.lb.defProtocol, "--protocol"); } ;
if (options.port) {
probe.port = validation.isInt(options.port, constants.lb.port, "--port"); }
else if (useDefaults) {
probe.port = utils.takeDefault(self.output, constants.lb.defPort, "--port"); } ;
if (options.interval) {
probe.intervalInSeconds = validation.isInt(options.interval, constants.lb.probe.interval, "--interval"); } ;
if (options.count) {
probe.numberOfProbes = validation.isInt(options.count, { }, "--count"); } ;
return probe; },
_parseBalancingRule: function(lb, rule, options, useDefaults) {
var self = this;
if (options.protocol) {
rule.protocol = validation.isIn(options.protocol, constants.lb.protocols, "--protocol"); }
else if (useDefaults) {
rule.protocol = utils.takeDefault(self.output, constants.lb.defProtocol, "--protocol"); } ;
if (options.frontendPort) {
rule.frontendPort = validation.isInt(options.frontendPort, constants.lb.port, "--frontend-port"); }
else if (useDefaults) {
rule.frontendPort = utils.takeDefault(self.output, constants.lb.defPort, "--frontend-port"); } ;
if (options.backendPort) {
rule.backendPort = validation.isInt(options.backendPort, constants.lb.port, "--backend-port"); }
else if (useDefaults) {
rule.backendPort = utils.takeDefault(self.output, constants.lb.defPort, "--backend-port"); } ;
if (options.idleTimeout) {
rule.idleTimeoutInMinutes = validation.isInt(options.idleTimeout, { }, "--idle-timeout"); }
else if (useDefaults) {
rule.idleTimeoutInMinutes = utils.takeDefault(self.output, constants.lb.defTimeout, "--idle-timeout"); } ;
if (options.enableFloatingIp) {
rule.enableFloatingIP = validation.isBool(options.enableFloatingIp, "--enable-floating-ip"); }
else if (useDefaults) {
rule.enableFloatingIP = utils.takeDefault(self.output, constants.lb.defFloatingIp, "--enable-floating-ip"); } ;
if (options.backendAddressPoolName) {
var pool = utils.findFirstCaseIgnore(lb.backendAddressPools, {
name: options.backendAddressPoolName });
if (!pool) {
throw new Error(util.format($("Backend address pool with name \"%s\" not found in the load balancer \"%s\""), options.backendAddressPoolName, lb.name)); } ;
rule.backendAddressPool = {
id: pool.id }; }
else if (useDefaults) {
if ((lb.backendAddressPools.length === 0)) {
throw new Error($("Load balancer must have at least one backend address pool if --backend-address-pool--name parameter is not specified.")); } ;
var defPool = lb.backendAddressPools[0];
self.output.warn(util.format($("Using backend address pool: %s"), defPool.name));
rule.backendAddressPool = {
id: defPool.id }; } ;
if (options.frontendIpName) {
var fip = utils.findFirstCaseIgnore(lb.frontendIPConfigurations, {
name: options.frontendIpName });
if (!fip) {
throw new Error(util.format($("Frontend IP configuration with name \"%s\" not found in the load balancer \"%s\""), options.frontendIpName, lb.name)); } ;
rule.frontendIPConfiguration = {
id: fip.id }; }
else if (useDefaults) {
if ((lb.frontendIPConfigurations.length === 0)) {
throw new Error($("Load balancer must have at least one frontend IP configuration if --frontend-ip-name parameter is not specified.")); } ;
var defFip = lb.frontendIPConfigurations[0];
self.output.warn(util.format($("Using frontend IP configuration: %s"), defFip.name));
rule.frontendIPConfiguration = {
id: defFip.id }; } ;
if (options.loadDistribution) {
rule.loadDistribution = validation.isIn(options.loadDistribution, constants.lb.distribution, "--load-distribution"); }
else if (useDefaults) {
rule.loadDistribution = utils.takeDefault(self.output, constants.lb.distribution[0], "--load-distribution"); } ;
if (options.probeName) {
if (utils.argHasValue(options.probeName)) {
if ((lb.probes.length === 0)) {
throw new Error(util.format($("No probes found for the load balancer \"%s\""), lb.name)); } ;
var probe = utils.findFirstCaseIgnore(lb.probes, {
name: options.probeName });
if (!probe) {
throw new Error(util.format($("Probe with name \"%s\" not found in the load balancer \"%s\""), options.probeName, lb.name)); } ;
rule.probe = {
id: probe.id }; }
else {
delete rule.probe; } ; } ;
return rule; },
_parseInboundNatRule: function(lb, rule, options, useDefaults) {
var self = this;
if (options.protocol) {
rule.protocol = validation.isIn(options.protocol, constants.lb.protocols, "--protocol"); }
else if (useDefaults) {
rule.protocol = utils.takeDefault(self.output, constants.lb.defProtocol, "--protocol"); } ;
if (options.frontendPort) {
rule.frontendPort = validation.isInt(options.frontendPort, constants.lb.port, "--frontend-port"); }
else if (useDefaults) {
rule.frontendPort = utils.takeDefault(self.output, constants.lb.defPort, "--frontend-port"); } ;
if (options.backendPort) {
rule.backendPort = validation.isInt(options.backendPort, constants.lb.port, "--backend-port"); }
else if (useDefaults) {
rule.backendPort = utils.takeDefault(self.output, constants.lb.defPort, "--backend-port"); } ;
if (options.enableFloatingIp) {
rule.enableFloatingIP = validation.isBool(options.enableFloatingIp, "--enable-floating-ip"); }
else if (useDefaults) {
rule.enableFloatingIP = utils.takeDefault(self.output, constants.lb.defFloatingIp, "--enable-floating-ip"); } ;
if (options.idleTimeout) {
rule.idleTimeoutInMinutes = validation.isInt(options.idleTimeout, { }, "--idle-timeout"); }
else if (useDefaults) {
rule.idleTimeoutInMinutes = utils.takeDefault(self.output, constants.lb.defTimeout, "--idle-timeout"); } ;
if (options.frontendIpName) {
var fip = utils.findFirstCaseIgnore(lb.frontendIPConfigurations, {
name: options.frontendIpName });
if (!fip) {
throw new Error(util.format($("Frontend IP configuration with name \"%s\" not found in the load balancer \"%s\""), options.frontendIpName, lb.name)); } ;
rule.frontendIPConfiguration = {
id: fip.id }; }
else if (useDefaults) {
if ((lb.frontendIPConfigurations.length === 0)) {
throw new Error(util.format($("Load balancer \"%s\" has no frontend IP conf