Esempio n. 1
0
 private Node createNode() throws IOException {
   Cluster cluster = entityFactory.make(Cluster.class);
   cluster.setName("unittest-" + UUID.randomUUID());
   cluster.setProvider("vagrant");
   node = vagrant.createNode(cluster);
   return node;
 }
Esempio n. 2
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;
 }
Esempio n. 3
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;
 }
Esempio n. 4
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;
 }