Examples of ChefApi


Examples of org.jclouds.chef.ChefApi

      if (computeContext != null) {
         computeContext.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
      }
      if (context != null) {
         view.getChefService().cleanupStaleNodesAndClients(group + "-", 1);
         ChefApi api = view.unwrapApi(ChefApi.class);
         if (clientName != null && api.getClient(clientName) != null) {
            api.deleteClient(clientName);
         }
         context.close();
      }
      super.tearDownContext();
   }
View Full Code Here

Examples of org.jclouds.chef.ChefApi

      if (computeContext != null) {
         computeContext.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
      }
      if (context != null) {
         view.getChefService().cleanupStaleNodesAndClients(group + "-", 1);
         ChefApi api = view.getApi(ChefApi.class);
         if (clientName != null && api.clientExists(clientName)) {
            api.deleteClient(clientName);
         }
         context.close();
      }
      super.tearDownContext();
   }
View Full Code Here

Examples of org.jclouds.chef.ChefApi

@Test(groups = { "unit" })
public class UpdateAutomaticAttributesOnNodeImplTest {

   @Test
   public void test() {
      ChefApi chef = createMock(ChefApi.class);

      Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();

      Node node = new Node("name", ImmutableSet.<String> of(), "_default");

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

      Node nodeWithAutomatic = new Node("name", ImmutableMap.<String, JsonBall> of(),
            ImmutableMap.<String, JsonBall> of(), ImmutableMap.<String, JsonBall> of(), automatic,
            ImmutableSet.<String> of(), "_default");

      expect(chef.getNode("name")).andReturn(node);
      node.getAutomatic().putAll(automaticSupplier.get());
      expect(chef.updateNode(nodeWithAutomatic)).andReturn(null);

      replay(chef);

      UpdateAutomaticAttributesOnNodeImpl updater = new UpdateAutomaticAttributesOnNodeImpl(chef, automaticSupplier);
View Full Code Here

Examples of org.jclouds.chef.ChefApi

@Test(groups = "unit", testName = "CreateNodeAndPopulateAutomaticAttributesImplTest")
public class CreateNodeAndPopulateAutomaticAttributesImplTest {

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

      Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();

      Node node = new Node("name", ImmutableSet.<String> of(), "_default");

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

      Node nodeWithAutomatic = new Node("name", ImmutableMap.<String, JsonBall> of(),
            ImmutableMap.<String, JsonBall> of(), ImmutableMap.<String, JsonBall> of(), automatic,
            ImmutableSet.<String> of(), "_default");

      node.getAutomatic().putAll(automaticSupplier.get());
      chef.createNode(nodeWithAutomatic);

      replay(chef);

      CreateNodeAndPopulateAutomaticAttributesImpl updater = new CreateNodeAndPopulateAutomaticAttributesImpl(chef,
            automaticSupplier);
View Full Code Here

Examples of org.jclouds.chef.ChefApi

   private Json json = injector.getInstance(Json.class);

   @Test(expectedExceptions = IllegalStateException.class)
   public void testWhenNoDatabagItem() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Client client = createMock(Client.class);

      RunListForGroup fn = new RunListForGroup(new BootstrapConfigForGroup("jclouds", chefApi), json);

      expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(null);

      replay(client);
      replay(chefApi);

      fn.apply("foo");
View Full Code Here

Examples of org.jclouds.chef.ChefApi

      verify(chefApi);
   }

   @Test
   public void testReadRunList() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Api api = createMock(Api.class);

      RunListForGroup fn = new RunListForGroup(new BootstrapConfigForGroup("jclouds", chefApi), json);
      DatabagItem config = new DatabagItem("foo",
            "{\"tomcat6\":{\"ssl_port\":8433},\"run_list\":[\"recipe[apache2]\",\"role[webserver]\"]}");

      expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(config);

      replay(api);
      replay(chefApi);

      assertEquals(fn.apply("foo"), ImmutableList.of("recipe[apache2]", "role[webserver]"));
View Full Code Here

Examples of org.jclouds.chef.ChefApi

            .modules(ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule())) //
            .buildView(ChefContext.class);
   }

   public void testCanAccessChefApi() {
      ChefApi api = context.getApi(ChefApi.class);
      assertNotNull(api);
   }
View Full Code Here

Examples of org.jclouds.chef.ChefApi

         throw e;
      }
   }

   private String findNextNodeName(ChefService client, String pattern) {
      ChefApi api = client.getContext().getApi(ChefApi.class);
      Set<String> nodes = api.listNodes();
      String nodeName;
      Set<String> names = newHashSet(nodes);
      int index = 0;
      while (true) {
         nodeName = String.format(pattern, index++);
View Full Code Here

Examples of org.jclouds.chef.ChefApi

@Test(groups = "unit", testName = "ClientForGroupTest")
public class ClientForGroupTest {

   public void testWhenNoClientsInList() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Client client = createMock(Client.class);
      PrivateKey privateKey = createMock(PrivateKey.class);

      ClientForGroup fn = new ClientForGroup(chefApi);

      expect(chefApi.listClients()).andReturn(ImmutableSet.<String> of());
      expect(chefApi.createClient("foo-client-00")).andReturn(client);
      expect(client.getPrivateKey()).andReturn(privateKey);

      replay(client);
      replay(chefApi);
View Full Code Here

Examples of org.jclouds.chef.ChefApi

      verify(client);
      verify(chefApi);
   }

   public void testWhenClientsInListAddsToEnd() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Client client = createMock(Client.class);
      PrivateKey privateKey = createMock(PrivateKey.class);

      ClientForGroup fn = new ClientForGroup(chefApi);

      expect(chefApi.listClients()).andReturn(
            ImmutableSet.<String> of("foo-client-00", "foo-client-01", "foo-client-02"));
      expect(chefApi.createClient("foo-client-03")).andReturn(client);
      expect(client.getPrivateKey()).andReturn(privateKey);

      replay(client);
      replay(chefApi);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.