Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/commons/factories/cluster-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* @desc Perform import cluster
* @memberOf clusterFactory
*/
vm.importCluster = function(data, clusterId) {
vm.importCluster = function(data) {
var url,
importRequest,
request;

url = config.baseUrl + "clusters/" + clusterId + "/import";
url = config.baseUrl + "/import";

importRequest = {
method: "POST",
Expand Down
2 changes: 1 addition & 1 deletion src/commons/factories/host-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
var url = "",
getObjectListRequest, request;

url = config.baseUrl +"clusters/" + clusterId +"/nodes";
url = config.baseUrl +"clusters/" + clusterId +"/peers";
//url = "/api/GetNodeList.json";

getObjectListRequest = {
Expand Down
46 changes: 46 additions & 0 deletions src/commons/factories/volume-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,52 @@

};

vm.startVolume = function(volume, clusterId) {
var url,
startRequest,
request;

url = config.baseUrl + "clusters/" + clusterId + "/volumes/" + volume.name + "/start";

startRequest = {
method: "POST",
url: url
};

request = angular.copy(startRequest);
return $http(request).then(function(response) {
return response.data;
}, function(e) {
utils.checkErrorCode(e);
console.log("Error Occurred: while starting volume");
throw e;
});

};

vm.stopVolume = function(volume, clusterId) {
var url,
stopRequest,
request;

url = config.baseUrl + "clusters/" + clusterId + "/volumes/" + volume.name + "/stop";

stopRequest = {
method: "POST",
url: url
};

request = angular.copy(stopRequest);
return $http(request).then(function(response) {
return response.data;
}, function(e) {
utils.checkErrorCode(e);
console.log("Error Occurred: while stopping volume");
throw e;
});

};

}

})();
6 changes: 3 additions & 3 deletions src/commons/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
template: "<cluster-list></cluster-list>"
})
.state("import-cluster", {
url: "/import-cluster/:clusterId",
template: "<import-cluster cluster='clusterTobeImported'></import-cluster>"
url: "/import-cluster",
template: "<import-cluster></import-cluster>"
})
.state("cluster-hosts", {
url: "/cluster-hosts/:clusterId",
Expand Down Expand Up @@ -216,4 +216,4 @@
});
}

}());
}());
6 changes: 3 additions & 3 deletions src/commons/services/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
request;

//url = "/api/events.json";
url = config.baseUrl + "clusters/" + clusterId + "/notifications";
url = config.baseUrl + "clusters/" + clusterId + "/events";

getEventListRequest = {
method: "GET",
Expand All @@ -245,7 +245,7 @@

request = angular.copy(getEventListRequest);
return $http(request).then(function(response) {
return response.data;
return response.data.events;
}, function(e) {
vm.checkErrorCode(e);
console.log("Error Occurred: while fetching getEventList");
Expand Down Expand Up @@ -310,4 +310,4 @@

};
};
})();
})();
25 changes: 16 additions & 9 deletions src/commons/stores/brick-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,27 @@

