azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
285 lines (131 loc) • 18.9 kB
JavaScript
/*** 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;
var url = require("url");
var path = require("path");
var util = require("util");
exports.init = function(cli) {
var log = cli.output;
var serviceFabric = cli.category("servicefabric").description($("Commands to manage your Azure Service Fabric"));
var cluster = serviceFabric.category("cluster").description($("Commands to manage your cluster"));
cluster.command("connect [connectionEndpoint]").description($("Connect cluster, Example: azure servicefabric cluster connect --connection-endpoint http://127.0.0.1:19080")).option("-e --connection-endpoint <connectionEndpoint>", $("the url of the connection endpoint, value is [http|https]://[ip_address]")).option("-p --client-key-path <clientKeyPath>", $("the path of the client key")).option("-c --client-cert-path <clientCertPath>", $("the path of the client cert")).option("-a --ca-cert-path <caCertPath>", $("the path of the ca cert, comma separated if multiple"), serviceFabricUtils.list).option("-t --strict-ssl-false", $("the boolean of the strict ssl, false to disable CN verification")).option("-u --reject-unauthorized-false", $("the boolean of the reject unauthorized, false to disable CA verification")).execute(function __1(connectionEndpoint, options, _) { var progress, data, httpUrlObj, config, client, res; var __frame = { name: "__1", line: 44 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
progress = cli.interaction.progress($("Connect cluster")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
data = { };
httpUrlObj = null;
if (!connectionEndpoint) {
httpUrlObj = url.parse("http://localhost:19080"); }
else {
httpUrlObj = url.parse(connectionEndpoint); } ;
if (((!httpUrlObj.protocol || !httpUrlObj.hostname) || !httpUrlObj.port)) {
return _(util.format("Invalid url %s", connectionEndpoint)); } ;
data.connectionEndpoint = url.format(httpUrlObj); return (function __$__1(_) { return (function __$__1(_) {
var __4 = options.clientKeyPath; if (!__4) { return _(null, __4); } ; return serviceFabricUtils.isFileExist(options.clientKeyPath, __cb(_, __frame, 16, 58, function ___(__0, __6) { var __5 = !__6; return _(null, __5); }, true)); })(__cb(_, __frame, -43, 17, function ___(__0, __3) { var __6 = __3; return (function __$__1(__then) { if (__6) { var __7 = __3; return _(null, __7); } else { __then(); } ; })(function __$__1() { return (function __$__1(_) {
var __5 = options.clientCertPath; if (!__5) { return _(null, __5); } ; return serviceFabricUtils.isFileExist(options.clientCertPath, __cb(_, __frame, 17, 57, function ___(__0, __7) { var __6 = !__7; return _(null, __6); }, true)); })(__cb(_, __frame, -43, 17, _, true)); }); }, true)); })(__cb(_, __frame, -43, 17, function ___(__0, __4) { return (function __$__1(__then) { if (__4) {
return _("Client key or cert certificate file does not exist."); } else { __then(); } ; })(function __$__1() { return (function __$__1(__then) {
if (options.caCertPath) {
return options.caCertPath.forEach_(__cb(_, __frame, 21, 29, __then, true), function __1(_, path) { var __frame = { name: "__1", line: 65 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() {
return serviceFabricUtils.isFileExist(path, __cb(_, __frame, 1, 36, function ___(__0, __2) { var __1 = !__2; return (function __$__1(__then) { if (__1) {
return _("CA certificate file does not exist."); } else { __then(); } ; })(_); }, true)); }); }); } else { __then(); } ; })(function __$__1() {
if (options.clientKeyPath) {
data.clientKeyPath = path.resolve(options.clientKeyPath); } ;
if (options.clientCertPath) {
data.clientCertPath = path.resolve(options.clientCertPath); } ; return (function __$__1(__then) {
if (options.caCertPath) {
return options.caCertPath.forEach_(__cb(_, __frame, 34, 29, function __$__1() {
data.caCertPaths = options.caCertPath; __then(); }, true), function __2(_, caPath, index) { var __frame = { name: "__2", line: 78 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { options.caCertPath[index] = path.resolve(caPath); _(); }); }); } else { __then(); } ; })(function __$__1() {
if (options.strictSslFlase) {
data.strictSsl = false; } ;
if (options.rejectUnauthorizedFalse) {
data.rejectUnauthorized = false; } ;
return serviceFabricUtils.writeConfigFile(data, __cb(_, __frame, 45, 27, function __$__1() {
return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 48, 40, function ___(__0, __5) { config = __5;
return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 50, 79, function ___(__0, __6) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 50, 130, function ___(__0, __7) { client = new serviceFabricClient("3.0-preview", __6, __7); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return client.clusterManifests.get(options, __cb(_, __frame, 53, 40, function ___(__0, __8) { res = __8; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
serviceFabricUtils.deleteServiceFabricConfig();
return _(util.format("Error connecting to the cluster %s. Please check the connection.", config.connectionEndpoint)); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() {
return serviceFabricUtils.writeConfigFile(data, __cb(_, __frame, 59, 27, function __$__1() {
progress.end(); __then(); }, true)); }); }); }, true)); }, true)); }, true)); }, true)); }); }); }); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
progress.end();
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() { _(); }); }); }); });
cluster.command("show").description($("Show cluster")).option("--select <fields>", $("select fields to show, call without this parameter to see all fields")).execute(function __2(options, _) { var progress, config; var __frame = { name: "__2", line: 115 }; return __func(_, this, arguments, __2, 1, __frame, function __$__2() {
progress = cli.interaction.progress($("Show cluster")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 4, 40, function ___(__0, __1) { config = __1; return (function __$__2(__then) {
if (options.select) {
return serviceFabricUtils.pick(config, options.select, __cb(_, __frame, 6, 38, function ___(__0, __2) { config = __2; __then(); }, true)); } else { __then(); } ; })(function __$__2() {
progress.end();
cli.interaction.formatOutput(config, function(data) {
log.json(data); }); __then(); }); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
progress.end();
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__2() { _(); }); }); }); });
var clusterManifest = cluster.category("manifest").description($("Commands to manage your cluster manifest"));
clusterManifest.command("show").description($("Show cluster manifest")).execute(function __3(options, _) { var progress, config, client, res; var __frame = { name: "__3", line: 140 }; return __func(_, this, arguments, __3, 1, __frame, function __$__3() {
progress = cli.interaction.progress($("Show cluster manifest")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
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.clusterManifests.get(options, __cb(_, __frame, 7, 42, function ___(__0, __4) { res = __4;
serviceFabricUtils.setClusterEnumVal(res);
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() { _(); }); }); }); });
var clusterHealth = cluster.category("health").description($("Commands to manage your cluster health"));
clusterHealth.command("show").description($("Show cluster health")).option("-f --events-health-state-filter <eventsHealthStateFilter>", $("the filter of the event health state, values are [Default|None|Ok|Warning|Error|All]")).option("-n --nodes-health-state-filter <nodesHealthStateFilter>", $("the filter of the nodes health state, values are [Default|None|Ok|Warning|Error|All]")).option("-a --applications-health-state-filter <applicationsHealthStateFilter>", $("the filter of the applications 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 __4(options, _) { var progress, config, client, res; var __frame = { name: "__4", line: 170 }; return __func(_, this, arguments, __4, 1, __frame, function __$__4() {
progress = cli.interaction.progress($("Show cluster health")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
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.clusterHealths.get(options, __cb(_, __frame, 7, 40, function ___(__0, __4) { res = __4; return (function __$__4(__then) {
if (options.select) {
return serviceFabricUtils.pick(res, options.select, __cb(_, __frame, 9, 35, function ___(__0, __5) { res = __5; __then(); }, true)); } else { __then(); } ; })(function __$__4() {
serviceFabricUtils.setClusterEnumVal(res);
progress.end();
cli.interaction.formatOutput(res, function(data) {
log.json(data); }); __then(); }); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) {
progress.end();
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__4() { _(); }); }); }); });
clusterHealth.command("send [sourceId] [property] [healthState]").description($("Send cluster health, Example: azure servicefabric cluster health send --source-id monitor --property pc --health-state Ok --description healthy")).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("-n --sequence-number <sequenceNumber>", $("the number of the sequence")).option("-o --remove-when-expired", $("the boolean of the remove when expired")).execute(function __5(sourceId, property, healthState, options, _) { var progress, config, client, clusterHealthReport, res; var __frame = { name: "__5", line: 203 }; return __func(_, this, arguments, __5, 4, __frame, function __$__5() {
progress = cli.interaction.progress($("Send cluster health")); 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, 5, 79, function ___(__0, __2) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 5, 130, function ___(__0, __3) { client = new serviceFabricClient("3.0-preview", __2, __3);
clusterHealthReport = { };
if (sourceId) { clusterHealthReport.sourceId = sourceId; } ;
if (property) { clusterHealthReport.property = property; } ;
if (healthState) { clusterHealthReport.healthState = serviceFabricUtils.getEnumVal("healthState", healthState); } ;
if (options.description) { clusterHealthReport.description = options.description; } ;
if (options.timeToLiveInMilliseconds) { clusterHealthReport.timeToLiveInMilliSeconds = options.timeToLiveInMilliseconds; } ;
if (options.sequenceNumber) { clusterHealthReport.sequenceNumber = options.sequenceNumber; } ;
if (options.removeWhenExpired) {
clusterHealthReport.removeWhenExpired = true; } ;
return client.clusterHealths.send(clusterHealthReport, options, __cb(_, __frame, 16, 40, 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 __$__5() { if (e) {
progress.end();
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__5() { _(); }); }); }); });
var clusterLoad = cluster.category("load").description($("Commands to manage your cluster load information"));
clusterLoad.command("show").description($("Show load information")).option("--select <fields>", $("select fields to show, call without this parameter to see all fields")).execute(function __6(options, _) { var progress, config, client, res; var __frame = { name: "__6", line: 238 }; return __func(_, this, arguments, __6, 1, __frame, function __$__6() {
progress = cli.interaction.progress($("Show load information")); 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.clusterLoadInformations.get(options, __cb(_, __frame, 7, 49, 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.setClusterEnumVal(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() { _(); }); }); }); });
var clusterUpgrade = cluster.category("upgrade").description($("Commands to manage your cluster upgrade"));
clusterUpgrade.command("show").description($("Show cluster upgrade")).execute(function __7(options, _) { var progress, config, client, res; var __frame = { name: "__7", line: 267 }; return __func(_, this, arguments, __7, 1, __frame, function __$__7() {
progress = cli.interaction.progress($("Show cluster upgrade")); 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, 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.upgradeProgresses.get(options, __cb(_, __frame, 7, 43, function ___(__0, __4) { res = __4;
serviceFabricUtils.setClusterEnumVal(res);
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() { _(); }); }); }); });};