azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
724 lines (402 loc) • 41.4 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 tagUtils = require("../tag/tagUtils");
var resourceUtils = require("../resource/resourceUtils");
var Subnet = require("./subnet");
var LoadBalancer = require("./loadBalancer");
var Nsg = require("./nsg");
var PublicIp = require("./publicIp");
function Nic(cli, networkManagementClient) {
this.networkManagementClient = networkManagementClient;
this.subnetCrud = new Subnet(cli, networkManagementClient);
this.loadBalancerCrud = new LoadBalancer(cli, networkManagementClient);
this.nsgCrud = new Nsg(cli, networkManagementClient);
this.publicIpCrud = new PublicIp(cli, networkManagementClient);
this.output = cli.output;
this.interaction = cli.interaction;};
__.extend(Nic.prototype, {
create: function create__1(resourceGroupName, nicName, options, _) { var self, nic, ipConfig, progress, __this = this; var __frame = { name: "create__1", line: 43 }; return __func(_, this, arguments, create__1, 3, __frame, function __$create__1() { self = __this;
if (((!options.subnetId && !options.subnetName) && !options.subnetVnetName)) {
return _(new Error($("--subnet-id or --subnet-name, --subnet-vnet-name parameters must be provided"))); } ;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 7, 19, function ___(__0, __1) { nic = __1;
if (nic) {
return _(new Error(util.format($("A network interface with name \"%s\" already exists in the resource group \"%s\""), nicName, resourceGroupName))); } ;
ipConfig = {
name: "default-ip-config" };
nic = {
location: options.location,
ipConfigurations: [] };
return self._parseNic(resourceGroupName, nic, options, __cb(_, __frame, 21, 15, function ___(__0, __2) { nic = __2;
return self._parseIpConfig(resourceGroupName, ipConfig, options, __cb(_, __frame, 23, 20, function ___(__0, __3) { ipConfig = __3;
nic.ipConfigurations.push(ipConfig);
progress = self.interaction.progress(util.format($("Creating network interface \"%s\""), nicName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$create__1() {
return self.networkManagementClient.networkInterfaces.createOrUpdate(resourceGroupName, nicName, nic, __cb(_, __frame, 29, 59, function ___(__0, __4) { nic = __4; _(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._showNic(nic, resourceGroupName, nicName); _(); }); }); }, true)); }, true)); }, true)); }); },
set: function set__2(resourceGroupName, nicName, options, _) { var self, nic, __this = this; var __frame = { name: "set__2", line: 80 }; return __func(_, this, arguments, set__2, 3, __frame, function __$set__2() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 3, 19, function ___(__0, __1) { nic = __1;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
return self._parseNic(resourceGroupName, nic, options, __cb(_, __frame, 8, 15, function ___(__0, __2) { nic = __2;
return self.update(resourceGroupName, nicName, nic, __cb(_, __frame, 9, 15, function ___(__0, __3) { nic = __3;
self._showNic(nic, resourceGroupName, nicName); _(); }, true)); }, true)); }, true)); }); },
list: function list__3(options, _) { var self, nics, progress, __this = this; var __frame = { name: "list__3", line: 93 }; return __func(_, this, arguments, list__3, 1, __frame, function __$list__3() { self = __this;
nics = null;
progress = self.interaction.progress($("Getting the network interfaces")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$list__3() { return (function __$list__3(__then) {
if (options.resourceGroup) { return (function __$list__3(__then) {
if (options.virtualMachineScaleSetName) { return (function __$list__3(__then) {
if (options.virtualMachineIndex) {
return self.networkManagementClient.networkInterfaces.listVirtualMachineScaleSetVMNetworkInterfaces(options.resourceGroup, options.virtualMachineScaleSetName, options.virtualMachineIndex, __cb(_, __frame, 10, 66, function ___(__0, __1) { nics = __1; __then(); }, true)); } else {
return self.networkManagementClient.networkInterfaces.listVirtualMachineScaleSetNetworkInterfaces(options.resourceGroup, options.virtualMachineScaleSetName, __cb(_, __frame, 12, 66, function ___(__0, __2) { nics = __2; __then(); }, true)); } ; })(__then); } else {
return self.networkManagementClient.networkInterfaces.list(options.resourceGroup, __cb(_, __frame, 15, 64, function ___(__0, __3) { nics = __3; __then(); }, true)); } ; })(__then); } else {
return self.networkManagementClient.networkInterfaces.listAll(__cb(_, __frame, 18, 62, function ___(__0, __4) { nics = __4; __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(nics, function(nics) {
if ((nics.length === 0)) {
self.output.warn($("No network interfaces found")); }
else {
self.output.table(nics, function(row, nic) {
row.cell($("Name"), nic.name);
row.cell($("Location"), (nic.location || ""));
var resInfo = resourceUtils.getResourceInformation(nic.id);
row.cell($("Resource group"), resInfo.resourceGroup);
row.cell($("Provisioning state"), nic.provisioningState);
row.cell($("MAC Address"), (nic.macAddress || ""));
row.cell($("IP forwarding"), nic.enableIPForwarding);
row.cell($("Internal DNS name"), (nic.dnsSettings.internalDnsNameLabel || ""));
row.cell($("Internal FQDN"), (nic.dnsSettings.internalFqdn || ""));
if (nic.dnsSettings.internalDomainNameSuffix) {
row.cell($("Internal domain name suffix"), (nic.dnsSettings.internalDomainNameSuffix || "")); } ; }); } ; }); _(); }); }); }); },
show: function show__4(resourceGroupName, nicName, options, _) { var self, nic, __this = this; var __frame = { name: "show__4", line: 140 }; return __func(_, this, arguments, show__4, 3, __frame, function __$show__4() { self = __this;
nic = null; return (function __$show__4(__then) {
if ((options.virtualMachineScaleSetName || options.virtualMachineIndex)) {
if (!((options.virtualMachineScaleSetName && options.virtualMachineIndex))) {
return _(new Error(util.format($("--virtual-machine-scale-set-name and --virtual-machine-index must be specified")))); } ;
return self.getFromScaleSet(resourceGroupName, options.virtualMachineScaleSetName, options.virtualMachineIndex, nicName, __cb(_, __frame, 8, 17, function ___(__0, __1) { nic = __1; __then(); }, true)); } else {
return self.get(resourceGroupName, nicName, __cb(_, __frame, 10, 17, function ___(__0, __2) { nic = __2; __then(); }, true)); } ; })(function __$show__4() {
self._showNic(nic, resourceGroupName, nicName); _(); }); }); },
get: function get__5(resourceGroupName, nicName, _) { var self, progress, nic, __this = this; var __frame = { name: "get__5", line: 156 }; return __func(_, this, arguments, get__5, 2, __frame, function __$get__5() { self = __this;
progress = self.interaction.progress(util.format($("Looking up the network interface \"%s\""), nicName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__5() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__5() {
return self.networkManagementClient.networkInterfaces.get(resourceGroupName, nicName, null, __cb(_, __frame, 4, 63, function ___(__0, __1) { nic = __1;
return _(null, nic); }, 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() { _(); }); }); }); },
getFromScaleSet: function getFromScaleSet__6(resourceGroupName, virtualMachineScaleSetName, virtualMachineIndex, nicName, _) { var self, progress, nic, __this = this; var __frame = { name: "getFromScaleSet__6", line: 172 }; return __func(_, this, arguments, getFromScaleSet__6, 4, __frame, function __$getFromScaleSet__6() { self = __this;
progress = self.interaction.progress(util.format($("Looking up the network interface \"%s\" in scale set \"%s\""), nicName, virtualMachineScaleSetName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getFromScaleSet__6() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getFromScaleSet__6() {
return self.networkManagementClient.networkInterfaces.getVirtualMachineScaleSetNetworkInterface(resourceGroupName, virtualMachineScaleSetName, virtualMachineIndex, nicName, null, __cb(_, __frame, 4, 63, function ___(__0, __1) { nic = __1;
return _(null, nic); }, true)); }); })(function ___(e, __result) { __catch(function __$getFromScaleSet__6() { if (e) {
if ((e.statusCode === 404)) {
return _(null, null); } ;
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$getFromScaleSet__6() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getFromScaleSet__6() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getFromScaleSet__6() { _(); }); }); }); },
delete: function delete__7(resourceGroupName, nicName, options, _) { var self, nic, progress, __this = this; var __frame = { name: "delete__7", line: 188 }; return __func(_, this, arguments, delete__7, 3, __frame, function __$delete__7() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 2, 19, function ___(__0, __2) { nic = __2;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ; return (function __$delete__7(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete network interface \"%s\"? [y/n] "), nicName), __cb(_, __frame, 8, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -187, 17, function ___(__0, __3) { return (function __$delete__7(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$delete__7() {
progress = self.interaction.progress(util.format($("Deleting network interface \"%s\""), nicName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$delete__7() {
return self.networkManagementClient.networkInterfaces.deleteMethod(resourceGroupName, nicName, __cb(_, __frame, 14, 53, function __$delete__7() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$delete__7() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$delete__7() { _(); }); }); }); }, true)); }, true)); }); },
update: function update__8(resourceGroupName, nicName, nic, _) { var self, progress, __this = this; var __frame = { name: "update__8", line: 208 }; return __func(_, this, arguments, update__8, 3, __frame, function __$update__8() { self = __this;
progress = self.interaction.progress(util.format($("Updating network interface \"%s\""), nicName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$update__8() {
return self.networkManagementClient.networkInterfaces.createOrUpdate(resourceGroupName, nicName, nic, __cb(_, __frame, 4, 59, function ___(__0, __1) { nic = __1;
return _(null, nic); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$update__8() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$update__8() { _(); }); }); }); },
createIpConfig: function createIpConfig__9(resourceGroupName, nicName, ipConfigName, options, _) { var self, nic, ipConfig, __this = this; var __frame = { name: "createIpConfig__9", line: 222 }; return __func(_, this, arguments, createIpConfig__9, 4, __frame, function __$createIpConfig__9() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 7, 19, function ___(__0, __1) { nic = __1;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
ipConfig = {
name: ipConfigName };
if (utils.findFirstCaseIgnore(nic.ipConfigurations, { name: ipConfigName })) {
return _(new Error(util.format($("IP configuration with name \"%s\" already exists in the nic \"%s\""), ipConfigName, nicName))); } ;
return self._parseIpConfig(resourceGroupName, ipConfig, options, __cb(_, __frame, 20, 20, function ___(__0, __2) { ipConfig = __2;
nic.ipConfigurations.push(ipConfig);
return self.update(resourceGroupName, nicName, nic, __cb(_, __frame, 26, 15, function ___(__0, __3) { nic = __3;
self._showNic(nic); _(); }, true)); }, true)); }, true)); }); },
setIpConfig: function setIpConfig__10(resourceGroupName, nicName, ipConfigName, options, _) { var self, nic, ipConfig, __this = this; var __frame = { name: "setIpConfig__10", line: 252 }; return __func(_, this, arguments, setIpConfig__10, 4, __frame, function __$setIpConfig__10() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 3, 19, function ___(__0, __1) { nic = __1;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
ipConfig = utils.findFirstCaseIgnore(nic.ipConfigurations, { name: ipConfigName });
if (!ipConfig) {
return _(new Error(util.format($("IP configuration with name \"%s\" not found in the nic \"%s\""), ipConfigName, nicName))); } ;
return self._parseIpConfig(resourceGroupName, ipConfig, options, __cb(_, __frame, 13, 20, function ___(__0, __2) { ipConfig = __2;
return self.update(resourceGroupName, nicName, nic, __cb(_, __frame, 17, 15, function ___(__0, __3) { nic = __3;
self._showNic(nic); _(); }, true)); }, true)); }, true)); }); },
listIpConfigs: function listIpConfigs__11(resourceGroupName, nicName, options, _) { var self, nic, __this = this; var __frame = { name: "listIpConfigs__11", line: 273 }; return __func(_, this, arguments, listIpConfigs__11, 3, __frame, function __$listIpConfigs__11() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 3, 19, function ___(__0, __1) { nic = __1;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
self.interaction.formatOutput(nic.ipConfigurations, function(ipConfigurations) {
if ((ipConfigurations.length === 0)) {
self.output.warn($("No ip configurations found")); }
else {
self.output.table(ipConfigurations, function(row, ipConfig) {
row.cell($("Name"), ipConfig.name);
row.cell($("Provisioning state"), ipConfig.provisioningState);
row.cell($("Private IP allocation"), ipConfig.privateIPAllocationMethod);
row.cell($("Private IP version"), ipConfig.privateIPAddressVersion);
row.cell($("Private IP address"), (ipConfig.privateIPAddress || ""));
var subnetName = "";
if (ipConfig.subnet) {
subnetName = resourceUtils.getResourceInformation(ipConfig.subnet.id).resourceName; } ;
row.cell($("Subnet"), subnetName);
var publicIpName = "";
if (ipConfig.publicIPAddress) {
publicIpName = resourceUtils.getResourceInformation(ipConfig.publicIPAddress.id).resourceName; } ;
row.cell($("Public IP"), publicIpName); }); } ; }); _(); }, true)); }); },
showIpConfig: function showIpConfig__12(resourceGroupName, nicName, ipConfigName, options, _) { var self, nic, ipConfig, __this = this; var __frame = { name: "showIpConfig__12", line: 308 }; return __func(_, this, arguments, showIpConfig__12, 4, __frame, function __$showIpConfig__12() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 3, 19, function ___(__0, __1) { nic = __1;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
ipConfig = utils.findFirstCaseIgnore(nic.ipConfigurations, { name: ipConfigName });
self._showIpConfig(ipConfig, nicName, ipConfigName); _(); }, true)); }); },
deleteIpConfig: function deleteIpConfig__13(resourceGroupName, nicName, ipConfigName, options, _) { var self, nic, index, __this = this; var __frame = { name: "deleteIpConfig__13", line: 320 }; return __func(_, this, arguments, deleteIpConfig__13, 4, __frame, function __$deleteIpConfig__13() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 3, 19, function ___(__0, __2) { nic = __2;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
index = utils.indexOfCaseIgnore(nic.ipConfigurations, { name: ipConfigName });
if ((index === -1)) {
return _(new Error(util.format($("IP configuration with name \"%s\" not found in the nic \"%s\""), ipConfigName, nicName))); } ; return (function __$deleteIpConfig__13(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete ip configuration \"%s\" ? [y/n] "), ipConfigName), __cb(_, __frame, 13, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -319, 17, function ___(__0, __3) { return (function __$deleteIpConfig__13(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$deleteIpConfig__13() {
nic.ipConfigurations.splice(index, 1);
return self.update(resourceGroupName, nicName, nic, __cb(_, __frame, 19, 15, function ___(__0, __4) { nic = __4;
self._showNic(nic); _(); }, true)); }); }, true)); }, true)); }); },
createBackendAddressPool: function createBackendAddressPool__14(resourceGroupName, nicName, ipConfigName, options, _) { var __this = this; var __frame = { name: "createBackendAddressPool__14", line: 346 }; return __func(_, this, arguments, createBackendAddressPool__14, 4, __frame, function __$createBackendAddressPool__14() {
return __this._updateBackendAddressPool(resourceGroupName, nicName, ipConfigName, options, true, __cb(_, __frame, 1, 9, function __$createBackendAddressPool__14() { _(); }, true)); }); },
deleteBackendAddressPool: function deleteBackendAddressPool__15(resourceGroupName, nicName, ipConfigName, options, _) { var __this = this; var __frame = { name: "deleteBackendAddressPool__15", line: 350 }; return __func(_, this, arguments, deleteBackendAddressPool__15, 4, __frame, function __$deleteBackendAddressPool__15() {
return __this._updateBackendAddressPool(resourceGroupName, nicName, ipConfigName, options, false, __cb(_, __frame, 1, 9, function __$deleteBackendAddressPool__15() { _(); }, true)); }); },
createInboundNatRule: function createInboundNatRule__16(resourceGroupName, nicName, ipConfigName, options, _) { var __this = this; var __frame = { name: "createInboundNatRule__16", line: 357 }; return __func(_, this, arguments, createInboundNatRule__16, 4, __frame, function __$createInboundNatRule__16() {
return __this._updateInboundNatRule(resourceGroupName, nicName, ipConfigName, options, true, __cb(_, __frame, 1, 9, function __$createInboundNatRule__16() { _(); }, true)); }); },
deleteInboundNatRule: function deleteInboundNatRule__17(resourceGroupName, nicName, ipConfigName, options, _) { var __this = this; var __frame = { name: "deleteInboundNatRule__17", line: 361 }; return __func(_, this, arguments, deleteInboundNatRule__17, 4, __frame, function __$deleteInboundNatRule__17() {
return __this._updateInboundNatRule(resourceGroupName, nicName, ipConfigName, options, false, __cb(_, __frame, 1, 9, function __$deleteInboundNatRule__17() { _(); }, true)); }); },
_parseNic: function _parseNic__18(resourceGroupName, nic, options, _) { var self, nsg, __this = this; var __frame = { name: "_parseNic__18", line: 368 }; return __func(_, this, arguments, _parseNic__18, 3, __frame, function __$_parseNic__18() { self = __this; return (function __$_parseNic__18(__then) {
if (options.networkSecurityGroupId) {
if (options.networkSecurityGroupName) { self.output.warn($("--network-security-group-name parameter will be ignored because --network-security-group-id and --network-security-group-name are mutually exclusive")); } ;
if (utils.argHasValue(options.networkSecurityGroupId)) {
nic.networkSecurityGroup = {
id: options.networkSecurityGroupId }; }
else {
delete nic.networkSecurityGroup; } ; __then(); } else { return (function __$_parseNic__18(__then) {
if (options.networkSecurityGroupName) { return (function __$_parseNic__18(__then) {
if (utils.argHasValue(options.networkSecurityGroupName)) {
return self.nsgCrud.get(resourceGroupName, options.networkSecurityGroupName, __cb(_, __frame, 14, 31, function ___(__0, __1) { nsg = __1;
if (!nsg) {
return _(new Error(util.format($("A network security group with name \"%s\" not found in the resource group \"%s\""), options.networkSecurityGroupName, resourceGroupName))); } ;
nic.networkSecurityGroup = {
id: nsg.id }; __then(); }, true)); } else {
delete nic.networkSecurityGroup; __then(); } ; })(__then); } else { __then(); } ; })(__then); } ; })(function __$_parseNic__18() {
if (options.internalDnsNameLabel) {
if (utils.argHasValue(options.internalDnsNameLabel)) {
if (!nic.dnsSettings) { nic.dnsSettings = { }; } ;
nic.dnsSettings.internalDnsNameLabel = options.internalDnsNameLabel; }
else {
delete nic.dnsSettings; } ; } ;
if (options.enableIpForwarding) {
nic.enableIPForwarding = utils.parseBool(options.enableIpForwarding, "--enable-ip-forwarding"); } ;
if (options.tags) {
if (utils.argHasValue(options.tags)) {
tagUtils.appendTags(nic, options); }
else {
nic.tags = { }; } ; } ;
return _(null, nic); }); }); },
_parseIpConfig: function _parseIpConfig__19(resourceGroupName, ipConfig, options, _) { var self, subnet, publicip, poolIds, natIds, __this = this; var __frame = { name: "_parseIpConfig__19", line: 418 }; return __func(_, this, arguments, _parseIpConfig__19, 3, __frame, function __$_parseIpConfig__19() { self = __this;
if (options.privateIpVersion) {
ipConfig.privateIPAddressVersion = validation.isIn(constants.publicIp.version, options.privateIpVersion, "--private-ip-version"); } ;
if (options.privateIpAddress) {
ipConfig.privateIPAddress = validation.isIP(options.privateIpAddress, "--private-ip-address");
ipConfig.privateIPAllocationMethod = "Static"; } ; return (function __$_parseIpConfig__19(__then) {
if (options.subnetId) {
if ((options.subnetName || options.subnetVnetName)) {
self.output.warn($("--subnet-name, --subnet-vnet-name parameters will be ignored because --subnet-name, --subnet-vnet-name and --subnet-id are mutually exclusive")); } ;
ipConfig.subnet = {
id: options.subnetId }; __then(); } else { return (function __$_parseIpConfig__19(__then) {
if ((options.subnetName && options.subnetVnetName)) {
return self.subnetCrud.get(resourceGroupName, options.subnetVnetName, options.subnetName, __cb(_, __frame, 20, 35, function ___(__0, __1) { subnet = __1;
if (!subnet) {
return _(new Error(util.format($("A subnet with name \"%s\" not found in the resource group \"%s\""), options.subnetName, resourceGroupName))); } ;
ipConfig.subnet = {
id: subnet.id }; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$_parseIpConfig__19() { return (function __$_parseIpConfig__19(__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")); } ;
if (utils.argHasValue(options.publicIpId)) {
ipConfig.publicIPAddress = {
id: options.publicIpId }; }
else {
delete ipConfig.publicIPAddress; } ; __then(); } else { return (function __$_parseIpConfig__19(__then) {
if (options.publicIpName) { return (function __$_parseIpConfig__19(__then) {
if (utils.argHasValue(options.publicIpName)) {
return self.publicIpCrud.get(resourceGroupName, options.publicIpName, __cb(_, __frame, 40, 41, function ___(__0, __2) { publicip = __2;
if (!publicip) {
return _(new Error(util.format($("A public ip address with name \"%s\" not found in the resource group \"%s\""), options.publicIpName, resourceGroupName))); } ;
ipConfig.publicIPAddress = {
id: publicip.id }; __then(); }, true)); } else {
delete ipConfig.publicIPAddress; __then(); } ; })(__then); } else { __then(); } ; })(__then); } ; })(function __$_parseIpConfig__19() {
if (options.lbAddressPoolIds) {
if (utils.argHasValue(options.lbAddressPoolIds)) {
ipConfig.loadBalancerBackendAddressPools = [];
poolIds = options.lbAddressPoolIds.split(",");
poolIds.forEach(function(poolId) {
poolId = poolId.replace(/'|''$/gm, "");
var pool = {
id: poolId };
ipConfig.loadBalancerBackendAddressPools.push(pool); }); }
else {
ipConfig.loadBalancerBackendAddressPools = []; } ; } ;
if (options.lbInboundNatRuleIds) {
if (utils.argHasValue(options.lbInboundNatRuleIds)) {
ipConfig.loadBalancerInboundNatRules = [];
natIds = options.lbInboundNatRuleIds.split(",");
natIds.forEach(function(natId) {
natId = natId.replace(/'|''$/gm, "");
var nat = {
id: natId };
ipConfig.loadBalancerInboundNatRules.push(nat); }); }
else {
ipConfig.loadBalancerInboundNatRules = []; } ; } ;
return _(null, ipConfig); }); }); }); },
_showNic: function(nic, resourceGroupName, nicName) {
var self = this;
self.interaction.formatOutput(nic, function(nic) {
if ((nic === null)) {
self.output.warn(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName));
return; } ;
self.output.nameValue($("Id"), nic.id);
self.output.nameValue($("Name"), nic.name);
self.output.nameValue($("Type"), nic.type);
self.output.nameValue($("Location"), nic.location);
self.output.nameValue($("Provisioning state"), nic.provisioningState);
self.output.nameValue($("Tags"), tagUtils.getTagsInfo(nic.tags));
self.output.nameValue($("MAC address"), nic.macAddress);
self.output.nameValue($("Internal DNS name label"), nic.dnsSettings.internalDnsNameLabel);
self.output.nameValue($("Internal FQDN"), nic.dnsSettings.internalFqdn);
self.output.nameValue($("Internal domain name suffix"), nic.dnsSettings.internalDomainNameSuffix);
self.output.nameValue($("Enable IP forwarding"), nic.enableIPForwarding);
if (nic.networkSecurityGroup) {
self.output.nameValue($("Network security group"), nic.networkSecurityGroup.id); } ;
if (nic.virtualMachine) {
self.output.nameValue($("Virtual machine"), nic.virtualMachine.id); } ;
self.output.header($("IP configurations"));
nic.ipConfigurations.forEach(function(ipConfig) {
self._showIpConfig(ipConfig, nicName, ipConfig.name);
self.output.data($(""), ""); }); }); },
_showIpConfig: function(ipConfig, nicName, ipConfigName) {
var self = this;
self.interaction.formatOutput(ipConfig, function(ipConfig) {
if (((ipConfig === null) || (ipConfig === undefined))) {
self.output.warn(util.format($("IP configuration with name \"%s\" not found in the nic \"%s\""), ipConfigName, nicName));
return; } ;
self.output.nameValue($("Name"), ipConfig.name, 2);
self.output.nameValue($("Provisioning state"), ipConfig.provisioningState, 2);
self.output.nameValue($("Private IP address"), ipConfig.privateIPAddress, 2);
self.output.nameValue($("Private IP version"), ipConfig.privateIPAddressVersion, 2);
self.output.nameValue($("Private IP allocation method"), ipConfig.privateIPAllocationMethod, 2);
if (ipConfig.publicIPAddress) {
self.output.nameValue($("Public IP address"), ipConfig.publicIPAddress.id, 2); } ;
if (ipConfig.subnet) {
self.output.nameValue($("Subnet"), ipConfig.subnet.id, 2); } ;
if ((ipConfig.loadBalancerBackendAddressPools && (ipConfig.loadBalancerBackendAddressPools.length > 0))) {
self.output.header($("Load balancer backend address pools"), 2);
ipConfig.loadBalancerBackendAddressPools.forEach(function(pool) {
self.output.nameValue($("Id"), pool.id, 4); }); } ;
if ((ipConfig.loadBalancerInboundNatRules && (ipConfig.loadBalancerInboundNatRules.length > 0))) {
self.output.header($("Load balancer inbound NAT rules"), 2);
ipConfig.loadBalancerInboundNatRules.forEach(function(rule) {
self.output.nameValue($("Id"), rule.id, 4); }); } ; }); },
_updateBackendAddressPool: function _updateBackendAddressPool__20(resourceGroupName, nicName, ipConfigName, options, isAdding, _) { var self, nic, ipConfig, poolId, lb, pool, index, __this = this; var __frame = { name: "_updateBackendAddressPool__20", line: 577 }; return __func(_, this, arguments, _updateBackendAddressPool__20, 5, __frame, function __$_updateBackendAddressPool__20() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 3, 19, function ___(__0, __1) { nic = __1;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
if (ipConfigName) {
ipConfig = utils.findFirstCaseIgnore(nic.ipConfigurations, { name: ipConfigName });
if (!ipConfig) {
return _(new Error(util.format($("An ip configuration with name \"%s\" not found in the nic \"%s\""), ipConfigName, nicName))); } ; }
else {
ipConfig = nic.ipConfigurations[0];
self.output.warn(util.format($("--ip-config-name not specified, using \"%s\" ip configuration"), ipConfig.name)); } ;
poolId = null;
if (!ipConfig.loadBalancerBackendAddressPools) {
ipConfig.loadBalancerBackendAddressPools = []; } ;
if (((!options.lbAddressPoolId && !options.lbName) && !options.lbAddressPoolName)) {
return _(new Error($("You must specify --lb-address-pool-id or --lb-name, --lb-address-pool-name"))); } ; return (function __$_updateBackendAddressPool__20(__then) {
if (options.lbAddressPoolId) {
if ((options.lbName || options.lbAddressPoolName)) {
self.output.warn("--lb-name parameter, --lb-address-pool-name will be ignored"); } ;
poolId = options.lbAddressPoolId; __then(); } else { return (function __$_updateBackendAddressPool__20(__then) {
if ((options.lbName || options.lbAddressPoolName)) {
if (!options.lbName) {
return _(new Error($("You must specify --lb-name parameter if --lb-address-pool-name is specified"))); } ;
if (!options.lbAddressPoolName) {
return _(new Error($("You must specify --lb-address-pool-name parameter if --lb-name is specified"))); } ;
return self.loadBalancerCrud.get(resourceGroupName, options.lbName, __cb(_, __frame, 42, 37, 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"), options.lbName, resourceGroupName))); } ;
pool = utils.findFirstCaseIgnore(lb.backendAddressPools, { name: options.lbAddressPoolName });
if (!pool) {
return _(new Error(util.format($("A backend address pool with name \"%s\" not found in the load balancer \"%s\" resource group \"%s\""), options.lbAddressPoolName, options.lbName, resourceGroupName))); } ;
poolId = pool.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$_updateBackendAddressPool__20() {
if (isAdding) {
if (utils.findFirstCaseIgnore(ipConfig.loadBalancerBackendAddressPools, { id: poolId })) {
return _(new Error(util.format($("Specified backend address pool already attached to NIC \"%s\" in the resource group \"%s\""), nicName, resourceGroupName))); } ;
ipConfig.loadBalancerBackendAddressPools.push({ id: poolId }); }
else {
index = utils.indexOfCaseIgnore(ipConfig.loadBalancerBackendAddressPools, { id: poolId });
if ((index === -1)) {
return _(new Error(util.format($("Backend address pool is not attached to NIC \"%s\" in the resource group \"%s\""), nicName, resourceGroupName))); } ;
ipConfig.loadBalancerBackendAddressPools.splice(index, 1); } ;
return self.update(resourceGroupName, nicName, nic, __cb(_, __frame, 67, 15, function ___(__0, __3) { nic = __3;
self._showNic(nic); _(); }, true)); }); }, true)); }); },
_updateInboundNatRule: function _updateInboundNatRule__21(resourceGroupName, nicName, ipConfigName, options, isAdding, _) { var self, nic, ipConfig, ruleId, lb, rule, index, __this = this; var __frame = { name: "_updateInboundNatRule__21", line: 648 }; return __func(_, this, arguments, _updateInboundNatRule__21, 5, __frame, function __$_updateInboundNatRule__21() { self = __this;
return self.get(resourceGroupName, nicName, __cb(_, __frame, 3, 19, function ___(__0, __1) { nic = __1;
if (!nic) {
return _(new Error(util.format($("A network interface with name \"%s\" not found in the resource group \"%s\""), nicName, resourceGroupName))); } ;
if (ipConfigName) {
ipConfig = utils.findFirstCaseIgnore(nic.ipConfigurations, { name: ipConfigName });
if (!ipConfig) {
return _(new Error(util.format($("An ip configuration with name \"%s\" not found in the nic \"%s\""), ipConfigName, nicName))); } ; }
else {
ipConfig = nic.ipConfigurations[0];
self.output.warn(util.format($("--ip-config-name not specified, using \"%s\" ip configuration"), ipConfig.name)); } ;
ruleId = null;
if (!ipConfig.loadBalancerInboundNatRules) {
ipConfig.loadBalancerInboundNatRules = []; } ;
if (((!options.lbInboundNatRuleId && !options.lbName) && !options.lbInboundNatRuleName)) {
return _(new Error($("You must specify --lb-inbound-nat-rule-id or --lb-name, --lb-inbound-nat-rule-name"))); } ; return (function __$_updateInboundNatRule__21(__then) {
if (options.lbInboundNatRuleId) {
if ((options.lbName || options.lbInboundNatRuleName)) {
self.output.warn("--lb-name, --lb-inbound-nat-rule-name will be ignored"); } ;
ruleId = options.lbInboundNatRuleId; __then(); } else { return (function __$_updateInboundNatRule__21(__then) {
if ((options.lbName || options.lbInboundNatRuleName)) {
if (!options.lbName) {
return _(new Error($("You must specify --lb-name parameter if --lb-inbound-nat-rule-name is specified"))); } ;
if (!options.lbInboundNatRuleName) {
return _(new Error($("You must specify --lb-inbound-nat-rule-name parameter if --lb-name is specified"))); } ;
return self.loadBalancerCrud.get(resourceGroupName, options.lbName, __cb(_, __frame, 42, 37, 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"), options.lbName, resourceGroupName))); } ;
rule = utils.findFirstCaseIgnore(lb.inboundNatRules, { name: options.lbInboundNatRuleName });
if (!rule) {
return _(new Error(util.format($("An inbound NAT rule with name \"%s\" not found in the load balancer \"%s\""), options.lbInboundNatRuleName, options.lbName))); }
else {
ruleId = rule.id; } ; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$_updateInboundNatRule__21() {
if (isAdding) {
if (!utils.findFirstCaseIgnore(ipConfig.loadBalancerInboundNatRules, { id: ruleId })) {
ipConfig.loadBalancerInboundNatRules.push({ id: ruleId }); }
else {
return _(new Error(util.format($("Inbound NAT rule already attached to NIC \"%s\" in the resource group \"%s\""), nicName, resourceGroupName))); } ; }
else {
index = utils.indexOfCaseIgnore(ipConfig.loadBalancerInboundNatRules, { id: ruleId });
if ((index !== -1)) {
ipConfig.loadBalancerInboundNatRules.splice(index, 1); }
else {
return _(new Error(util.format($("Inbound NAT rule is not attached to NIC \"%s\" in the resource group \"%s\""), nicName, resourceGroupName))); } ; } ;
return self.update(resourceGroupName, nicName, nic, __cb(_, __frame, 70, 15, function ___(__0, __3) { nic = __3;
self._showNic(nic); _(); }, true)); }); }, true)); }); }});
module.exports = Nic;