Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.4] Add static region list for (bootstrap) authentication to a subscribed… #4325

Merged
merged 2 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import layout from './template';
import { get, set, computed, setProperties } from '@ember/object';
import { next } from '@ember/runloop';
import { REGIONS } from 'shared/utils/amazon';
import { OCI_REGIONS } from 'shared/utils/oci';
import { Promise } from 'rsvp';

const CRED_CONFIG_CHOICES = [
Expand Down Expand Up @@ -63,6 +64,7 @@ export default Component.extend(ViewNewEdit, {
region: null,
sinlgeCloudKeyChoice: null,
regionChoices: REGIONS,
ociRegionChoices: OCI_REGIONS,
mode: 'new',

init() {
Expand Down Expand Up @@ -239,7 +241,7 @@ export default Component.extend(ViewNewEdit, {

if (cloudCredentialType === 'oci') {
let authConfig = {
region: 'us-phoenix-1',
region: this.config.region,
tenancyOCID: this.config.tenancyId,
userOCID: this.config.userId,
fingerprint: this.config.fingerprint,
Expand Down
39 changes: 27 additions & 12 deletions lib/global-admin/addon/components/cru-cloud-credential/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@
id="oci-tenancy"
}}
</div>

<div class="col span-6">
<label class="acc-label">
{{t "modalAddCloudKey.oci.authRegion.label"}}{{field-required}}
</label>
<select class="form-control" onchange={{action (mut config.region) value="target.value"}}>
<option value="" selected={{eq config.region choice}}>Select a region to authenticate credentials</option>
{{#each ociRegionChoices as |choice|}}
<option value={{choice}} selected={{eq config.region choice}}>{{choice}}</option>
{{/each}}
</select>
</div>
</div>

<div class="row">
Expand Down Expand Up @@ -211,6 +223,21 @@
</div>
</div>

<div class="row">
<div class="col span-6">
<label class="acc-label" for="oci-privateKeyPassphrase">
{{t "modalAddCloudKey.oci.secretKeyPassphrase.label"}}
</label>
{{input
type="password"
classNames="form-control"
placeholder=(t "modalAddCloudKey.oci.secretKeyPassphrase.placeholder")
value=config.privateKeyPassphrase
id="oci-privateKeyPassphrase"
}}
</div>
</div>

<div class="row">
<div class="col span-6">
<label class="acc-label" for="oci-privateKeyContents">
Expand All @@ -229,18 +256,6 @@
}}
</div>

<div class="col span-6">
<label class="acc-label" for="oci-privateKeyPassphrase">
{{t "modalAddCloudKey.oci.secretKeyPassphrase.label"}}
</label>
{{input
type="password"
classNames="form-control"
placeholder=(t "modalAddCloudKey.oci.secretKeyPassphrase.placeholder")
value=config.privateKeyPassphrase
id="oci-privateKeyPassphrase"
}}
</div>
</div>

{{else if (eq cloudCredentialType "vmware")}}
Expand Down
34 changes: 10 additions & 24 deletions lib/nodes/addon/components/driver-oci/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Component from '@ember/component';
import NodeDriver from 'shared/mixins/node-driver';
import layout from './template';
import { inject as service } from '@ember/service';
import { OCI_REGIONS } from 'shared/utils/oci';

export default Component.extend(NodeDriver, {
intl: service(),
Expand All @@ -17,6 +18,7 @@ export default Component.extend(NodeDriver, {
nodeAvailabilityDomain: '',
nodeImage: '',
step: 1,
regionChoices: OCI_REGIONS,

config: alias('model.ociConfig'),

Expand All @@ -30,26 +32,7 @@ export default Component.extend(NodeDriver, {
},
},

regionChoices: computed('model.cloudCredentialId', async function() {
let token = get(this, 'primaryResource.cloudCredentialId');

if ( token !== null && token !== '') {
const auth = {
type: 'cloud',
token
};

const options = await this.oci.request(auth, 'regions');

return this.mapToContent(options);
}

return {
value: '',
label: '',
};
}),
adChoices: computed('config.region', 'model.cloudCredentialId', async function() {
adChoices: computed('config.region', 'model.cloudCredentialId', 'primaryResource.cloudCredentialId', async function() {
let token = get(this, 'primaryResource.cloudCredentialId');
let region = get(this, 'config.region');

Expand All @@ -74,7 +57,7 @@ export default Component.extend(NodeDriver, {
let compartment = get(this, 'config.nodeCompartmentId');

if (token !== null && token !== '' && compartment !== null && compartment !== ''
&& compartment.startsWith('ocid1.compartment')) {
&& (compartment.startsWith('ocid1.compartment') || compartment.startsWith('ocid1.tenancy'))) {
const auth = {
type: 'cloud',
token
Expand All @@ -99,7 +82,7 @@ export default Component.extend(NodeDriver, {
let compartment = get(this, 'config.nodeCompartmentId');

if (token !== null && token !== '' && compartment !== null && compartment !== ''
&& compartment.startsWith('ocid1.compartment')) {
&& (compartment.startsWith('ocid1.compartment') || compartment.startsWith('ocid1.tenancy'))) {
const auth = {
type: 'cloud',
token
Expand Down Expand Up @@ -185,7 +168,10 @@ export default Component.extend(NodeDriver, {
if (!get(this, 'config.nodeShape')) {
errors.push('Specifying a oci node shape is required');
}
if (!get(this, 'config.nodeCompartmentId') || !get(this, 'config.nodeCompartmentId').startsWith('ocid1.compartment')) {
if (!get(this, 'config.nodeCompartmentId')) {
errors.push('Specifying an oci node compartment is required');
}
if (!get(this, 'config.nodeCompartmentId').startsWith('ocid1.compartment') && !get(this, 'config.nodeCompartmentId').startsWith('ocid1.tenancy')) {
errors.push('Specifying a valid oci node compartment is required');
}
if (!get(this, 'config.nodeAvailabilityDomain')) {
Expand All @@ -194,7 +180,7 @@ export default Component.extend(NodeDriver, {
if (!get(this, 'config.vcnCompartmentId')) {
set(this, 'config.vcnCompartmentId', get(this, 'config.nodeCompartmentId'));
} else {
if (!get(this, 'config.vcnCompartmentId').startsWith('ocid1.compartment')) {
if (!get(this, 'config.vcnCompartmentId').startsWith('ocid1.compartment') && !get(this, 'config.vcnCompartmentId').startsWith('ocid1.tenancy')) {
errors.push('Specifying a valid oci VCN compartment is required');
}
}
Expand Down
15 changes: 7 additions & 8 deletions lib/nodes/addon/components/driver-oci/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
<div class="row">

<div class="col span-6">
<label class="acc-label">{{t 'nodeDriver.oci.region.label'}}{{field-required}}</label>
{{#input-or-display value=selectedRegion}}
{{searchable-select class="form-control"
content=regionChoices
value=config.region
placeholder=(t "nodeDriver.oci.region.placeholder")
}}
{{/input-or-display}}
<label class="acc-label">{{t "nodeDriver.oci.region.label"}}{{field-required}}</label>
<select class="form-control" onchange={{action (mut config.region) value="target.value"}}>
<option value="" selected={{eq config.region choice}}>Select a region</option>
{{#each regionChoices as |choice|}}
<option value={{choice}} selected={{eq config.region choice}}>{{choice}}</option>
{{/each}}
</select>
</div>

<div class="col span-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { equal } from '@ember/object/computed'
import { get, set, computed, setProperties } from '@ember/object';
import { inject as service } from '@ember/service';
import { hash } from 'rsvp';
import { OCI_REGIONS } from 'shared/utils/oci';


const vcnIdMap = { quick: 'Quick Create', }
Expand All @@ -15,23 +16,23 @@ const subnetAccessMap = {
}

export default Component.extend(ClusterDriver, {
intl: service(),
intl: service(),
layout,
configField: 'okeEngineConfig',
instanceConfig: '',
step: 1,
lanChanged: null,
refresh: false,
vcnCreationMode: 'none',
vpcs: null,
subnets: null,
eipIds: null,
nodeFlavors: null,
keypairs: null,
availableZones: null,

isNew: equal('mode', 'new'),
editing: equal('mode', 'edit'),
configField: 'okeEngineConfig',
instanceConfig: '',
step: 1,
lanChanged: null,
refresh: false,
vcnCreationMode: 'none',
vpcs: null,
subnets: null,
eipIds: null,
nodeFlavors: null,
keypairs: null,
availableZones: null,
authRegionChoices: OCI_REGIONS,
isNew: equal('mode', 'new'),
editing: equal('mode', 'edit'),

init() {
this._super(...arguments);
Expand Down Expand Up @@ -91,20 +92,14 @@ export default Component.extend(ClusterDriver, {
url: '/meta/oci/okeVersions',
method: 'POST',
data
}),
regions: store.rawRequest({
url: '/meta/oci/regions',
method: 'POST',
data
})
}

return hash(ociRequest).then((resp) => {
const { okeVersions, regions } = resp;
const { okeVersions } = resp;

setProperties(this, {
okeVersions: (get( okeVersions, 'body') || []),
regions: (get( regions, 'body') || []),
errors: [],
});

Expand Down Expand Up @@ -272,11 +267,11 @@ export default Component.extend(ClusterDriver, {

return subnetAccess && subnetAccessMap[subnetAccess];
}),
canAuthenticate: computed('config.tenancyId', 'config.compartmentId', 'config.userOcid', 'config.fingerprint', 'config.privateKeyContents', function() {
return get(this, 'config.tenancyId') && get(this, 'config.compartmentId') && get(this, 'config.userOcid') && get(this, 'config.fingerprint') && get(this, 'config.privateKeyContents') ? false : true;
canAuthenticate: computed('config.tenancyId', 'config.region', 'config.userOcid', 'config.fingerprint', 'config.privateKeyContents', function() {
return get(this, 'config.tenancyId') && get(this, 'config.region') && get(this, 'config.userOcid') && get(this, 'config.fingerprint') && get(this, 'config.privateKeyContents') ? false : true;
}),
canAddK8sVersion: computed('config.region', 'config.kubernetesVersion', function() {
return !(get(this, 'config.region') && get(this, 'config.kubernetesVersion'));
canAddK8sVersion: computed('config.kubernetesVersion', 'config.compartmentId', function() {
return !(get(this, 'config.compartmentId') && get(this, 'config.kubernetesVersion'));
}),

canSaveVCN: computed('vcnCreationMode', 'config.vcnName', 'config.loadBalancerSubnetName1', 'config.loadBalancerSubnetName2', 'config.subnetAccess', 'config.vcnCidr', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@
{{/input-or-display}}
</div>


<div class="col span-6">
<label class="acc-label">
{{t 'clusterNew.oracleoke.compartmentOCID.label'}}{{field-required}}
{{t 'clusterNew.oracleoke.region.label'}}{{field-required}}
</label>
{{#input-or-display editable=isNew value=config.compartmentId}}
{{input type="text" name="compartment" classNames="form-control" placeholder=(t 'clusterNew.oracleoke.compartmentOCID.placeholder') value=config.compartmentId}}
{{/input-or-display}}
{{#if (and (eq step 1) isNew)}}
<select class="form-control" onchange={{action (mut config.region) value="target.value"}}>
{{#each authRegionChoices as |choice|}}
<option value={{choice}} selected={{eq config.region choice}}>{{choice}}</option>
{{/each}}
</select>
<p class="help-block">
{{t 'clusterNew.oracleoke.region.help'}}
</p>
{{else}}
<div>{{config.region}}</div>
{{/if}}
</div>

</div>
Expand All @@ -52,6 +60,9 @@
{{/input-or-display}}
</div>

</div>
<div class="row">

<div class="col span-6">
<label class="acc-label">
{{t 'clusterNew.oracleoke.secretKeyPassphrase.label'}}
Expand Down Expand Up @@ -102,18 +113,6 @@
expandAll=al.expandAll
expand=(action expandFn)
}}
<div class="row">
<div class="col span-6">
<label class="acc-label">
{{t 'clusterNew.oracleoke.region.label'}}{{field-required}}
</label>
{{#if (eq step 2)}}
{{#input-or-display editable=isNew value=config.region}}
{{input type="text" name="region" classNames="form-control" placeholder=(t 'clusterNew.oracleoke.region.placeholder') value=config.region}}
{{/input-or-display}}
{{/if}}
</div>
</div>
<div class="row">

<div class="col span-4">
Expand Down Expand Up @@ -171,20 +170,6 @@
expand=(action expandFn)
}}
<div class="row">
<div class="col span-4 mb-0">
<label class="acc-label">
{{t 'clusterNew.oracleoke.region.label'}}
</label>
{{#if (eq step 2)}}
<select class="form-control" onchange={{action (mut config.region) value="target.value"}}>
{{#each regions as |choice|}}
<option value={{choice}} selected={{eq config.region choice}}>{{choice}}</option>
{{/each}}
</select>
{{else}}
<div>{{config.region}}</div>
{{/if}}
</div>
<div class="col span-4 mb-0">
<label class="acc-label">
{{t 'clusterNew.oracleoke.version.label'}}
Expand Down Expand Up @@ -214,6 +199,17 @@
</div>

</div>
<div class="row">
<div class="col span-4">
<label class="acc-label">
{{t 'clusterNew.oracleoke.compartmentOCID.label'}}{{field-required}}
</label>
{{#input-or-display editable=(and (eq step 2) isNew) value=config.compartmentId}}
{{input type="text" name="compartment" classNames="form-control" placeholder=(t 'clusterNew.oracleoke.compartmentOCID.placeholder') value=config.compartmentId}}
{{/input-or-display}}
</div>

</div>
{{/accordion-list-item}}
{{#if (eq step 2)}}
{{save-cancel editing=(eq mode 'edit')
Expand Down
Loading