Skip to content

Commit

Permalink
Cluster short name changes
Browse files Browse the repository at this point in the history
Tendrl-bug-id: Tendrl#656
  • Loading branch information
gnehapk authored and a2batic committed Apr 13, 2018
1 parent 00d1d18 commit fc2355a
Show file tree
Hide file tree
Showing 24 changed files with 169 additions and 119 deletions.
8 changes: 6 additions & 2 deletions src/commons/stores/cluster-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@
* @desc store for import cluster
* @memberOf clusterStore
*/
store.importCluster = function(clusterId, enableProfiling) {
store.importCluster = function(clusterId, enableProfiling, clusterName) {
var requestData = {
"Cluster.volume_profiling_flag": enableProfiling === "leaveAsIs" ? "leave-as-is" : enableProfiling
},
deferred;

if (clusterName) {
requestData["Cluster.short_name"] = clusterName;
}

deferred = $q.defer();
clusterFactory.importCluster(requestData, clusterId)
.then(function(data) {
Expand Down Expand Up @@ -211,7 +215,7 @@
temp.integrationId = cluster.integration_id;
temp.sdsVersion = cluster.sds_version;
temp.sdsName = cluster.sds_name;
temp.name = cluster.cluster_id;
temp.name = (cluster.short_name && cluster.short_name !== "None") ? cluster.short_name : cluster.integration_id;
temp.clusterId = cluster.cluster_id;
temp.currentTask = cluster.current_job;
temp.jobType = JSON.parse(cluster.current_job).job_name;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/base/header/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<select id="repeatSelect" ng-model="$root.selectedClusterOption" class="cluster-options btn btn-default dropdown-toggle filterSelect" ng-change="header.goToClusterPage()" uib-tooltip-html="header.getClusterName($root.selectedClusterOption)" tooltip-placement="auto bottom">
<option value="" disabled ng-selected="!$root.selectedClusterOption">Select a cluster...</option>
<option value="allClusters" ng-selected="$root.selectedClusterOption === 'allClusters'">All Clusters</option>
<option ng-repeat="cluster in $root.clusterData" value="{{cluster.clusterId}}" ng-selected="$root.selectedClusterOption === '{{cluster.clusterId}}'" ng-show="cluster.managed === 'Yes' && cluster.jobType !== 'UnmanageCluster'">{{cluster.clusterId}}</option>
<option ng-repeat="cluster in $root.clusterData" value="{{cluster.clusterId}}" ng-selected="$root.selectedClusterOption === '{{cluster.clusterId}}'" ng-show="cluster.managed === 'Yes' && cluster.jobType !== 'UnmanageCluster'">{{cluster.name}}</option>
<!-- To filter managed clusters : | filter: {is_managed: 'yes'}-->
</select>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/modules/bricks/host-bricks/host-bricks.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
function init() {
vm.clusterId = $stateParams.clusterId;
vm.hostId = $stateParams.hostId;
vm.clusterName = clusterStore.getClusterDetails(vm.clusterId).name;

if ($rootScope.clusterData) {
brickStore.getHostBrickList(vm.clusterId, vm.hostId)
Expand Down Expand Up @@ -153,7 +154,7 @@
hostName = brick.brickPath.split(":")[0].replace(/\./gi, "_");

brickName = brickName.replace(/\//gi, "|");
utils.redirectToGrafana("bricks", { clusterId: vm.clusterId, hostName: hostName, brickName: brickName, volumeName: brick.volName });
utils.redirectToGrafana("bricks", { clusterId: vm.clusterName, hostName: hostName, brickName: brickName, volumeName: brick.volName });
}

function _performAction(action, item) {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/bricks/volume-bricks/volume-bricks.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
function init() {
vm.clusterId = $stateParams.clusterId;
vm.volumeId = $stateParams.volumeId;
vm.clusterName = clusterStore.getClusterDetails(vm.clusterId).name;

if ($rootScope.clusterData && volumeStore.volumeList.length) {
clusterStore.getCluster(vm.clusterId)
Expand Down Expand Up @@ -275,7 +276,7 @@
hostName = brick.fqdn.replace(/\./gi, "_");

brickName = brickName.replace(/\//gi, "|");
utils.redirectToGrafana("bricks", { clusterId: vm.clusterId, hostName: hostName, brickName: brickName, volumeName: volumeStore.getVolumeObject(vm.volumeId).name });
utils.redirectToGrafana("bricks", { clusterId: vm.clusterName, hostName: hostName, brickName: brickName, volumeName: volumeStore.getVolumeObject(vm.volumeId).name });
}

function _matchesFilter(item, filter) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/clusters/cluster-list/cluster-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
}

function redirectToGrafana(cluster) {
utils.redirectToGrafana("glance", { clusterId: cluster.clusterId });
utils.redirectToGrafana("glance", { clusterId: cluster.name });
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/modules/clusters/expand-cluster/expand-cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<custom-modal-header title="vm.modalHeader.title" close="vm.modalHeader.close"></custom-modal-header>
<div class="modal-body">
<div class="col-md-12 desc">
{{vm.clusterId}} will be expanded by importing the new hosts listed below. Further actions will not be allowed on this cluster until expansion is complete.
{{vm.clusterName}} will be expanded by importing the new hosts listed below. Further actions will not be allowed on this cluster until expansion is complete.
</div>
<div class="toolbar-pf row">
<div class="form-group toolbar-pf-filter col-sm-6">
Expand Down
3 changes: 2 additions & 1 deletion src/modules/clusters/expand-cluster/expand-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

vm.disableExpand = false;
vm.clusterId = selectedCluster.clusterId;
vm.clusterName = selectedCluster.name;
vm.hostList = [];
vm.filteredHostList = [];
vm.filters = [];
Expand All @@ -22,7 +23,7 @@
vm.confirmModal = confirmModal;

vm.modalHeader = {
"title": "Expand " + selectedCluster.clusterId,
"title": "Expand " + vm.clusterName,
"close": vm.closeModal
};

Expand Down
2 changes: 1 addition & 1 deletion src/modules/clusters/host-list-modal/host-list-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
vm.filters = [];

vm.modalHeader = {
"title": "Hosts on " + vm.clusterId,
"title": "Hosts on " + cluster.name,
"close": vm.closeModal
};

Expand Down
13 changes: 13 additions & 0 deletions src/modules/clusters/import-cluster/import-cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@
<span class="pficon pficon-warning-triangle-o"></span>
Import cluster previously failed with <a ng-click="vm.openImportErrorModal(vm.taskId)" class="alert-link">{{vm.taskId}}</a>. Be sure that all the issues have been corrected and the cluster has been unmanaged before proceeding.
</div>
<div class="alert alert-danger" ng-show="vm.errorMsg.length > 0">
<span class="pficon pficon-error-circle-o"></span>
<label ng-bind="vm.errorMsg"></label>
</div>
<h1 class="bold-text">Import Cluster</h1>
<div class="container-fluid">
<div class="row cluster-name">
<label class="col-sm-2 col-md-1" for="clusterName">Cluster Name</label>
<div class="col-sm-4 col-md-3">
<div class="row">
<input class="col-md-12 col-sm-12" type="text" name="clusterName" ng-model="vm.clusterName"/>
</div>
<div class="row name-validation-msg">Only alphanumeric and underscore characters are allowed.</div>
</div>
</div>
<div class="row">
<h3 class="col-sm-12">Review the hosts for the <span class="bold-text">{{vm.cluster.name}}</span> and click Import to monitor this cluster.</h3>
</div>
Expand Down
92 changes: 52 additions & 40 deletions src/modules/clusters/import-cluster/import-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

var vm = this;

vm.clusterNamePattern = /^[a-zA-Z0-9][A-Za-z0-9_]*$/i;
vm.filtersText = "";
vm.clusterName = "";
vm.enableProfiling = "enable";
vm.taskInitiated = false;
vm.importIcon = false;
Expand Down Expand Up @@ -120,6 +122,55 @@
wizardDoneListener = $rootScope.$on("modal.done", closeWizard);
}

/**
* @name importCluster
* @desc Perform import cluster
* @memberOf importClusterController
*/
function importCluster() {
var clusterName;

if (vm.clusterName) {
clusterName = vm.clusterName.match(vm.clusterNamePattern);
}

if (clusterName !== null) {
clusterStore.importCluster(vm.clusterId, vm.enableProfiling, vm.clusterName)
.then(function(data) {
vm.importIcon = true;
vm.taskInitiated = true;
vm.jobId = data.job_id;
}).catch(function(e){
vm.importIcon = false;
vm.taskInitiated = false;
Notifications.message("danger", "", "Failed to initaite import.");
});
} else {
vm.errorMsg = "Please enter a valid cluster name. Only alphanumeric and underscore characters are allowed."
}

}

/**
* @name importCancel
* @desc Cancels import cluster
* @memberOf importClusterController
*/
function importCancel() {
$state.go("clusters");
}

/**
* @name viewTaskProgress
* @desc redirect user to task detail page
* @memberOf importClusterController
*/
function viewTaskProgress() {

if (vm.clusterId) {
$state.go("global-task-detail", { clusterId: vm.clusterId, taskId: vm.jobId });
}
}

function _setImportDetail() {
vm.clusterObj = clusterStore.getClusterDetails(vm.clusterId);
Expand Down Expand Up @@ -184,45 +235,6 @@
});
_applyFilters(filters);
}

/**
* @name importCluster
* @desc Perform import cluster
* @memberOf importClusterController
*/
function importCluster() {
clusterStore.importCluster(vm.clusterId, vm.enableProfiling)
.then(function(data) {
vm.importIcon = true;
vm.taskInitiated = true;
vm.jobId = data.job_id;
}).catch(function(e){
vm.importIcon = false;
vm.taskInitiated = false;
Notifications.message("danger", "", "Failed to initaite import.");
});
}

/**
* @name importCancel
* @desc Cancels import cluster
* @memberOf importClusterController
*/
function importCancel() {
$state.go("clusters");
}

/**
* @name viewTaskProgress
* @desc redirect user to task detail page
* @memberOf importClusterController
*/
function viewTaskProgress() {
if (vm.clusterId) {
$state.go("global-task-detail", { clusterId: vm.clusterId, taskId: vm.jobId });
}
}

}

})();
})();
14 changes: 13 additions & 1 deletion src/modules/clusters/import-cluster/import-cluster.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
margin: 20px 0;
}

