@spinnaker/oracle 0.0.0-main-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.
- package/CHANGELOG.md +868 -0
- package/LICENSE.txt +203 -0
- package/dist/common/footer.component.d.ts +2 -0
- package/dist/domain/IOracleLoadBalancer.d.ts +114 -0
- package/dist/helpContents/oracleHelpContents.d.ts +1 -0
- package/dist/image/image.reader.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3634 -0
- package/dist/index.js.map +1 -0
- package/dist/instance/details/instance.details.controller.d.ts +2 -0
- package/dist/loadBalancer/configure/createLoadBalancer.controller.d.ts +87 -0
- package/dist/loadBalancer/details/loadBalancerDetail.controller.d.ts +21 -0
- package/dist/loadBalancer/loadBalancer.transformer.d.ts +12 -0
- package/dist/oracle.module.d.ts +2 -0
- package/dist/oracle.settings.d.ts +15 -0
- package/dist/pipeline/stages/bake/bakeExecutionDetails.controller.d.ts +2 -0
- package/dist/pipeline/stages/bake/ociBakeStage.d.ts +2 -0
- package/dist/pipeline/stages/destroyAsg/destroyAsgStage.d.ts +2 -0
- package/dist/pipeline/stages/disableAsg/disableAsgStage.d.ts +2 -0
- package/dist/pipeline/stages/findAmi/findAmiStage.d.ts +2 -0
- package/dist/pipeline/stages/findImageFromTags/oracleFindImageFromTagsStage.d.ts +2 -0
- package/dist/pipeline/stages/resizeAsg/resizeAsgStage.d.ts +2 -0
- package/dist/pipeline/stages/scaleDownCluster/scaleDownClusterStage.d.ts +2 -0
- package/dist/pipeline/stages/shrinkCluster/shrinkClusterStage.d.ts +2 -0
- package/dist/securityGroup/configure/createSecurityGroup.controller.d.ts +2 -0
- package/dist/securityGroup/securityGroup.reader.d.ts +2 -0
- package/dist/securityGroup/securityGroup.transformer.d.ts +2 -0
- package/dist/serverGroup/configure/serverGroup.configure.module.d.ts +2 -0
- package/dist/serverGroup/configure/serverGroupCommandBuilder.service.d.ts +2 -0
- package/dist/serverGroup/configure/serverGroupConfiguration.service.d.ts +2 -0
- package/dist/serverGroup/configure/wizard/basicSettings/basicSettings.controller.d.ts +2 -0
- package/dist/serverGroup/configure/wizard/capacity/capacitySelector.component.d.ts +2 -0
- package/dist/serverGroup/configure/wizard/cloneServerGroup.controller.d.ts +2 -0
- package/dist/serverGroup/details/resize/resizeCapacity.component.d.ts +2 -0
- package/dist/serverGroup/details/resize/resizeServerGroup.controller.d.ts +2 -0
- package/dist/serverGroup/details/rollback/rollbackServerGroup.controller.d.ts +2 -0
- package/dist/serverGroup/details/serverGroupDetails.controller.d.ts +2 -0
- package/dist/serverGroup/serverGroup.transformer.d.ts +2 -0
- package/package.json +38 -0
- package/src/common/footer.component.html +7 -0
- package/src/common/footer.component.js +18 -0
- package/src/common/ocid/ocid.component.js +15 -0
- package/src/common/ocid/ocid.template.html +10 -0
- package/src/common/ocid/truncateOcid.filter.js +14 -0
- package/src/domain/IOracleLoadBalancer.ts +110 -0
- package/src/helpContents/oracleHelpContents.ts +52 -0
- package/src/image/image.reader.js +38 -0
- package/src/index.ts +1 -0
- package/src/instance/details/instance.details.controller.js +56 -0
- package/src/instance/details/instanceDetails.html +31 -0
- package/src/loadBalancer/configure/backendSets.html +67 -0
- package/src/loadBalancer/configure/certificates.html +63 -0
- package/src/loadBalancer/configure/createLoadBalancer.controller.spec.ts +201 -0
- package/src/loadBalancer/configure/createLoadBalancer.controller.ts +540 -0
- package/src/loadBalancer/configure/createLoadBalancer.html +25 -0
- package/src/loadBalancer/configure/createLoadBalancerProperties.html +167 -0
- package/src/loadBalancer/configure/editLoadBalancer.html +26 -0
- package/src/loadBalancer/configure/listeners.html +88 -0
- package/src/loadBalancer/details/loadBalancerDetail.controller.spec.ts +62 -0
- package/src/loadBalancer/details/loadBalancerDetail.controller.ts +163 -0
- package/src/loadBalancer/details/loadBalancerDetail.html +100 -0
- package/src/loadBalancer/loadBalancer.transformer.ts +144 -0
- package/src/oracle.module.ts +94 -0
- package/src/oracle.settings.ts +19 -0
- package/src/pipeline/disableAsg/disableAsgStage.html +11 -0
- package/src/pipeline/disableAsg/disableAsgStage.js +62 -0
- package/src/pipeline/disableAsg/disableAsgStepLabel.html +1 -0
- package/src/pipeline/stages/bake/bakeExecutionDetails.controller.js +38 -0
- package/src/pipeline/stages/bake/bakeExecutionDetails.html +52 -0
- package/src/pipeline/stages/bake/bakeStage.html +109 -0
- package/src/pipeline/stages/bake/ociBakeStage.js +147 -0
- package/src/pipeline/stages/destroyAsg/destroyAsgStage.html +9 -0
- package/src/pipeline/stages/destroyAsg/destroyAsgStage.js +64 -0
- package/src/pipeline/stages/destroyAsg/destroyAsgStepLabel.html +1 -0
- package/src/pipeline/stages/disableAsg/disableAsgStage.html +11 -0
- package/src/pipeline/stages/disableAsg/disableAsgStage.js +63 -0
- package/src/pipeline/stages/disableAsg/disableAsgStepLabel.html +1 -0
- package/src/pipeline/stages/findAmi/findAmiStage.html +20 -0
- package/src/pipeline/stages/findAmi/findAmiStage.js +82 -0
- package/src/pipeline/stages/findImageFromTags/findImageFromTagsExecutionDetails.html +44 -0
- package/src/pipeline/stages/findImageFromTags/findImageFromTagsStage.html +11 -0
- package/src/pipeline/stages/findImageFromTags/oracleFindImageFromTagsStage.js +36 -0
- package/src/pipeline/stages/resizeAsg/resizeAsgStage.html +89 -0
- package/src/pipeline/stages/resizeAsg/resizeAsgStage.js +101 -0
- package/src/pipeline/stages/resizeAsg/resizeAsgStepLabel.html +1 -0
- package/src/pipeline/stages/scaleDownCluster/scaleDownClusterStage.html +35 -0
- package/src/pipeline/stages/scaleDownCluster/scaleDownClusterStage.js +75 -0
- package/src/pipeline/stages/shrinkCluster/shrinkClusterStage.html +34 -0
- package/src/pipeline/stages/shrinkCluster/shrinkClusterStage.js +71 -0
- package/src/securityGroup/configure/createSecurityGroup.controller.js +19 -0
- package/src/securityGroup/configure/createSecurityGroup.html +19 -0
- package/src/securityGroup/securityGroup.reader.js +15 -0
- package/src/securityGroup/securityGroup.transformer.js +25 -0
- package/src/serverGroup/configure/serverGroup.configure.module.js +15 -0
- package/src/serverGroup/configure/serverGroupCommandBuilder.service.js +105 -0
- package/src/serverGroup/configure/serverGroupConfiguration.service.js +229 -0
- package/src/serverGroup/configure/wizard/advancedSettings/advancedSettings.html +13 -0
- package/src/serverGroup/configure/wizard/basicSettings/basicSettings.controller.js +35 -0
- package/src/serverGroup/configure/wizard/basicSettings/basicSettings.html +134 -0
- package/src/serverGroup/configure/wizard/capacity/capacity.html +7 -0
- package/src/serverGroup/configure/wizard/capacity/capacitySelector.component.html +13 -0
- package/src/serverGroup/configure/wizard/capacity/capacitySelector.component.js +17 -0
- package/src/serverGroup/configure/wizard/cloneServerGroup.controller.js +109 -0
- package/src/serverGroup/configure/wizard/instanceType/instanceType.html +29 -0
- package/src/serverGroup/configure/wizard/loadBalancers/loadBalancers.html +44 -0
- package/src/serverGroup/configure/wizard/network/networkSettings.html +15 -0
- package/src/serverGroup/configure/wizard/serverGroupWizard.html +40 -0
- package/src/serverGroup/configure/wizard/templateSelection/templateSelection.html +9 -0
- package/src/serverGroup/details/resize/resizeCapacity.component.html +36 -0
- package/src/serverGroup/details/resize/resizeCapacity.component.js +42 -0
- package/src/serverGroup/details/resize/resizeServerGroup.controller.js +62 -0
- package/src/serverGroup/details/resize/resizeServerGroup.html +33 -0
- package/src/serverGroup/details/rollback/rollbackServerGroup.controller.js +73 -0
- package/src/serverGroup/details/rollback/rollbackServerGroup.html +41 -0
- package/src/serverGroup/details/serverGroupDetails.controller.js +230 -0
- package/src/serverGroup/details/serverGroupDetails.html +94 -0
- package/src/serverGroup/serverGroup.transformer.js +29 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import type { StateService } from '@uirouter/angularjs';
|
|
2
|
+
import UIROUTER_ANGULARJS from '@uirouter/angularjs';
|
|
3
|
+
import type { IController } from 'angular';
|
|
4
|
+
import { module } from 'angular';
|
|
5
|
+
import type { IModalServiceInstance } from 'angular-ui-bootstrap';
|
|
6
|
+
import ANGULAR_UI_BOOTSTRAP from 'angular-ui-bootstrap';
|
|
7
|
+
import { cloneDeep, trimEnd } from 'lodash';
|
|
8
|
+
|
|
9
|
+
import type { Application, IAccountDetails, ILoadBalancer, INetwork, IRegion, ISubnet } from '@spinnaker/core';
|
|
10
|
+
import {
|
|
11
|
+
AccountService,
|
|
12
|
+
LoadBalancerWriter,
|
|
13
|
+
NameUtils,
|
|
14
|
+
NetworkReader,
|
|
15
|
+
SubnetReader,
|
|
16
|
+
TaskMonitor,
|
|
17
|
+
} from '@spinnaker/core';
|
|
18
|
+
import type {
|
|
19
|
+
IOracleBackEndSet,
|
|
20
|
+
IOracleListener,
|
|
21
|
+
IOracleListenerCertificate,
|
|
22
|
+
IOracleLoadBalancer,
|
|
23
|
+
IOracleSubnet,
|
|
24
|
+
} from '../../domain/IOracleLoadBalancer';
|
|
25
|
+
import { LoadBalancingPolicy } from '../../domain/IOracleLoadBalancer';
|
|
26
|
+
|
|
27
|
+
import type { OracleLoadBalancerTransformer } from '../loadBalancer.transformer';
|
|
28
|
+
import { ORACLE_LOAD_BALANCER_TRANSFORMER } from '../loadBalancer.transformer';
|
|
29
|
+
|
|
30
|
+
export class OracleLoadBalancerController implements IController {
|
|
31
|
+
public oracle = 'oracle';
|
|
32
|
+
public shapes: string[] = ['100Mbps', '400Mbps', '8000Mbps']; // TODO desagar use listShapes to get this from clouddriver later
|
|
33
|
+
public loadBalancingPolicies: string[] = Object.keys(LoadBalancingPolicy).map((k) => (LoadBalancingPolicy as any)[k]);
|
|
34
|
+
public pages: { [key: string]: any } = {
|
|
35
|
+
properties: require('./createLoadBalancerProperties.html'),
|
|
36
|
+
listeners: require('./listeners.html'),
|
|
37
|
+
backendSets: require('./backendSets.html'),
|
|
38
|
+
certificates: require('./certificates.html'),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
public state: { [key: string]: boolean } = {
|
|
42
|
+
accountsLoaded: false,
|
|
43
|
+
submitting: false,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
public allVnets: INetwork[];
|
|
47
|
+
public allSubnets: IOracleSubnet[];
|
|
48
|
+
public filteredVnets: INetwork[];
|
|
49
|
+
public filteredSubnets: ISubnet[];
|
|
50
|
+
public filteredSubnetsByType: ISubnet[];
|
|
51
|
+
public selectedVnet: INetwork;
|
|
52
|
+
public selectedSubnets: IOracleSubnet[];
|
|
53
|
+
public numSubnetsAllowed = 1;
|
|
54
|
+
public listeners: IOracleListener[] = [];
|
|
55
|
+
public backendSets: IOracleBackEndSet[] = [];
|
|
56
|
+
public certificates: IOracleListenerCertificate[] = [];
|
|
57
|
+
|
|
58
|
+
public static $inject = [
|
|
59
|
+
'$scope',
|
|
60
|
+
'$uibModalInstance',
|
|
61
|
+
'$state',
|
|
62
|
+
'oracleLoadBalancerTransformer',
|
|
63
|
+
'application',
|
|
64
|
+
'loadBalancer',
|
|
65
|
+
'isNew',
|
|
66
|
+
];
|
|
67
|
+
constructor(
|
|
68
|
+
private $scope: ng.IScope,
|
|
69
|
+
private $uibModalInstance: IModalServiceInstance,
|
|
70
|
+
private $state: StateService,
|
|
71
|
+
private oracleLoadBalancerTransformer: OracleLoadBalancerTransformer,
|
|
72
|
+
private application: Application,
|
|
73
|
+
private loadBalancer: IOracleLoadBalancer,
|
|
74
|
+
private isNew: boolean,
|
|
75
|
+
) {
|
|
76
|
+
this.initializeController();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public onApplicationRefresh() {
|
|
80
|
+
// If the user has already closed the modal, do not navigate to the new details view
|
|
81
|
+
if (this.$scope.$$destroyed) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.$uibModalInstance.close();
|
|
85
|
+
const newStateParams = {
|
|
86
|
+
name: this.loadBalancer.name,
|
|
87
|
+
accountId: this.loadBalancer.account,
|
|
88
|
+
region: this.loadBalancer.region,
|
|
89
|
+
provider: 'oracle',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (!this.$state.includes('**.loadBalancerDetails')) {
|
|
93
|
+
this.$state.go('.loadBalancerDetails', newStateParams);
|
|
94
|
+
} else {
|
|
95
|
+
this.$state.go('^.loadBalancerDetails', newStateParams);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public onTaskComplete() {
|
|
100
|
+
this.application.loadBalancers.refresh();
|
|
101
|
+
this.application.loadBalancers.onNextRefresh(this.$scope, this.onApplicationRefresh);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public initializeCreateMode() {
|
|
105
|
+
AccountService.listAccounts(this.oracle).then((accounts: IAccountDetails[]) => {
|
|
106
|
+
this.$scope.accounts = accounts; // TODO desagar does this need to be in $scope?
|
|
107
|
+
this.state.accountsLoaded = true;
|
|
108
|
+
this.$scope.state = this.state;
|
|
109
|
+
this.accountUpdated();
|
|
110
|
+
});
|
|
111
|
+
this.loadVnets();
|
|
112
|
+
this.loadSubnets();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private initControllerFromLoadBalancerCmd() {
|
|
116
|
+
this.numSubnetsAllowed = this.calcNumSubnetsAllowed();
|
|
117
|
+
if (this.$scope.loadBalancerCmd.listeners) {
|
|
118
|
+
Object.keys(this.$scope.loadBalancerCmd.listeners).forEach((lis) => {
|
|
119
|
+
this.listeners.push(this.$scope.loadBalancerCmd.listeners[lis]);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (this.$scope.loadBalancerCmd.backendSets) {
|
|
123
|
+
Object.keys(this.$scope.loadBalancerCmd.backendSets).forEach((b) => {
|
|
124
|
+
this.backendSets.push(this.$scope.loadBalancerCmd.backendSets[b]);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (this.$scope.loadBalancerCmd.certificates) {
|
|
128
|
+
Object.keys(this.$scope.loadBalancerCmd.certificates).forEach((b) => {
|
|
129
|
+
this.certificates.push(this.$scope.loadBalancerCmd.certificates[b]);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public initializeController() {
|
|
135
|
+
if (this.loadBalancer) {
|
|
136
|
+
this.$scope.loadBalancerCmd = this.oracleLoadBalancerTransformer.convertLoadBalancerForEditing(this.loadBalancer);
|
|
137
|
+
this.initControllerFromLoadBalancerCmd();
|
|
138
|
+
if (this.isNew) {
|
|
139
|
+
const nameParts = NameUtils.parseLoadBalancerName(this.loadBalancer.name);
|
|
140
|
+
this.$scope.loadBalancerCmd.stack = nameParts.stack;
|
|
141
|
+
this.$scope.loadBalancerCmd.detail = nameParts.freeFormDetails;
|
|
142
|
+
delete this.$scope.loadBalancerCmd.name;
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
this.$scope.loadBalancerCmd = this.oracleLoadBalancerTransformer.constructNewLoadBalancerTemplate(
|
|
146
|
+
this.application,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
this.$scope.prevBackendSetNames = [];
|
|
150
|
+
this.$scope.prevCertNames = [];
|
|
151
|
+
if (this.isNew) {
|
|
152
|
+
this.updateName();
|
|
153
|
+
this.updateLoadBalancerNames();
|
|
154
|
+
this.initializeCreateMode();
|
|
155
|
+
}
|
|
156
|
+
this.$scope.taskMonitor = new TaskMonitor({
|
|
157
|
+
application: this.application,
|
|
158
|
+
title: (this.isNew ? 'Creating ' : 'Updating ') + 'your load balancer',
|
|
159
|
+
modalInstance: this.$uibModalInstance,
|
|
160
|
+
onTaskComplete: this.onTaskComplete,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public updateLoadBalancerNames() {
|
|
165
|
+
const account = this.$scope.loadBalancerCmd.credentials;
|
|
166
|
+
const region = this.$scope.loadBalancerCmd.region;
|
|
167
|
+
|
|
168
|
+
const accountLoadBalancerNamesByRegion: { [key: string]: string[] } = {};
|
|
169
|
+
this.application
|
|
170
|
+
.getDataSource('loadBalancers')
|
|
171
|
+
.refresh(true)
|
|
172
|
+
.then(() => {
|
|
173
|
+
const loadBalancers: ILoadBalancer[] = this.application.loadBalancers.data;
|
|
174
|
+
loadBalancers.forEach((loadBalancer) => {
|
|
175
|
+
if (loadBalancer.account === account) {
|
|
176
|
+
accountLoadBalancerNamesByRegion[loadBalancer.region] =
|
|
177
|
+
accountLoadBalancerNamesByRegion[loadBalancer.region] || [];
|
|
178
|
+
accountLoadBalancerNamesByRegion[loadBalancer.region].push(loadBalancer.name);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
this.$scope.existingLoadBalancerNames = accountLoadBalancerNamesByRegion[region] || [];
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public validateBeforeSubmit() {
|
|
187
|
+
return this.propertiesValid() && this.listenersValid();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Used to prevent form submission if listeners are invalid
|
|
192
|
+
* Currently it calls the two validations applicable to listeners.
|
|
193
|
+
* @returns {boolean}
|
|
194
|
+
*/
|
|
195
|
+
public listenersValid() {
|
|
196
|
+
return this.listenersUniqueProtocolPort() && this.listenersBackendSetsExist() && this.listenersCertificatesExist();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Used to prevent form submission if the properties section is invalid
|
|
201
|
+
* Current the only validation is for subnet count.
|
|
202
|
+
*/
|
|
203
|
+
public propertiesValid() {
|
|
204
|
+
return this.selectedSubnets && this.selectedSubnets.length === this.calcNumSubnetsAllowed();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public listenersUniqueProtocolPort() {
|
|
208
|
+
// validate that listeners have unique protocol/port combination
|
|
209
|
+
const countsMap: { [key: string]: number } = {};
|
|
210
|
+
this.listeners.reduce((counts, listener) => {
|
|
211
|
+
const protocolPort = listener.protocol + '_' + listener.port;
|
|
212
|
+
counts[protocolPort] = counts[protocolPort] ? counts[protocolPort] + 1 : 1;
|
|
213
|
+
return counts;
|
|
214
|
+
}, countsMap);
|
|
215
|
+
// There should be no protocol/port combo in the countsMap with a count > 1
|
|
216
|
+
return (
|
|
217
|
+
Object.keys(countsMap).filter((key) => {
|
|
218
|
+
return countsMap[key] > 1;
|
|
219
|
+
}).length === 0
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
public listenersBackendSetsExist() {
|
|
224
|
+
// validate that the listeners' selected backend sets must exist. This is needed because Angular
|
|
225
|
+
// does not clear the selected backendSet from the drop down if the backend set is deleted.
|
|
226
|
+
const listenersWithNonExistentBackendSet: IOracleListener[] = this.listeners.filter(
|
|
227
|
+
(listener) => !this.backendSets.find((backendSet) => backendSet.name === listener.defaultBackendSetName),
|
|
228
|
+
);
|
|
229
|
+
return listenersWithNonExistentBackendSet.length === 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public listenersCertificatesExist() {
|
|
233
|
+
// validate that the listeners' selected certificate names exist. This is needed because Angular
|
|
234
|
+
// does not clear the selected certificate from the drop down if the certificate is deleted.
|
|
235
|
+
const listenersWithNonExistentCertificate: IOracleListener[] = this.listeners.filter(
|
|
236
|
+
(listener) =>
|
|
237
|
+
listener.sslConfiguration &&
|
|
238
|
+
!this.certificates.find((cert) => cert.certificateName === listener.sslConfiguration.certificateName),
|
|
239
|
+
);
|
|
240
|
+
return listenersWithNonExistentCertificate.length === 0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
public updateName() {
|
|
244
|
+
this.$scope.loadBalancerCmd.name = this.getName();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
public getName() {
|
|
248
|
+
const lb = this.$scope.loadBalancerCmd;
|
|
249
|
+
const lbName = [this.application.name, lb.stack || '', lb.detail || ''].join('-');
|
|
250
|
+
return trimEnd(lbName, '-');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
public accountUpdated() {
|
|
254
|
+
this.loadRegionsForAccount();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public regionUpdated() {
|
|
258
|
+
this.updateLoadBalancerNames();
|
|
259
|
+
this.updateVnets();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
public loadRegionsForAccount() {
|
|
263
|
+
AccountService.getRegionsForAccount(this.$scope.loadBalancerCmd.credentials).then((regions: IRegion[]) => {
|
|
264
|
+
this.$scope.regions = regions; // TODO desagar does this need to be in $scope?
|
|
265
|
+
if (regions.length === 1) {
|
|
266
|
+
this.$scope.loadBalancerCmd.region = regions[0].name;
|
|
267
|
+
this.regionUpdated();
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public loadVnets() {
|
|
273
|
+
NetworkReader.listNetworksByProvider(this.oracle).then((vnets: INetwork[]) => {
|
|
274
|
+
this.allVnets = vnets || [];
|
|
275
|
+
if (this.$scope.loadBalancerCmd.region) {
|
|
276
|
+
this.updateVnets();
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
public loadSubnets() {
|
|
282
|
+
SubnetReader.listSubnetsByProvider(this.oracle).then((subnets: IOracleSubnet[]) => {
|
|
283
|
+
this.allSubnets = subnets || [];
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public updateVnets() {
|
|
288
|
+
const account = this.$scope.loadBalancerCmd.credentials;
|
|
289
|
+
const region = this.$scope.loadBalancerCmd.region;
|
|
290
|
+
this.filteredVnets = this.allVnets.filter((vnet: INetwork) => {
|
|
291
|
+
return vnet.account === account && vnet.region === region;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
public updateSubnets(network: INetwork) {
|
|
296
|
+
this.selectedSubnets = [];
|
|
297
|
+
this.$scope.loadBalancerCmd.subnetIds = [];
|
|
298
|
+
this.filteredSubnets = this.allSubnets.filter((subnet: IOracleSubnet) => {
|
|
299
|
+
return subnet.vcnId === network.id;
|
|
300
|
+
});
|
|
301
|
+
this.filteredSubnetsByType = cloneDeep(this.filteredSubnets);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
public selectedVnetChanged(network: INetwork) {
|
|
305
|
+
this.selectedVnet = network;
|
|
306
|
+
this.$scope.loadBalancerCmd.vpcId = network.id;
|
|
307
|
+
this.updateSubnets(network);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public selectedSubnetsChanged(selectedSubnet: IOracleSubnet) {
|
|
311
|
+
if (selectedSubnet.availabilityDomain) {
|
|
312
|
+
this.filteredSubnetsByType = this.filteredSubnets.filter((subnet: IOracleSubnet) => {
|
|
313
|
+
return !!subnet.availabilityDomain;
|
|
314
|
+
});
|
|
315
|
+
} else {
|
|
316
|
+
this.filteredSubnetsByType = [];
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
public selectedSubnetRemoved() {
|
|
321
|
+
if (this.selectedSubnets.length === 0) {
|
|
322
|
+
this.filteredSubnetsByType = cloneDeep(this.filteredSubnets);
|
|
323
|
+
}
|
|
324
|
+
if (this.selectedSubnets.length === 1 && this.selectedSubnets[0].availabilityDomain) {
|
|
325
|
+
this.filteredSubnetsByType = this.filteredSubnets.filter((subnet: IOracleSubnet) => {
|
|
326
|
+
return !!subnet.availabilityDomain;
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
public isPrivateChanged() {
|
|
332
|
+
this.numSubnetsAllowed = this.calcNumSubnetsAllowed();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
public listenerIsSslChanged(listener: IOracleListener) {
|
|
336
|
+
if (listener.isSsl) {
|
|
337
|
+
listener.sslConfiguration = this.oracleLoadBalancerTransformer.constructNewSSLConfiguration();
|
|
338
|
+
} else {
|
|
339
|
+
listener.sslConfiguration = undefined;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public calcNumSubnetsAllowed() {
|
|
344
|
+
if (this.$scope.loadBalancerCmd.isPrivate) {
|
|
345
|
+
return 1;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (this.selectedSubnets && this.selectedSubnets.length === 1 && !this.selectedSubnets[0].availabilityDomain) {
|
|
349
|
+
return 1;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return 2;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
public getSubnetLimit() {}
|
|
356
|
+
|
|
357
|
+
public removeListener(idx: number) {
|
|
358
|
+
this.listeners.splice(idx, 1);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
public addListener() {
|
|
362
|
+
this.listeners.push(this.oracleLoadBalancerTransformer.constructNewListenerTemplate());
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
public removeBackendSet(idx: number) {
|
|
366
|
+
const backendSet = this.backendSets[idx];
|
|
367
|
+
this.backendSets.splice(idx, 1);
|
|
368
|
+
this.$scope.prevBackendSetNames.splice(idx, 1);
|
|
369
|
+
// Also clear the defaultBackendSetName field of any listeners who are using this backendSet
|
|
370
|
+
this.listeners.forEach((lis) => {
|
|
371
|
+
if (lis.defaultBackendSetName === backendSet.name) {
|
|
372
|
+
lis.defaultBackendSetName = undefined;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
public isBackendSetRemovable(idx: number): boolean {
|
|
378
|
+
const backendSet = this.backendSets[idx];
|
|
379
|
+
if (backendSet && backendSet.backends && backendSet.backends.length > 0) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
let hasListener = false;
|
|
383
|
+
this.listeners.forEach((lis) => {
|
|
384
|
+
if (lis.defaultBackendSetName === backendSet.name) {
|
|
385
|
+
hasListener = true;
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
return !hasListener;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
public addBackendSet() {
|
|
392
|
+
const nameSuffix: number = this.backendSets.length + 1;
|
|
393
|
+
const name: string = 'backendSet' + nameSuffix;
|
|
394
|
+
this.$scope.prevBackendSetNames.push(name);
|
|
395
|
+
this.backendSets.push(this.oracleLoadBalancerTransformer.constructNewBackendSetTemplate(name));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
public backendSetNameChanged(idx: number) {
|
|
399
|
+
const prevName = this.$scope.prevBackendSetNames && this.$scope.prevBackendSetNames[idx];
|
|
400
|
+
if (prevName && prevName !== this.backendSets[idx].name) {
|
|
401
|
+
this.listeners
|
|
402
|
+
.filter((lis) => lis.defaultBackendSetName === prevName)
|
|
403
|
+
.forEach((lis) => {
|
|
404
|
+
lis.defaultBackendSetName = this.backendSets[idx].name;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public isCertRemovable(idx: number): boolean {
|
|
410
|
+
const cert = this.certificates[idx];
|
|
411
|
+
let hasListener = false;
|
|
412
|
+
this.listeners.forEach((lis) => {
|
|
413
|
+
if (lis.isSsl && lis.sslConfiguration && lis.sslConfiguration.certificateName === cert.certificateName) {
|
|
414
|
+
hasListener = true;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
return !hasListener;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
public removeCert(idx: number) {
|
|
421
|
+
const cert = this.certificates[idx];
|
|
422
|
+
this.certificates.splice(idx, 1);
|
|
423
|
+
this.$scope.prevCertNames.splice(idx, 1);
|
|
424
|
+
// Also clear the certificateName field of any listeners who are using this certificate
|
|
425
|
+
this.listeners.forEach((lis) => {
|
|
426
|
+
if (lis.sslConfiguration && lis.sslConfiguration.certificateName === cert.certificateName) {
|
|
427
|
+
lis.sslConfiguration.certificateName = undefined;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
public addCert() {
|
|
433
|
+
const nameSuffix: number = this.certificates.length + 1;
|
|
434
|
+
const name: string = 'certificate' + nameSuffix;
|
|
435
|
+
this.$scope.prevCertNames.push(name);
|
|
436
|
+
this.certificates.push(this.oracleLoadBalancerTransformer.constructNewCertificateTemplate(name));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
public certNameChanged(idx: number) {
|
|
440
|
+
const prevName = this.$scope.prevCertNames && this.$scope.prevCertNames[idx];
|
|
441
|
+
if (prevName && prevName !== this.certificates[idx].certificateName) {
|
|
442
|
+
this.listeners
|
|
443
|
+
.filter((lis) => lis.sslConfiguration && lis.sslConfiguration.certificateName === prevName)
|
|
444
|
+
.forEach((lis) => {
|
|
445
|
+
lis.sslConfiguration.certificateName = this.certificates[idx].certificateName;
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
public submit() {
|
|
451
|
+
const descriptor = this.isNew ? 'Create' : 'Update';
|
|
452
|
+
|
|
453
|
+
this.$scope.taskMonitor.submit(() => {
|
|
454
|
+
const params = {
|
|
455
|
+
cloudProvider: 'oracle',
|
|
456
|
+
application: this.application.name,
|
|
457
|
+
clusterName: this.$scope.loadBalancerCmd.clusterName,
|
|
458
|
+
resourceGroupName: this.$scope.loadBalancerCmd.clusterName,
|
|
459
|
+
loadBalancerName: this.$scope.loadBalancerCmd.name,
|
|
460
|
+
loadBalancerId: null as string,
|
|
461
|
+
};
|
|
462
|
+
if (this.loadBalancer && this.loadBalancer.id) {
|
|
463
|
+
params.loadBalancerId = this.loadBalancer.id;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (this.selectedVnet) {
|
|
467
|
+
this.$scope.loadBalancerCmd.vpcId = this.selectedVnet.id;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (this.selectedSubnets && this.selectedSubnets.length > 0) {
|
|
471
|
+
this.$scope.loadBalancerCmd.subnetIds = this.selectedSubnets.map((subnet: IOracleSubnet) => {
|
|
472
|
+
return subnet.id;
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
for (const subnet of this.selectedSubnets) {
|
|
476
|
+
if (!this.$scope.loadBalancerCmd.subnetTypeMap) {
|
|
477
|
+
this.$scope.loadBalancerCmd.subnetTypeMap = {
|
|
478
|
+
[subnet.id]: !subnet.availabilityDomain ? 'Regional' : 'AD',
|
|
479
|
+
};
|
|
480
|
+
} else {
|
|
481
|
+
this.$scope.loadBalancerCmd.subnetTypeMap[subnet.id] = !subnet.availabilityDomain ? 'Regional' : 'AD';
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (this.backendSets) {
|
|
487
|
+
this.$scope.loadBalancerCmd.backendSets = this.backendSets.reduce(
|
|
488
|
+
(backendSetsMap: { [name: string]: IOracleBackEndSet }, backendSet: IOracleBackEndSet) => {
|
|
489
|
+
backendSetsMap[backendSet.name] = backendSet;
|
|
490
|
+
return backendSetsMap;
|
|
491
|
+
},
|
|
492
|
+
{},
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (this.listeners) {
|
|
497
|
+
this.$scope.loadBalancerCmd.listeners = this.listeners.reduce(
|
|
498
|
+
(listenersMap: { [name: string]: IOracleListener }, listener: IOracleListener) => {
|
|
499
|
+
listener.name = listener.protocol + '_' + listener.port;
|
|
500
|
+
listenersMap[listener.name] = listener;
|
|
501
|
+
return listenersMap;
|
|
502
|
+
},
|
|
503
|
+
{},
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (this.certificates) {
|
|
508
|
+
this.$scope.loadBalancerCmd.certificates = this.certificates.reduce(
|
|
509
|
+
(certMap: { [name: string]: IOracleListenerCertificate }, cert: IOracleListenerCertificate) => {
|
|
510
|
+
certMap[cert.certificateName] = cert;
|
|
511
|
+
if (!cert.isNew) {
|
|
512
|
+
// existing certificate sends only the name
|
|
513
|
+
certMap[cert.certificateName].publicCertificate = null;
|
|
514
|
+
}
|
|
515
|
+
return certMap;
|
|
516
|
+
},
|
|
517
|
+
{},
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
this.$scope.loadBalancerCmd.type = 'upsertLoadBalancer';
|
|
522
|
+
if (!this.$scope.loadBalancerCmd.vnet && !this.$scope.loadBalancerCmd.subnetType) {
|
|
523
|
+
this.$scope.loadBalancerCmd.securityGroups = null;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return LoadBalancerWriter.upsertLoadBalancer(this.$scope.loadBalancerCmd, this.application, descriptor, params);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
public cancel() {
|
|
531
|
+
this.$uibModalInstance.dismiss();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export const ORACLE_LOAD_BALANCER_CREATE_CONTROLLER = 'spinnaker.oracle.loadBalancer.create.controller';
|
|
536
|
+
module(ORACLE_LOAD_BALANCER_CREATE_CONTROLLER, [
|
|
537
|
+
ANGULAR_UI_BOOTSTRAP as any,
|
|
538
|
+
UIROUTER_ANGULARJS,
|
|
539
|
+
ORACLE_LOAD_BALANCER_TRANSFORMER,
|
|
540
|
+
]).controller('oracleCreateLoadBalancerCtrl', OracleLoadBalancerController);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<form name="form" class="form-horizontal" novalidate validate-on-submit>
|
|
2
|
+
<v2-modal-wizard heading="Create New Oracle Load Balancer" task-monitor="taskMonitor" dismiss="$dismiss()">
|
|
3
|
+
<v2-wizard-page key="Properties" label="Properties">
|
|
4
|
+
<ng-include src="ctrl.pages.properties"></ng-include>
|
|
5
|
+
</v2-wizard-page>
|
|
6
|
+
<v2-wizard-page key="Certificates" label="SSL Certificates" done="true">
|
|
7
|
+
<ng-include src="ctrl.pages.certificates"></ng-include>
|
|
8
|
+
</v2-wizard-page>
|
|
9
|
+
<v2-wizard-page key="Backend Sets" label="Backend Sets" done="true" hide-subheading="true">
|
|
10
|
+
<ng-include src="ctrl.pages.backendSets"></ng-include>
|
|
11
|
+
</v2-wizard-page>
|
|
12
|
+
<v2-wizard-page key="Listeners" label="Listeners" done="true">
|
|
13
|
+
<ng-include src="ctrl.pages.listeners"></ng-include>
|
|
14
|
+
</v2-wizard-page>
|
|
15
|
+
</v2-modal-wizard>
|
|
16
|
+
<div class="modal-footer">
|
|
17
|
+
<button ng-disabled="ctrl.taskMonitor.submitting" class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
|
|
18
|
+
<submit-button
|
|
19
|
+
is-disabled="!state.accountsLoaded || !form.$valid || !ctrl.validateBeforeSubmit() || ctrl.taskMonitor.submitting"
|
|
20
|
+
submitting="ctrl.taskMonitor.submitting"
|
|
21
|
+
on-click="form.$valid && ctrl.validateBeforeSubmit() && ctrl.submit()"
|
|
22
|
+
is-new="ctrl.isNew"
|
|
23
|
+
></submit-button>
|
|
24
|
+
</div>
|
|
25
|
+
</form>
|