Skip to content

Commit

Permalink
#58: added agent-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed Jul 7, 2013
1 parent 358e25b commit bf1a0fb
Show file tree
Hide file tree
Showing 17 changed files with 350 additions and 23 deletions.
5 changes: 0 additions & 5 deletions agent/org.linkedin.glu.agent-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ dependencies {

cmdline {
resources << packageIncludes
resources << [
from: consoleKeys,
into: new File(assemblePackageFile, 'conf/keys'),
replaceTokens: false
]
}
2 changes: 1 addition & 1 deletion packaging/org.linkedin.glu.packaging-all/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {

def dependentClis = [
':agent:org.linkedin.glu.agent-server': 'agent-server',
// ':agent:org.linkedin.glu.agent-cli': 'agent-cli',
':agent:org.linkedin.glu.agent-cli': 'agent-cli',
':console:org.linkedin.glu.console-server': 'console-server',
// ':console:org.linkedin.glu.console-cli': 'console-cli',
':packaging:org.linkedin.glu.packaging-setup': 'setup'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ init()
GLU_TUTORIAL_DISTS=$GLU_TUTORIAL_DIR/distributions/tutorial
GLU_TUTORIAL_BIN=$GLU_TUTORIAL_DIR/bin

GLU_TUTORIAL_AGENT_ROOT=$GLU_TUTORIAL_DISTS/agents/org.linkedin.glu.agent-server-$GLU_TUTORIAL_AGENT_NAME-$tutorialZooKeeperCluster-$GLU_VERSION
GLU_TUTORIAL_AGENT_ROOT=$GLU_TUTORIAL_DISTS/agents/org.linkedin.glu.agent-server-$GLU_TUTORIAL_AGENT_NAME-$GLU_TUTORIAL_ZOOKEEPER_CLUSTER_NAME-$GLU_VERSION
GLU_TUTORIAL_AGENT_CLI_ROOT=$GLU_TUTORIAL_DISTS/agent-cli/org.linkedin.glu.agent-cli-$GLU_VERSION
GLU_TUTORIAL_CONSOLE_ROOT=$GLU_TUTORIAL_DISTS/consoles/org.linkedin.glu.console-server-$GLU_TUTORIAL_CONSOLE_NAME-$GLU_VERSION
GLU_TUTORIAL_ZOOKEEPER_ROOT=$GLU_TUTORIAL_DISTS/zookeeper-clusters/zookeeper-cluster-$GLU_TUTORIAL_ZOOKEEPER_CLUSTER_NAME/org.linkedin.zookeeper-server-$ZOOKEEPER_VERSION

GLU_TUTORIAL_AGENT_LINK=$GLU_TUTORIAL_DIR/agent-server
GLU_TUTORIAL_AGENT_CLI_LINK=$GLU_TUTORIAL_DIR/agent-cli
GLU_TUTORIAL_CONSOLE_LINK=$GLU_TUTORIAL_DIR/console-server
GLU_TUTORIAL_ZOOKEEPER_LINK=$GLU_TUTORIAL_DIR/zookeeper-server

Expand All @@ -74,6 +76,9 @@ setup()
ln -s $GLU_TUTORIAL_AGENT_ROOT $GLU_TUTORIAL_AGENT_LINK
ln -s $GLU_TUTORIAL_AGENT_LINK/bin/agentctl.sh $GLU_TUTORIAL_BIN/agent-server.sh

ln -s $GLU_TUTORIAL_AGENT_CLI_ROOT $GLU_TUTORIAL_AGENT_CLI_LINK
ln -s $GLU_TUTORIAL_AGENT_CLI_LINK/bin/agent-cli.sh $GLU_TUTORIAL_BIN/agent-cli.sh

ln -s $GLU_TUTORIAL_CONSOLE_ROOT $GLU_TUTORIAL_CONSOLE_LINK
ln -s $GLU_TUTORIAL_CONSOLE_LINK/bin/consolectl.sh $GLU_TUTORIAL_BIN/console-server.sh

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

metaModelVersion = '1.0.0'
gluVersion = '@glu.version@'

def fabric = 'glu-dev-1'

def gluVersion = '@glu.version@'
def zooKeeperVersion = '@zookeeper.version@'

def keys = [
Expand Down Expand Up @@ -59,15 +59,13 @@ fabrics[fabric] = [
agents << [
name: 'agent-1',
host: 'localhost',
fabric: fabric,
version: gluVersion
fabric: fabric
]

consoles << [
name: 'tutorialConsole',
host: 'localhost',
plugins: ['org.linkedin.glu.orchestration.engine.plugins.builtin.StreamFileContentPlugin'],
version: gluVersion,
configTokens: [
dataSource: """
dataSource.dbCreate ='update'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (c) 2010-2010 LinkedIn, Inc
# Portions 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
Expand All @@ -19,9 +20,17 @@ url=https://localhost:12906/

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

keystorePath=./conf/keys/console.keystore
keystorePassword=nacEn92x8-1
keyPassword=nWVxpMg6Tkv
keystorePassword=${keys.consoleKeyStore.storePassword}
keyPassword=${keys.consoleKeyStore.keyPassword}

truststorePath=./conf/keys/agent.truststore
truststorePassword=nacEn92x8-1
truststorePassword=${keys.agentTrustStore.storePassword}

<% } else { %>
sslEnabled=false
<% } %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.
*/

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

if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.
*/

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

if(uri)
{
if(uri.isAbsolute())
{
packagerContext.shell.fetch(uri, toResource)
}
else
{
def relativeKeyStoreFile = uri.toString()
def keyStore = packagerContext.keysRoot.createRelative(relativeKeyStoreFile)
packagerContext.shell.fetch(keyStore, toResource)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.
*/



package org.pongasoft.glu.packaging.setup

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

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

Map<String, String> getConfigTokens()
{
metaModel.configTokens
}

PackagedArtifact createPackage()
{
String packageName = inputPackage.filename

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

Resource packagePath = outputFolder.createRelative(packageName)

if(!dryMode)
{
copyInputPackage(packagePath)
configure(packagePath, tokens)
}

return new PackagedArtifact(location: packagePath)
}

Resource configure(Resource packagePath, Map tokens)
{
processConfigs('agent-cli', tokens, packagePath)
return packagePath
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class GluPackager
packageAgents()
packageConsoles()
packageZooKeeperClusters()
packageAgentCli()
}

void packageAgents()
Expand Down Expand Up @@ -164,6 +165,31 @@ public class GluPackager
packager.createPackage()
}

protected PackagedArtifact packageAgentCli()
{
def out = shell.mkdirs(outputFolder.createRelative('agent-cli'))
def packager =
new AgentCliPackager(packagerContext: createPackagerContext(),
outputFolder: out,
inputPackage: getInputPackage('org.linkedin.glu.agent-cli',
gluMetaModel.gluVersion),
configsRoots: configsRoots,
metaModel: gluMetaModel,
dryMode: dryMode)

PackagedArtifact pa = packager.createPackage()

if(!packagedArtifacts[gluMetaModel])
packagedArtifacts[gluMetaModel] = [:]

packagedArtifacts[gluMetaModel].agentCli = pa

if(!dryMode)
println "Generated agent-cli package ${pa.location}"

return pa
}

protected PackagerContext createPackagerContext()
{
new PackagerContext(shell: shell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public abstract class BasePackagerTest extends GroovyTestCase
new BinaryResource(resource: resource)
}

public static final int CONFIG_TEMPLATES_COUNT = 17
public static final int CONFIG_TEMPLATES_COUNT = 20

public static final String GLU_VERSION = 'g.v.0'
public static final String ZOOKEEPER_VERSION = 'z.v.1'
Expand Down
Loading

0 comments on commit bf1a0fb

Please sign in to comment.