Package org.jclouds.chef

Examples of org.jclouds.chef.ChefService


     * @param services
     * @return
     */
    public static ChefService getChefService(String id, String api, List<ChefService> services) {
        if (!Strings.isNullOrEmpty(id)) {
            ChefService service = null;
            for (ChefService svc : services) {
                if (id.equals(svc.getContext().unwrap().getName())) {
                    service = svc;
                    break;
                }
            }
            if (service == null) {
                throw new IllegalArgumentException("No chef service with id" + id + " found.");
            }
            return service;
        }

        if (!Strings.isNullOrEmpty(api)) {
            ChefService service = null;
            for (ChefService svc : services) {
                if (api.equals(svc.getContext().unwrap().getId())) {
                    service = svc;
                    break;
                }
View Full Code Here


    public static ChefService findOrCreateChefService(String api, String name, String clientName, String clientCredential, String clientKeyFile, String validatorName, String validatorCredential, String validatorKeyFile, String endpoint, List<ChefService> chefServices) {
        if ((name == null && api == null) && (chefServices != null && chefServices.size() == 1)) {
            return chefServices.get(0);
        }

        ChefService chefService = null;
        String apiValue = ChefHelper.getChefApi(api);
        String clientNameValue = ChefHelper.getClientName(clientName);
        String clientCredentialValue = ChefHelper.getClientCredential(clientCredential);
        String clientKeyFileValue = ChefHelper.getClientKeyFile(clientKeyFile);
        String validatorNameValue = ChefHelper.getValidatorName(validatorName);
View Full Code Here

        builder = builder.name(name).modules(ImmutableSet.<Module>of(new SLF4JLoggingModule()));
        builder = builder.name(name).credentials(clientName, clientCredential).overrides(chefConfig);

        // builder.build() does not compile on JDK 6
        ChefContext context = builder.build(ChefContext.class);
        ChefService service = context.getChefService();
        return service;
    }
View Full Code Here

@Command(scope = "chef", name = "cookbook-list", description = "Lists the Chef Cook Books")
public class ChefCookbookListCommand extends ChefCommandWithOptions {

    @Override
    protected Object doExecute() throws Exception {
        ChefService service = null;
        try {
            service = getChefService();
        } catch (Throwable t) {
            System.err.println(t.getMessage());
            return null;
        }
        printCookbooks(service, service.listCookbookVersions(), System.out);
        return null;
    }
View Full Code Here

    public List<ChefService> getChefServices() {
        if (api == null) {
            return chefServices;
        } else {
            try {
                ChefService service = getChefService();
                return Collections.singletonList(service);
            } catch (Throwable t) {
                return Collections.emptyList();
            }
        }
View Full Code Here

    }

    @Override
    public Statement getStatement() {
        Statement statement = null;
        ChefService chefService = getChefService();
        if (chefService != null) {
            List<String> runlist = new RunListBuilder().addRecipes(cookbook).build();
            BootstrapConfig bootstrapConfig = BootstrapConfig.builder().runList(runlist).build();
            chefService.updateBootstrapConfigForGroup("single", bootstrapConfig);
            statement = chefService.createBootstrapScriptForGroup("single");
        }
        return statement;
    }
View Full Code Here

    }

    @Override
    public Statement getStatement() {
        Statement statement = null;
        ChefService chefService = getChefService();
        if (chefService != null) {
            List<String> runlist = new RunListBuilder().addRecipes(cookbook).build();
            BootstrapConfig bootstrapConfig = BootstrapConfig.builder().runList(runlist).build();
            chefService.updateBootstrapConfigForGroup(group, bootstrapConfig);
            statement = chefService.createBootstrapScriptForGroup(group);
        }
        return statement;
    }
View Full Code Here

     * @param bundleContext
     * @param api
     * @return
     */
    public synchronized ChefService waitForChefService(BundleContext bundleContext, String name, String api) {
        ChefService chefService = null;
        try {
            for (int r = 0; r < 6; r++) {
                ServiceReference[] references = null;
                if (name != null) {
                    references = bundleContext.getAllServiceReferences(ChefService.class.getName(), "(" + Constants.NAME + "="
View Full Code Here

                String validatorName = (String) properties.get(ChefConstants.VALIDATOR_NAME);
                String validatorKeyFile = (String) properties.get(ChefConstants.VALIDATOR_KEY_FILE);
                String validatorCredential = (String) properties.get(ChefConstants.VALIDATOR_CREDENTIAL);
                String endpoint = (String) properties.get(ChefConstants.ENDPOINT);

                ChefService service = ChefHelper.createChefService(apiMetadata, id, clientName, clientCredential, clientKeyFile, validatorName, validatorCredential, validatorKeyFile, endpoint);
                newRegistration = bundleContext.registerService(
                        ChefService.class.getName(), service, properties);

                //If all goes well remove the pending pid.
                if (pendingPids.containsKey(pid)) {
View Full Code Here

    }

    @Override
    public Statement getStatement() {
        Statement statement = null;
        ChefService chefService = getChefService();
        if (chefService != null) {
            List<String> runlist = new RunListBuilder().addRecipes(cookbook).build();
            chefService.updateRunListForGroup(runlist, "single");
            statement = chefService.createBootstrapScriptForGroup("single");
        }
        return statement;
    }
View Full Code Here

TOP

Related Classes of org.jclouds.chef.ChefService

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.