mirror of https://github.com/apache/jclouds.git
issue 191
This commit is contained in:
parent
ee2679346f
commit
7d1e4ff514
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.ohai;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.chef.ChefClient;
|
||||||
|
import org.jclouds.chef.domain.Node;
|
||||||
|
import org.jclouds.domain.JsonBall;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Updates node with new automatic attributes.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class CreateNode {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final ChefClient chef;
|
||||||
|
private final Supplier<Map<String, JsonBall>> automaticSupplier;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public CreateNode(ChefClient chef, @Named("automatic") Supplier<Map<String, JsonBall>> automaticSupplier) {
|
||||||
|
this.chef = checkNotNull(chef, "chef");
|
||||||
|
this.automaticSupplier = checkNotNull(automaticSupplier, "automaticSupplier");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node createNode(String nodeName, Iterable<String> runList) {
|
||||||
|
logger.info("creating node %s", nodeName);
|
||||||
|
Node node = new Node(nodeName, runList);
|
||||||
|
node.getAutomatic().putAll(automaticSupplier.get());
|
||||||
|
node = chef.createNode(node);
|
||||||
|
logger.debug("done creating node %s", nodeName);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue