Skip to content

Commit

Permalink
feat(nutanix): add nodes sections on nutanix dashboard
Browse files Browse the repository at this point in the history
ref: MANAGER-14695

Signed-off-by: Thibault Barske <[email protected]>
  • Loading branch information
tibs245 committed Nov 22, 2024
1 parent 8019676 commit fa52234
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/manager/modules/nutanix/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ export const CLUSTER_STATUS = {
DEPLOYING: 'deploying',
ERROR: 'error',
};

export const NODE_STATUS = {
DEPLOYED: 'deployed',
DEPLOYING: 'deploying',
DEPLOY_CANCELLED: 'deploy_cancelled',
DEPLOY_FAILURE: 'deploy_failure',
UNDEPLOYED: 'undeployed',
UNDEPLOYING: 'undeploying',
UNDEPLOY_CANCELLED: 'undeploy_cancelled',
UNDEPLOY_FAILURE: 'undeploy_failure',
UNKNOWN: 'unknown',
};

export const NUTANIX_SERVICE_TYPE = 'NUTANIX';

export const NUTANIX_ORDER_URL = {
Expand Down Expand Up @@ -44,6 +57,7 @@ export function getNutanixOrderUrl(subsidiary) {

export default {
CLUSTER_STATUS,
NODE_STATUS,
NOT_SUBSCRIBED,
SERVER_OPTIONS,
NUTANIX_SERVICE_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export default class NutanixGeneralInfoCtrl {
this.REPLICATION_FACTOR_PREFIX = REPLICATION_FACTOR_PREFIX;
this.NUTANIX_PERSONAL_LICENSE_EDITION = NUTANIX_PERSONAL_LICENSE_EDITION;
this.GENERAL_INFO_TILE_TITLE = GENERAL_INFO_TILE_TITLE;
this.nodes = [];
}

$onInit() {
this.loadServicesDetails();
this.loadNodesStatus();
this.setPrivateBandwidthServiceId();
this.clusterRedeploying = this.cluster.status === CLUSTER_STATUS.DEPLOYING;
this.showRedeployWarningModal = false;
Expand Down Expand Up @@ -61,6 +63,27 @@ export default class NutanixGeneralInfoCtrl {
});
}

loadNodesStatus() {
this.loadingNodeStatus = true;
return this.NutanixService.getNodeWithState(this.serviceInfo.serviceName)
.then((nodes) => {
this.nodes = nodes;
})
.finally(() => {
this.loadingNodeStatus = false;
});
}

get numberNodeDeployed() {
if (this.loadingNodeStatus) return '-';
return this.nodes.filter((node) => node.isDeployed).length;
}

get numberNodeToDeploy() {
if (this.loadingNodeStatus) return '-';
return this.nodes.filter((node) => !node.isDeployed).length;
}

setPrivateBandwidthServiceId() {
this.privateBandwidthServiceId = this.clusterAddOns.find((addOn) =>
addOn.billing?.plan?.code?.startsWith(PRIVATE_BANDWIDTH_SERVICE_PREFIX),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,53 @@
</oui-tile-description>
</oui-tile-definition>

<!-- number of nodes -->
<oui-tile-definition
term="{{:: 'nutanix_dashboard_cluster_number_of_nodes' | translate }}"
>
<oui-tile-description class="align-items-start">
<div class="text-break">
<span class="font-weight-bold text-break"
>{{ $ctrl.nodes.length }}</span
>
{{ "nutanix_dashboard_cluster_total_suscribed" |
translate }}
</div>
<div>
<span
class="oui-badge oui-badge_warning text-break ml-n1"
data-translate="nutanix_dashboard_cluster_node_to_deploy"
data-translate-values="{ numberOfNodes: $ctrl.numberNodeToDeploy, suffixPlurial: ($ctrl.numberNodeToDeploy > 1 ? 's' : '') }"
></span>
</div>
<div>
<span
class="oui-badge oui-badge_success text-break ml-n1"
data-translate="nutanix_dashboard_cluster_node_deployed"
data-translate-values="{ numberOfNodes: $ctrl.numberNodeDeployed, suffixPlurial: ($ctrl.numberNodeDeployed > 1 ? 's' : '') }"
></span>
</div>
<div>
<a class="oui-link_icon" href="#">
Gérer mes noeuds
<span
class="oui-icon oui-icon-arrow-right"
aria-hidden="true"
></span>
</a>
</div>
</oui-tile-description>
<oui-action-menu data-compact data-placement="end">
<oui-action-menu-item
on-click="$ctrl.goToEditName($ctrl.serviceDetails.resource.displayName)"
>
<span
data-translate="nutanix_dashboard_cluster_buy_node"
></span>
</oui-action-menu-item>
</oui-action-menu>
</oui-tile-definition>

<!-- Fault Tolerance Domain -->
<oui-tile-definition
term="{{:: $ctrl.GENERAL_INFO_TILE_TITLE.FAULT_TOLENRANCE_DOMAIN }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"nutanix_dashboard_cluster_admin_interface_info": "Veuillez vous connecter via Prism Central pour gérer votre cluster Nutanix",
"nutanix_dashboard_cluster_access_admin_interface": "Accéder à Prism Central",
"nutanix_dashboard_cluster_type_of_pack": "Type de pack",
"nutanix_dashboard_cluster_number_of_nodes": "Nombre de noeuds",
"nutanix_dashboard_cluster_buy_node": "Commande un noeud",
"nutanix_dashboard_cluster_licence": "Licence",
"nutanix_dashboard_cluster_rack_awareness_info": "Votre cluster Nutanix est déployé dans plusieurs baies.",
"nutanix_dashboard_cluster_node_awareness_info": "Votre cluster Nutanix est déployé dans une seule baie.",
Expand All @@ -20,5 +22,8 @@
"nutanix_dashboard_cluster_redeploy_modal_header": "Redéploiement du cluster",
"nutanix_dashboard_cluster_redeploy_modal_description": "Il est nécessaire de désinstaller votre licence Nutanix de votre cluster dans Prism Central avant le redéploiement de votre cluster.",
"nutanix_dashboard_cluster_redeploy_modal_continue": "Continuer",
"nutanix_dashboard_cluster_redeploy_modal_cancel": "Annuler"
"nutanix_dashboard_cluster_redeploy_modal_cancel": "Annuler",
"nutanix_dashboard_cluster_total_suscribed": "noeuds dans la souscription initale",
"nutanix_dashboard_cluster_node_to_deploy": "{{numberOfNodes}} noeud{{suffixPlurial}} à configurer",
"nutanix_dashboard_cluster_node_deployed": "{{numberOfNodes}} noeud{{suffixPlurial}} installé"
}
17 changes: 17 additions & 0 deletions packages/manager/modules/nutanix/src/node.class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NODE_STATUS } from './constants';

export default class Cluster {
constructor({ ahvIp, cvmIp, server, status }) {
Object.assign(this, {
ahvIp,
cvmIp,
server,
});

this.status = NODE_STATUS[status] ?? NODE_STATUS.UNKNOWN;
}

get isDeployed() {
return this.status === NODE_STATUS.DEPLOYED;
}
}
12 changes: 11 additions & 1 deletion packages/manager/modules/nutanix/src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class NutanixService {
/**
*
* @param {string} nodeServiceName
* @param {clusrer[]} clusters
* @param {cluster[]} clusters
* @returns {*} - cluster if found, null otherwise
*/
static getClusterByNodeName(nodeServiceName, clusters = []) {
Expand Down Expand Up @@ -169,6 +169,16 @@ export default class NutanixService {
.then((res) => res);
}

getNodeWithState(serviceName) {
return this.$http
.get(`/nutanix/${serviceName}/nodes`, {
serviceType: 'aapi',
})
.then(({ data }) => {
data.map((node) => new Node(node));
});
}

getServer(nodeId) {
return this.$http
.get(`/sws/dedicated/server/${nodeId}`, {
Expand Down

0 comments on commit fa52234

Please sign in to comment.