From 160e56ab98b1c630bead95d0800ab4b9cc59e311 Mon Sep 17 00:00:00 2001 From: John Mazzitelli Date: Fri, 2 Oct 2009 11:30:51 -0400 Subject: initial skeleton as generated by pluginGen --- pom.xml | 180 ++++++++++++++++++++- .../rhq/plugins/puppet/puppet/PuppetComponent.java | 115 +++++++++++++ .../rhq/plugins/puppet/puppet/PuppetDiscovery.java | 50 ++++++ src/main/resources/META-INF/rhq-plugin.xml | 32 ++++ 4 files changed, 376 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/rhq/plugins/puppet/puppet/PuppetComponent.java create mode 100644 src/main/java/org/rhq/plugins/puppet/puppet/PuppetDiscovery.java create mode 100644 src/main/resources/META-INF/rhq-plugin.xml diff --git a/pom.xml b/pom.xml index be1f264..7710ebd 100644 --- a/pom.xml +++ b/pom.xml @@ -1 +1,179 @@ -TODO: put pom xml here + + + 4.0.0 + + + org.rhq + rhq-plugins-parent + 1.4.0-SNAPSHOT + + + org.rhq + puppet-plugin + jar + + RHQ puppet Plugin + Content push via puppet + + + TODO + 1.4.0-SNAPSHOT + + + + + + maven-compiler-plugin + + 1.5 + 1.5 + + + + + + + + + + dev + + + ../../.. + ${rhq.rootDir}/${rhq.defaultDevContainerPath} + ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins + + + + + + + maven-antrun-plugin + 1.1 + + + + deploy + compile + + + + + *** Updating ${deployment.file}... + + + + + run + + + + + deploy-jar-meta-inf + package + + + + *** Updating META-INF dir in ${deployment.file}... + + + + + + + + + + + run + + + + + undeploy + clean + + + + *** Deleting ${deployment.file}... + + + + + run + + + + + + + + + + + + + + + + + false + + jboss + JBoss Repository + http://repository.jboss.org/maven2/ + + + + + + + + false + + jboss + JBoss Plugin Repository + http://repository.jboss.org/maven2/ + + + + + + + commons-logging + commons-logging + 1.1 + + + org.rhq + rhq-core-domain + ${rhq.version} + provided + + + org.rhq + rhq-core-plugin-api + ${rhq.version} + provided + + + org.rhq + rhq-core-native-system + ${rhq.version} + provided + + + + + + \ 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 discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception { + + Set discoveredResources = new HashSet(); + + /** + * 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 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit