diff options
author | John Mazzitelli <mazz@redhat.com> | 2009-10-02 11:30:51 -0400 |
---|---|---|
committer | John Mazzitelli <mazz@redhat.com> | 2009-10-02 11:30:51 -0400 |
commit | 160e56ab98b1c630bead95d0800ab4b9cc59e311 (patch) | |
tree | 1a8a0e5ce9b0952274e1953e903821e4d288edf2 | |
parent | 389a8916a5501152f08c6ff6d1846fbda47b923e (diff) | |
download | puppet-plugin-160e56ab98b1c630bead95d0800ab4b9cc59e311.tar.gz puppet-plugin-160e56ab98b1c630bead95d0800ab4b9cc59e311.tar.xz puppet-plugin-160e56ab98b1c630bead95d0800ab4b9cc59e311.zip |
initial skeleton as generated by pluginGen
-rw-r--r-- | pom.xml | 180 | ||||
-rw-r--r-- | src/main/java/org/rhq/plugins/puppet/puppet/PuppetComponent.java | 115 | ||||
-rw-r--r-- | src/main/java/org/rhq/plugins/puppet/puppet/PuppetDiscovery.java | 50 | ||||
-rw-r--r-- | src/main/resources/META-INF/rhq-plugin.xml | 32 |
4 files changed, 376 insertions, 1 deletions
@@ -1 +1,179 @@ -TODO: put pom xml here +<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.rhq</groupId> + <artifactId>rhq-plugins-parent</artifactId> + <version>1.4.0-SNAPSHOT</version><!-- TODO adjust RHQ version --> + </parent> + + <groupId>org.rhq</groupId> + <artifactId>puppet-plugin</artifactId> + <packaging>jar</packaging> + + <name>RHQ puppet Plugin</name> + <description>Content push via puppet</description> + + <properties> + <scm.module.path>TODO</scm.module.path> + <rhq.version>1.4.0-SNAPSHOT</rhq.version> <!-- TODO adjust, see above too --> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + + + </plugins> + </build> + + <profiles> + <profile> + <id>dev</id> + + <properties> + <rhq.rootDir>../../..</rhq.rootDir> + <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> + <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir> + </properties> + + <build> + <plugins> + + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + + <execution> + <id>deploy</id> + <phase>compile</phase> + <configuration> + <tasks> + <mkdir dir="${rhq.deploymentDir}"/> + <property name="deployment.file" + location="${rhq.deploymentDir}/${project.build.finalName}.jar"/> + <echo>*** Updating ${deployment.file}...</echo> + <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + <execution> + <id>deploy-jar-meta-inf</id> + <phase>package</phase> + <configuration> + <tasks> + <property name="deployment.file" + location="${rhq.deploymentDir}/${project.build.finalName}.jar"/> + <echo>*** Updating META-INF dir in ${deployment.file}...</echo> + <unjar src="${project.build.directory}/${project.build.finalName}.jar" + dest="${project.build.outputDirectory}"> + <patternset> + <include name="META-INF/**"/> + </patternset> + </unjar> + <jar destfile="${deployment.file}" + manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" + update="true"> + </jar> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + <execution> + <id>undeploy</id> + <phase>clean</phase> + <configuration> + <tasks> + <property name="deployment.file" + location="${rhq.deploymentDir}/${project.build.finalName}.jar"/> + <echo>*** Deleting ${deployment.file}...</echo> + <delete file="${deployment.file}"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + </executions> + </plugin> + + </plugins> + </build> + + </profile> + </profiles> + + + <repositories> + <repository> + <snapshots> + <enabled>false</enabled> + </snapshots> + <id>jboss</id> + <name>JBoss Repository</name> + <url>http://repository.jboss.org/maven2/</url> + </repository> + <!-- TODO add your own maven repositories here (if needed) --> + </repositories> + + <pluginRepositories> + <pluginRepository> + <snapshots> + <enabled>false</enabled> + </snapshots> + <id>jboss</id> + <name>JBoss Plugin Repository</name> + <url>http://repository.jboss.org/maven2/</url> + </pluginRepository> + </pluginRepositories> + + + <dependencies> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.rhq</groupId> + <artifactId>rhq-core-domain</artifactId> + <version>${rhq.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.rhq</groupId> + <artifactId>rhq-core-plugin-api</artifactId> + <version>${rhq.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.rhq</groupId> + <artifactId>rhq-core-native-system</artifactId> + <version>${rhq.version}</version> + <scope>provided</scope> + </dependency> + + <!-- TODO add your dependencies here --> + + </dependencies> +</project>
\ No newline at end of file diff --git a/src/main/java/org/rhq/plugins/puppet/puppet/PuppetComponent.java b/src/main/java/org/rhq/plugins/puppet/puppet/PuppetComponent.java new file mode 100644 index 0000000..05993e2 --- /dev/null +++ b/src/main/java/org/rhq/plugins/puppet/puppet/PuppetComponent.java @@ -0,0 +1,115 @@ + +package org.rhq.plugins.puppet.puppet; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; +import org.rhq.core.pluginapi.inventory.CreateResourceReport; +import org.rhq.core.pluginapi.inventory.DeleteResourceFacet; +import org.rhq.core.pluginapi.inventory.ResourceComponent; +import org.rhq.core.pluginapi.inventory.ResourceContext; +import org.rhq.core.pluginapi.operation.OperationContext; +import org.rhq.core.pluginapi.operation.OperationFacet; +import org.rhq.core.pluginapi.operation.OperationResult; + + +public class PuppetComponent implements ResourceComponent +, OperationFacet +, CreateChildResourceFacet +, DeleteResourceFacet +{ + private final Log log = LogFactory.getLog(this.getClass()); + + private static final int CHANGEME = 1; // TODO remove or change this + + + + + /** + * Return availability of this resource + * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability() + */ + public AvailabilityType getAvailability() { + // TODO supply real implementation + return AvailabilityType.UP; + } + + + /** + * Start the resource connection + * @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext) + */ + public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception { + + Configuration conf = context.getPluginConfiguration(); + // TODO add code to start the resource / connection to it + + + } + + + /** + * Tear down the rescource connection + * @see org.rhq.core.pluginapi.inventory.ResourceComponent#stop() + */ + public void stop() { + + + } + + + + + + public void startOperationFacet(OperationContext context) { + + } + + + /** + * Invokes the passed operation on the managed resource + * @param name Name of the operation + * @param params The method parameters + * @return An operation result + * @see org.rhq.core.pluginapi.operation.OperationFacet + */ + public OperationResult invokeOperation(String name, Configuration params) throws Exception { + + OperationResult res = new OperationResult(); + if ("dummyOperation".equals(name)) { + // TODO implement me + + } + return res; + } + + + + /** + * Create a child resource + * @see org.rhq.core.pluginapi.inventory.CreateChildResourceFacet + */ + public CreateResourceReport createResource(CreateResourceReport report) + { + // TODO supply code to create a child resource + + return null; // TODO change this + } + + /** + * Delete a child resource + * @see org.rhq.core.pluginapi.inventory.DeleteResourceFacet + */ + public void deleteResource() throws Exception + { + // TODO supply code to delete a child resource + } + +}
\ No newline at end of file diff --git a/src/main/java/org/rhq/plugins/puppet/puppet/PuppetDiscovery.java b/src/main/java/org/rhq/plugins/puppet/puppet/PuppetDiscovery.java new file mode 100644 index 0000000..5d2255e --- /dev/null +++ b/src/main/java/org/rhq/plugins/puppet/puppet/PuppetDiscovery.java @@ -0,0 +1,50 @@ +package org.rhq.plugins.puppet.puppet; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.Property; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ProcessScanResult; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; + + +/** + * Discovery class + */ +public class PuppetDiscovery implements ResourceDiscoveryComponent { + + + private final Log log = LogFactory.getLog(this.getClass()); + + + /** + * Run the discovery + */ + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception { + + Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(); + + /** + * TODO : do your discovery here + * A discovered resource must have a unique key, that must + * stay the same when the resource is discovered the next + * time + */ + DiscoveredResourceDetails detail = null; // new DiscoveredResourceDetails( ); + + + // Add to return values + discoveredResources.add(detail); + log.info("Discovered new ... TODO "); // TODO change + + return discoveredResources; + + } +}
\ No newline at end of file diff --git a/src/main/resources/META-INF/rhq-plugin.xml b/src/main/resources/META-INF/rhq-plugin.xml new file mode 100644 index 0000000..78f1f2d --- /dev/null +++ b/src/main/resources/META-INF/rhq-plugin.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<plugin name="puppet" + displayName="puppetPlugin" + package="org.rhq.plugins.puppet.puppet" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="urn:xmlns:rhq-plugin" + xmlns:c="urn:xmlns:rhq-configuration"> + + + <server + name="puppet" + discovery="PuppetDiscovery" + class="PuppetComponent" + createDeletePolicy="both" + > + + <plugin-configuration> + <!-- TODO add your own here --> + <c:simple-property name="dummy"/> + </plugin-configuration> + + <!-- TODO process scans --> + + <operation name="dummyOperation"> + <!-- TODO supply parameters and return values --> + </operation> + + + </server> + + +</plugin>
\ No newline at end of file |