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 26, 2024
1 parent 8019676 commit 9b2343f
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 3 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 All @@ -51,7 +53,7 @@ export default class NutanixGeneralInfoCtrl {

loadServicesDetails() {
this.loadingServicesDetails = true;
return this.NutanixService.getServicesDetails(this.serviceInfo.serviceId)
return this.NutanixService.getServicesDetails(this.serviceId)
.then((servicesDetails) => {
this.servicesDetails = servicesDetails;
this.getPackType();
Expand All @@ -61,6 +63,25 @@ export default class NutanixGeneralInfoCtrl {
});
}

loadNodesStatus() {
this.loadingNodesStatus = true;
return this.NutanixService.getNodesWithState(this.serviceName)
.then((nodes) => {
this.nodes = nodes;
})
.finally(() => {
this.loadingNodesStatus = false;
});
}

get numberNodesDeployed() {
return this.nodes.filter((node) => node.isDeployed).length;
}

get numberNodesToDeploy() {
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,76 @@
</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"
data-ng-bind="$ctrl.nodes.length"
></span>
<span
data-translate="nutanix_dashboard_cluster_total_suscribed"
></span>
</div>
<div>
<oui-skeleton
data-ng-if="$ctrl.loadingNodesStatus"
size="s"
></oui-skeleton>
<span
data-ng-else
class="oui-badge oui-badge_warning text-break ml-n1"
data-ng-pluralize
data-count="$ctrl.numberNodesToDeploy"
data-when="{
'one': ('nutanix_dashboard_cluster_node_to_deploy' | translate:{numberOfNodes: $ctrl.numberNodesToDeploy}),
'other': ('nutanix_dashboard_cluster_several_nodes_to_deploy' | translate:{numberOfNodes: $ctrl.numberNodesToDeploy}),
}"
></span>
</div>
<div>
<oui-skeleton
data-ng-if="$ctrl.loadingNodesStatus"
size="s"
></oui-skeleton>
<span
data-ng-else
class="oui-badge oui-badge_success text-break ml-n1"
data-ng-pluralize
data-count="$ctrl.numberNodesDeployed"
data-when="{
'one': ('nutanix_dashboard_cluster_one_node_deployed' | translate:{numberOfNodes: $ctrl.numberNodesDeployed}),
'other': ('nutanix_dashboard_cluster_several_nodes_deployed' | translate:{numberOfNodes: $ctrl.numberNodesDeployed}),
}"
></span>
</div>
<div>
<a
class="oui-link_icon"
href="#"
data-translate="nutanix_dashboard_cluster_manage_nodes"
>
<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,9 @@
"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_manage_nodes": "Gérer mes noeuds",
"nutanix_dashboard_cluster_number_of_nodes": "Nombre de noeuds",
"nutanix_dashboard_cluster_buy_node": "Commander 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 +23,10 @@
"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 à configurer",
"nutanix_dashboard_cluster_several_nodes_to_deploy": "{{numberOfNodes}} noeuds à configurer",
"nutanix_dashboard_cluster_node_deployed": "{{numberOfNodes}} noeud installé",
"nutanix_dashboard_cluster_several_nodes_deployed": "{{numberOfNodes}} noeuds installés"
}
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 Node {
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);
}

getNodesWithState(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 9b2343f

Please sign in to comment.