Skip to content

Commit

Permalink
#58: moved plugins inside exploded war
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed Jul 10, 2013
1 parent 84dd4b9 commit 1b29d08
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ url=https://localhost:12906/

################################
# Security:
<% def keys = (gluMetaModel.fabrics.values() as List)[0].keys %>
<% def keys = (agentCliMetaModel.gluMetaModel.fabrics.values() as List)[0].keys %>
<% if(keys) { %>
sslEnabled=true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/

// only one set of keys per console at the moment...
def uri = (gluMetaModel.fabrics.values() as List)[0].keys?.agentTrustStore?.uri
def uri = (agentCliMetaModel.gluMetaModel.fabrics.values() as List)[0].keys?.agentTrustStore?.uri

if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/

// only one set of keys per console at the moment...
def uri = (gluMetaModel.fabrics.values() as List)[0].keys?.consoleKeyStore?.uri
def uri = (agentCliMetaModel.gluMetaModel.fabrics.values() as List)[0].keys?.consoleKeyStore?.uri

if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*/

// delete the subfolder contexts and webapps since they come prepopulated with values we do not want
packagerContext.shell.rmdirs(toResource.parentResource.createRelative('contexts'))
packagerContext.shell.rmdirs(toResource.parentResource.createRelative('webapps'))
shell.rmdirs(toResource.parentResource.createRelative('contexts'))
shell.rmdirs(toResource.parentResource.createRelative('webapps'))
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ plugins.StreamFileContentPlugin.maskFileContent = true

// define the plugins as a Map, or a class name or an array of class names
orchestration.engine.plugins = [
<%= consoleMetaModel.plugins?.collect { "'${it}'" }?.join(',\n') %>
<%= consoleMetaModel.plugins?.collect { "'${it.fqcn}'" }?.join(',\n') %>
]

// extra plugin configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

// download/fetch the URI
if(consoleMetaModel.dataSourceDriverUri) {
packagerContext.shell.fetch(consoleMetaModel.dataSourceDriverUri, toResource)
shell.mkdirs(toResource.parentResource)
shell.fetch(consoleMetaModel.dataSourceDriverUri, toResource.parentResource)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2013 Yan Pujante
*
* 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.
*/

// download/fetch all the plugins
if(consoleMetaModel.plugins) {

def classPaths = consoleMetaModel.plugins*.classPath.flatten().findAll { it }.unique()

if(classPaths)
shell.mkdirs(toResource.parentResource)

classPaths.each { classPath ->
shell.fetch(classPath, toResource.parentResource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
// myid exists only if "real" cluster (meaning more than 1 server)
if(zooKeeperMetaModel.zooKeeperCluster.zooKeepers.size() > 1)
{
packagerContext.shell.saveContent(toResource, "${zooKeeperMetaModel.serverIdx}")
shell.saveContent(toResource, "${zooKeeperMetaModel.serverIdx}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,34 @@
package org.pongasoft.glu.packaging.setup

import org.linkedin.util.io.resource.Resource
import org.pongasoft.glu.provisioner.core.metamodel.GluMetaModel
import org.pongasoft.glu.provisioner.core.metamodel.AgentCliMetaModel

/**
* @author yan@pongasoft.com */
public class AgentCliPackager extends BasePackager
{
GluMetaModel metaModel
AgentCliMetaModel metaModel

PackagedArtifact createPackage()
{
String packageName = inputPackage.filename
String packageName = ensureVersion(metaModel.version)

def tokens = [
gluMetaModel: metaModel,
agentCliMetaModel: metaModel,
]
tokens[PACKAGER_CONTEXT_KEY] = packagerContext

Resource packagePath = outputFolder.createRelative(packageName)
def parts = [packageName]
parts << metaModel.version

Resource packagePath = outputFolder.createRelative(parts.join('-'))

if(!dryMode)
{
copyInputPackage(packagePath)
configure(packagePath, tokens)
if(metaModel.stateMachine)
generateStateMachineJarFile(metaModel.stateMachine,
if(metaModel.gluMetaModel.stateMachine)
generateStateMachineJarFile(metaModel.gluMetaModel.stateMachine,
packagePath.createRelative('lib'))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,27 @@
package org.pongasoft.glu.packaging.setup

import org.linkedin.util.io.resource.Resource
import org.pongasoft.glu.provisioner.core.metamodel.GluMetaModel
import org.pongasoft.glu.provisioner.core.metamodel.ConsoleCliMetaModel

/**
* @author yan@pongasoft.com */
public class ConsoleCliPackager extends BasePackager
{
GluMetaModel metaModel
ConsoleCliMetaModel metaModel

PackagedArtifact createPackage()
{
String packageName = inputPackage.filename
String packageName = ensureVersion(metaModel.version)

def tokens = [
gluMetaModel: metaModel,
consoleCliMetaModel: metaModel,
]
tokens[PACKAGER_CONTEXT_KEY] = packagerContext

Resource packagePath = outputFolder.createRelative(packageName)
def parts = [packageName]
parts << metaModel.version

Resource packagePath = outputFolder.createRelative(parts.join('-'))

if(!dryMode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.pongasoft.glu.packaging.setup

import org.linkedin.groovy.util.net.GroovyNetUtils
import org.linkedin.util.io.resource.Resource
import org.pongasoft.glu.provisioner.core.metamodel.ConsoleMetaModel

Expand Down Expand Up @@ -62,12 +61,10 @@ public class ConsoleServerPackager extends BasePackager
def tokens = [
consoleMetaModel: metaModel,
envPropertyNames: ENV_PROPERTY_NAMES,
'jetty.distribution': jettyDistribution
'jetty.distribution': jettyDistribution,
'console.war': "org.linkedin.glu.console-webapp-${metaModel.version}"
]

if(metaModel.dataSourceDriverUri)
tokens['dataSource.driver'] = GroovyNetUtils.guessFilename(metaModel.dataSourceDriverUri)

tokens[PACKAGER_CONTEXT_KEY] = packagerContext
tokens[CONFIG_TOKENS_KEY] = [*:configTokens]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class BasePackagerTest extends GroovyTestCase
new BinaryResource(resource: resource)
}

public static final int CONFIG_TEMPLATES_COUNT = 20
public static final int CONFIG_TEMPLATES_COUNT = 21

public static final String GLU_VERSION = 'g.v.0'
public static final String ZOOKEEPER_VERSION = 'z.v.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class TestAgentCliPackager extends BasePackagerTest
outputFolder: shell.mkdirs('/out'),
inputPackage: inputPackage,
configsRoots: copyConfigs(shell.toResource('/configs')),
metaModel: testModel)
metaModel: testModel.agentCli)

PackagedArtifact artifact = packager.createPackage()

Expand Down Expand Up @@ -101,6 +101,9 @@ truststorePassword=nacEn92x8-1
ShellImpl.createTempShell { Shell shell ->

def metaModel = """
gluVersion = '${GLU_VERSION}'
fabrics['f1'] = [ : ]
stateMachine = [
Expand All @@ -124,7 +127,7 @@ stateMachine = [
outputFolder: shell.mkdirs('/out'),
inputPackage: inputPackage,
configsRoots: copyConfigs(shell.toResource('/configs')),
metaModel: toGluMetaModel(metaModel))
metaModel: toGluMetaModel(metaModel).agentCli)

PackagedArtifact artifact = packager.createPackage()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TestConsoleCliPackager extends BasePackagerTest
outputFolder: shell.mkdirs('/out'),
inputPackage: inputPackage,
configsRoots: copyConfigs(shell.toResource('/configs')),
metaModel: testModel)
metaModel: testModel.consoleCli)

PackagedArtifact artifact = packager.createPackage()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class TestConsoleServerPackager extends BasePackagerTest
ShellImpl.createTempShell { Shell shell ->

def driverResource = shell.saveContent('/drivers/db-driver.jar', 'this is the driver')
def plugin1Resource = shell.saveContent('/plugins/plugin1.jar', 'this is the plugin1')
def plugin2Resource = shell.saveContent('/plugins/plugin2.jar', 'this is the plugin2')

def metaModel = """
fabrics['f1'] = [
Expand All @@ -112,7 +114,10 @@ consoles << [
internalPath: '/ic',
externalHost: 'h2',
externalPath: '/ec',
plugins: ['p1', 'p2'],
plugins: [
[fqcn: 'p1', classPath: ['${plugin1Resource.toURI()}']],
[fqcn: 'p2', classPath: ['${plugin2Resource.toURI()}']],
],
version: '${GLU_VERSION}',
dataSourceDriverUri: '${driverResource.toURI()}',
configTokens: [
Expand All @@ -131,6 +136,7 @@ consoles << [
def inputPackage = shell.mkdirs("/dist/org.linkedin.glu.console-server-${GLU_VERSION}")

def jettyDistribution = "jetty-distribution-${JETTY_VERSION}"
def consoleWar = "org.linkedin.glu.console-webapp-${GLU_VERSION}"
def jettyPackage = shell.mkdirs(inputPackage.createRelative(jettyDistribution))
shell.saveContent(jettyPackage.'/lib/acme.jar', 'this is the jar')
shell.saveContent(jettyPackage.'/contexts/dummy-context.xml', 'will be deleted')
Expand Down Expand Up @@ -258,9 +264,16 @@ JVM_SIZE="-Xmx555m"
"/${jettyDistribution}/contexts/console-jetty-context.xml": TUTORIAL_CONSOLE_JETTY_CONTEXT.replace('/console', '/ic'),
"/${jettyDistribution}/contexts/glu-jetty-context.xml": DEFAULT_GLU_JETTY_CONTEXT,
"/${jettyDistribution}/lib": DIRECTORY,
"/${jettyDistribution}/lib/ext": DIRECTORY,
"/${jettyDistribution}/lib/ext/db-driver.jar": "this is the driver",
"/${jettyDistribution}/lib/acme.jar": 'this is the jar',
"/glu": DIRECTORY,
"/glu/repository": DIRECTORY,
"/glu/repository/exploded-wars": DIRECTORY,
"/glu/repository/exploded-wars/${consoleWar}": DIRECTORY,
"/glu/repository/exploded-wars/${consoleWar}/WEB-INF": DIRECTORY,
"/glu/repository/exploded-wars/${consoleWar}/WEB-INF/lib": DIRECTORY,
"/glu/repository/exploded-wars/${consoleWar}/WEB-INF/lib/db-driver.jar": "this is the driver",
"/glu/repository/exploded-wars/${consoleWar}/WEB-INF/lib/plugin1.jar": "this is the plugin1",
"/glu/repository/exploded-wars/${consoleWar}/WEB-INF/lib/plugin2.jar": "this is the plugin2",
]

checkPackageContent(expectedResources, artifact.location)
Expand Down
Loading

0 comments on commit 1b29d08

Please sign in to comment.