store.getVolumeBrickList = function(clusterId, volId) {
var subVolumes = [],
volume,
deferred,
len,
i;

deferred = $q.defer();
brickFactory.getVolumeBrickList(clusterId, volId)
volume = volumeStore.getVolumeObject(volId);
brickFactory.getVolumeBrickList(clusterId, volume.name)
.then(function(data) {
_createSubVolumes(data);
len = subVolumes.length;
//_createSubVolumes(data);
len = volume.subvols.length;
for (i = 0; i < len; i++) {
subVolumes[i].utilization = _calcUtilization(subVolumes[i].bricks);
for(var j=0;j<volume.subvols[i].bricks.length;j++) {
var brickId = volume.subvols[i].bricks[j].id;
Object.assign(volume.subvols[i].bricks[j], data.find((e) => { return e.info.id == brickId }));
}
volume.subvols[i].utilization = _calcUtilization(volume.subvols[i].bricks);
}
deferred.resolve(volume.subvols);

deferred.resolve(subVolumes);
//deferred.resolve(subVolumes);
}).catch(function(e) {
deferred.reject(e);
});
Expand Down Expand Up @@ -104,10 +111,10 @@
total;

for (i = 0; i < len; i++) {
used = parseFloat(bricks[i].utilization.used);
total = parseFloat(bricks[i].utilization.total);
utilization.used += (used * total) / 100;
utilization.total += parseFloat(bricks[i].utilization.total);
used = parseFloat(bricks[i].size.used);
total = parseFloat(bricks[i].size.capacity);
utilization.used += used;
utilization.total += total;
}
percent_used = (utilization.used / utilization.total) * 100;
utilization.used = percent_used.toFixed(2);
Expand Down
47 changes: 25 additions & 22 deletions src/commons/stores/cluster-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.service("clusterStore", clusterStore);

/*@ngInject*/
function clusterStore($state, $filter, $q, $rootScope, nodeStore, clusterFactory) {
function clusterStore($state, $filter, $q, $rootScope, peerStore, volumeFactory, clusterFactory) {
var store = this;

store.selectedTab = 1;
Expand Down Expand Up @@ -83,7 +83,7 @@
temp.status = nodes[i].status;
temp.managed = nodes[i].is_managed === "yes" ? "Yes" : "No";
temp.ipAddress = nodes[i].ipv4_addr;
tags = nodeStore.findRole(nodes[i].tags);
tags = peerStore.findRole(nodes[i].tags);
temp.role = tags ? tags.role : "None";
temp.release = tags.release !== "NA" ? (tags.release + " " + data.sds_version) : "NA";

Expand All @@ -98,18 +98,19 @@
* @desc store for import cluster
* @memberOf clusterStore
*/
store.importCluster = function(clusterId, enableProfiling, clusterName) {
store.importCluster = function(gd2Url, secret, clusterName) {
var requestData = {
"Cluster.volume_profiling_flag": enableProfiling === "leaveAsIs" ? "leave-as-is" : enableProfiling
"gd2_url": gd2Url,
"secret": secret
},
deferred;

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

deferred = $q.defer();
clusterFactory.importCluster(requestData, clusterId)
clusterFactory.importCluster(requestData)
.then(function(data) {
deferred.resolve(data);
}).catch(function(e) {
Expand Down Expand Up @@ -217,35 +218,37 @@
"rhgs": "RHGS"
};

temp.integrationId = cluster.integration_id;
temp.sdsVersion = cluster.sds_version;
temp.sdsName = cluster.sds_name;
temp.showSdsName = sdsMapping[cluster.sds_name.toLowerCase()];
temp.name = (cluster.short_name && cluster.short_name !== "None") ? cluster.short_name : cluster.integration_id;
temp.clusterId = cluster.cluster_id;
temp.integrationId = cluster['cluster-id'];
temp.sdsVersion = cluster.version;
temp.sdsName = 'gluster'; // TODO cluster.sds_name;
temp.showSdsName = sdsMapping[temp.sdsName.toLowerCase()];
temp.name = (cluster.short_name && cluster.short_name !== "None") ? cluster.short_name : cluster['cluster-id'];
temp.clusterId = cluster['cluster-id'];
temp.currentTask = cluster.current_job || {};
temp.jobType = temp.currentTask.job_name;
temp.currentStatus = temp.currentTask.status;
temp.managed = cluster.is_managed === "yes" ? "Yes" : "No";
temp.managed = "Yes"; // cluster.is_managed === "yes" ? "Yes" : "No";
temp.currentTaskId = temp.currentTask.job_id;
temp.volCount = cluster.globaldetails && cluster.globaldetails.vol_count ? parseInt(cluster.globaldetails.vol_count) : 0;
//temp.volCount = cluster.globaldetails && cluster.globaldetails.vol_count ? parseInt(cluster.globaldetails.vol_count) : 0;
temp.volCount = cluster.volumes.length;
temp.alertCount = cluster.alert_counters ? parseInt(cluster.alert_counters.alert_count) : 0;
temp.hostCount = cluster.nodes.length || 0;
temp.state = cluster.status;
temp.isProfilingEnabled = _getProfileStatus(temp, cluster);
temp.hostCount = cluster.peers.length;
temp.state = 'healthy';//cluster.status;
temp.isProfilingEnabled = 'TODO'// TODO - derive this from volumes store, aggregate profiling statuses of volumes as yes, no, mixed - _getProfileStatus(temp, cluster);
temp.readyState = false;

temp.hosts = store.getAssociatedHosts(cluster);
temp.isAnyHostUnmanaged = nodeStore.isAnyHostUnmanaged(temp.hosts);
temp.hosts = []; // TODO store.getAssociatedHosts(cluster);
temp.isAnyHostUnmanaged = []; //nodeStore.isAnyHostUnmanaged(temp.hosts);

temp.errors = cluster.errors ? cluster.errors : [];

/*This block has be placed here, as it initializes statusIcon (used at line 283)*/
// TODO - also hit peers, volumes, devices stores, find if any
if (temp.managed === "Yes") {
if (cluster.globaldetails && cluster.globaldetails.status === "healthy") {
if (temp.state === "healthy") {
temp.status = "HEALTH_OK";
temp.statusIcon = "Healthy";
} else if (cluster.globaldetails && cluster.globaldetails.status === "unhealthy") {
} else if (temp.state === "unhealthy") {
temp.status = "HEALTH_ERR";
temp.statusIcon = "Unhealthy";
} else {
Expand Down Expand Up @@ -287,7 +290,7 @@
} else if (temp.managed === "Yes") {

if (temp.isAnyHostUnmanaged) {
temp.message = "Expansion required";
//temp.message = "Expansion required";
}

if (temp.jobType === "ExpandClusterWithDetectedPeers" && temp.currentStatus === "in_progress") {
Expand Down
4 changes: 2 additions & 2 deletions src/commons/stores/events-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
temp = {},
temp.timeStamp = new Date(data[i].timestamp);
temp.priority = data[i].priority;
temp.message = data[i].message;
temp.name = data[i].name;
temp.message_id = data[i].message_id;
res.push(temp);
}
Expand All @@ -89,4 +89,4 @@
};
}

})();
})();
Loading