Commit 761e5d13 authored by afreyssin's avatar afreyssin

CTRL-Green use-case.

parent c64f3ddd
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.testctrlgreen;
import java.util.Date;
import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;
import javax.jms.JMSException;
import joram.ctrlgreen.Action;
import joram.ctrlgreen.ActionHandler;
import joram.ctrlgreen.ActionReturn;
import joram.ctrlgreen.ClientFramework;
import joram.ctrlgreen.Trace;
import org.objectweb.joram.client.jms.ConnectionFactory;
import org.objectweb.joram.client.jms.FactoryParameters;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
public class SimTalend implements ActionHandler {
static ClientFramework framework = null;
public static void main(String[] args) throws Exception {
String host = null;
int port = -1;
if (args.length != 0) {
if (args.length != 2) {
System.err.println("usage: java ... TestCMDBFramework host port");
System.exit(-1);
}
host = args[0];
port = Integer.parseInt(args[1]);
}
ConnectionFactory cf = TcpConnectionFactory.create(host, port);
FactoryParameters parameters = cf.getParameters();
parameters.connectingTimer = 10;
parameters.cnxPendingTimer = 5000;
framework = new ClientFramework("Talend", cf);
SimTalend handler = new SimTalend();
framework.setActionHandler(handler);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
Properties parameters = new Properties();
parameters.setProperty("par1", "value1");
parameters.setProperty("par2", "value2");
parameters.setProperty("par3", new Date().toString());
try {
framework.publishParameters(parameters);
} catch (JMSException e) {
e.printStackTrace();
}
}}, 10000, 5000);
System.in.read();
framework.close();
System.exit(0);
}
@Override
public ActionReturn onAction(Action action) {
System.out.println("SimTalend.onAction: " + action);
if (action.getType() == Action.VMWare_Inventory) {
try {
framework.publishInventoryVMWare(
"<inventory name=\"Inventory\">\n" +
" <vm name=\"vm1\"\\>\n" +
" <vm name=\"vm2\"\\>\n" +
"<\\inventory>\n");
} catch (JMSException exc) {
Trace.error("CMDBFramework.onInventory: Cannot publish inventory.", exc);
return new ActionReturn(ActionReturn.ERROR, "Cannot publish inventory");
}
}
return new ActionReturn();
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.testctrlgreen;
import javax.jms.JMSException;
import fr.dyade.aaa.util.management.MXWrapper;
import joram.ctrlgreen.Action;
import joram.ctrlgreen.ActionReturn;
import joram.ctrlgreen.CMDBFramework;
import joram.ctrlgreen.InventoryHandler;
import joram.ctrlgreen.Trace;
public class TestCMDBFramework implements InventoryHandler, TestCMDBFrameworkMBean {
static CMDBFramework framework = null;
public static void main(String[] args) throws Exception {
String host = null;
int port = -1;
if (args.length != 0) {
if (args.length != 2) {
System.err.println("usage: java ... TestCMDBFramework host port");
System.exit(-1);
}
host = args[0];
port = Integer.parseInt(args[1]);
}
TestCMDBFramework handler = new TestCMDBFramework();
MXWrapper.registerMBean(handler, "CMDB", "name=test");
framework = new CMDBFramework(host, port, handler);
System.in.read();
framework.close();
System.exit(0);
}
public String askInventory() {
ActionReturn ret = null;
try {
ret = framework.invokeAction("Talend",
new Action(Action.VMWare_Inventory, "Get VMWare Inventory"));
} catch (JMSException e) {
e.printStackTrace();
return null;
}
return ret.toString();
}
@Override
public void onInventory(String inventory) {
System.out.println("CMDBFramework.onInventory: " + inventory);
try {
framework.publishInventoryCMDB("<!-- From CMDB -->\n" + inventory);
} catch (JMSException exc) {
Trace.error("CMDBFramework.onInventory: Cannot publish inventory.", exc);
}
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.testctrlgreen;
public interface TestCMDBFrameworkMBean {
public String askInventory();
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.testctrlgreen;
import joram.ctrlgreen.Action;
import joram.ctrlgreen.ActionHandler;
import joram.ctrlgreen.ActionReturn;
import joram.ctrlgreen.DNSFramework;
public class TestDNSFramework implements ActionHandler {
public static void main(String[] args) throws Exception {
String host = null;
int port = -1;
if (args.length != 0) {
if (args.length != 2) {
System.err.println("usage: java ... TestCMDBFramework host port");
System.exit(-1);
}
host = args[0];
port = Integer.parseInt(args[1]);
}
TestDNSFramework handler = new TestDNSFramework();
DNSFramework framework = new DNSFramework(host, port, handler);
System.in.read();
framework.close();
System.exit(0);
}
@Override
public ActionReturn onAction(Action action) {
System.out.println("TestDNSFramework.onAction: " + action);
return new ActionReturn();
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.testctrlgreen;
import joram.ctrlgreen.Action;
import joram.ctrlgreen.ActionHandler;
import joram.ctrlgreen.ActionReturn;
import joram.ctrlgreen.InventoryHandler;
import joram.ctrlgreen.ScopeBRFramework;
public class TestScopeBRFramework implements InventoryHandler, ActionHandler {
public static void main(String[] args) throws Exception {
String host = null;
int port = -1;
if (args.length != 0) {
if (args.length != 2) {
System.err.println("usage: java ... TestCMDBFramework host port");
System.exit(-1);
}
host = args[0];
port = Integer.parseInt(args[1]);
}
TestScopeBRFramework handler = new TestScopeBRFramework();
ScopeBRFramework framework = new ScopeBRFramework(host, port, handler, handler);
System.in.read();
framework.close();
System.exit(0);
}
@Override
public void onInventory(String inventory) {
System.out.println("TestScopeBRFramework.onInventory: " + inventory);
}
@Override
public ActionReturn onAction(Action action) {
System.out.println("TestScopeBRFramework.onAction: " + action);
return new ActionReturn();
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.testctrlgreen;
import java.util.Properties;
import javax.jms.JMSException;
import fr.dyade.aaa.util.management.MXWrapper;
import joram.ctrlgreen.Action;
import joram.ctrlgreen.ActionReturn;
import joram.ctrlgreen.InventoryHandler;
import joram.ctrlgreen.ParameterHandler;
import joram.ctrlgreen.TuneFramework;
public class TestTuneFramework implements InventoryHandler, ParameterHandler, TestTuneFrameworkMBean {
static TuneFramework framework = null;
public static void main(String[] args) throws Exception {
String host = null;
int port = -1;
if (args.length != 0) {
if (args.length != 2) {
System.err.println("usage: java ... TestCMDBFramework host port");
System.exit(-1);
}
host = args[0];
port = Integer.parseInt(args[1]);
}
TestTuneFramework handler = new TestTuneFramework();
MXWrapper.registerMBean(handler, "Tune", "name=test");
framework = new TuneFramework(host, port, handler, handler);
System.out.println("Try to get Inventory..");
ActionReturn ret = framework.invokeAction("Talend",
new Action(Action.VMWare_Inventory, "Get VMWare Inventory"));
System.out.println("Receives: " + ret);
System.out.println("Request DNS..");
ret = framework.invokeAction("DNS",
new Action(Action.DNS_AddEntry, "vm1 192.168.1.12"));
System.out.println("Receives: " + ret);
System.out.println("Request ScopeBR..");
ret = framework.invokeAction("ScopeBR",
new Action(Action.ScopeBR_Validate, "Action plan.."));
System.out.println("Receives: " + ret);
System.in.read();
framework.close();
System.exit(0);
}
public String askInventory() {
ActionReturn ret = null;
try {
ret = framework.invokeAction("Talend",
new Action(Action.VMWare_Inventory, "Get VMWare Inventory"));
} catch (JMSException e) {
e.printStackTrace();
return null;
}
return ret.toString();
}
public String askDNS() {
ActionReturn ret = null;
try {
ret = framework.invokeAction("DNS",
new Action(Action.DNS_DeleteEntry, "vm2 18.1.1.10"));
} catch (JMSException e) {
e.printStackTrace();
return null;
}
return ret.toString();
}
public String askScopeBR() {
ActionReturn ret = null;
try {
ret = framework.invokeAction("ScopeBR",
new Action(Action.ScopeBR_Validate, "Action plan2.."));
} catch (JMSException e) {
e.printStackTrace();
return null;
}
return ret.toString();
}
@Override
public void onParameter(Properties parameters) {
System.out.println("TuneFramework.onParameter: " + parameters);
}
@Override
public void onInventory(String inventory) {
System.out.println("TuneFramework.onInventory: " + inventory);
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.testctrlgreen;
public interface TestTuneFrameworkMBean {
public String askDNS();
public String askInventory();
public String askScopeBR();
}
<?xml version="1.0"?>
<config>
<property name="Transaction" value="@transaction@"/>
<server id="0" name="s0" hostname="localhost">
<service class="org.objectweb.joram.mom.proxies.ConnectionManager" args="root root"/>
<service class="org.objectweb.joram.mom.proxies.tcp.TcpProxyService" args="16010"/>
<service class="fr.dyade.aaa.jndi2.server.JndiServer" args="16400"/>
</server>
</config>
\ No newline at end of file
java.naming.factory.initial fr.dyade.aaa.jndi2.client.NamingContextFactory
java.naming.factory.host localhost
java.naming.factory.port 16400
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment