azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
473 lines (235 loc) • 25.7 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,__tryCatch=__rt.__tryCatch; var __ = require("underscore");
var util = require("util");
var async = require("async");
var utils = require("../../../util/utils");
var $ = utils.getLocaleString;
function VMImage(cli, serviceClients, resourceGroupName, params) {
this.cli = cli;
this.serviceClients = serviceClients;
this.resourceGroupName = resourceGroupName;
this.params = params;};
__.extend(VMImage.prototype, {
getVMImagePublisherList: function getVMImagePublisherList__1(location, _) { var publishers, progress, __this = this; var __frame = { name: "getVMImagePublisherList__1", line: 31 }; return __func(_, this, arguments, getVMImagePublisherList__1, 1, __frame, function __$getVMImagePublisherList__1() {
progress = __this.cli.interaction.progress(util.format($("Getting virtual machine and/or extension image publishers (Location: \"%s\")"), location)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getVMImagePublisherList__1() {
return __this.serviceClients.computeManagementClient.virtualMachineImages.listPublishers(location, __cb(_, __frame, 4, 84, function ___(__0, __1) { publishers = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getVMImagePublisherList__1() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getVMImagePublisherList__1() {
return _(null, publishers); }); }); }); },
getVMImageOffersList: function getVMImageOffersList__2(location, publisherName, _) { var offers, progress, __this = this; var __frame = { name: "getVMImageOffersList__2", line: 43 }; return __func(_, this, arguments, getVMImageOffersList__2, 2, __frame, function __$getVMImageOffersList__2() {
progress = __this.cli.interaction.progress(util.format($("Getting virtual machine image offers (Publisher: \"%s\" Location:\"%s\")"), publisherName, location)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getVMImageOffersList__2() {
return __this.serviceClients.computeManagementClient.virtualMachineImages.listOffers(location, publisherName, __cb(_, __frame, 4, 80, function ___(__0, __1) { offers = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getVMImageOffersList__2() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getVMImageOffersList__2() {
offers.map(function(sku) {
sku.publisher = publisherName;
return sku; });
return _(null, offers); }); }); }); },
getVMImageSkusList: function getVMImageSkusList__3(location, publisherName, offer, _) { var skus, progress, __this = this; var __frame = { name: "getVMImageSkusList__3", line: 60 }; return __func(_, this, arguments, getVMImageSkusList__3, 3, __frame, function __$getVMImageSkusList__3() {
progress = __this.cli.interaction.progress(util.format($("Getting virtual machine image skus (Publisher:\"%s\" Offer:\"%s\" Location:\"%s\")"), publisherName, offer, location)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getVMImageSkusList__3() {
return __this.serviceClients.computeManagementClient.virtualMachineImages.listSkus(location, publisherName, offer, __cb(_, __frame, 4, 78, function ___(__0, __1) { skus = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getVMImageSkusList__3() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getVMImageSkusList__3() {
skus.map(function(sku) {
sku.publisher = publisherName;
sku.offer = offer;
return sku; });
return _(null, skus); }); }); }); },
getVMImageListForSku: function getVMImageListForSku__4(location, publisherName, offer, skus, _) { var images, progress, __this = this; var __frame = { name: "getVMImageListForSku__4", line: 78 }; return __func(_, this, arguments, getVMImageListForSku__4, 4, __frame, function __$getVMImageListForSku__4() {
progress = __this.cli.interaction.progress(util.format($("Getting virtual machine images (Publisher:\"%s\" Offer:\"%s\" Sku: \"%s\" Location:\"%s\")"), publisherName, offer, skus, location)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getVMImageListForSku__4() {
return __this.serviceClients.computeManagementClient.virtualMachineImages.list(location, publisherName, offer, skus, __cb(_, __frame, 4, 80, function ___(__0, __1) { images = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getVMImageListForSku__4() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getVMImageListForSku__4() {
return _(null, images); }); }); }); },
getVMImageList: function getVMImageList__5(imageFilter, _) { var __this = this; var __frame = { name: "getVMImageList__5", line: 90 }; return __func(_, this, arguments, getVMImageList__5, 1, __frame, function __$getVMImageList__5() { return (function __$getVMImageList__5(__then) {
if (!imageFilter.location) {
return __this.cli.interaction.prompt($("Enter location: "), __cb(_, __frame, 2, 50, function ___(__0, __1) { imageFilter.location = __1; __then(); }, true)); } else { __then(); } ; })(function __$getVMImageList__5() { return (function __$getVMImageList__5(__then) {
if (((imageFilter.publishername && imageFilter.offer) && imageFilter.skus)) {
return __this._getVMImageListForPublisherOfferAndSkus(imageFilter, __cb(_, __frame, 6, 18, _, true)); } else { __then(); } ; })(function __$getVMImageList__5() { return (function __$getVMImageList__5(__then) {
if ((imageFilter.publishername && imageFilter.offer)) {
return __this._getVMImageListForPublisherAndOffer(imageFilter, __cb(_, __frame, 10, 18, _, true)); } else { __then(); } ; })(function __$getVMImageList__5() { return (function __$getVMImageList__5(__then) {
if (imageFilter.publishername) {
return __this._getVMImageListForPublisher(imageFilter, __cb(_, __frame, 14, 18, _, true)); } else { __then(); } ; })(_); }); }); }); }); },
_getVMImageListForPublisherOfferAndSkus: function _getVMImageListForPublisherOfferAndSkus__6(imageFilter, _) { var that, images, imageQueries, imageCollection, __this = this; var __frame = { name: "_getVMImageListForPublisherOfferAndSkus__6", line: 108 }; return __func(_, this, arguments, _getVMImageListForPublisherOfferAndSkus__6, 1, __frame, function __$_getVMImageListForPublisherOfferAndSkus__6() { that = __this;
return that.getVMImageListForSku(imageFilter.location, imageFilter.publishername, imageFilter.offer, imageFilter.skus, __cb(_, __frame, 3, 22, function ___(__0, __1) { images = __1;
imageQueries = [];
images.forEach(function(image) {
imageQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineImages.get(imageFilter.location, imageFilter.publishername, imageFilter.offer, imageFilter.skus, image.name, function(error, imgResult) {
imgResult = (error ? { osDiskImage: { }, dataDiskImages: [] } : imgResult);
image.publisher = imageFilter.publishername;
image.offer = imageFilter.offer;
image.skus = imageFilter.skus;
image.urn = ((((((image.publisher + ":") + image.offer) + ":") + image.skus) + ":") + image.name);
image.operatingSystem = imgResult.osDiskImage.operatingSystem;
image.dataDiskImages = imgResult.dataDiskImages;
image.purchasePlan = imgResult.purchasePlan;
return callBack(null, image); }); }); });
return async.parallel(imageQueries, __cb(_, __frame, 27, 32, function ___(__0, __2) { imageCollection = __2;
return _(null, imageCollection); }, true)); }, true)); }); },
_getVMImageListForPublisherAndOffer: function _getVMImageListForPublisherAndOffer__7(imageFilter, _) { var that, imageQueries, skusCollection, imageCollection, __this = this; var __frame = { name: "_getVMImageListForPublisherAndOffer__7", line: 139 }; return __func(_, this, arguments, _getVMImageListForPublisherAndOffer__7, 1, __frame, function __$_getVMImageListForPublisherAndOffer__7() { that = __this;
return that.getVMImageSkusList(imageFilter.location, imageFilter.publishername, imageFilter.offer, __cb(_, __frame, 4, 30, function ___(__0, __1) { skusCollection = __1;
imageQueries = [];
skusCollection.forEach(function(skus) {
imageQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineImages.list(imageFilter.location, imageFilter.publishername, imageFilter.offer, skus.name, function(error, vmImages) {
vmImages = (error ? [] : vmImages);
vmImages.skus = skus.name;
skus.vmImages = vmImages;
return callBack(error, vmImages); }); }); });
return async.parallel(imageQueries, __cb(_, __frame, 22, 10, function __$_getVMImageListForPublisherAndOffer__7() {
imageQueries = [];
skusCollection.forEach(function(skus) {
skus.vmImages.forEach(function(image) {
imageQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineImages.get(imageFilter.location, imageFilter.publishername, imageFilter.offer, skus.vmImages.skus, image.name, function(error, imgResult) {
imgResult = (error ? { osDiskImage: { }, dataDiskImages: [] } : imgResult);
image.publisher = imageFilter.publishername;
image.offer = imageFilter.offer;
image.skus = skus.vmImages.skus;
image.urn = ((((((image.publisher + ":") + image.offer) + ":") + image.skus) + ":") + image.name);
image.operatingSystem = imgResult.osDiskImage.operatingSystem;
image.dataDiskImages = imgResult.dataDiskImages;
image.purchasePlan = imgResult.purchasePlan;
return callBack(null, image); }); }); }); });
return async.parallel(imageQueries, __cb(_, __frame, 50, 32, function ___(__0, __2) { imageCollection = __2;
return _(null, imageCollection); }, true)); }, true)); }, true)); }); },
_getVMImageListForPublisher: function _getVMImageListForPublisher__8(imageFilter, _) { var that, imageQueries, offers, skuQueries, skusCollections, imageCollection, __this = this; var __frame = { name: "_getVMImageListForPublisher__8", line: 193 }; return __func(_, this, arguments, _getVMImageListForPublisher__8, 1, __frame, function __$_getVMImageListForPublisher__8() { that = __this;
return that.getVMImageOffersList(imageFilter.location, imageFilter.publishername, __cb(_, __frame, 4, 22, function ___(__0, __1) { offers = __1;
skuQueries = [];
offers.forEach(function(offer) {
skuQueries.push(function(callBack) {
offer = offer;
that.serviceClients.computeManagementClient.virtualMachineImages.listSkus(imageFilter.location, imageFilter.publishername, offer.name, function(error, skus) {
skus = (error ? [] : skus);
skus.offer = offer.name;
offer.skus = skus;
return callBack(error, skus); }); }); });
return async.parallel(skuQueries, __cb(_, __frame, 22, 32, function ___(__0, __2) { skusCollections = __2;
imageQueries = [];
skusCollections.forEach(function(skusCollection) {
skusCollection.forEach(function(skus) {
imageQueries.push(function(callBack) {
skus = skus;
that.serviceClients.computeManagementClient.virtualMachineImages.list(imageFilter.location, imageFilter.publishername, skusCollection.offer, skus.name, function(error, vmImages) {
vmImages = (error ? [] : vmImages);
vmImages.skus = skus.name;
skus.vmImages = vmImages;
return callBack(error, vmImages); }); }); }); });
return async.parallel(imageQueries, __cb(_, __frame, 43, 10, function __$_getVMImageListForPublisher__8() {
imageQueries = [];
skusCollections.forEach(function(skusCollection) {
skusCollection.forEach(function(skus) {
skus.vmImages.forEach(function(image) {
imageQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineImages.get(imageFilter.location, imageFilter.publishername, skusCollection.offer, skus.name, image.name, function(error, imgResult) {
imgResult = (error ? { osDiskImage: { }, dataDiskImages: [] } : imgResult);
image.publisher = imageFilter.publishername;
image.offer = skusCollection.offer;
image.skus = skus.name;
image.urn = ((((((image.publisher + ":") + image.offer) + ":") + image.skus) + ":") + image.name);
image.operatingSystem = imgResult.osDiskImage.operatingSystem;
image.dataDiskImages = imgResult.dataDiskImages;
image.purchasePlan = imgResult.purchasePlan;
return callBack(null, image); }); }); }); }); });
return async.parallel(imageQueries, __cb(_, __frame, 72, 32, function ___(__0, __3) { imageCollection = __3;
return _(null, imageCollection); }, true)); }, true)); }, true)); }, true)); }); },
getVMImageDetails: function getVMImageDetails__9(imageFilter, _) { var that, imageQueries, imageCollection, __this = this; var __frame = { name: "getVMImageDetails__9", line: 269 }; return __func(_, this, arguments, getVMImageDetails__9, 1, __frame, function __$getVMImageDetails__9() { that = __this;
imageQueries = [];
imageQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineImages.get(imageFilter.location, imageFilter.publishername, imageFilter.offer, imageFilter.skus, imageFilter.version, function(error, imgResult) {
if (error) {
callBack(error);
return; } ;
imgResult = (error ? { } : imgResult);
return callBack(null, imgResult); }); });
return async.parallel(imageQueries, __cb(_, __frame, 15, 32, function ___(__0, __1) { imageCollection = __1;
return _(null, imageCollection); }, true)); }); },
getVMExtensionImageList: function getVMExtensionImageList__10(location, publisher, typeName, _) { var __this = this; var __frame = { name: "getVMExtensionImageList__10", line: 288 }; return __func(_, this, arguments, getVMExtensionImageList__10, 3, __frame, function __$getVMExtensionImageList__10() { return (function __$getVMExtensionImageList__10(__then) {
if (!location) {
return __this.cli.interaction.prompt($("Enter location: "), __cb(_, __frame, 2, 38, function ___(__0, __1) { location = __1; __then(); }, true)); } else { __then(); } ; })(function __$getVMExtensionImageList__10() { return (function __$getVMExtensionImageList__10(__then) {
if ((publisher && typeName)) {
return __this.getVMExtensionImageVersionList(location, publisher, typeName, __cb(_, __frame, 6, 18, _, true)); } else { return (function __$getVMExtensionImageList__10(__then) {
if ((publisher && !typeName)) {
return __this._getExtImageListForPublisher(location, publisher, __cb(_, __frame, 9, 18, _, true)); } else { return (function __$getVMExtensionImageList__10(__then) {
if ((!publisher && typeName)) {
return __this.cli.interaction.prompt($("Enter publisher name: "), __cb(_, __frame, 12, 39, function ___(__0, __4) { publisher = __4;
return __this.getVMExtensionImageVersionList(location, publisher, typeName, __cb(_, __frame, 13, 18, _, true)); }, true)); } else {
return __this._getExtImageListForLocation(location, __cb(_, __frame, 16, 18, _, true)); } ; })(__then); } ; })(__then); } ; })(_); }); }); },
_getExtImageListForLocation: function _getExtImageListForLocation__11(location, _) { var that, publishers, typeQueries, typeCollections, verCollections, imgResult, __this = this; var __frame = { name: "_getExtImageListForLocation__11", line: 308 }; return __func(_, this, arguments, _getExtImageListForLocation__11, 1, __frame, function __$_getExtImageListForLocation__11() { that = __this;
return __this.serviceClients.computeManagementClient.virtualMachineImages.listPublishers(location, __cb(_, __frame, 2, 86, function ___(__0, __1) { publishers = __1;
typeQueries = [];
publishers.forEach(function(publisherItem) {
typeQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineExtensionImages.listTypes(location, publisherItem.name, function(error, types) {
types = (error ? [] : types);
types.publisher = publisherItem.name;
types.location = location;
return callBack(error, types); }); }); });
return async.parallel(typeQueries, __cb(_, __frame, 18, 32, function ___(__0, __2) { typeCollections = __2;
imageQueries = [];
typeCollections.forEach(function(typeCollection) {
typeCollection.forEach(function(typeItem) {
imageQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineExtensionImages.listVersions(typeCollection.location, typeCollection.publisher, typeItem.name, function(error, verItems) {
verItems = (error ? [] : verItems);
verItems.publisher = typeCollection.publisher;
verItems.location = typeCollection.location;
verItems.typeName = typeItem.name;
return callBack(error, verItems); }); }); }); });
return async.parallel(imageQueries, __cb(_, __frame, 39, 31, function ___(__0, __3) { verCollections = __3;
imgResult = [];
verCollections.forEach(function(verCol) {
if (verCol) {
verCol.forEach(function(verItem) {
imgResult.push({
publisher: verCol.publisher,
location: verCol.location,
typeName: verCol.typeName,
name: verItem.name }); }); } ; });
return _(null, imgResult); }, true)); }, true)); }, true)); }); },
_getExtImageListForPublisher: function _getExtImageListForPublisher__12(location, publisher, _) { var that, typeNames, verQueries, verCollections, imgResult, __this = this; var __frame = { name: "_getExtImageListForPublisher__12", line: 366 }; return __func(_, this, arguments, _getExtImageListForPublisher__12, 2, __frame, function __$_getExtImageListForPublisher__12() { that = __this;
return that.getVMExtensionImageTypeList(location, publisher, __cb(_, __frame, 2, 25, function ___(__0, __1) { typeNames = __1;
verQueries = [];
typeNames.forEach(function(typeItem) {
verQueries.push(function(callBack) {
that.serviceClients.computeManagementClient.virtualMachineExtensionImages.listVersions(location, publisher, typeItem.name, function(error, item) {
item = (error ? [] : item);
item.publisher = publisher;
item.location = location;
item.typeName = typeItem.name;
return callBack(error, item); }); }); });
return async.parallel(verQueries, __cb(_, __frame, 20, 31, function ___(__0, __2) { verCollections = __2;
imgResult = [];
verCollections.forEach(function(verCol) {
if (verCol) {
verCol.forEach(function(resourceItem) {
imgResult.push({
publisher: verCol.publisher,
location: verCol.location,
typeName: verCol.typeName,
name: resourceItem.name }); }); } ; });
return _(null, imgResult); }, true)); }, true)); }); },
getVMExtensionImageTypeList: function getVMExtensionImageTypeList__13(location, publisherName, _) { var extTypes, progress, __this = this; var __frame = { name: "getVMExtensionImageTypeList__13", line: 405 }; return __func(_, this, arguments, getVMExtensionImageTypeList__13, 2, __frame, function __$getVMExtensionImageTypeList__13() {
progress = __this.cli.interaction.progress(util.format($("Getting virtual machine extension image types (Publisher: \"%s\" Location:\"%s\")"), publisherName, location)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getVMExtensionImageTypeList__13() {
return __this.serviceClients.computeManagementClient.virtualMachineExtensionImages.listTypes(location, publisherName, __cb(_, __frame, 4, 91, function ___(__0, __1) { extTypes = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getVMExtensionImageTypeList__13() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getVMExtensionImageTypeList__13() {
extTypes.map(function(item) {
item.publisher = publisherName;
return item; });
return _(null, extTypes); }); }); }); },
getVMExtensionImageVersionList: function getVMExtensionImageVersionList__14(location, publisherName, typeName, _) { var extVersions, resultList, progress, __this = this; var __frame = { name: "getVMExtensionImageVersionList__14", line: 425 }; return __func(_, this, arguments, getVMExtensionImageVersionList__14, 3, __frame, function __$getVMExtensionImageVersionList__14() {
extVersions = [];
resultList = null;
progress = __this.cli.interaction.progress(util.format($("Getting virtual machine extension image versions (Publisher: \"%s\" Type:\"%s\" Location:\"%s\")"), publisherName, typeName, location)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getVMExtensionImageVersionList__14() {
return __this.serviceClients.computeManagementClient.virtualMachineExtensionImages.listVersions(location, publisherName, typeName, __cb(_, __frame, 6, 93, function ___(__0, __1) { resultList = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getVMExtensionImageVersionList__14() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getVMExtensionImageVersionList__14() {
resultList.forEach(function(versionItem) {
extVersions.push(versionItem); });
extVersions.map(function(item) {
item.publisher = publisherName;
item.typeName = typeName;
return item; });
return _(null, extVersions); }); }); }); },
getVMExtensionImage: function getVMExtensionImage__15(location, publisherName, typeName, version, _) { var extImage, progress, __this = this; var __frame = { name: "getVMExtensionImage__15", line: 453 }; return __func(_, this, arguments, getVMExtensionImage__15, 4, __frame, function __$getVMExtensionImage__15() {
extImage = null;
progress = __this.cli.interaction.progress(util.format($("Getting virtual machine extension images (Publisher: \"%s\" Type:\"%s\" Version:\"%s\" Location:\"%s\")"), publisherName, typeName, version, location)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getVMExtensionImage__15() {
return __this.serviceClients.computeManagementClient.virtualMachineExtensionImages.get(location, publisherName, typeName, version, __cb(_, __frame, 4, 91, function ___(__0, __1) { extImage = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getVMExtensionImage__15() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getVMExtensionImage__15() {
return _(null, extImage); }); }); }); }});
module.exports = VMImage;