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

feat(netapp): retrieve region information from catalog #14226

Merged
merged 1 commit into from
Nov 22, 2024
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
53 changes: 21 additions & 32 deletions packages/manager/modules/netapp/src/order/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,33 @@ export const SIZE_MULTIPLE = 8;
export const SIZE_FACTOR = 1000;

export const REGION_LABEL = 'region';
export const NETWORK_LABEL = 'network';

// Private connectivity via our vRack service is not compatible with below regions.
export const IN_COMPATIBLE_REGION = ['BHS', 'SBG'];

export const DATACENTER_TO_COUNTRY = {
PAR: 'fr',
GRA: 'fr',
SBG: 'fr',
LIM: 'de',
WAW: 'pl',
ERI: 'uk',
VIN: 'us',
HIL: 'us',
BHS: 'ca',
SGP: 'sg',
SYD: 'au',
RBX: 'fr',
YYZ: 'ca',
YNM: 'in',
CR2: 'fr',
export const REGION_TO_COUNTRY = {
'eu-west-par': 'fr',
'eu-west-gra': 'fr',
'eu-west-sbg': 'fr',
'eu-west-lim': 'de',
'eu-central-waw': 'pl',
'eu-west-eri': 'gb',
'us-east-vin': 'us',
'us-west-hil': 'us',
'ca-east-bhs': 'ca',
'ap-southeast-sgp': 'sg',
'ap-southeast-syd': 'au',
'eu-west-rbx': 'fr',
'ca-east-tor': 'ca',
'ap-south-mum': 'in',
'labeu-west-1-preprod': 'fr',
};

export const DATACENTER_TO_REGION = {
RBX: 'eu-west-rbx',
GRA: 'eu-west-gra',
SBG: 'eu-west-sbg',
PAR: 'eu-west-par',
CR2: 'labeu-west-1-preprod',
LIM: 'eu-west-lim',
WAW: 'eu-central-waw',
ERI: 'eu-west-eri',
BHS: 'ca-east-bhs',
YYZ: 'ca-east-tor',
SGP: 'ap-southeast-sgp',
SYD: 'ap-southeast-syd',
YNM: 'ap-south-mum',
VIN: 'us-east-vin',
HIL: 'us-west-hil',
export const LICENSE_TYPE = {
Premium: 'Premium',
Standard: 'Standard',
Extreme: 'Ultra',
};

export default {
Expand Down
41 changes: 19 additions & 22 deletions packages/manager/modules/netapp/src/order/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { CatalogPricing } from '@ovh-ux/manager-models';

import {
REGION_LABEL,
NETWORK_LABEL,
SIZE_FACTOR,
SIZE_MULTIPLE,
DATACENTER_TO_COUNTRY,
DATACENTER_TO_REGION,
REGION_TO_COUNTRY,
LICENSE_TYPE,
} from './constants';

const findRegionConfiguration = (configurations) =>
Expand Down Expand Up @@ -46,6 +47,7 @@ export default class OvhManagerNetAppOrderCtrl {
this.$window = $window;
this.coreConfig = coreConfig;
this.RedirectionService = RedirectionService;
this.LICENSE_TYPE = LICENSE_TYPE;
}

$onInit() {
Expand Down Expand Up @@ -76,26 +78,17 @@ export default class OvhManagerNetAppOrderCtrl {
}

onRegionStepFocus() {
const plans = getPlansWithLicense(
this.catalog.plans,
this.selectedLicense.name,
);
this.regions = uniq(
plans.flatMap(
({ configurations }) =>
configurations.find(({ name }) => name === 'region').values,
),
const [product] = this.catalog.products[0].blobs.meta.configurations.filter(
({ name }) => name === 'region',
);

this.catalogByLocation = this.regions.map((datacenter) => {
const flag =
datacenter === 'ERI' ? 'gb' : DATACENTER_TO_COUNTRY[datacenter];
this.catalogByLocation = product.values.map((region) => {
const [, networkValue] = region.blobs.tags[0].split(':');
const flag = REGION_TO_COUNTRY[region.value];
return {
datacenter,
regionName: DATACENTER_TO_REGION[datacenter],
location: this.$translate.instant(
`netapp_location_${DATACENTER_TO_REGION[datacenter]}`,
),
network: networkValue,
regionName: region.value,
location: this.$translate.instant(`netapp_location_${region.value}`),
icon: `oui-flag oui-flag_${flag}`,
};
});
Expand All @@ -110,7 +103,7 @@ export default class OvhManagerNetAppOrderCtrl {
);
const availablePlans = getPlansWithRegion(
plans,
this.selectedRegion.datacenter,
this.selectedRegion.regionName,
);
this.plans = availablePlans.map((plan) => ({
...plan,
Expand Down Expand Up @@ -169,7 +162,7 @@ export default class OvhManagerNetAppOrderCtrl {
goToOrderUrl() {
const pricingModeType = this.pricingMode.pricingMode.replace(/[0-9]+/, '');
this.atInternet.trackClick({
name: `netapp::order::confirm::${this.selectedRegion.datacenter}_${this.selectedLicense.name}_${this.selectedSize}TB_${this.duration.duration}_${pricingModeType}`,
name: `netapp::order::confirm::${this.selectedRegion.regionName}_${this.selectedLicense.name}_${this.selectedSize}TB_${this.duration.duration}_${pricingModeType}`,
type: 'action',
});

Expand All @@ -186,7 +179,11 @@ export default class OvhManagerNetAppOrderCtrl {
configuration: [
{
label: REGION_LABEL,
value: this.selectedRegion.datacenter,
value: this.selectedRegion.regionName,
},
{
label: NETWORK_LABEL,
value: this.selectedRegion.network,
},
],
};
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/modules/netapp/src/order/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 data-translate="netapp_order"></h1>
data-ng-repeat="license in $ctrl.licenses track by $index"
name="license"
model="$ctrl.selectedLicense"
label="{{:: ('netapp_order_performance_level_type_' + license.name) | translate }}"
label="{{:: $ctrl.LICENSE_TYPE[license.name]}}"
values="[license]"
>
<oui-select-picker-description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
"netapp_order_region": "Région",
"netapp_order_performance_level": "Niveau de performance",
"netapp_order_performance_level_description": "Choisissez le niveau de performance du service selon vos besoins",
"netapp_order_performance_level_type_Premium": "Licence Premium",
"netapp_order_performance_level_type_Premium_description": "Équilibre entre prix et performance.",
"netapp_order_performance_level_type_Premium_additionnal_description": "64Mo/s et 4000 IOPS par To provisionné.",
"netapp_order_performance_level_type_Standard": "Licence standard",
"netapp_order_performance_level_type_Standard_description": "Pour vos cas d'usage de stockage",
"netapp_order_performance_level_type_Extreme": "Licence Ultra",
"netapp_order_performance_level_type_Extreme_description": "Quand votre activité nécessite une grande bande passante",
"netapp_order_size": "Capacité de stockage",
"netapp_order_size_description": "Précisez la capacité totale de stockage souhaitée de votre service Enterprise File Storage.",
Expand Down
Loading