@spinnaker/amazon 0.11.0 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/aws.settings.d.ts +1 -0
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/instance/awsInstanceType.service.d.ts +10 -2
  6. package/dist/instance/awsInstanceTypes.d.ts +10 -0
  7. package/dist/instance/details/CostFactor.d.ts +6 -0
  8. package/dist/search/searchResultFormatter.d.ts +2 -2
  9. package/dist/serverGroup/configure/serverGroupConfiguration.service.d.ts +14 -1
  10. package/dist/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.d.ts +3 -4
  11. package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.d.ts +9 -0
  12. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.d.ts +13 -0
  13. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.d.ts +9 -0
  14. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.d.ts +11 -0
  15. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.d.ts +14 -0
  16. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.d.ts +12 -0
  17. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.d.ts +15 -0
  18. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.d.ts +8 -0
  19. package/dist/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.d.ts +8 -0
  20. package/dist/serverGroup/configure/wizard/pages/ServerGroupInstanceType.d.ts +9 -6
  21. package/dist/serverGroup/details/scalingPolicy/ScalingPolicySummary.d.ts +0 -1
  22. package/dist/serverGroup/details/scalingPolicy/chart/MetricAlarmChart.d.ts +0 -4
  23. package/dist/serverGroup/details/scalingPolicy/index.d.ts +0 -1
  24. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingChart.d.ts +1 -3
  25. package/package.json +5 -5
  26. package/src/aws.module.ts +3 -3
  27. package/src/aws.settings.ts +2 -0
  28. package/src/function/details/FunctionActions.spec.tsx +15 -12
  29. package/src/function/details/FunctionActions.tsx +2 -1
  30. package/src/help/amazon.help.ts +9 -6
  31. package/src/image/image.reader.spec.ts +75 -0
  32. package/src/instance/awsInstanceType.service.spec.js +37 -71
  33. package/src/instance/awsInstanceType.service.ts +191 -0
  34. package/src/instance/awsInstanceTypes.ts +311 -0
  35. package/src/instance/details/CostFactor.tsx +29 -0
  36. package/src/instance/details/InstanceInformation.spec.tsx +2 -1
  37. package/src/instance/details/instance.details.controller.js +472 -473
  38. package/src/loadBalancer/details/LoadBalancerActions.tsx +2 -1
  39. package/src/loadBalancer/details/loadBalancerDetails.controller.spec.ts +5 -3
  40. package/src/search/{searchResultFormatter.js → searchResultFormatter.ts} +5 -4
  41. package/src/securityGroup/details/securityGroupDetail.controller.js +2 -1
  42. package/src/serverGroup/configure/AmazonImageSelectInput.spec.tsx +10 -7
  43. package/src/serverGroup/configure/serverGroupCommandBuilder.aws.service.spec.js +302 -1
  44. package/src/serverGroup/configure/serverGroupCommandBuilder.service.js +96 -24
  45. package/src/serverGroup/configure/serverGroupCommandBuilder.spec.js +25 -8
  46. package/src/serverGroup/configure/serverGroupConfiguration.service.spec.ts +6 -13
  47. package/src/serverGroup/configure/serverGroupConfiguration.service.ts +26 -1
  48. package/src/serverGroup/configure/wizard/AmazonCloneServerGroupModal.tsx +1 -1
  49. package/src/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.tsx +31 -31
  50. package/src/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.tsx +133 -0
  51. package/src/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.tsx +99 -0
  52. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.tsx +36 -0
  53. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.tsx +144 -0
  54. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.tsx +137 -0
  55. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.tsx +135 -0
  56. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.tsx +137 -0
  57. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.less +5 -0
  58. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.tsx +108 -0
  59. package/src/serverGroup/configure/wizard/instanceType/advancedMode/advancedMode.less +110 -0
  60. package/src/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.tsx +62 -0
  61. package/src/serverGroup/configure/wizard/pages/ServerGroupInstanceType.tsx +106 -62
  62. package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.tsx +1 -1
  63. package/src/serverGroup/details/AmazonServerGroupActions.tsx +2 -1
  64. package/src/serverGroup/details/scalingPolicy/ScalingPolicySummary.tsx +7 -3
  65. package/src/serverGroup/details/scalingPolicy/StepPolicySummary.tsx +26 -28
  66. package/src/serverGroup/details/scalingPolicy/chart/MetricAlarmChart.tsx +1 -25
  67. package/src/serverGroup/details/scalingPolicy/index.ts +0 -1
  68. package/src/serverGroup/details/scalingPolicy/scalingPolicy.module.ts +1 -9
  69. package/src/serverGroup/details/scalingPolicy/scalingPolicySummary.component.ts +6 -2
  70. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingChart.tsx +2 -17
  71. package/src/serverGroup/details/scalingPolicy/upsert/alarm/AlarmConfigurer.less +1 -1
  72. package/src/serverGroup/details/scalingProcesses/AutoScalingProcessService.spec.ts +1 -2
  73. package/src/serverGroup/details/sections/AdvancedSettingsDetailsSection.tsx +3 -2
  74. package/src/serverGroup/details/sections/AmazonCapacityDetailsSection.tsx +3 -8
  75. package/src/serverGroup/details/sections/InstancesDistributionDetailsSection.spec.tsx +8 -5
  76. package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.spec.tsx +8 -5
  77. package/src/serverGroup/details/sections/ScalingPoliciesDetailsSection.tsx +3 -3
  78. package/src/serverGroup/details/sections/ScalingProcessesDetailsSection.tsx +3 -10
  79. package/src/serverGroup/details/sections/ScheduledActionsDetailsSection.tsx +3 -2
  80. package/src/serverGroup/details/sections/SecurityGroupsDetailsSection.tsx +3 -2
  81. package/src/serverGroup/serverGroup.transformer.spec.ts +5 -3
  82. package/src/subnet/SubnetSelectInput.spec.tsx +7 -4
  83. package/src/vpc/{VpcReader.spec.js → VpcReader.spec.ts} +2 -10
  84. package/src/vpc/VpcTag.spec.tsx +37 -0
  85. package/src/vpc/vpc.module.ts +6 -2
  86. package/dist/reactShims/aws.ngReact.d.ts +0 -11
  87. package/dist/serverGroup/details/scalingPolicy/ScalingPolicyTypeRegistry.d.ts +0 -10
  88. package/dist/serverGroup/details/scalingPolicy/alarmBasedSummary.component.d.ts +0 -2
  89. package/dist/serverGroup/details/scalingPolicy/detailsSummary.component.d.ts +0 -12
  90. package/dist/serverGroup/details/scalingPolicy/popover/scalingPolicyPopover.component.d.ts +0 -1
  91. package/dist/serverGroup/details/scalingPolicy/stepPolicySummary.component.d.ts +0 -1
  92. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingPolicy.config.d.ts +0 -1
  93. package/dist/serverGroup/details/scalingPolicy/targetTracking/targetTracking.module.d.ts +0 -2
  94. package/dist/serverGroup/details/scalingPolicy/targetTracking/targetTrackingChart.component.d.ts +0 -1
  95. package/dist/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.d.ts +0 -1
  96. package/dist/vpc/vpcTag.directive.d.ts +0 -2
  97. package/src/image/image.reader.spec.js +0 -123
  98. package/src/instance/awsInstanceType.service.js +0 -437
  99. package/src/reactShims/aws.ngReact.ts +0 -27
  100. package/src/serverGroup/details/scalingPolicy/ScalingPolicyTypeRegistry.ts +0 -18
  101. package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.html +0 -35
  102. package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js +0 -60
  103. package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.template.html +0 -5
  104. package/src/serverGroup/details/scalingPolicy/detailsSummary.component.ts +0 -32
  105. package/src/serverGroup/details/scalingPolicy/popover/scalingPolicyDetails.popover.html +0 -1
  106. package/src/serverGroup/details/scalingPolicy/popover/scalingPolicyPopover.component.html +0 -107
  107. package/src/serverGroup/details/scalingPolicy/popover/scalingPolicyPopover.component.ts +0 -31
  108. package/src/serverGroup/details/scalingPolicy/scalingPolicySummary.component.less +0 -15
  109. package/src/serverGroup/details/scalingPolicy/stepPolicySummary.component.ts +0 -10
  110. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingPolicy.config.ts +0 -6
  111. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTracking.module.ts +0 -8
  112. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingChart.component.ts +0 -16
  113. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts +0 -14
  114. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.html +0 -5
  115. package/src/vpc/vpcTag.directive.js +0 -34
  116. package/src/vpc/vpcTag.directive.spec.js +0 -60