.cluster-name {
font-size: 14px;

label {
font-weight: normal;
}

.name-validation-msg {
font-size: 10px;
font-style: italic;
}
}

.alert a {
cursor: pointer;
}
Expand All @@ -29,7 +42,6 @@
}

.volume-profile {
margin-top: 10px;
font-size: 14px;

input[type=checkbox],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<i class="pficon pficon pficon-warning-triangle-o"></i>
</div>
<div class="col-md-10 desc">
Upon completion of this action, <strong>{{vm.clusterId}}</strong> will no longer be managed and must be imported again to initiate management and perform further monitoring. <br> <br>After clicking Unmanage, a task will be submitted to perform this action. This task cannot be undone, proceed with care.
Upon completion of this action, <strong>{{vm.clusterName}}</strong> will no longer be managed and must be imported again to initiate management and perform further monitoring. <br> <br>After clicking Unmanage, a task will be submitted to perform this action. This task cannot be undone, proceed with care.
</div>
</div>
<custom-modal-footer modal-footer="vm.modalFooter"></custom-modal-footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
vm.closeModal = closeModal;
vm.confirmModal = confirmModal;
vm.clusterId = selectedCluster.clusterId;
vm.clusterName = selectedCluster.name;

vm.modalHeader = {
"title": "Unmanage Cluster",
Expand Down Expand Up @@ -54,7 +55,7 @@
$rootScope.$emit("modal.done", "close");
}

function openProgressModal(clusterId, jobId) {
function openProgressModal(selectedCluster, jobId) {
var wizardDoneListener,
modalInstance,
closeWizard;
Expand All @@ -69,7 +70,7 @@
resolve: {
progressCluster: function() {
return {
clusterId: clusterId,
cluster: selectedCluster,
jobId: jobId
};
}
Expand Down Expand Up @@ -100,7 +101,7 @@
.then(function(data) {
vm.initiateUnmanage = false;
jobId = data.job_id;
openProgressModal(vm.clusterId, jobId);
openProgressModal(selectedCluster, jobId);
selectedCluster.disableUnmanage = true;
}).catch(function(error) {
Notifications.message("danger", "", "Failed to initiate unmanage");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<i class="pficon pficon pficon-ok"></i>
</div>
<div class="col-md-10 desc">
Unmanage Cluster task Submitted An Unmanage Cluster task has been submitted to unmanage <strong>{{vm.clusterId}}</strong>. You will be notified when processing is complete.
Unmanage Cluster task Submitted An Unmanage Cluster task has been submitted to unmanage <strong>{{vm.clusterName}}</strong>. You will be notified when processing is complete.
</div>
</div>
<custom-modal-footer modal-footer="vm.modalFooter"></custom-modal-footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
vm.cancelModal = cancelModal;
vm.closeModal = closeModal;
vm.confirmModal = confirmModal;
vm.clusterId = progressCluster.clusterId;
vm.clusterId = progressCluster.cluster.clusterId;
vm.clusterName = progressCluster.cluster.name;
vm.jobId = progressCluster.jobId;

vm.modalHeader = {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/hosts/host-detail/host-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
_makeTabList();
vm.isDataLoading = false;
vm.clusterObj = clusterStore.getClusterDetails(vm.clusterId);
vm.clusterName = vm.clusterObj.clusterId || "NA";
vm.clusterName = vm.clusterObj.name || "NA";
vm.clusterStatus = vm.clusterObj.status;
if (!nodeStore.nodeList.length) {
nodeStore.getNodeList(vm.clusterId)
Expand All @@ -63,7 +63,7 @@
_makeTabList();
vm.isDataLoading = false;
vm.clusterObj = clusterStore.getClusterDetails(vm.clusterId);
vm.clusterName = vm.clusterObj.clusterId || "NA";
vm.clusterName = vm.clusterObj.name || "NA";
vm.clusterStatus = vm.clusterObj.status;
if (!nodeStore.nodeList.length) {
nodeStore.getNodeList(vm.clusterId)
Expand Down
9 changes: 1 addition & 8 deletions src/modules/hosts/host-list/host-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@
}, 1000 * config.nodeRefreshIntervalTime, 1);
}

function redirectToGrafana(host, $event) {
utils.redirectToGrafana("hosts", $event, {
clusterId: host.integrationId,
hostName: host.name.split(".").join("_")
});
}

/*Cancelling interval when scope is destroy*/
$scope.$on("$destroy", function() {
$interval.cancel(hostListTimer);
Expand Down Expand Up @@ -163,7 +156,7 @@

function redirectToGrafana(host) {
utils.redirectToGrafana("hosts", {
clusterId: host.integrationId,
clusterId: host.clusterName,
hostName: host.name.split(".").join("_")
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/modules/tasks/global-task-detail/global-task-detail.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div ng-if="clusterData === null && !isAPINotFoundError" class="spinner spinner-lg"></div>
<div ng-if="clusterData !== null" class="tendrl-global-task-detail-view-container container-fluid">

<ul class="breadcrumb custom-breadcrumb" ng-if="!glbTaskDetailCntrl.isDataLoading && glbTaskDetailCntrl.taskDetail">
<li><a ui-sref="clusters">All Clusters</a></li>
<li>
Expand All @@ -24,7 +23,7 @@
<div class="form-group required">
<label class="col-sm-3 col-md-1 detail-label">Status:</label>
<label class="col-sm-4 col-md-1 status-value"><i ng-class="{'pficon pficon-ok status-icon': (glbTaskDetailCntrl.taskDetail.status === 'finished')}"></i>{{glbTaskDetailCntrl.taskDetail.status === 'finished' ? "Completed": glbTaskDetailCntrl.taskDetail.status}}</label>
<label class="col-sm-4 col-md-2" ng-show="(glbTaskDetailCntrl.taskDetail.flow === 'ImportCluster') && (glbTaskDetailCntrl.taskDetail.status === 'finished') &&(!$root.selectedClusterOption)"><a href="" ng-click="glbTaskDetailCntrl.goToClusterDetail()">View cluster details</a></label>
<label class="col-sm-4 col-md-2" ng-show="(glbTaskDetailCntrl.taskDetail.flow === 'ImportCluster') && (glbTaskDetailCntrl.taskDetail.status === 'finished') &&(!$root.selectedClusterOption)"><span class="spinner spinner-xs spinner-inline" ng-show="glbTaskDetailCntrl.showLoadingIcon"></span> <a href="" ng-click="glbTaskDetailCntrl.goToClusterDetail()">View cluster details</a></label>
</div>
</form>
<center ng-if="!glbTaskDetailCntrl.taskDetail && !glbTaskDetailCntrl.isDataLoading">
Expand Down

0 comments on commit fc2355a

Please sign in to comment.