X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=blueprints%2Fcommon%2Feliot-ui%2Fbe%2Fsrc%2Feliotk8sclient%2Fsrc%2Fmain%2Fjava%2Fcom%2Feliot%2Feliotbe%2Feliotk8sclient%2Fcontroller%2FNodeController.java;fp=blueprints%2Fcommon%2Feliot-ui%2Fbe%2Fsrc%2Feliotk8sclient%2Fsrc%2Fmain%2Fjava%2Fcom%2Feliot%2Feliotbe%2Feliotk8sclient%2Fcontroller%2FNodeController.java;h=0000000000000000000000000000000000000000;hb=434326c60fb0434bda587102b4746173fe425dea;hp=850cc727f104ec2075e6e07f14e506d795decd1d;hpb=37827e492060182b32df67c2a538a29808fa5e17;p=eliot.git diff --git a/blueprints/common/eliot-ui/be/src/eliotk8sclient/src/main/java/com/eliot/eliotbe/eliotk8sclient/controller/NodeController.java b/blueprints/common/eliot-ui/be/src/eliotk8sclient/src/main/java/com/eliot/eliotbe/eliotk8sclient/controller/NodeController.java deleted file mode 100644 index 850cc72..0000000 --- a/blueprints/common/eliot-ui/be/src/eliotk8sclient/src/main/java/com/eliot/eliotbe/eliotk8sclient/controller/NodeController.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.eliot.eliotbe.eliotk8sclient.controller; - -import com.eliot.eliotbe.eliotk8sclient.model.*; -import io.kubernetes.client.ApiException; -import io.kubernetes.client.apis.CoreV1Api; -import io.kubernetes.client.models.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - - -import java.util.ArrayList; -import java.util.List; - -@CrossOrigin -@RestController -public class NodeController { - - //API To fetch the Node Details in the ELIOT Cluster. - @GetMapping(path = "/getnodes") - public ResponseEntity getNodeList() throws ApiException { - CoreV1Api api = new CoreV1Api(); - V1NodeList eliotNodes = api.listNode(false,null,null,null,null,50,null,360,false); - Node nodeDetails; - - EliotNodes nodeDetailList = new EliotNodes(); - List nodeListElement = new ArrayList<>(); - - for(V1Node item: eliotNodes.getItems()) - { - nodeDetails = new Node(); - nodeDetails.setNodeName(item.getMetadata().getName()); - nodeDetails.setNodeStatus(item.getStatus().getConditions().get(3).getStatus()); - if (item.getMetadata().getLabels().containsKey("node-role.kubernetes.io/master")) - nodeDetails.setNodeRole("Master"); - else - nodeDetails.setNodeRole("Worker"); - nodeDetails.setAge(item.getMetadata().getCreationTimestamp().toString()); - nodeDetails.setVersion(item.getStatus().getNodeInfo().getKubeletVersion()); - nodeDetails.setInternalIp(item.getStatus().getAddresses().get(0).getAddress()); - nodeDetails.setExternalIp("null"); - nodeDetails.setKernel(item.getStatus().getNodeInfo().getKernelVersion()); - nodeDetails.setOsImage(item.getStatus().getNodeInfo().getOsImage()); - nodeDetails.setContainerRuntime(item.getStatus().getNodeInfo().getContainerRuntimeVersion()); - - nodeListElement.add(nodeDetails); - - } - - nodeDetailList.setEliotNodes(nodeListElement); - return new ResponseEntity<>(nodeDetailList, HttpStatus.OK); - } - - @GetMapping(path = "/getpods") - public ResponseEntity getAllPodList() throws ApiException { - Pod podDetail; - - // the CoreV1Api loads default api-client from global configuration. - CoreV1Api api = new CoreV1Api(); - - // invokes the CoreV1Api client - - V1PodList eliotPods = api.listPodForAllNamespaces(null,null, - null,null,null,null,null,null,null); - - EliotPods podDetailList = new EliotPods(); - List podlistElement = new ArrayList<>(); - - - for (V1Pod item : eliotPods.getItems()) { - podDetail = new Pod(); - podDetail.setNamespace(item.getMetadata().getNamespace()); - podDetail.setName(item.getMetadata().getName()); - podDetail.setStatus(item.getStatus().getPhase()); - podDetail.setIp(item.getStatus().getPodIP()); - podDetail.setNode(item.getSpec().getNodeName()); - podDetail.setReadiness("null"); - podlistElement.add(podDetail); - } - - podDetailList.setEliotPods(podlistElement); - return new ResponseEntity<>(podDetailList, HttpStatus.OK); - } - - - @GetMapping(path = "/getservices") - public ResponseEntity getServiceList() throws ApiException{ - - CoreV1Api api = new CoreV1Api(); - Service serviceDetail; - //JSON Object for ELIOT Services being send in Response. - EliotServices svcDetailList = new EliotServices(); - - //List of Services running on ELIOT K8S Cluster - List listOfServiceElement = new ArrayList<>(); - V1ServiceList eliotServices = api.listServiceForAllNamespaces(null, null, false, null, - 50, null, null, 360, false); - - for (V1Service item : eliotServices.getItems()) { - serviceDetail = new Service(); - serviceDetail.setServiceName(item.getMetadata().getName()); - serviceDetail.setServiceType(item.getSpec().getType()); - serviceDetail.setClusterIp(item.getSpec().getClusterIP()); - //TODO: Need to fetch external IP and set in the parameter. - serviceDetail.setExternalIp("none"); - //TODO : Need to fetch Protocol and set in the Parameter. - serviceDetail.setPorts(item.getSpec().getPorts().get(0).getPort().toString()); - serviceDetail.setAge(item.getMetadata().getCreationTimestamp().toString()); - serviceDetail.setSelector(""); - - listOfServiceElement.add(serviceDetail); - - } - svcDetailList.setEliotServices(listOfServiceElement); - - - return new ResponseEntity<>(svcDetailList,HttpStatus.OK); - - } -}