UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

248 lines (108 loc) 15.9 kB
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var utils = require("../../util/utils"); var serviceFabricUtils = require("./serviceFabricUtils"); var serviceFabricClient = require("azure-servicefabric"); var $ = utils.getLocaleString; exports.init = function(cli) { var log = cli.output; var serviceFabric = cli.category("servicefabric").description($("Commands to manage your Azure Service Fabric")); var node = serviceFabric.category("node").description($("Commands to manage your node")); node.command("show").description($("Show node")).option("-n --node-name <nodeName>", $("the name of the node")).option("--select <fields>", $("select fields to show, call without this parameter to see all fields")).execute(function __1(options, _) { var progress, config, client, res; var __frame = { name: "__1", line: 37 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { progress = cli.interaction.progress($("Show node")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 4, 40, function ___(__0, __1) { config = __1; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 6, 79, function ___(__0, __2) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 6, 130, function ___(__0, __3) { client = new serviceFabricClient("3.0-preview", __2, __3); res = null; return (function __$__1(__then) { if (!options.nodeName) { return client.nodes.list(options, __cb(_, __frame, 9, 29, function ___(__0, __4) { res = __4; __then(); }, true)); } else { return client.nodes.get(options.nodeName, options, __cb(_, __frame, 12, 29, function ___(__0, __5) { res = __5; __then(); }, true)); } ; })(function __$__1() { return (function __$__1(__then) { if (options.select) { return serviceFabricUtils.pick(res, options.select, __cb(_, __frame, 15, 35, function ___(__0, __6) { res = __6; __then(); }, true)); } else { __then(); } ; })(function __$__1() { serviceFabricUtils.setNodeEnumVal(res); progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }); }); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() { _(); }); }); }); }); node.command("enable [nodeName]").description($("Enable node, Example: azure servicefabric node enable --node-name node1")).option("-n --node-name <nodeName>", $("the name of the node")).execute(function __2(nodeName, options, _) { var progress, config, client, res; var __frame = { name: "__2", line: 70 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() { return cli.interaction.promptIfNotGiven($("nodeName: "), nodeName, __cb(_, __frame, 1, 33, function ___(__0, __1) { nodeName = __1; progress = cli.interaction.progress($("Enable node")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 6, 40, function ___(__0, __2) { config = __2; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 8, 79, function ___(__0, __3) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 8, 130, function ___(__0, __4) { client = new serviceFabricClient("3.0-preview", __3, __4); return client.nodes.enable(nodeName, options, __cb(_, __frame, 9, 31, function ___(__0, __5) { res = __5; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__2() { _(); }); }); }, true)); }); }); node.command("disable [nodeName] [deactivationIntent]").description($("Disable node, Example: azure servicefabric node enable --node-name node1 --deactivation-intent Pause")).option("-n --node-name <nodeName>", $("the name of the node")).option("-i --deactivation-intent <deactivationIntent>", $("the intent of the deactivation, values are [Pause|Restart|RemoveData|RemoveNode]")).execute(function __3(nodeName, deactivationIntent, options, _) { var progress, config, client, disableNode, res; var __frame = { name: "__3", line: 96 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() { return cli.interaction.promptIfNotGiven($("nodeName: "), nodeName, __cb(_, __frame, 1, 33, function ___(__0, __1) { nodeName = __1; return cli.interaction.promptIfNotGiven($("deactivationIntent: "), deactivationIntent, __cb(_, __frame, 2, 43, function ___(__0, __2) { deactivationIntent = __2; progress = cli.interaction.progress($("Disable node")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 7, 40, function ___(__0, __3) { config = __3; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 9, 79, function ___(__0, __4) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 9, 130, function ___(__0, __5) { client = new serviceFabricClient("3.0-preview", __4, __5); disableNode = { }; if (deactivationIntent) { disableNode.deactivationIntent = serviceFabricUtils.getEnumVal("deactivationIntent", deactivationIntent); } ; return client.nodes.disable(nodeName, disableNode, options, __cb(_, __frame, 12, 31, function ___(__0, __6) { res = __6; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__3() { _(); }); }); }, true)); }, true)); }); }); var nodeState = node.category("state").description($("Commands to manage your node load state")); nodeState.command("delete [nodeName]").description($("Delete node state")).option("-n --node-name <nodeName>", $("the name of the node")).execute(function __4(nodeName, options, _) { var progress, config, client, res; var __frame = { name: "__4", line: 127 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() { return cli.interaction.promptIfNotGiven($("nodeName: "), nodeName, __cb(_, __frame, 1, 33, function ___(__0, __1) { nodeName = __1; progress = cli.interaction.progress($("Delete node state")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 6, 40, function ___(__0, __2) { config = __2; client = new serviceFabricClient("3.0-preview", (config.connectionEndpoint ? config.connectionEndpoint : null), config); return client.nodeStates.remove(nodeName, options, __cb(_, __frame, 9, 36, function ___(__0, __3) { res = __3; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__4() { _(); }); }); }, true)); }); }); var nodeLoad = node.category("load").description($("Commands to manage your node load")); nodeLoad.command("show [nodeName]").description($("Show node load information")).option("-n --node-name <nodeName>", $("the name of the node")).option("--select <fields>", $("select fields to show, call without this parameter to see all fields")).execute(function __5(nodeName, options, _) { var progress, config, client, res; var __frame = { name: "__5", line: 156 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() { progress = cli.interaction.progress($("Show node load")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 4, 40, function ___(__0, __1) { config = __1; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 6, 79, function ___(__0, __2) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 6, 130, function ___(__0, __3) { client = new serviceFabricClient("3.0-preview", __2, __3); return client.nodeLoadInformations.get(nodeName, options, __cb(_, __frame, 7, 46, function ___(__0, __4) { res = __4; return (function __$__5(__then) { if (options.select) { return serviceFabricUtils.pick(res, options.select, __cb(_, __frame, 9, 35, function ___(__0, __5) { res = __5; __then(); }, true)); } else { __then(); } ; })(function __$__5() { serviceFabricUtils.setNodeEnumVal(res); progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__5() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__5() { _(); }); }); }); }); var nodeHealth = node.category("health").description($("Commands to manage your node health")); nodeHealth.command("show [nodeName]").description($("Show node health")).option("-n --node-name <nodeName>", $("the name of the node")).option("-f --events-health-state-filter <eventsHealthStateFilter>", $("the filter of the event health state, values are [Default|None|Ok|Warning|Error|All]")).option("--select <fields>", $("select fields to show, call without this parameter to see all fields")).execute(function __6(nodeName, options, _) { var progress, config, client, res; var __frame = { name: "__6", line: 188 }; return __func(_, this, arguments, __6, 2, __frame, function __$__6() { progress = cli.interaction.progress($("Show node health")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 4, 40, function ___(__0, __1) { config = __1; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 6, 79, function ___(__0, __2) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 6, 130, function ___(__0, __3) { client = new serviceFabricClient("3.0-preview", __2, __3); return client.nodeHealths.get(nodeName, options, __cb(_, __frame, 7, 37, function ___(__0, __4) { res = __4; return (function __$__6(__then) { if (options.select) { return serviceFabricUtils.pick(res, options.select, __cb(_, __frame, 9, 35, function ___(__0, __5) { res = __5; __then(); }, true)); } else { __then(); } ; })(function __$__6() { serviceFabricUtils.setNodeEnumVal(res); progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__6() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__6() { _(); }); }); }); }); nodeHealth.command("send [nodeName] [sourceId] [property] [healthState]").description($("Send node health, Example: azure servicefabric node health send --node-name node1 fabric:app --source-id monitor --property pc --health-state Ok --description healthy")).option("-n --node-name <nodeName>", $("the name of the node")).option("-i --source-id <sourceId>", $("the id of the source")).option("-p --property <property>", $("the property")).option("-e --health-state <healthState>", $("the state of the health, values are [Ok|Warning|Error|Unknown]")).option("-d --description <description>", $("the description")).option("-m --time-to-live-in-milliseconds <timeToLiveInMilliseconds>", $("the time in milliseconds for live")).option("-q --sequence-number <sequenceNumber>", $("the number of the sequence")).option("-w --remove-when-expired", $("the boolean of the remove when expired")).execute(function __7(nodeName, sourceId, property, healthState, options, _) { var progress, config, client, nodeHealthReport, res; var __frame = { name: "__7", line: 222 }; return __func(_, this, arguments, __7, 5, __frame, function __$__7() { progress = cli.interaction.progress($("Send node health")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 4, 40, function ___(__0, __1) { config = __1; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 5, 79, function ___(__0, __2) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 5, 130, function ___(__0, __3) { client = new serviceFabricClient("3.0-preview", __2, __3); nodeHealthReport = { }; if (sourceId) { nodeHealthReport.sourceId = sourceId; } ; if (property) { nodeHealthReport.property = property; } ; if (healthState) { nodeHealthReport.healthState = serviceFabricUtils.getEnumVal("healthState", healthState); } ; if (options.description) { nodeHealthReport.description = options.description; } ; if (options.timeToLiveInMilliseconds) { nodeHealthReport.timeToLiveInMilliSeconds = options.timeToLiveInMilliseconds; } ; if (options.sequenceNumber) { nodeHealthReport.sequenceNumber = options.sequenceNumber; } ; if (options.removeWhenExpired) { nodeHealthReport.removeWhenExpired = true; } ; return client.nodeHealths.send(nodeName, nodeHealthReport, options, __cb(_, __frame, 16, 37, function ___(__0, __4) { res = __4; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__7() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__7() { _(); }); }); }); });};