@@ -15,153 +15,135 @@ import {
15
15
  } from '@spinnaker/core';
16
16
 
17
17
  import { AmazonInstanceWriter } from '../amazon.instance.write.service';
18
+ import { AWSProviderSettings } from '../../aws.settings';
18
19
  import { applyHealthCheckInfoToTargetGroups, getAllTargetGroups } from './utils';
19
- import { AMAZON_VPC_VPCTAG_DIRECTIVE } from '../../vpc/vpcTag.directive';
20
20
 
21
21
  export const AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER = 'spinnaker.amazon.instance.details.controller';
22
22
  export const name = AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER; // for backwards compatibility
23
- module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [
24
- UIROUTER_ANGULARJS,
25
- ANGULAR_UI_BOOTSTRAP,
26
- AMAZON_VPC_VPCTAG_DIRECTIVE,
27
- ]).controller('awsInstanceDetailsCtrl', [
28
- '$scope',
29
- '$state',
30
- 'instance',
31
- 'app',
32
- 'moniker',
33
- 'environment',
34
- '$q',
35
- 'overrides',
36
- function ($scope, $state, instance, app, moniker, environment, $q, overrides) {
37
- $scope.isDisabled = !SETTINGS.awsAdHocInfraWritesEnabled;
38
-
39
- // needed for standalone instances
40
- $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('aws', 'instance.detailsTemplateUrl');
41
-
42
- $scope.state = {
43
- loading: true,
44
- standalone: app.isStandalone,
45
- instancePort: _.get(app, 'attributes.instancePort') || SETTINGS.defaultInstancePort || 80,
46
- };
47
-
48
- $scope.application = app;
49
- $scope.moniker = moniker;
50
- $scope.environment = environment;
51
-
52
- $scope.securityGroupsLabel = FirewallLabels.get('Firewalls');
53
-
54
- function extractHealthMetrics(instance, latest) {
55
- // do not backfill on standalone instances
56
- if (app.isStandalone) {
57
- instance.health = latest.health;
58
- }
23
+ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [UIROUTER_ANGULARJS, ANGULAR_UI_BOOTSTRAP]).controller(
24
+ 'awsInstanceDetailsCtrl',
25
+ [
26
+ '$scope',
27
+ '$state',
28
+ 'instance',
29
+ 'app',
30
+ 'moniker',
31
+ 'environment',
32
+ '$q',
33
+ 'overrides',
34
+ function ($scope, $state, instance, app, moniker, environment, $q, overrides) {
35
+ $scope.isDisabled = !AWSProviderSettings.adHocInfraWritesEnabled;
36
+
37
+ // needed for standalone instances
38
+ $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('aws', 'instance.detailsTemplateUrl');
39
+
40
+ $scope.state = {
41
+ loading: true,
42
+ standalone: app.isStandalone,
43
+ instancePort: _.get(app, 'attributes.instancePort') || SETTINGS.defaultInstancePort || 80,
44
+ };
59
45
 
60
- instance.health = instance.health || [];
61
- const displayableMetrics = instance.health.filter(function (metric) {
62
- return metric.type !== 'Amazon' || metric.state !== 'Unknown';
63
- });
46
+ $scope.application = app;
47
+ $scope.moniker = moniker;
48
+ $scope.environment = environment;
64
49
 
65
- if (!app.isStandalone) {
66
- // augment with target group healthcheck data
67
- const targetGroups = getAllTargetGroups(
68
- app.loadBalancers.data.filter(function (loadBalancer) {
69
- return loadBalancer.cloudProvider === 'aws';
70
- }),
71
- );
72
- applyHealthCheckInfoToTargetGroups(displayableMetrics, targetGroups, instance.account);
73
- }
50
+ $scope.securityGroupsLabel = FirewallLabels.get('Firewalls');
74
51
 
75
- // backfill details where applicable
76
- if (latest.health) {
77
- displayableMetrics.forEach(function (metric) {
78
- const detailsMatch = latest.health.filter(function (latestHealth) {
79
- return latestHealth.type === metric.type;
80
- });
81
- if (detailsMatch.length) {
82
- _.defaults(metric, detailsMatch[0]);
83
- }
52
+ function extractHealthMetrics(instance, latest) {
53
+ // do not backfill on standalone instances
54
+ if (app.isStandalone) {
55
+ instance.health = latest.health;
56
+ }
57
+
58
+ instance.health = instance.health || [];
59
+ const displayableMetrics = instance.health.filter(function (metric) {
60
+ return metric.type !== 'Amazon' || metric.state !== 'Unknown';
84
61
  });
85
- }
86
- $scope.healthMetrics = displayableMetrics;
87
- }
88
-
89
- function retrieveInstance() {
90
- const extraData = {};
91
- let instanceSummary, loadBalancers, targetGroups, account, region, vpcId, serverGroupDisabled;
92
- if (!app.serverGroups) {
93
- // standalone instance
94
- instanceSummary = { id: instance.instanceId }; // terminate call expects `id` to be populated
95
- loadBalancers = [];
96
- targetGroups = [];
97
- account = instance.account;
98
- region = instance.region;
99
- } else {
100
- app.serverGroups.data.some(function (serverGroup) {
101
- return serverGroup.instances.some(function (possibleInstance) {
102
- if (possibleInstance.id === instance.instanceId) {
103
- instanceSummary = possibleInstance;
104
- loadBalancers = serverGroup.loadBalancers;
105
- targetGroups = serverGroup.targetGroups;
106
- account = serverGroup.account;
107
- region = serverGroup.region;
108
- vpcId = serverGroup.vpcId;
109
- serverGroupDisabled = serverGroup.isDisabled;
110
- extraData.serverGroup = serverGroup.name;
111
- extraData.vpcId = serverGroup.vpcId;
112
- return true;
62
+
63
+ if (!app.isStandalone) {
64
+ // augment with target group healthcheck data
65
+ const targetGroups = getAllTargetGroups(
66
+ app.loadBalancers.data.filter(function (loadBalancer) {
67
+ return loadBalancer.cloudProvider === 'aws';
68
+ }),
69
+ );
70
+ applyHealthCheckInfoToTargetGroups(displayableMetrics, targetGroups, instance.account);
71
+ }
72
+
73
+ // backfill details where applicable
74
+ if (latest.health) {
75
+ displayableMetrics.forEach(function (metric) {
76
+ const detailsMatch = latest.health.filter(function (latestHealth) {
77
+ return latestHealth.type === metric.type;
78
+ });
79
+ if (detailsMatch.length) {
80
+ _.defaults(metric, detailsMatch[0]);
113
81
  }
114
82
  });
115
- });
116
- if (!instanceSummary) {
117
- // perhaps it is in a server group that is part of another app
118
- app.loadBalancers.data.some(function (loadBalancer) {
119
- return (
120
- loadBalancer.instances.some(function (possibleInstance) {
121
- if (possibleInstance.id === instance.instanceId) {
122
- instanceSummary = possibleInstance;
123
- loadBalancers = [loadBalancer.name];
124
- account = loadBalancer.account;
125
- region = loadBalancer.region;
126
- vpcId = loadBalancer.vpcId;
127
- return true;
128
- }
129
- }) ||
130
- loadBalancer.targetGroups.some(function (targetGroup) {
131
- return targetGroup.instances.some(function (possibleInstance) {
83
+ }
84
+ $scope.healthMetrics = displayableMetrics;
85
+ }
86
+
87
+ function retrieveInstance() {
88
+ const extraData = {};
89
+ let instanceSummary, loadBalancers, targetGroups, account, region, vpcId, serverGroupDisabled;
90
+ if (!app.serverGroups) {
91
+ // standalone instance
92
+ instanceSummary = { id: instance.instanceId }; // terminate call expects `id` to be populated
93
+ loadBalancers = [];
94
+ targetGroups = [];
95
+ account = instance.account;
96
+ region = instance.region;
97
+ } else {
98
+ app.serverGroups.data.some(function (serverGroup) {
99
+ return serverGroup.instances.some(function (possibleInstance) {
100
+ if (possibleInstance.id === instance.instanceId) {
101
+ instanceSummary = possibleInstance;
102
+ loadBalancers = serverGroup.loadBalancers;
103
+ targetGroups = serverGroup.targetGroups;
104
+ account = serverGroup.account;
105
+ region = serverGroup.region;
106
+ vpcId = serverGroup.vpcId;
107
+ serverGroupDisabled = serverGroup.isDisabled;
108
+ extraData.serverGroup = serverGroup.name;
109
+ extraData.vpcId = serverGroup.vpcId;
110
+ return true;
111
+ }
112
+ });
113
+ });
114
+ if (!instanceSummary) {
115
+ // perhaps it is in a server group that is part of another app
116
+ app.loadBalancers.data.some(function (loadBalancer) {
117
+ return (
118
+ loadBalancer.instances.some(function (possibleInstance) {
132
119
  if (possibleInstance.id === instance.instanceId) {
133
120
  instanceSummary = possibleInstance;
134
- targetGroups = [targetGroup.name];
121
+ loadBalancers = [loadBalancer.name];
135
122
  account = loadBalancer.account;
136
123
  region = loadBalancer.region;
137
124
  vpcId = loadBalancer.vpcId;
138
125
  return true;
139
126
  }
140
- });
141
- })
142
- );
143
- });
144
- if (!instanceSummary) {
145
- // perhaps it is in a disabled server group via a load balancer
146
- app.loadBalancers.data.some(function (loadBalancer) {
147
- return (
148
- loadBalancer.serverGroups.some(function (serverGroup) {
149
- if (!serverGroup.isDisabled) {
150
- return false;
151
- }
152
- return serverGroup.instances.some(function (possibleInstance) {
127
+ }) ||
128
+ loadBalancer.targetGroups.some(function (targetGroup) {
129
+ return targetGroup.instances.some(function (possibleInstance) {
153
130
  if (possibleInstance.id === instance.instanceId) {
154
131
  instanceSummary = possibleInstance;
155
- loadBalancers = [loadBalancer.name];
132
+ targetGroups = [targetGroup.name];
156
133
  account = loadBalancer.account;
157
134
  region = loadBalancer.region;
158
135
  vpcId = loadBalancer.vpcId;
159
136
  return true;
160
137
  }
161
138
  });
162
- }) ||
163
- loadBalancer.targetGroups.some(function (targetGroup) {
164
- targetGroup.serverGroups.some(function (serverGroup) {
139
+ })
140
+ );
141
+ });
142
+ if (!instanceSummary) {
143
+ // perhaps it is in a disabled server group via a load balancer
144
+ app.loadBalancers.data.some(function (loadBalancer) {
145
+ return (
146
+ loadBalancer.serverGroups.some(function (serverGroup) {
165
147
  if (!serverGroup.isDisabled) {
166
148
  return false;
167
149
  }
@@ -175,413 +157,430 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [
175
157
  return true;
176
158
  }
177
159
  });
178
- });
179
- })
180
- );
181
- });
160
+ }) ||
161
+ loadBalancer.targetGroups.some(function (targetGroup) {
162
+ targetGroup.serverGroups.some(function (serverGroup) {
163
+ if (!serverGroup.isDisabled) {
164
+ return false;
165
+ }
166
+ return serverGroup.instances.some(function (possibleInstance) {
167
+ if (possibleInstance.id === instance.instanceId) {
168
+ instanceSummary = possibleInstance;
169
+ loadBalancers = [loadBalancer.name];
170
+ account = loadBalancer.account;
171
+ region = loadBalancer.region;
172
+ vpcId = loadBalancer.vpcId;
173
+ return true;
174
+ }
175
+ });
176
+ });
177
+ })
178
+ );
179
+ });
180
+ }
182
181
  }
183
182
  }
184
- }
185
183
 
186
- if (instanceSummary && account && region) {
187
- instanceSummary.account = account;
188
- extraData.account = account;
189
- extraData.region = region;
190
- RecentHistoryService.addExtraDataToLatest('instances', extraData);
191
- return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then((details) => {
192
- if ($scope.$$destroyed) {
193
- return;
194
- }
195
- $scope.state.loading = false;
196
- extractHealthMetrics(instanceSummary, details);
197
- $scope.instance = _.defaults(details, instanceSummary);
198
- $scope.instance.account = account;
199
- $scope.instance.region = region;
200
- $scope.instance.vpcId = vpcId;
201
- $scope.instance.serverGroupDisabled = serverGroupDisabled;
202
- $scope.instance.loadBalancers = loadBalancers;
203
- $scope.instance.targetGroups = targetGroups;
204
- if ($scope.instance.networkInterfaces) {
205
- $scope.instance.ipv6Addresses = _.flatMap($scope.instance.networkInterfaces, (i) =>
206
- i.ipv6Addresses.map((a) => ({
207
- ip: a.ipv6Address,
208
- url: `http://${a.ipv6Address}:${$scope.state.instancePort}`,
209
- })),
210
- );
211
-
212
- const permanentNetworkInterfaces = $scope.instance.networkInterfaces.filter(
213
- (f) => f.attachment.deleteOnTermination === false,
214
- );
215
- if (permanentNetworkInterfaces.length) {
216
- $scope.instance.permanentIps = permanentNetworkInterfaces.map((f) => f.privateIpAddress);
184
+ if (instanceSummary && account && region) {
185
+ instanceSummary.account = account;
186
+ extraData.account = account;
187
+ extraData.region = region;
188
+ RecentHistoryService.addExtraDataToLatest('instances', extraData);
189
+ return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then((details) => {
190
+ if ($scope.$$destroyed) {
191
+ return;
217
192
  }
218
- }
219
- $scope.baseIpAddress = details.publicDnsName || details.privateIpAddress;
220
- if (overrides.instanceDetailsLoaded) {
221
- overrides.instanceDetailsLoaded();
222
- }
223
- }, autoClose);
224
- }
193
+ $scope.state.loading = false;
194
+ extractHealthMetrics(instanceSummary, details);
195
+ $scope.instance = _.defaults(details, instanceSummary);
196
+ $scope.instance.account = account;
197
+ $scope.instance.region = region;
198
+ $scope.instance.vpcId = vpcId;
199
+ $scope.instance.serverGroupDisabled = serverGroupDisabled;
200
+ $scope.instance.loadBalancers = loadBalancers;
201
+ $scope.instance.targetGroups = targetGroups;
202
+ if ($scope.instance.networkInterfaces) {
203
+ $scope.instance.ipv6Addresses = _.flatMap($scope.instance.networkInterfaces, (i) =>
204
+ i.ipv6Addresses.map((a) => ({
205
+ ip: a.ipv6Address,
206
+ url: `http://${a.ipv6Address}:${$scope.state.instancePort}`,
207
+ })),
208
+ );
225
209
 
226
- if (!instanceSummary) {
227
- $scope.instanceIdNotFound = instance.instanceId;
228
- $scope.state.loading = false;
229
- }
210
+ const permanentNetworkInterfaces = $scope.instance.networkInterfaces.filter(
211
+ (f) => f.attachment.deleteOnTermination === false,
212
+ );
213
+ if (permanentNetworkInterfaces.length) {
214
+ $scope.instance.permanentIps = permanentNetworkInterfaces.map((f) => f.privateIpAddress);
215
+ }
216
+ }
217
+ $scope.baseIpAddress = details.publicDnsName || details.privateIpAddress;
218
+ if (overrides.instanceDetailsLoaded) {
219
+ overrides.instanceDetailsLoaded();
220
+ }
221
+ }, autoClose);
222
+ }
230
223
 
231
- return $q.when(null);
232
- }
224
+ if (!instanceSummary) {
225
+ $scope.instanceIdNotFound = instance.instanceId;
226
+ $scope.state.loading = false;
227
+ }
233
228
 
234
- function autoClose() {
235
- if ($scope.$$destroyed) {
236
- return;
237
- }
238
- if (app.isStandalone) {
239
- $scope.state.loading = false;
240
- $scope.instanceIdNotFound = instance.instanceId;
241
- $scope.state.notFoundStandalone = true;
242
- RecentHistoryService.removeLastItem('instances');
243
- } else {
244
- $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' });
229
+ return $q.when(null);
245
230
  }
246
- }
247
-
248
- this.canDeregisterFromLoadBalancer = function () {
249
- const healthMetrics = $scope.instance.health || [];
250
- return healthMetrics.some(function (health) {
251
- return health.type === 'LoadBalancer';
252
- });
253
- };
254
231
 
255
- this.canRegisterWithLoadBalancer = function () {
256
- const instance = $scope.instance;
257
- const healthMetrics = instance.health || [];
258
- if (!instance.loadBalancers || !instance.loadBalancers.length) {
259
- return false;
232
+ function autoClose() {
233
+ if ($scope.$$destroyed) {
234
+ return;
235
+ }
236
+ if (app.isStandalone) {
237
+ $scope.state.loading = false;
238
+ $scope.instanceIdNotFound = instance.instanceId;
239
+ $scope.state.notFoundStandalone = true;
240
+ RecentHistoryService.removeLastItem('instances');
241
+ } else {
242
+ $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' });
243
+ }
260
244
  }
261
- const outOfService = healthMetrics.some(function (health) {
262
- return health.type === 'LoadBalancer' && health.state === 'OutOfService';
263
- });
264
- const hasLoadBalancerHealth = healthMetrics.some(function (health) {
265
- return health.type === 'LoadBalancer';
266
- });
267
- return outOfService || !hasLoadBalancerHealth;
268
- };
269
-
270
- this.canDeregisterFromTargetGroup = function () {
271
- const healthMetrics = $scope.instance.health || [];
272
- return healthMetrics.some(function (health) {
273
- return health.type === 'TargetGroup' && health.state !== 'OutOfService';
274
- });
275
- };
276
245
 
277
- this.canRegisterWithTargetGroup = function () {
278
- const instance = $scope.instance;
279
- const healthMetrics = instance.health || [];
280
- if (!instance.targetGroups || !instance.targetGroups.length) {
281
- return false;
282
- }
283
- const outOfService = healthMetrics.some(function (health) {
284
- return health.type === 'TargetGroup' && health.state === 'OutOfService';
285
- });
286
- const hasTargetGroupHealth = healthMetrics.some(function (health) {
287
- return health.type === 'TargetGroup';
288
- });
289
- return outOfService || !hasTargetGroupHealth;
290
- };
291
-
292
- this.canRegisterWithDiscovery = function () {
293
- const instance = $scope.instance;
294
- const healthMetrics = instance.health || [];
295
- const discoveryHealth = healthMetrics.filter(function (health) {
296
- return health.type === 'Discovery';
297
- });
298
- return discoveryHealth.length ? discoveryHealth[0].state === 'OutOfService' : false;
299
- };
300
-
301
- this.terminateInstance = function terminateInstance() {
302
- const instance = $scope.instance;
303
-
304
- const taskMonitor = {
305
- application: app,
306
- title: 'Terminating ' + instance.instanceId,
307
- onTaskComplete: function () {
308
- if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
309
- $state.go('^');
310
- }
311
- },
246
+ this.canDeregisterFromLoadBalancer = function () {
247
+ const healthMetrics = $scope.instance.health || [];
248
+ return healthMetrics.some(function (health) {
249
+ return health.type === 'LoadBalancer';
250
+ });
312
251
  };
313
252
 
314
- const submitMethod = function () {
315
- return AmazonInstanceWriter.terminateInstance(instance, app);
253
+ this.canRegisterWithLoadBalancer = function () {
254
+ const instance = $scope.instance;
255
+ const healthMetrics = instance.health || [];
256
+ if (!instance.loadBalancers || !instance.loadBalancers.length) {
257
+ return false;
258
+ }
259
+ const outOfService = healthMetrics.some(function (health) {
260
+ return health.type === 'LoadBalancer' && health.state === 'OutOfService';
261
+ });
262
+ const hasLoadBalancerHealth = healthMetrics.some(function (health) {
263
+ return health.type === 'LoadBalancer';
264
+ });
265
+ return outOfService || !hasLoadBalancerHealth;
316
266
  };
317
267
 
318
- ConfirmationModalService.confirm({
319
- header: 'Really terminate ' + instance.instanceId + '?',
320
- buttonText: 'Terminate ' + instance.instanceId,
321
- account: instance.account,
322
- taskMonitorConfig: taskMonitor,
323
- submitMethod: submitMethod,
324
- });
325
- };
326
-
327
- this.terminateInstanceAndShrinkServerGroup = function terminateInstanceAndShrinkServerGroup() {
328
- const instance = $scope.instance;
329
-
330
- const taskMonitor = {
331
- application: app,
332
- title: 'Terminating ' + instance.instanceId + ' and shrinking server group',
333
- onTaskComplete: function () {
334
- if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
335
- $state.go('^');
336
- }
337
- },
268
+ this.canDeregisterFromTargetGroup = function () {
269
+ const healthMetrics = $scope.instance.health || [];
270
+ return healthMetrics.some(function (health) {
271
+ return health.type === 'TargetGroup' && health.state !== 'OutOfService';
272
+ });
338
273
  };
339
274
 
340
- const submitMethod = function () {
341
- return AmazonInstanceWriter.terminateInstanceAndShrinkServerGroup(instance, app);
275
+ this.canRegisterWithTargetGroup = function () {
276
+ const instance = $scope.instance;
277
+ const healthMetrics = instance.health || [];
278
+ if (!instance.targetGroups || !instance.targetGroups.length) {
279
+ return false;
280
+ }
281
+ const outOfService = healthMetrics.some(function (health) {
282
+ return health.type === 'TargetGroup' && health.state === 'OutOfService';
283
+ });
284
+ const hasTargetGroupHealth = healthMetrics.some(function (health) {
285
+ return health.type === 'TargetGroup';
286
+ });
287
+ return outOfService || !hasTargetGroupHealth;
342
288
  };
343
289
 
344
- ConfirmationModalService.confirm({
345
- header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?',
346
- buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup,
347
- account: instance.account,
348
- taskMonitorConfig: taskMonitor,
349
- submitMethod: submitMethod,
350
- });
351
- };
352
-
353
- this.rebootInstance = function rebootInstance() {
354
- const instance = $scope.instance;
355
-
356
- const taskMonitor = {
357
- application: app,
358
- title: 'Rebooting ' + instance.instanceId,
290
+ this.canRegisterWithDiscovery = function () {
291
+ const instance = $scope.instance;
292
+ const healthMetrics = instance.health || [];
293
+ const discoveryHealth = healthMetrics.filter(function (health) {
294
+ return health.type === 'Discovery';
295
+ });
296
+ return discoveryHealth.length ? discoveryHealth[0].state === 'OutOfService' : false;
359
297
  };
360
298
 
361
- const submitMethod = (params = {}) => {
362
- if (app.attributes && app.attributes.platformHealthOnlyShowOverride && app.attributes.platformHealthOnly) {
363
- params.interestingHealthProviderNames = ['Amazon'];
364
- }
299
+ this.terminateInstance = function terminateInstance() {
300
+ const instance = $scope.instance;
365
301
 
366
- return AmazonInstanceWriter.rebootInstance(instance, app, params);
302
+ const taskMonitor = {
303
+ application: app,
304
+ title: 'Terminating ' + instance.instanceId,
305
+ onTaskComplete: function () {
306
+ if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
307
+ $state.go('^');
308
+ }
309
+ },
310
+ };
311
+
312
+ const submitMethod = function () {
313
+ return AmazonInstanceWriter.terminateInstance(instance, app);
314
+ };
315
+
316
+ ConfirmationModalService.confirm({
317
+ header: 'Really terminate ' + instance.instanceId + '?',
318
+ buttonText: 'Terminate ' + instance.instanceId,
319
+ account: instance.account,
320
+ taskMonitorConfig: taskMonitor,
321
+ submitMethod: submitMethod,
322
+ });
367
323
  };
368
324
 
369
- ConfirmationModalService.confirm({
370
- header: 'Really reboot ' + instance.instanceId + '?',
371
- buttonText: 'Reboot ' + instance.instanceId,
372
- account: instance.account,
373
- platformHealthOnlyShowOverride: app.attributes.platformHealthOnlyShowOverride,
374
- platformHealthType: 'Amazon',
375
- taskMonitorConfig: taskMonitor,
376
- submitMethod: submitMethod,
377
- });
378
- };
325
+ this.terminateInstanceAndShrinkServerGroup = function terminateInstanceAndShrinkServerGroup() {
326
+ const instance = $scope.instance;
379
327
 
380
- this.registerInstanceWithLoadBalancer = function registerInstanceWithLoadBalancer() {
381
- const instance = $scope.instance;
382
- const loadBalancerNames = instance.loadBalancers.join(' and ');
383
-
384
- const taskMonitor = {
385
- application: app,
386
- title: 'Registering ' + instance.instanceId + ' with ' + loadBalancerNames,
328
+ const taskMonitor = {
329
+ application: app,
330
+ title: 'Terminating ' + instance.instanceId + ' and shrinking server group',
331
+ onTaskComplete: function () {
332
+ if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
333
+ $state.go('^');
334
+ }
335
+ },
336
+ };
337
+
338
+ const submitMethod = function () {
339
+ return AmazonInstanceWriter.terminateInstanceAndShrinkServerGroup(instance, app);
340
+ };
341
+
342
+ ConfirmationModalService.confirm({
343
+ header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?',
344
+ buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup,
345
+ account: instance.account,
346
+ taskMonitorConfig: taskMonitor,
347
+ submitMethod: submitMethod,
348
+ });
387
349
  };
388
350
 
389
- const submitMethod = function () {
390
- return AmazonInstanceWriter.registerInstanceWithLoadBalancer(instance, app);
391
- };
351
+ this.rebootInstance = function rebootInstance() {
352
+ const instance = $scope.instance;
392
353
 
393
- ConfirmationModalService.confirm({
394
- header: 'Really register ' + instance.instanceId + ' with ' + loadBalancerNames + '?',
395
- buttonText: 'Register ' + instance.instanceId,
396
- account: instance.account,
397
- taskMonitorConfig: taskMonitor,
398
- submitMethod: submitMethod,
399
- });
400
- };
354
+ const taskMonitor = {
355
+ application: app,
356
+ title: 'Rebooting ' + instance.instanceId,
357
+ };
401
358
 
402
- this.deregisterInstanceFromLoadBalancer = function deregisterInstanceFromLoadBalancer() {
403
- const instance = $scope.instance;
404
- const loadBalancerNames = instance.loadBalancers.join(' and ');
359
+ const submitMethod = (params = {}) => {
360
+ if (app.attributes && app.attributes.platformHealthOnlyShowOverride && app.attributes.platformHealthOnly) {
361
+ params.interestingHealthProviderNames = ['Amazon'];
362
+ }
405
363
 
406
- const taskMonitor = {
407
- application: app,
408
- title: 'Deregistering ' + instance.instanceId + ' from ' + loadBalancerNames,
364
+ return AmazonInstanceWriter.rebootInstance(instance, app, params);
365
+ };
366
+
367
+ ConfirmationModalService.confirm({
368
+ header: 'Really reboot ' + instance.instanceId + '?',
369
+ buttonText: 'Reboot ' + instance.instanceId,
370
+ account: instance.account,
371
+ platformHealthOnlyShowOverride: app.attributes.platformHealthOnlyShowOverride,
372
+ platformHealthType: 'Amazon',
373
+ taskMonitorConfig: taskMonitor,
374
+ submitMethod: submitMethod,
375
+ });
409
376
  };
410
377
 
411
- const submitMethod = function () {
412
- return AmazonInstanceWriter.deregisterInstanceFromLoadBalancer(instance, app);
378
+ this.registerInstanceWithLoadBalancer = function registerInstanceWithLoadBalancer() {
379
+ const instance = $scope.instance;
380
+ const loadBalancerNames = instance.loadBalancers.join(' and ');
381
+
382
+ const taskMonitor = {
383
+ application: app,
384
+ title: 'Registering ' + instance.instanceId + ' with ' + loadBalancerNames,
385
+ };
386
+
387
+ const submitMethod = function () {
388
+ return AmazonInstanceWriter.registerInstanceWithLoadBalancer(instance, app);
389
+ };
390
+
391
+ ConfirmationModalService.confirm({
392
+ header: 'Really register ' + instance.instanceId + ' with ' + loadBalancerNames + '?',
393
+ buttonText: 'Register ' + instance.instanceId,
394
+ account: instance.account,
395
+ taskMonitorConfig: taskMonitor,
396
+ submitMethod: submitMethod,
397
+ });
413
398
  };
414
399
 
415
- ConfirmationModalService.confirm({
416
- header: 'Really deregister ' + instance.instanceId + ' from ' + loadBalancerNames + '?',
417
- buttonText: 'Deregister ' + instance.instanceId,
418
- account: instance.account,
419
- taskMonitorConfig: taskMonitor,
420
- submitMethod: submitMethod,
421
- });
422
- };
423
-
424
- this.registerInstanceWithTargetGroup = function registerInstanceWithTargetGroup() {
425
- const instance = $scope.instance;
426
- const targetGroupNames = instance.targetGroups.join(' and ');
427
-
428
- const taskMonitor = {
429
- application: app,
430
- title: 'Registering ' + instance.instanceId + ' with ' + targetGroupNames,
400
+ this.deregisterInstanceFromLoadBalancer = function deregisterInstanceFromLoadBalancer() {
401
+ const instance = $scope.instance;
402
+ const loadBalancerNames = instance.loadBalancers.join(' and ');
403
+
404
+ const taskMonitor = {
405
+ application: app,
406
+ title: 'Deregistering ' + instance.instanceId + ' from ' + loadBalancerNames,
407
+ };
408
+
409
+ const submitMethod = function () {
410
+ return AmazonInstanceWriter.deregisterInstanceFromLoadBalancer(instance, app);
411
+ };
412
+
413
+ ConfirmationModalService.confirm({
414
+ header: 'Really deregister ' + instance.instanceId + ' from ' + loadBalancerNames + '?',
415
+ buttonText: 'Deregister ' + instance.instanceId,
416
+ account: instance.account,
417
+ taskMonitorConfig: taskMonitor,
418
+ submitMethod: submitMethod,
419
+ });
431
420
  };
432
421
 
433
- const submitMethod = function () {
434
- return AmazonInstanceWriter.registerInstanceWithTargetGroup(instance, app);
422
+ this.registerInstanceWithTargetGroup = function registerInstanceWithTargetGroup() {
423
+ const instance = $scope.instance;
424
+ const targetGroupNames = instance.targetGroups.join(' and ');
425
+
426
+ const taskMonitor = {
427
+ application: app,
428
+ title: 'Registering ' + instance.instanceId + ' with ' + targetGroupNames,
429
+ };
430
+
431
+ const submitMethod = function () {
432
+ return AmazonInstanceWriter.registerInstanceWithTargetGroup(instance, app);
433
+ };
434
+
435
+ ConfirmationModalService.confirm({
436
+ header: 'Really register ' + instance.instanceId + ' with ' + targetGroupNames + '?',
437
+ buttonText: 'Register ' + instance.instanceId,
438
+ account: instance.account,
439
+ taskMonitorConfig: taskMonitor,
440
+ submitMethod: submitMethod,
441
+ });
435
442
  };
436
443
 
437
- ConfirmationModalService.confirm({
438
- header: 'Really register ' + instance.instanceId + ' with ' + targetGroupNames + '?',
439
- buttonText: 'Register ' + instance.instanceId,
440
- account: instance.account,
441
- taskMonitorConfig: taskMonitor,
442
- submitMethod: submitMethod,
443
- });
444
- };
445
-
446
- this.deregisterInstanceFromTargetGroup = function deregisterInstanceFromTargetGroup() {
447
- const instance = $scope.instance;
448
- const targetGroupNames = instance.targetGroups.join(' and ');
449
-
450
- const taskMonitor = {
451
- application: app,
452
- title: 'Deregistering ' + instance.instanceId + ' from ' + targetGroupNames,
444
+ this.deregisterInstanceFromTargetGroup = function deregisterInstanceFromTargetGroup() {
445
+ const instance = $scope.instance;
446
+ const targetGroupNames = instance.targetGroups.join(' and ');
447
+
448
+ const taskMonitor = {
449
+ application: app,
450
+ title: 'Deregistering ' + instance.instanceId + ' from ' + targetGroupNames,
451
+ };
452
+
453
+ const submitMethod = function () {
454
+ return AmazonInstanceWriter.deregisterInstanceFromTargetGroup(instance, app);
455
+ };
456
+
457
+ ConfirmationModalService.confirm({
458
+ header: 'Really deregister ' + instance.instanceId + ' from ' + targetGroupNames + '?',
459
+ buttonText: 'Deregister ' + instance.instanceId,
460
+ account: instance.account,
461
+ taskMonitorConfig: taskMonitor,
462
+ submitMethod: submitMethod,
463
+ });
453
464
  };
454
465
 
455
- const submitMethod = function () {
456
- return AmazonInstanceWriter.deregisterInstanceFromTargetGroup(instance, app);
457
- };
466
+ this.enableInstanceInDiscovery = function enableInstanceInDiscovery() {
467
+ const instance = $scope.instance;
458
468
 
459
- ConfirmationModalService.confirm({
460
- header: 'Really deregister ' + instance.instanceId + ' from ' + targetGroupNames + '?',
461
- buttonText: 'Deregister ' + instance.instanceId,
462
- account: instance.account,
463
- taskMonitorConfig: taskMonitor,
464
- submitMethod: submitMethod,
465
- });
466
- };
469
+ const taskMonitor = {
470
+ application: app,
471
+ title: 'Enabling ' + instance.instanceId + ' in discovery',
472
+ };
467
473
 
468
- this.enableInstanceInDiscovery = function enableInstanceInDiscovery() {
469
- const instance = $scope.instance;
474
+ const submitMethod = function () {
475
+ return AmazonInstanceWriter.enableInstanceInDiscovery(instance, app);
476
+ };
470
477
 
471
- const taskMonitor = {
472
- application: app,
473
- title: 'Enabling ' + instance.instanceId + ' in discovery',
478
+ ConfirmationModalService.confirm({
479
+ header: 'Really enable ' + instance.instanceId + ' in discovery?',
480
+ buttonText: 'Enable ' + instance.instanceId,
481
+ account: instance.account,
482
+ taskMonitorConfig: taskMonitor,
483
+ submitMethod: submitMethod,
484
+ });
474
485
  };
475
486
 
476
- const submitMethod = function () {
477
- return AmazonInstanceWriter.enableInstanceInDiscovery(instance, app);
478
- };
487
+ this.disableInstanceInDiscovery = function disableInstanceInDiscovery() {
488
+ const instance = $scope.instance;
479
489
 
480
- ConfirmationModalService.confirm({
481
- header: 'Really enable ' + instance.instanceId + ' in discovery?',
482
- buttonText: 'Enable ' + instance.instanceId,
483
- account: instance.account,
484
- taskMonitorConfig: taskMonitor,
485
- submitMethod: submitMethod,
486
- });
487
- };
490
+ const taskMonitor = {
491
+ application: app,
492
+ title: 'Disabling ' + instance.instanceId + ' in discovery',
493
+ };
488
494
 
489
- this.disableInstanceInDiscovery = function disableInstanceInDiscovery() {
490
- const instance = $scope.instance;
495
+ const submitMethod = function () {
496
+ return AmazonInstanceWriter.disableInstanceInDiscovery(instance, app);
497
+ };
491
498
 
492
- const taskMonitor = {
493
- application: app,
494
- title: 'Disabling ' + instance.instanceId + ' in discovery',
499
+ ConfirmationModalService.confirm({
500
+ header: 'Really disable ' + instance.instanceId + ' in discovery?',
501
+ buttonText: 'Disable ' + instance.instanceId,
502
+ account: instance.account,
503
+ taskMonitorConfig: taskMonitor,
504
+ submitMethod: submitMethod,
505
+ });
495
506
  };
496
507
 
497
- const submitMethod = function () {
498
- return AmazonInstanceWriter.disableInstanceInDiscovery(instance, app);
508
+ this.hasHealthState = function hasHealthState(healthProviderType, state) {
509
+ const instance = $scope.instance;
510
+ const healthMetrics = instance.health || [];
511
+ return healthMetrics.some(function (health) {
512
+ return health.type === healthProviderType && health.state === state;
513
+ });
499
514
  };
500
515
 
501
- ConfirmationModalService.confirm({
502
- header: 'Really disable ' + instance.instanceId + ' in discovery?',
503
- buttonText: 'Disable ' + instance.instanceId,
504
- account: instance.account,
505
- taskMonitorConfig: taskMonitor,
506
- submitMethod: submitMethod,
507
- });
508
- };
516
+ const constructInstanceActions = (instance) => {
517
+ const constantActions = [
518
+ { label: 'Reboot', triggerAction: this.rebootInstance },
519
+ { label: 'Terminate', triggerAction: this.terminateInstance },
520
+ { label: 'Terminate and Shrink Server Group', triggerAction: this.terminateInstanceAndShrinkServerGroup },
521
+ ];
522
+ const conditionalActions = [];
523
+
524
+ if (this.canRegisterWithDiscovery() && !instance.serverGroupDisabled) {
525
+ conditionalActions.push({
526
+ label: 'Enable In Discovery',
527
+ triggerAction: this.enableInstanceInDiscovery,
528
+ });
529
+ }
509
530
 
510
- this.hasHealthState = function hasHealthState(healthProviderType, state) {
511
- const instance = $scope.instance;
512
- const healthMetrics = instance.health || [];
513
- return healthMetrics.some(function (health) {
514
- return health.type === healthProviderType && health.state === state;
515
- });
516
- };
517
-
518
- const constructInstanceActions = (instance) => {
519
- const constantActions = [
520
- { label: 'Reboot', triggerAction: this.rebootInstance },
521
- { label: 'Terminate', triggerAction: this.terminateInstance },
522
- { label: 'Terminate and Shrink Server Group', triggerAction: this.terminateInstanceAndShrinkServerGroup },
523
- ];
524
- const conditionalActions = [];
525
-
526
- if (this.canRegisterWithDiscovery() && !instance.serverGroupDisabled) {
527
- conditionalActions.push({
528
- label: 'Enable In Discovery',
529
- triggerAction: this.enableInstanceInDiscovery,
530
- });
531
- }
531
+ if (this.hasHealthState('Discovery', 'Up') || this.hasHealthState('Discovery', 'Down')) {
532
+ conditionalActions.push({
533
+ label: 'Disable in Discovery',
534
+ triggerAction: this.disableInstanceInDiscovery,
535
+ });
536
+ }
532
537
 
533
- if (this.hasHealthState('Discovery', 'Up') || this.hasHealthState('Discovery', 'Down')) {
534
- conditionalActions.push({
535
- label: 'Disable in Discovery',
536
- triggerAction: this.disableInstanceInDiscovery,
537
- });
538
- }
538
+ if (this.canRegisterWithLoadBalancer()) {
539
+ conditionalActions.push({
540
+ label: 'Register with Load Balancer',
541
+ triggerAction: this.registerInstanceWithLoadBalancer,
542
+ });
543
+ }
539
544
 
540
- if (this.canRegisterWithLoadBalancer()) {
541
- conditionalActions.push({
542
- label: 'Register with Load Balancer',
543
- triggerAction: this.registerInstanceWithLoadBalancer,
544
- });
545
- }
545
+ if (this.canDeregisterFromLoadBalancer()) {
546
+ conditionalActions.push({
547
+ label: 'Deregister from Load Balancer',
548
+ triggerAction: this.deregisterInstanceFromLoadBalancer,
549
+ });
550
+ }
546
551
 
547
- if (this.canDeregisterFromLoadBalancer()) {
548
- conditionalActions.push({
549
- label: 'Deregister from Load Balancer',
550
- triggerAction: this.deregisterInstanceFromLoadBalancer,
551
- });
552
- }
552
+ if (this.canRegisterWithTargetGroup()) {
553
+ conditionalActions.push({
554
+ label: 'Register with Target Group',
555
+ triggerAction: this.registerInstanceWithTargetGroup,
556
+ });
557
+ }
553
558
 
554
- if (this.canRegisterWithTargetGroup()) {
555
- conditionalActions.push({
556
- label: 'Register with Target Group',
557
- triggerAction: this.registerInstanceWithTargetGroup,
558
- });
559
- }
559
+ if (this.canDeregisterFromTargetGroup()) {
560
+ conditionalActions.push({
561
+ label: 'Deregister from Target Group',
562
+ triggerAction: this.deregisterInstanceFromTargetGroup,
563
+ });
564
+ }
565
+ return conditionalActions.concat(constantActions);
566
+ };
560
567
 
561
- if (this.canDeregisterFromTargetGroup()) {
562
- conditionalActions.push({
563
- label: 'Deregister from Target Group',
564
- triggerAction: this.deregisterInstanceFromTargetGroup,
565
- });
566
- }
567
- return conditionalActions.concat(constantActions);
568
- };
569
-
570
- const initialize = app.isStandalone
571
- ? retrieveInstance()
572
- : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance);
573
-
574
- initialize.then(() => {
575
- $scope.instanceActions = constructInstanceActions($scope.instance);
576
- // Two things to look out for here:
577
- // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there
578
- // is no point in subscribing to the refresh
579
- // 2. If this is a standalone instance, there is no application that will refresh
580
- if (!$scope.$$destroyed && !app.isStandalone) {
581
- app.serverGroups.onRefresh($scope, retrieveInstance);
582
- }
583
- });
568
+ const initialize = app.isStandalone
569
+ ? retrieveInstance()
570
+ : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance);
571
+
572
+ initialize.then(() => {
573
+ $scope.instanceActions = constructInstanceActions($scope.instance);
574
+ // Two things to look out for here:
575
+ // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there
576
+ // is no point in subscribing to the refresh
577
+ // 2. If this is a standalone instance, there is no application that will refresh
578
+ if (!$scope.$$destroyed && !app.isStandalone) {
579
+ app.serverGroups.onRefresh($scope, retrieveInstance);
580
+ }
581
+ });
584
582
 
585
- $scope.account = instance.account;
586
- },
587
- ]);
583
+ $scope.account = instance.account;
584
+ },
585
+ ],
586
+ );