Search in sources :

Example 1 with ChefApiMetadata

use of org.jclouds.chef.ChefApiMetadata in project legacy-jclouds-examples by jclouds.

the class MainApp method initChefService.

private static ChefService initChefService(String client, String validator) {
    try {
        Properties chefConfig = new Properties();
        chefConfig.put(ChefProperties.CHEF_VALIDATOR_NAME, validator);
        chefConfig.put(ChefProperties.CHEF_VALIDATOR_CREDENTIAL, credentialForClient(validator));
        ContextBuilder builder = //
        ContextBuilder.newBuilder(new ChefApiMetadata()).credentials(client, //
        credentialForClient(client)).modules(//
        ImmutableSet.<Module>of(new SLF4JLoggingModule())).overrides(//
        chefConfig);
        System.out.printf(">> initializing %s%n", builder.getApiMetadata());
        ChefContext context = builder.build();
        return context.getChefService();
    } catch (Exception e) {
        System.err.println("error reading private key " + e.getMessage());
        System.exit(1);
        return null;
    }
}
Also used : ChefContext(org.jclouds.chef.ChefContext) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) ContextBuilder(org.jclouds.ContextBuilder) Properties(java.util.Properties) ChefProperties(org.jclouds.chef.config.ChefProperties) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) Module(com.google.inject.Module) SshjSshClientModule(org.jclouds.sshj.config.SshjSshClientModule) EnterpriseConfigurationModule(org.jclouds.enterprise.config.EnterpriseConfigurationModule) RunNodesException(org.jclouds.compute.RunNodesException) RunScriptOnNodesException(org.jclouds.compute.RunScriptOnNodesException) ChefApiMetadata(org.jclouds.chef.ChefApiMetadata)

Aggregations

Module (com.google.inject.Module)1 Properties (java.util.Properties)1 ContextBuilder (org.jclouds.ContextBuilder)1 ChefApiMetadata (org.jclouds.chef.ChefApiMetadata)1 ChefContext (org.jclouds.chef.ChefContext)1 ChefProperties (org.jclouds.chef.config.ChefProperties)1 RunNodesException (org.jclouds.compute.RunNodesException)1 RunScriptOnNodesException (org.jclouds.compute.RunScriptOnNodesException)1 EnterpriseConfigurationModule (org.jclouds.enterprise.config.EnterpriseConfigurationModule)1 SLF4JLoggingModule (org.jclouds.logging.slf4j.config.SLF4JLoggingModule)1 SshjSshClientModule (org.jclouds.sshj.config.SshjSshClientModule)1