Skip to content

Commit

Permalink
feat(nutanix): add node to nutanix cluster
Browse files Browse the repository at this point in the history
ref: MANAGER-14556

Signed-off-by: Thibault Barske <[email protected]>
  • Loading branch information
tibs245 committed Dec 10, 2024
1 parent 85ab77f commit 2c82e3a
Show file tree
Hide file tree
Showing 27 changed files with 482 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/manager/modules/nutanix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@ovh-ux/manager-models": "^2.1.0",
"bootstrap4": "twbs/bootstrap#v4.6.2",
"ipaddr.js": "^1.9.1",
"jsurl": "^0.1.4",
"lodash": "^4.17.14"
},
"peerDependencies": {
Expand Down
38 changes: 38 additions & 0 deletions packages/manager/modules/nutanix/src/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
export const PRODUCT_ID = 'nutanix';

export const ORDER_EXPRESS_URLS = {
CZ: 'https://www.ovh.cz/order/express/#/new/express/resume?products=',
DE: 'https://www.ovh.de/order/express/#/new/express/resume?products=',
ES: 'https://www.ovh.es/order/express/#/new/express/resume?products=',
FI: 'https://www.ovh-hosting.fi/order/express/#/new/express/resume?products=',
FR: 'https://www.ovh.com/fr/order/express/#/new/express/resume?products=',
GB: 'https://www.ovh.co.uk/order/express/#/new/express/resume?products=',
IE: 'https://www.ovh.ie/order/express/#/new/express/resume?products=',
IT: 'https://www.ovh.it/order/express/#/new/express/resume?products=',
LT: 'https://www.ovh.lt/order/express/#/new/express/resume?products=',
MA: 'https://www.ovh.ma/order/express/#/new/express/resume?products=',
NL: 'https://www.ovh.nl/order/express/#/new/express/resume?products=',
PL: 'https://www.ovh.pl/order/express/#/new/express/resume?products=',
PT: 'https://www.ovh.pt/order/express/#/new/express/resume?products=',
SN: 'https://www.ovh.sn/order/express/#/new/express/resume?products=',
TN: 'https://www.ovh.com/tn/order/express/#/new/express/resume?products=',
US: 'https://us.ovhcloud.com/order/express/#/express/review?products=',
ASIA: 'https://ca.ovh.com/asia/order/express/#/new/express/resume?products=',
IN: 'https://ca.ovh.com/in/order/express/#/express/review?products=',
AU: 'https://ca.ovh.com/au/order/express/#/new/express/resume?products=',
CA: 'https://ca.ovh.com/en/order/express/#/new/express/resume?products=',
QC: 'https://ca.ovh.com/fr/order/express/#/new/express/resume?products=',
SG: 'https://ca.ovh.com/sg/order/express/#/new/express/resume?products=',
WE: 'https://us.ovh.com/us/order/express/#/new/express/resume?products=',
WS: 'https://us.ovh.com/es/order/express/#/new/express/resume?products=',
};

export const NOT_SUBSCRIBED = 'notSubscribed';
export const SERVER_OPTIONS = {
BANDWIDTH: 'BANDWIDTH',
Expand All @@ -21,6 +50,8 @@ export const NODE_STATUS = {
UNKNOWN: 'unknown',
};

export const MAX_NODES_BY_CLUSTER = 15;

export const NUTANIX_SERVICE_TYPE = 'NUTANIX';

export const NUTANIX_ORDER_URL = {
Expand Down Expand Up @@ -55,11 +86,18 @@ export function getNutanixOrderUrl(subsidiary) {
return NUTANIX_ORDER_URL[subsidiary] || NUTANIX_ORDER_URL.DEFAULT;
}

export function getOrderExpressUrl(subsidiary) {
return ORDER_EXPRESS_URLS[subsidiary] || ORDER_EXPRESS_URLS.DEFAULT;
}

export default {
PRODUCT_ID,
NUTANIX_ORDER_URL,
CLUSTER_STATUS,
NODE_STATUS,
NOT_SUBSCRIBED,
SERVER_OPTIONS,
NUTANIX_SERVICE_TYPE,
FEATURES,
MAX_NODES_BY_CLUSTER,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import template from './template.html';
import controller from './controller';

export default {
bindings: {
goBack: '<',
nodeTechnicalDetails: '<',
cluster: '<',
server: '<',
nodePricing: '<',
nodeOrderLinkGenerator: '<',
expressOrderLink: '<',
handleSuccess: '<',
},
template,
controller,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { MAX_NODES_BY_CLUSTER } from '../../../constants';

export default class {
/* @ngInject */
constructor($window, $translate) {
this.$translate = $translate;
this.$window = $window;
this.numberOfNodes = 1;
}

get maxNodeToBuy() {
return MAX_NODES_BY_CLUSTER - this.cluster.targetSpec.nodes.length;
}

get nodePriceText() {
return this.nodePricing.price.text;
}

generateOrderExpressLink() {
this.nodeOrderLinkGenerator.setQuantity(this.numberOfNodes);
const expressOrderParams = this.nodeOrderLinkGenerator.generateLinkParams();

return `${this.expressOrderLink}${expressOrderParams}`;
}

onSubmit() {
this.openExpressOrderTab();

this.handleSuccess(
`${this.$translate.instant(
'nutanix_dashboard_add_nodes_success_banner',
)}<a href="${this.generateOrderExpressLink()}" target="_blank">${this.generateOrderExpressLink()}</a>`,
);
}

openExpressOrderTab() {
this.$window.open(this.generateOrderExpressLink(), '_blank');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import angular from 'angular';
import '@ovh-ux/manager-core';
import '@uirouter/angularjs';
import 'angular-translate';
import '@ovh-ux/ui-kit';

import component from './component';

const moduleName = 'ovhManagerNutanixAddNutanixNodesModal';

angular
.module(moduleName, [
'oui',
'ovhManagerCore',
'pascalprecht.translate',
'ui.router',
])
.component('addNutanixNodesModal', component)
.run(/* @ngTranslationsInject:json ./translations */);

export default moduleName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<oui-modal
data-on-dismiss="$ctrl.goBack()"
data-primary-action="$ctrl.onSubmit()"
data-primary-label="{{ !($ctrl.loading || $ctrl.terminationUnavailable) ? ('nutanix_dashboard_add_nodes_confirm' | translate) : '' }}"
data-secondary-action="$ctrl.goBack()"
data-secondary-disabled="$ctrl.loading"
data-secondary-label="{{:: 'nutanix_dashboard_add_nodes_cancel' | translate }}"
data-loading="$ctrl.cancelSubscriptionForm.isSubmiting || $ctrl.loading"
data-heading="{{:: 'nutanix_dashboard_add_nodes_title' | translate }}"
>
<div>
<p
class="oui-heading_4"
data-translate="nutanix_dashboard_add_nodes_actual_configuration"
></p>
<div>
<strong
data-translate="nutanix_dashboard_add_nodes_server_model"
></strong>
{{ $ctrl.server.description }}
</div>
<div>
<strong data-translate="nutanix_dashboard_add_nodes_cpu"></strong>
{{ $ctrl.nodeTechnicalDetails.cpu }}
</div>
<div>
<strong
data-translate="nutanix_dashboard_add_nodes_memory"
></strong>
{{$ctrl.nodeTechnicalDetails.memoryCapacity}}
</div>
<div>
<strong
data-translate="nutanix_dashboard_add_nodes_stokage"
></strong>
{{ $ctrl.nodeTechnicalDetails.storageCapacity }}
</div>

<form class="mt-4" name="cancelSubscriptionForm" novalidate>
<p
class="oui-heading_4"
data-translate="nutanix_dashboard_add_nodes_informations"
></p>

<div>
<span
data-translate="nutanix_dashboard_add_nodes_price_preffix"
></span>
<span class="font-weight-bold">{{$ctrl.nodePriceText}}</span>
<span
data-translate="nutanix_dashboard_add_nodes_price_suffix"
></span>

<oui-field>
<oui-numeric
name="numberOfNodes"
model="$ctrl.numberOfNodes"
min="1"
max="$ctrl.maxNodeToBuy"
on-change="$ctrl.onChange(modelValue)"
>
</oui-numeric>
</oui-field>
</div>
</form>
</div>
</oui-modal>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"nutanix_dashboard_add_nodes_title": "Commande de noeud(s)",
"nutanix_dashboard_add_nodes_actual_configuration": "Configuration actuelle des noeuds de votre cluster",
"nutanix_dashboard_add_nodes_server_model": "Modèle de serveurs :",
"nutanix_dashboard_add_nodes_cpu": "CPU :",
"nutanix_dashboard_add_nodes_memory": "Mémoire :",
"nutanix_dashboard_add_nodes_stokage": "Stokage :",
"nutanix_dashboard_add_nodes_informations": "Informations",
"nutanix_dashboard_add_nodes_price_preffix": "Le prix du noeud est de",
"nutanix_dashboard_add_nodes_price_suffix": "HT/mois",
"nutanix_dashboard_add_nodes_number_of_nodes_available": "Votre cluster est composé de {{numberOfNodes}} noeuds actuellement et vous pouvez l'étendre jusqu'à 15 noeuds.",
"nutanix_dashboard_add_nodes_number_of_nodes_to_command": "Nombre de noeuds supplémentaires à commander.",
"nutanix_dashboard_add_nodes_confirm": "Commander",
"nutanix_dashboard_add_nodes_cancel": "Annuler",
"nutanix_dashboard_add_nodes_success_banner": "Votre commande de nœud(s) a été initiée. Si vous ne l'avez pas encore finalisée, vous pouvez la compléter en cliquant sur le lien suivant : "
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import atInternet from '@ovh-ux/ng-at-internet';
import angular from 'angular';
import addNodeComponent from '../../component/add-nodes-modal/module';

import '@ovh-ux/ng-translate-async-loader';
import '@uirouter/angularjs';
import 'angular-translate';
import '@ovh-ux/ui-kit';

import routing from './add-nodes.routing';

const moduleName = 'ovhManagerDedicatedServerDashboardTerminate';

angular
.module(moduleName, [
atInternet,
'oui',
'pascalprecht.translate',
'ui.router',
addNodeComponent,
])
.config(routing);

export default moduleName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { getOrderExpressUrl } from '../../../constants';
import NodeExpressOrderLinkGenerator from '../../node-express-order-link-generator';

export default /* @ngInject */ ($stateProvider) => {
$stateProvider.state('nutanix.dashboard.general-info.add-nodes', {
url: '/add-nodes',
views: {
modal: {
component: 'addNutanixNodesModal',
},
},
layout: 'modal',
resolve: {
goBack: /* @ngInject */ (goToDashboard) => goToDashboard,
nodeTechnicalDetails: /* @ngInject */ (NutanixService, cluster) =>
NutanixService.getNodeHardwareInfo(cluster.targetSpec.nodes[0].server),
nodePricing: /* ngInject */ (clusterAddOns) => {
return clusterAddOns[0].billing.pricing;
},
handleError: /* @ngInject */ (Alerter, goBack) => (error) => {
Alerter.error(
error.message || error.data?.message,
'nutanix_dashboard_alert',
);
goBack();
},
nodeOrderLinkGenerator: /* @ngInject */ (serviceName, clusterAddOns) =>
new NodeExpressOrderLinkGenerator(serviceName, clusterAddOns[0]),
expressOrderLink: /* @ngInject */ (coreConfig) =>
getOrderExpressUrl(coreConfig.getUser().ovhSubsidiary),
handleSuccess: /* @ngInject */ (Alerter, goBack) => (message) => {
Alerter.success(message, 'nutanix_dashboard_alert');
goBack();
},
},
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import angular from 'angular';

import '@uirouter/angularjs';
import 'oclazyload';

const moduleName = 'ovhManagerNutanixAddNodesLazyLoading';

angular.module(moduleName, ['ui.router', 'oc.lazyLoad']).config(
/* @ngInject */ ($stateProvider) => {
$stateProvider.state('nutanix.dashboard.general-info.add-nodes.**', {
url: '/add-nodes',
lazyLoad: ($transition$) => {
const $ocLazyLoad = $transition$.injector().get('$ocLazyLoad');
return import('./add-nodes.module').then((mod) =>
$ocLazyLoad.inject(mod.default || mod),
);
},
});
},
);

export default moduleName;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {
goToEditName: '<',
goToUpgradePrivateBandwidth: '<',
goToRedeploy: '<',
goToAddNode: '<',
server: '<',
serviceDetails: '<',
serviceInfo: '<',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import editName from './edit-display-name';
import licenceTile from '../component/licence-tile/module';
import redeploy from './redeploy';
import datacenterName from '../component/datacenter-name/module';
import addNodes from './add-nodes';

const moduleName = 'ovhManagerNutanixGeneralInfo';

Expand All @@ -37,6 +38,7 @@ angular
licenceTile,
redeploy,
datacenterName,
addNodes,
])
.config(routing)
.component('nutanixGeneralInfo', component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ export default /* @ngInject */ ($stateProvider) => {
component: 'nutanixGeneralInfo',
resolve: {
trackingPrefix: /* @ngInject */ () => TRACKING.DASHBOARD,
goToDashboard: /* @ngInject */ ($state) => () =>
$state.go('nutanix.dashboard.general-info'),
goToEditName: /* @ngInject */ ($state) => (displayName) =>
$state.go('nutanix.dashboard.general-info.edit-display-name', {
displayName,
}),
goToAddNode: /* @ngInject */ ($state) => () =>
$state.go('nutanix.dashboard.general-info.add-nodes'),
goToNutanixGeneralInfo: /* @ngInject */ (
$state,
Alerter,
Expand All @@ -37,8 +41,6 @@ export default /* @ngInject */ ($stateProvider) => {
clusterTechnicalDetails.license.edition,
isLegacyPack: /* @ngInject */ (packType) =>
LEGACY_PACK_TYPES.includes(packType),
clusterAddOns: /* @ngInject */ (NutanixService, serviceInfo) =>
NutanixService.getClusterOptions(serviceInfo.serviceId),
goToUpgradePrivateBandwidth: /* @ngInject */ ($state) => () =>
$state.go('nutanix.dashboard.general-info.bandwidth-private-order'),
handleError: /* @ngInject */ (Alerter) => (error) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@
</div>
</oui-tile-description>
<oui-action-menu data-compact data-placement="end">
<oui-action-menu-item
on-click="$ctrl.goToEditName($ctrl.serviceDetails.resource.displayName)"
>
<oui-action-menu-item on-click="$ctrl.goToAddNode()">
<span
data-translate="nutanix_dashboard_cluster_buy_node"
></span>
Expand Down
Loading

0 comments on commit 2c82e3a

Please sign in to comment.