Package org.jclouds.chef.domain

Examples of org.jclouds.chef.domain.Node$Builder


      handler = injector.getInstance(Key.get(new TypeLiteral<ParseJson<Node>>() {
      }));
   }

   public void test() {
      Node node = Node.builder() //
            .name("adrian-jcloudstest") //
            .normalAttribute("tomcat6", new JsonBall("{\"ssl_port\":8433}")) //
            .runListElement("recipe[java]") //
            .environment("prod") //
            .build();
View Full Code Here


      ChefApi chef = createMock(ChefApi.class);

      Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();
      Supplier<Map<String, JsonBall>> automaticSupplier = Suppliers.<Map<String, JsonBall>> ofInstance(automatic);

      Node node = Node.builder().name("name").environment("_default").build();
      Node nodeWithAutomatic = Node.builder().name("name").environment("_default").automaticAttributes(automatic)
            .build();

      expect(chef.getNode("name")).andReturn(node);
      expect(chef.updateNode(nodeWithAutomatic)).andReturn(null);
View Full Code Here

   public void testExecute() {
      Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
      try {
         api.createNode(Node.builder().name(prefix).runList(runList).environment("_default").build());
         strategy.execute(prefix);
         Node node = api.getNode(prefix);
         assertEquals(node.getName(), prefix);
         assertEquals(node.getRunList(), runList);
         assertEquals(node.getAutomaticAttributes().get("current_user").toString(), currentUserProvider.get().toString());
      } finally {
         api.deleteNode(prefix);
      }
   }
View Full Code Here

   public void testWithNoRunlist() {
      ChefApi chef = createMock(ChefApi.class);

      Supplier<Map<String, JsonBall>> automaticSupplier = Suppliers.<Map<String, JsonBall>> ofInstance(ImmutableMap.<String, JsonBall> of());

      Node nodeWithAutomatic = Node.builder().name("name").environment("_default")
            .automaticAttributes(automaticSupplier.get()).build();

      chef.createNode(nodeWithAutomatic);

      replay(chef);
View Full Code Here

   @Test
   public void testExecute() {
      Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
      try {
         strategy.execute(prefix, runList);
         Node node = api.getNode(prefix);
         assertEquals(node.getName(), prefix);
         assertEquals(node.getRunList(), runList);
         assertEquals(node.getAutomaticAttributes().get("current_user").toString(), currentUserProvider.get().toString());
      } finally {
         api.deleteNode(prefix);
      }
   }
View Full Code Here

   @Test(dependsOnMethods = "testCreateRole")
   public void testCreateNode() throws Exception {
      api.deleteNode(PREFIX);
      api.createNode(Node.builder().name(PREFIX).runListElement("role[" + PREFIX + "]").environment("_default").build());
      Node node = api.getNode(PREFIX);
      // TODO check recipes
      assertNotNull(node, "Created node should not be null");
      Set<String> nodes = api.listNodes();
      assertTrue(nodes.contains(PREFIX), String.format("node %s not in %s", PREFIX, nodes));
   }
View Full Code Here

   }

   @Test(dependsOnMethods = "testCreateNode")
   public void testUpdateNode() throws Exception {
      for (String nodename : api.listNodes()) {
         Node node = api.getNode(nodename);
         api.updateNode(node);
      }
   }
View Full Code Here

   @Test(dependsOnMethods = "testCreateEnvironment")
   public void testListNodesInEnvironment() {
      api.deleteNode(ENV_NODE);
      api.createNode(Node.builder().name(ENV_NODE).runListElement("role[" + PREFIX + "]").environment(PREFIX).build());
      Node node = api.getNode(ENV_NODE);
      assertNotNull(node, "Created node should not be null");
      Set<String> nodeList = api.listNodesInEnvironment(PREFIX);
      assertTrue(!nodeList.isEmpty());
   }
View Full Code Here

   }

   @Override
   public Node execute(Node node) {
      logger.trace("creating node %s", node.getName());
      Node withAutomatic = Node.builder() //
            .name(node.getName()) //
            .normalAttributes(node.getNormalAttributes()) //
            .overrideAttributes(node.getOverrideAttributes()) //
            .defaultAttributes(node.getDefaultAttributes()) //
            .automaticAttributes(node.getAutomaticAttributes()) //
            .automaticAttributes(automaticSupplier.get()) //
            .runList(node.getRunList()) //
            .environment(node.getEnvironment()) //
            .build();
     
     
      chef.createNode(withAutomatic);
      logger.debug("created node %s", withAutomatic.getName());
      return node;
   }
View Full Code Here

   }

   @Override
   public void execute(String nodeName) {
      logger.trace("updating node %s", nodeName);
      Node node = chef.getNode(nodeName);
      Node updated = Node.builder() //
            .name(node.getName()) //
            .normalAttributes(node.getNormalAttributes()) //
            .overrideAttributes(node.getOverrideAttributes()) //
            .defaultAttributes(node.getDefaultAttributes()) //
            .automaticAttributes(automaticSupplier.get()) //
View Full Code Here

TOP

Related Classes of org.jclouds.chef.domain.Node$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.