UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

331 lines (164 loc) 26.7 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 service = serviceFabric.category("service").description($("Commands to manage your service")); var serviceGroup = service.category("group").description($("Commands to manage your service group")); serviceGroup.command("create [applicationName] [serviceName] [serviceTypeName] [serviceKind] [partitionScheme]").description($("Create service group, Example: servicefabric service create --application-name fabric:/app --service-name fabric:/app/service --service-type-name ServiceType1 --service-kind Stateless --instance-count 1 --partition-scheme Singleton")).option("-n --application-name <applicationName>", $("the name of the application")).option("-e --service-name <serviceName>", $("the name of the service")).option("-t --service-type-name <serviceTypeName>", $("the name of the service type")).option("-k --service-kind <serviceKind>", $("the kind of the service, values are [Stateless|Stateful]")).option("-c --instance-count <instanceCount>", $("the count of the instance")).option("-r --target-replica-set-size <targetReplicaSetSize>", $("the size of the target replica set")).option("-m --min-replica-set-size <minReplicaSetSize>", $("the size of the min replica set")).option("-p --has-persisted-state", $("the state of the persisted")).option("-a --partition-scheme <partitionScheme>", $("the scheme of the partition")).option("-t --partition-count <partitionCount>", $("the count of the partition")).option("-i --partition-names <partitionNames>", $("the names of the partition")).option("-l --partition-low-key <partitionLowKey>", $("the key of the partition low")).option("-g --partition-high-key <partitionHighKey>", $("the key of the partition high")).option("-d --service-group-member-description <serviceGroupMemberDescription>", $("the description of the service group member")).option("-o --placement-constraints <placementConstraints>", $("the constraints of the placement")).option("-n --correlation-schema <correlationSchema>", $("the schema of the correlation, json string")).option("-a --service-load-metrics <serviceLoadMetrics>", $("the metrics of the service load, json string")).option("-y --service-placement-policy-description <servicePlacementPolicyDescription>", $("the description of the service placement policy, json string")).execute(function __1(applicationName, serviceName, serviceTypeName, serviceKind, partitionScheme, options, _) { var progress, config, client, serviceGroupDescription, res; var __frame = { name: "__1", line: 56 }; return __func(_, this, arguments, __1, 6, __frame, function __$__1() { return cli.interaction.promptIfNotGiven("applicationName", applicationName, __cb(_, __frame, 1, 40, function ___(__0, __1) { applicationName = __1; return cli.interaction.promptIfNotGiven("serviceName", serviceName, __cb(_, __frame, 2, 36, function ___(__0, __2) { serviceName = __2; return cli.interaction.promptIfNotGiven("serviceTypeName", serviceTypeName, __cb(_, __frame, 3, 40, function ___(__0, __3) { serviceTypeName = __3; return cli.interaction.promptIfNotGiven("serviceKind", serviceKind, __cb(_, __frame, 4, 36, function ___(__0, __4) { serviceKind = __4; return (function __$__1(__then) { if ((serviceKind === "Stateless")) { return cli.interaction.promptIfNotGiven("instanceCount", options.instanceCount, __cb(_, __frame, 6, 48, function ___(__0, __5) { options.instanceCount = __5; __then(); }, true)); } else { return (function __$__1(__then) { if ((serviceKind === "Stateful")) { return cli.interaction.promptIfNotGiven("targetReplicaSetSize", options.targetReplicaSetSize, __cb(_, __frame, 9, 55, function ___(__0, __6) { options.targetReplicaSetSize = __6; return cli.interaction.promptIfNotGiven("minReplicaSetSize", options.minReplicaSetSize, __cb(_, __frame, 10, 52, function ___(__0, __7) { options.minReplicaSetSize = __7; __then(); }, true)); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__1() { return cli.interaction.promptIfNotGiven("partitionScheme", partitionScheme, __cb(_, __frame, 12, 40, function ___(__0, __8) { partitionScheme = __8; return cli.interaction.promptIfNotGiven("serviceGroupMemberDescription", options.serviceGroupMemberDescription, __cb(_, __frame, 13, 62, function ___(__0, __9) { options.serviceGroupMemberDescription = __9; return serviceFabricUtils.isSubPath(applicationName, serviceName, __cb(_, __frame, 14, 30, function ___(__0, __11) { var __10 = !__11; return (function __$__1(__then) { if (__10) { return _("ServiceName is not a sub-path of the applicationName"); } else { __then(); } ; })(function __$__1() { progress = cli.interaction.progress($("Create service group")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 21, 40, function ___(__0, __12) { config = __12; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 23, 79, function ___(__0, __13) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 23, 130, function ___(__0, __14) { client = new serviceFabricClient("3.0-preview", __13, __14); serviceGroupDescription = { }; if (applicationName) { serviceGroupDescription.applicationName = applicationName; } ; if (serviceName) { serviceGroupDescription.serviceName = serviceName; } ; if (serviceTypeName) { serviceGroupDescription.serviceTypeName = serviceTypeName; } ; if (serviceKind) { serviceGroupDescription.ServiceKind = serviceFabricUtils.getEnumVal("serviceKind", serviceKind); } ; if ((serviceKind === "Stateless")) { serviceGroupDescription.instanceCount = Number(options.instanceCount); } else { if ((serviceKind === "Stateful")) { serviceGroupDescription.targetReplicaSetSize = Number(options.targetReplicaSetSize); serviceGroupDescription.minReplicaSetSize = Number(options.minReplicaSetSize); if (options.hasPersistedState) { serviceGroupDescription.hasPersistedState = true; } else { serviceGroupDescription.hasPersistedState = false; } ; } ; } ; serviceGroupDescription.partitionDescription = { partitionScheme: serviceFabricUtils.getEnumVal("partitionScheme", partitionScheme) }; if (options.partitionCount) { serviceGroupDescription.partitionDescription.count = Number(options.partitionCount); } ; if (options.partitionNames) { serviceGroupDescription.partitionDescription.names = JSON.parse(options.partitionNames); } ; if (options.partitionLowKey) { serviceGroupDescription.partitionDescription.lowKey = options.partitionLowKey; } ; if (options.partitionHighKey) { serviceGroupDescription.partitionDescription.highKey = options.partitionHighKey; } ; if (options.serviceGroupMemberDescription) { serviceGroupDescription.serviceGroupMemberDescription = JSON.parse(options.serviceGroupMemberDescription); } ; if (options.placementConstraints) { serviceGroupDescription.placementConstraints = options.placementConstraints; } ; if (options.correlationSchema) { serviceGroupDescription.correlationSchema = JSON.parse(options.correlationSchema); serviceGroupDescription.correlationSchema.forEach(function(element) { if (element.serviceCorrelationScheme) { element.serviceCorrelationScheme = serviceFabricUtils.getEnumVal("serviceCorrelationScheme", element.serviceCorrelationScheme); } ; }); } ; if (options.serviceLoadMetrics) { serviceGroupDescription.serviceLoadMetrics = JSON.parse(options.serviceLoadMetrics); } ; if (options.servicePlacementPolicyDescription) { serviceGroupDescription.servicePlacementPolicyDescription = JSON.parse(options.servicePlacementPolicyDescription); serviceGroupDescription.servicePlacementPolicyDescription.forEach(function(element) { if (element.type) { element.type = serviceFabricUtils.getEnumVal("servicePlacementPolicyType", element.type); } ; }); } ; return serviceFabricUtils.parseUrl(applicationName, __cb(_, __frame, 69, 65, function ___(__0, __15) { return client.serviceGroups.create(__15, serviceGroupDescription, options, __cb(_, __frame, 69, 39, function ___(__0, __16) { res = __16; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() { _(); }); }); }); }, true)); }, true)); }, true)); }); }, true)); }, true)); }, true)); }, true)); }); }); serviceGroup.command("update [applicationName] [serviceName] [serviceKind]").description($("Update service group")).option("-n --application-name <applicationName>", $("the name of the application")).option("-e --service-name <serviceName>", $("the name of the service")).option("-k --service-kind <serviceKind>", $("the kind of the service, values are [Stateless|Stateful]")).option("-c --instance-count <instanceCount>", $("the count of the instance")).option("-r --target-replica-set-size <targetReplicaSetSize>", $("the size of the target replica set")).option("-m --min-replica-set-size <minReplicaSetSize>", $("the size of the min replica set")).option("-i --replica-restart-wait-duration-in-milliseconds <replicaRestartWaitDurationInMilliseconds>", $("the milliseconds of the replica restart wait duration")).option("-d --quorum-loss-wait-duration-in-milliseconds <quorumLossWaitDurationInMilliseconds>", $("the milliseconds of the quorum loss wait duration")).option("-b --stand-by-replica-keep-duration-in-milliseconds <standByReplicaKeepDurationInMilliseconds>", $("the milliseconds of the stand by replica keep duration")).execute(function __2(applicationName, serviceName, serviceKind, options, _) { var progress, config, client, updateServiceGroupDescription, res; var __frame = { name: "__2", line: 149 }; return __func(_, this, arguments, __2, 4, __frame, function __$__2() { return cli.interaction.promptIfNotGiven("applicationName:", applicationName, __cb(_, __frame, 1, 40, function ___(__0, __1) { applicationName = __1; return cli.interaction.promptIfNotGiven("serviceName:", serviceName, __cb(_, __frame, 2, 36, function ___(__0, __2) { serviceName = __2; return cli.interaction.promptIfNotGiven("serviceKind:", serviceKind, __cb(_, __frame, 3, 36, function ___(__0, __3) { serviceKind = __3; progress = cli.interaction.progress($("Update service group")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 8, 40, function ___(__0, __4) { config = __4; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 10, 79, function ___(__0, __5) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 10, 130, function ___(__0, __6) { client = new serviceFabricClient("3.0-preview", __5, __6); return serviceFabricUtils.parseUrl(applicationName, __cb(_, __frame, 11, 45, function ___(__0, __7) { applicationName = __7; return serviceFabricUtils.parseUrl(serviceName, __cb(_, __frame, 12, 41, function ___(__0, __8) { serviceName = __8; updateServiceGroupDescription = { }; updateServiceGroupDescription.ServiceKind = serviceFabricUtils.getEnumVal("serviceKind", serviceKind); updateServiceGroupDescription.flags = 0; if ((options.targetReplicaSetSize || options.instanceCount)) { updateServiceGroupDescription.flags |= 1; } ; if (options.replicaRestartWaitDurationInMilliseconds) { updateServiceGroupDescription.flags |= 2; } ; if (options.quorumLossWaitDurationInMilliseconds) { updateServiceGroupDescription.flags |= 4; } ; if (options.standByReplicaKeepDurationInMilliseconds) { updateServiceGroupDescription.flags |= 8; } ; if (options.minReplicaSetSize) { updateServiceGroupDescription.flags |= 16; } ; if ((serviceKind === "Stateless")) { updateServiceGroupDescription.instanceCount = Number(options.instanceCount); } else { if ((serviceKind === "Stateful")) { updateServiceGroupDescription.targetReplicaSetSize = Number(options.targetReplicaSetSize); updateServiceGroupDescription.minReplicaSetSize = Number(options.minReplicaSetSize); } ; } ; if (options.replicaRestartWaitDurationInMilliseconds) { updateServiceGroupDescription.replicaRestartWaitDurationInMilliseconds = Number(options.replicaRestartWaitDurationInMilliseconds); } ; if (options.quorumLossWaitDurationInMilliseconds) { updateServiceGroupDescription.quorumLossWaitDurationInMilliseconds = Number(options.quorumLossWaitDurationInMilliseconds); } ; if (options.standByReplicaKeepDurationInMilliseconds) { updateServiceGroupDescription.standByReplicaKeepDurationInMilliseconds = Number(options.standByReplicaKeepDurationInMilliseconds); } ; return client.serviceGroups.update(applicationName, serviceName, updateServiceGroupDescription, options, __cb(_, __frame, 41, 39, function ___(__0, __9) { res = __9; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__2() { _(); }); }); }, true)); }, true)); }, true)); }); }); serviceGroup.command("delete [applicationName] [serviceName]").description($("Delete service group")).option("-n --application-name <applicationName>", $("the name of the application")).option("-e --service-name <serviceName>", $("the name of the service")).execute(function __3(applicationName, serviceName, options, _) { var progress, config, client, res; var __frame = { name: "__3", line: 207 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() { return cli.interaction.promptIfNotGiven("applicationName", applicationName, __cb(_, __frame, 1, 40, function ___(__0, __1) { applicationName = __1; return cli.interaction.promptIfNotGiven("serviceName", serviceName, __cb(_, __frame, 2, 36, function ___(__0, __2) { serviceName = __2; progress = cli.interaction.progress($("Delete service group")); 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); return serviceFabricUtils.parseUrl(applicationName, __cb(_, __frame, 10, 45, function ___(__0, __6) { applicationName = __6; return serviceFabricUtils.parseUrl(serviceName, __cb(_, __frame, 11, 41, function ___(__0, __7) { serviceName = __7; return client.serviceGroups.remove(applicationName, serviceName, options, __cb(_, __frame, 12, 39, function ___(__0, __8) { res = __8; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }, 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 serviceGroupTemplate = serviceGroup.category("template").description($("Commands to manage your service group template")); serviceGroupTemplate.command("create [applicationName] [serviceName] [serviceTypeName]").description($("Create service group from template")).option("-n --application-name <applicationName>", $("the name of the application")).option("-e --service-name <serviceName>", $("the name of the service")).option("-t --service-type-name <serviceTypeName>", $("the name of the service type")).execute(function __4(applicationName, serviceName, serviceTypeName, options, _) { var progress, config, client, serviceGroupTemplate, res; var __frame = { name: "__4", line: 240 }; return __func(_, this, arguments, __4, 4, __frame, function __$__4() { return cli.interaction.promptIfNotGiven("applicationName", applicationName, __cb(_, __frame, 1, 40, function ___(__0, __1) { applicationName = __1; return cli.interaction.promptIfNotGiven("serviceName", serviceName, __cb(_, __frame, 2, 36, function ___(__0, __2) { serviceName = __2; return cli.interaction.promptIfNotGiven("serviceTypeName", serviceTypeName, __cb(_, __frame, 3, 40, function ___(__0, __3) { serviceTypeName = __3; progress = cli.interaction.progress($("Create service group from template")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return serviceFabricUtils.readServiceFabricConfig(progress, __cb(_, __frame, 8, 40, function ___(__0, __4) { config = __4; return serviceFabricUtils.createConnectionUrl(config, __cb(_, __frame, 10, 79, function ___(__0, __5) { return serviceFabricUtils.getClientOptions(config, __cb(_, __frame, 10, 130, function ___(__0, __6) { client = new serviceFabricClient("3.0-preview", __5, __6); return serviceFabricUtils.parseUrl(applicationName, __cb(_, __frame, 11, 45, function ___(__0, __7) { applicationName = __7; serviceGroupTemplate = { }; if (serviceName) { serviceGroupTemplate.serviceName = serviceName; } ; if (serviceTypeName) { serviceGroupTemplate.serviceTypeName = serviceTypeName; } ; return client.serviceFromTemplates.create(applicationName, serviceGroupTemplate, options, __cb(_, __frame, 15, 46, function ___(__0, __8) { res = __8; progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }, true)); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__4() { _(); }); }); }, true)); }, true)); }, true)); }); }); var serviceGroupDescription = serviceGroup.category("description").description($("Commands to manage your service group description")); serviceGroupDescription.command("show [serviceName]").description($("Show service group description")).option("-n --service-name <serviceName>", $("the name of the service")).option("--select <fields>", $("select fields to show, call without this parameter to see all fields")).execute(function __5(serviceName, options, _) { var progress, config, client, res; var __frame = { name: "__5", line: 275 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() { progress = cli.interaction.progress($("Show service group description")); 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 serviceFabricUtils.parseUrl(serviceName, __cb(_, __frame, 7, 41, function ___(__0, __4) { serviceName = __4; return client.serviceGroupDescriptions.get("_", serviceName, options, __cb(_, __frame, 8, 50, function ___(__0, __5) { res = __5; return (function __$__5(__then) { if (options.select) { return serviceFabricUtils.pick(res, options.select, __cb(_, __frame, 10, 35, function ___(__0, __6) { res = __6; __then(); }, true)); } else { __then(); } ; })(function __$__5() { serviceFabricUtils.setServiceGroupEnumVal(res); progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }); }, true)); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__5() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__5() { _(); }); }); }); }); var serviceGroupMember = serviceGroup.category("member").description($("Commands to manage your service")); serviceGroupMember.command("show [applicationName] [serviceName]").description($("Show service group member")).option("-n --application-name <applicationName>", $("the name of the application")).option("-e --service-name <serviceName>", $("the name of the service")).option("--select <fields>", $("select fields to show, call without this parameter to see all fields")).execute(function __6(applicationName, serviceName, options, _) { var progress, config, client, res; var __frame = { name: "__6", line: 308 }; return __func(_, this, arguments, __6, 3, __frame, function __$__6() { progress = cli.interaction.progress($("Show service group member")); 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 serviceFabricUtils.parseUrl(applicationName, __cb(_, __frame, 7, 45, function ___(__0, __4) { applicationName = __4; return serviceFabricUtils.parseUrl(serviceName, __cb(_, __frame, 8, 41, function ___(__0, __5) { serviceName = __5; return client.serviceGroupMembers.get(applicationName, serviceName, options, __cb(_, __frame, 9, 45, function ___(__0, __6) { res = __6; return (function __$__6(__then) { if (options.select) { return serviceFabricUtils.pick(res, options.select, __cb(_, __frame, 11, 35, function ___(__0, __7) { res = __7; __then(); }, true)); } else { __then(); } ; })(function __$__6() { serviceFabricUtils.setServiceGroupEnumVal(res); progress.end(); cli.interaction.formatOutput(res, function(data) { log.json(data); }); __then(); }); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__6() { if (e) { progress.end(); return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__6() { _(); }); }); }); });};