UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

81 lines (38 loc) 4.4 kB
/*** 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 fs = require("fs"); var utils = require("../../../util/utils"); var $ = utils.getLocaleString; var VNetUtil = require("./../../../util/vnet.util"); function NetworkConfig(cli, networkManagementClient) { this.networkManagementClient = networkManagementClient; this.vnetUtil = new VNetUtil(); this.output = cli.output; this.interaction = cli.interaction;}; __.extend(NetworkConfig.prototype, { export: function export__1(filePath, options, _) { var self, networkConfiguration, __this = this; var __frame = { name: "export__1", line: 31 }; return __func(_, this, arguments, export__1, 2, __frame, function __$export__1() { self = __this; return self.get(__cb(_, __frame, 2, 36, function ___(__0, __1) { networkConfiguration = __1; delete networkConfiguration["$"]; fs.writeFileSync(filePath, JSON.stringify(networkConfiguration, null, 2)); self.output.verbose(util.format($("Network Configuration exported to %s"), filePath)); _(); }, true)); }); }, import: function import__2(filePath, options, _) { var self, configXml, networkConfiguration, __this = this; var __frame = { name: "import__2", line: 39 }; return __func(_, this, arguments, import__2, 2, __frame, function __$import__2() { self = __this; configXml = fs.readFileSync(filePath, "utf8"); self.output.verbose(util.format($("Importing Network Configuration from %s"), filePath)); networkConfiguration = JSON.parse(utils.stripBOM(configXml)); return self.set(networkConfiguration, __cb(_, __frame, 5, 9, function __$import__2() { _(); }, true)); }); }, get: function get__3(_) { var self, progress, response, __this = this; var __frame = { name: "get__3", line: 47 }; return __func(_, this, arguments, get__3, 0, __frame, function __$get__3() { self = __this; progress = self.interaction.progress($("Looking up network configuration")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__3() { return self.networkManagementClient.networks.getConfiguration(__cb(_, __frame, 4, 59, function ___(__0, __1) { response = __1; return _(null, self.vnetUtil.getNetworkConfigObj(response.configuration)); }, true)); }); })(function ___(e, __result) { __catch(function __$get__3() { if (e) { if ((e.statusCode === 404)) { return _(null, self.vnetUtil.getNewNetworkConfigObj()); } ; return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$get__3() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$get__3() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$get__3() { _(); }); }); }); }, set: function set__4(networkConfiguration, _) { var self, configXml, config, progress, __this = this; var __frame = { name: "set__4", line: 63 }; return __func(_, this, arguments, set__4, 1, __frame, function __$set__4() { self = __this; configXml = self.vnetUtil.getNetworkConfigXml(networkConfiguration); config = { configuration: configXml }; progress = self.interaction.progress($("Setting network configuration")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$set__4() { return self.networkManagementClient.networks.setConfiguration(config, __cb(_, __frame, 10, 44, function __$set__4() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$set__4() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$set__4() { _(); }); }); }); }}); module.exports = NetworkConfig;