示例#1
0
 /**
  * Edits a cluster
  *
  * @param name the cluster's name
  */
 @RequestMapping(value = "/clusters/{name}", method = RequestMethod.PUT)
 public Cluster updateCluster(
     @PathVariable("name") final String name,
     @RequestParam(value = "name", required = true) final String newName) {
   Cluster cluster = clusterRepo.findByName(name).orElseThrow(NotFoundException::new);
   cluster.setName(newName);
   clusterRepo.save(cluster);
   return cluster;
 }
示例#2
0
 /**
  * Adds a new cluster
  *
  * @param name the cluster's name
  */
 @RequestMapping(value = "/clusters", method = RequestMethod.POST)
 public Cluster addCluster(
     @RequestParam(value = "name", required = true) final String name,
     @RequestParam(value = "vagrant", required = true) final String provider) {
   Cluster cluster = new Cluster();
   cluster.setName(name);
   cluster.setProvider(provider);
   clusterRepo.save(cluster);
   return cluster;
 }
示例#3
0
 /**
  * Returns all clusters
  *
  * @return all clusters
  */
 @RequestMapping(value = "/clusters", method = RequestMethod.GET)
 public Collection<Cluster> clusters() {
   Collection<Cluster> clusters = clusterRepo.findAll();
   for (Cluster cluster : clusters) {
     ClusterStrategy strategy =
         strategyFactory.getStrategy(ClusterStrategy.class, cluster.getProvider());
     for (Node node : cluster.getNodes()) {
       try {
         node.setStatus(strategy.getNodeStatus(node));
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
   }
   return clusters;
 }
示例#4
0
 /**
  * Returns the clustj with the given name
  *
  * @param name the name of the cluster
  * @return the cluster with the given name
  */
 @RequestMapping(value = "/clusters/{name}", method = RequestMethod.GET)
 public Cluster cluster(@PathVariable(value = "name") String name) {
   return clusterRepo.findByName(name).orElseThrow(NotFoundException::new);
 }
示例#5
0
 /**
  * Deletes a cluster
  *
  * @param name the cluster's name
  */
 @RequestMapping(value = "/clusters/{name}", method = RequestMethod.DELETE)
 public void deleteCluster(@PathVariable("name") final String name) {
   Cluster cluster = clusterRepo.findByName(name).orElseThrow(NotFoundException::new);
   clusterRepo.delete(cluster);
 }