mirror of https://github.com/apache/jclouds.git
refactored chef module to make a new servlet context listener
This commit is contained in:
parent
ca247efaed
commit
57ba278cbb
|
@ -0,0 +1,92 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
$HeadURL$ $Revision$ $Date$ Copyright (C) 2010 Cloud Conscious, LLC
|
||||||
|
<info@cloudconscious.com>
|
||||||
|
|
||||||
|
====================================================================
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to you 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.html 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.
|
||||||
|
====================================================================
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-chef-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../project/pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-chef</artifactId>
|
||||||
|
<name>jclouds Chef core</name>
|
||||||
|
<description>jclouds components to access Chef</description>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/chef</connection>
|
||||||
|
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/chef</developerConnection>
|
||||||
|
<url>http://jclouds.googlecode.com/svn/trunk/chef</url>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<!-- bootstrapping: need to fetch the project POM -->
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jclouds-googlecode-deploy</id>
|
||||||
|
<url>http://jclouds.googlecode.com/svn/repo</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jclouds-rimu-snapshots-nexus</id>
|
||||||
|
<url>http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jclouds.chef.identity>chef-validator</jclouds.chef.identity>
|
||||||
|
<jclouds.chef.rsa-key>/etc/chef/validation.pem</jclouds.chef.rsa-key>
|
||||||
|
<jclouds.chef.endpoint>http://localhost:4000</jclouds.chef.endpoint>
|
||||||
|
<jclouds.test.identity>${jclouds.chef.identity}</jclouds.test.identity>
|
||||||
|
<jclouds.test.credential>${jclouds.chef.rsa-key}</jclouds.test.credential>
|
||||||
|
<jclouds.test.endpoint>${jclouds.chef.endpoint}</jclouds.test.endpoint>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>1.2.14</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -55,7 +55,7 @@ public class ChefContextBuilder extends RestContextBuilder<ChefClient, ChefAsync
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ChefContextBuilder withModules(Module... modules) {
|
public ChefContextBuilder withModules(Iterable<Module> modules) {
|
||||||
return (ChefContextBuilder) super.withModules(modules);
|
return (ChefContextBuilder) super.withModules(modules);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,12 @@ import com.google.inject.ImplementedBy;
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(BaseChefService.class)
|
@ImplementedBy(BaseChefService.class)
|
||||||
public interface ChefService {
|
public interface ChefService {
|
||||||
|
/**
|
||||||
|
* @return a reference to the context that created this.
|
||||||
|
*/
|
||||||
|
ChefContext getContext();
|
||||||
|
|
||||||
void cleanupStaleNodesAndClients(String prefix, int minutesStale);
|
void cleanupStaleNodesAndClients(String prefix, int secondsStale);
|
||||||
|
|
||||||
void createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList);
|
void createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.jclouds.chef.internal;
|
package org.jclouds.chef.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -7,6 +9,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.chef.ChefContext;
|
||||||
import org.jclouds.chef.ChefService;
|
import org.jclouds.chef.ChefService;
|
||||||
import org.jclouds.chef.domain.Node;
|
import org.jclouds.chef.domain.Node;
|
||||||
import org.jclouds.chef.reference.ChefConstants;
|
import org.jclouds.chef.reference.ChefConstants;
|
||||||
|
@ -30,6 +33,7 @@ public class BaseChefService implements ChefService {
|
||||||
@Named(ChefConstants.CHEF_LOGGER)
|
@Named(ChefConstants.CHEF_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final ChefContext chefContext;
|
||||||
private final CleanupStaleNodesAndClients cleanupStaleNodesAndClients;
|
private final CleanupStaleNodesAndClients cleanupStaleNodesAndClients;
|
||||||
private final CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes;
|
private final CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes;
|
||||||
private final DeleteAllClientsAndNodesInList deleteAllClientsAndNodesInList;
|
private final DeleteAllClientsAndNodesInList deleteAllClientsAndNodesInList;
|
||||||
|
@ -37,20 +41,24 @@ public class BaseChefService implements ChefService {
|
||||||
private final UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode;
|
private final UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected BaseChefService(CleanupStaleNodesAndClients cleanupStaleNodesAndClients,
|
protected BaseChefService(ChefContext chefContext, CleanupStaleNodesAndClients cleanupStaleNodesAndClients,
|
||||||
CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes,
|
CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes,
|
||||||
DeleteAllClientsAndNodesInList deleteAllClientsAndNodesInList, GetNodes getNodes,
|
DeleteAllClientsAndNodesInList deleteAllClientsAndNodesInList, GetNodes getNodes,
|
||||||
UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode) {
|
UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode) {
|
||||||
this.cleanupStaleNodesAndClients = cleanupStaleNodesAndClients;
|
this.chefContext = checkNotNull(chefContext, "chefContext");
|
||||||
this.createNodeAndPopulateAutomaticAttributes = createNodeAndPopulateAutomaticAttributes;
|
this.cleanupStaleNodesAndClients = checkNotNull(cleanupStaleNodesAndClients, "cleanupStaleNodesAndClients");
|
||||||
this.deleteAllClientsAndNodesInList = deleteAllClientsAndNodesInList;
|
this.createNodeAndPopulateAutomaticAttributes = checkNotNull(createNodeAndPopulateAutomaticAttributes,
|
||||||
this.getNodes = getNodes;
|
"createNodeAndPopulateAutomaticAttributes");
|
||||||
this.updateAutomaticAttributesOnNode = updateAutomaticAttributesOnNode;
|
this.deleteAllClientsAndNodesInList = checkNotNull(deleteAllClientsAndNodesInList,
|
||||||
|
"deleteAllClientsAndNodesInList");
|
||||||
|
this.getNodes = checkNotNull(getNodes, "getNodes");
|
||||||
|
this.updateAutomaticAttributesOnNode = checkNotNull(updateAutomaticAttributesOnNode,
|
||||||
|
"updateAutomaticAttributesOnNode");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanupStaleNodesAndClients(String prefix, int minutesStale) {
|
public void cleanupStaleNodesAndClients(String prefix, int secondsStale) {
|
||||||
cleanupStaleNodesAndClients.execute(prefix, minutesStale);
|
cleanupStaleNodesAndClients.execute(prefix, secondsStale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,4 +91,9 @@ public class BaseChefService implements ChefService {
|
||||||
updateAutomaticAttributesOnNode.execute(nodeName);
|
updateAutomaticAttributesOnNode.execute(nodeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChefContext getContext() {
|
||||||
|
return chefContext;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -67,5 +67,6 @@ public interface ChefConstants {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final String CHEF_LOGGER = "jclouds.chef";
|
public static final String CHEF_LOGGER = "jclouds.chef";
|
||||||
|
public static final String CHEF_SERVICE_CLIENT = "chef.service.client";
|
||||||
|
public static final String CHEF_NODENAME = "chef.nodename";
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue