summaryrefslogtreecommitdiff
path: root/cpp/src/IcePack/Parser.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2004-06-02 21:17:40 +0000
committerBenoit Foucher <benoit@zeroc.com>2004-06-02 21:17:40 +0000
commitc209ff436f4268b8db689a2dd17615456eea78ce (patch)
tree5feb8607988706851bfdfdd5ba2d3924ba5b8f6c /cpp/src/IcePack/Parser.cpp
parentFixed to AMD code generation. (diff)
downloadice-c209ff436f4268b8db689a2dd17615456eea78ce.tar.bz2
ice-c209ff436f4268b8db689a2dd17615456eea78ce.tar.xz
ice-c209ff436f4268b8db689a2dd17615456eea78ce.zip
Merged icepack_refactoring2_branch, many IcePack changes.
Diffstat (limited to 'cpp/src/IcePack/Parser.cpp')
-rw-r--r--cpp/src/IcePack/Parser.cpp725
1 files changed, 631 insertions, 94 deletions
diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp
index 183825eb110..f48e202d5f0 100644
--- a/cpp/src/IcePack/Parser.cpp
+++ b/cpp/src/IcePack/Parser.cpp
@@ -7,8 +7,13 @@
//
// **********************************************************************
+#include <IceUtil/OutputUtil.h>
#include <Ice/Ice.h>
+#include <IceXML/Parser.h>
#include <IcePack/Parser.h>
+#include <IcePack/DescriptorVisitor.h>
+#include <IcePack/DescriptorParser.h>
+#include <IcePack/DescriptorUtil.h>
#ifdef GPL_BUILD
# include <IcePack/GPL.h>
@@ -25,6 +30,7 @@ extern FILE* yyin;
extern int yydebug;
using namespace std;
+using namespace IceUtil;
using namespace Ice;
using namespace IcePack;
@@ -33,6 +39,227 @@ namespace IcePack
Parser* parser;
+class ServerDescribe : public DescriptorVisitor
+{
+public:
+
+ ServerDescribe(IceUtil::Output&, const Ice::CommunicatorPtr&, AdminPrx&);
+
+ void describe(const ServerDescriptorPtr&);
+
+private:
+
+ virtual bool visitServerStart(const ServerWrapper&, const ServerDescriptorPtr&);
+ virtual void visitServerEnd(const ServerWrapper&, const ServerDescriptorPtr&);
+ virtual bool visitServiceStart(const ServiceWrapper&, const ServiceDescriptorPtr&);
+ virtual void visitServiceEnd(const ServiceWrapper&, const ServiceDescriptorPtr&);
+ virtual void visitDbEnv(const DbEnvWrapper&, const DbEnvDescriptor&);
+ virtual bool visitAdapterStart(const AdapterWrapper&, const AdapterDescriptor&);
+ virtual void visitAdapterEnd(const AdapterWrapper&, const AdapterDescriptor&);
+ virtual void visitObject(const ObjectWrapper&, const ObjectDescriptor&);
+
+ IceUtil::Output& _out;
+ Ice::CommunicatorPtr _communicator;
+ AdminPrx _admin;
+};
+
+}
+
+ServerDescribe::ServerDescribe(IceUtil::Output& out, const Ice::CommunicatorPtr& communicator, AdminPrx& admin) :
+ _out(out),
+ _communicator(communicator),
+ _admin(admin)
+{
+}
+
+void
+ServerDescribe::describe(const ServerDescriptorPtr& desc)
+{
+ ServerWrapper(desc).visit(*this);
+}
+
+bool
+ServerDescribe::visitServerStart(const ServerWrapper&, const ServerDescriptorPtr& server)
+{
+ _out << "server '" << server->name << "' ";
+ if(JavaServerDescriptorPtr::dynamicCast(server))
+ {
+ if(JavaIceBoxDescriptorPtr::dynamicCast(server))
+ {
+ _out << " (Java IceBox)";
+ }
+ else
+ {
+ _out << " (Java)";
+ }
+ }
+ else if(CppIceBoxDescriptorPtr::dynamicCast(server))
+ {
+ _out << " (IceBox)";
+ }
+
+ _out << sb;
+ _out << nl << "node = '" << server->node << "'";
+ _out << nl << "application = '" << server->application << "'";
+ _out << nl << "exe = '" << server->exe << "'";
+ if(!server->pwd.empty())
+ {
+ _out << nl << "pwd = '" << server->pwd << "'";
+ }
+ _out << nl << "activation = '" << (_admin->getServerActivation(server->name) == OnDemand ? "on-demand" : "manual")
+ << "'";
+ if(JavaServerDescriptorPtr::dynamicCast(server))
+ {
+ JavaServerDescriptorPtr s = JavaServerDescriptorPtr::dynamicCast(server);
+ _out << nl << "className = '" << s->className << "'";
+ if(!s->jvmOptions.empty())
+ {
+ _out << nl << "jvmOptions = '";
+ for(Ice::StringSeq::const_iterator p = s->jvmOptions.begin(); p != s->jvmOptions.end(); ++p)
+ {
+ _out << *p << " ";
+ }
+ }
+ }
+ if(JavaIceBoxDescriptorPtr::dynamicCast(server))
+ {
+ JavaIceBoxDescriptorPtr s = JavaIceBoxDescriptorPtr::dynamicCast(server);
+ _out << nl << "service manager endpoints = '" << s->endpoints << "'";
+ }
+ if(CppIceBoxDescriptorPtr::dynamicCast(server))
+ {
+ CppIceBoxDescriptorPtr s = CppIceBoxDescriptorPtr::dynamicCast(server);
+ _out << nl << "service manager endpoints = '" << s->endpoints << "'";
+ }
+ if(!server->comment.empty())
+ {
+ _out << nl << "comment";
+ _out << sb;
+ _out << nl << server->comment;
+ _out << eb;
+ }
+ if(!server->options.empty())
+ {
+ _out << nl << "options = '";
+ for(Ice::StringSeq::const_iterator p = server->options.begin(); p != server->options.end(); ++p)
+ {
+ _out << *p << " ";
+ }
+ }
+ if(!server->envs.empty())
+ {
+ _out << nl << "envs = '";
+ for(Ice::StringSeq::const_iterator p = server->envs.begin(); p != server->envs.end(); ++p)
+ {
+ _out << *p << " ";
+ }
+ }
+ if(!server->properties.empty())
+ {
+ _out << nl << "properties";
+ _out << sb;
+ for(PropertyDescriptorSeq::const_iterator p = server->properties.begin(); p != server->properties.end(); ++p)
+ {
+ _out << nl << p->name << "=" << p->value;
+ }
+ _out << eb;
+ }
+
+ return true;
+}
+
+void
+ServerDescribe::visitServerEnd(const ServerWrapper&, const ServerDescriptorPtr& server)
+{
+ _out << eb;
+ _out << nl;
+}
+
+bool
+ServerDescribe::visitServiceStart(const ServiceWrapper&, const ServiceDescriptorPtr& service)
+{
+ _out << nl << "service '" << service->name << "'";
+ _out << sb;
+ _out << nl << "entry = '" << service->entry << "'";
+ if(!service->comment.empty())
+ {
+ _out << nl << "comment";
+ _out << sb;
+ _out << nl << service->comment;
+ _out << eb;
+ }
+ if(!service->properties.empty())
+ {
+ _out << nl << "properties";
+ _out << sb;
+ for(PropertyDescriptorSeq::const_iterator p = service->properties.begin(); p != service->properties.end(); ++p)
+ {
+ _out << nl << p->name << "=" << p->value;
+ }
+ _out << eb;
+ }
+ return true;
+}
+
+void
+ServerDescribe::visitServiceEnd(const ServiceWrapper&, const ServiceDescriptorPtr& service)
+{
+ _out << eb;
+}
+
+void
+ServerDescribe::visitDbEnv(const DbEnvWrapper&, const DbEnvDescriptor& dbEnv)
+{
+ _out << nl << "database environment '" << dbEnv.name << "'";
+ if(!dbEnv.dbHome.empty() || !dbEnv.properties.empty())
+ {
+ _out << sb;
+ if(!dbEnv.dbHome.empty())
+ {
+ _out << nl << "home = '" << dbEnv.dbHome << "'";
+ }
+ if(!dbEnv.properties.empty())
+ {
+ _out << nl << "properties";
+ _out << sb;
+ for(PropertyDescriptorSeq::const_iterator p = dbEnv.properties.begin(); p != dbEnv.properties.end(); ++p)
+ {
+ _out << nl << p->name << "=" << p->value;
+ }
+ _out << eb;
+ }
+ _out << eb;
+ }
+}
+
+bool
+ServerDescribe::visitAdapterStart(const AdapterWrapper&, const AdapterDescriptor& adapter)
+{
+ _out << nl << "adapter '" << adapter.name << "'";
+ _out << sb;
+ _out << nl << "id = '" << adapter.id << "'";
+ _out << nl << "endpoints = '" << adapter.endpoints << "'";
+ _out << nl << "register process = '" << (adapter.registerProcess ? "true" : "false") << "'";
+ return true;
+}
+
+void
+ServerDescribe::visitAdapterEnd(const AdapterWrapper&, const AdapterDescriptor& adapter)
+{
+ _out << eb;
+}
+
+void
+ServerDescribe::visitObject(const ObjectWrapper&, const ObjectDescriptor& object)
+{
+ _out << nl << "object";
+ if(!object.type.empty())
+ {
+ _out << sb;
+ _out << nl << "proxy = '" << _communicator->proxyToString(object.proxy) << "' ";
+ _out << nl << "type = '" << object.type << "'";
+ _out << eb;
+ }
}
ParserPtr
@@ -48,25 +275,35 @@ IcePack::Parser::usage()
"help Print this message.\n"
"exit, quit Exit this program.\n"
"\n"
- "application add DESC [TARGET1 [TARGET2 ...]]\n"
- " Add servers described in application descriptor\n"
- " DESC. If specified the optional targets TARGET will\n"
- " be deployed.\n"
- "application remove DESC Remove servers described in application descriptor\n"
- " DESC.\n"
- "\n"
+ "application add DESC [TARGET ... ] [NAME=VALUE ... ]\n"
+ " Add application described in DESC. If specified\n"
+ " the optional targets TARGET will be deployed.\n"
+ "application remove NAME Remove application NAME.\n"
+ "application describe NAME Describe application NAME.\n"
+ "application diff DESC [TARGET ... ] [NAME=VALUE ... ]\n"
+ " Print the differences betwen the application\n"
+ " described in DESC and the current deployment.\n"
+ "application update DESC [TARGET ... ] [NAME=VALUE ... ]\n"
+ " Update the application described in DESC.\n"
+ "application list List all deployed applications.\n"
+ "\n"
"node list List all registered nodes.\n"
"node ping NAME Ping node NAME.\n"
+ "node remove NAME Remove the servers deployed on node NAME and\n"
+ " the node NAME.\n"
"node shutdown NAME Shutdown node NAME.\n"
"\n"
"server list List all registered servers.\n"
- "server add NODE NAME DESC [PATH [LIBPATH [TARGET1 [TARGET2 ...]]]]\n"
- " Add server NAME to node NODE with deployment\n"
- " descriptor DESC, optional PATH and LIBPATH. If\n"
- " specified the optional targets TARGET will be\n"
- " deployed.\n"
+ "server add DESC NODE [TARGET ... ] [NAME=VALUE ... ]\n"
+ " Add server described in descriptor DESC to the node\n"
+ " NODE. If specified the optional targets TARGET will\n"
+ " be deployed.\n"
+ "server update DESC NODE [TARGET ... ] [NAME=VALUE ... ]\n"
+ " Update server described in descriptor DESC on the\n"
+ " node NODE. If specified the optional targets TARGET\n"
+ " will be deployed.\n"
"server remove NAME Remove server NAME.\n"
- "server describe NAME Get server NAME description.\n"
+ "server describe NAME Describe server NAME.\n"
"server state NAME Get server NAME state.\n"
"server pid NAME Get server NAME pid.\n"
"server start NAME Start server NAME.\n"
@@ -88,13 +325,13 @@ IcePack::Parser::usage()
"\n"
"shutdown Shut the IcePack registry down.\n"
#ifdef GPL_BUILD
- "show copying Show conditions for redistributing copies of this program.\n"
+ "show copying Show conditions for redistributing copies of this\n"
+ " program.\n"
"show warranty Show the warranty for this program.\n"
#endif
;
}
-
void
IcePack::Parser::addApplication(const list<string>& args)
{
@@ -106,31 +343,40 @@ IcePack::Parser::addApplication(const list<string>& args)
try
{
- list<string>::const_iterator p = args.begin();
+ StringSeq targets;
+ map<string, string> vars;
+ list<string>::const_iterator p = args.begin();
string descriptor = *p++;
- StringSeq targets;
for(; p != args.end(); ++p)
{
- targets.push_back(*p);
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
}
- _admin->addApplication(descriptor, targets);
+ _admin->addApplication(DescriptorParser::parseApplicationDescriptor(descriptor, targets, vars, _communicator));
}
- catch(const ServerDeploymentException& ex)
+ catch(const IceXML::ParserException& ex)
{
ostringstream s;
- s << ex << ": " << ex.server << ":\n" << ex.reason;
- error(s.str());
+ s << ex;
+ error(s.str());
}
catch(const DeploymentException& ex)
{
ostringstream s;
- s << ex << ": " << ex.component << ":\n" << ex.reason;
+ s << ex << ":\n" << ex.reason;
error(s.str());
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -151,17 +397,259 @@ IcePack::Parser::removeApplication(const list<string>& args)
{
list<string>::const_iterator p = args.begin();
+ string name = *p++;
+
+ _admin->removeApplication(name);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream s;
+ s << ex << ":\n" << ex.reason;
+ error(s.str());
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
+IcePack::Parser::describeApplication(const list<string>& args)
+{
+ if(args.size() < 1)
+ {
+ error("`application describe' requires at exactly one argument\n(`help' for more info)");
+ return;
+ }
+
+ try
+ {
+ list<string>::const_iterator p = args.begin();
+
+ string name = *p++;
+
+ ApplicationDescriptorPtr application = _admin->getApplicationDescriptor(name);
+
+ IceUtil::Output out(cout);
+ out << "application '" << application->name << "'";
+ out << sb;
+ if(!application->comment.empty())
+ {
+ out << nl << "comment = " << application->comment;
+ }
+ if(!application->servers.empty())
+ {
+ map<string, set<string> > servers;
+ {
+ for(ServerDescriptorSeq::const_iterator p = application->servers.begin();
+ p != application->servers.end();
+ ++p)
+ {
+ map<string, set<string> >::iterator q = servers.find((*p)->node);
+ if(q == servers.end())
+ {
+ q = servers.insert(make_pair((*p)->node, set<string>())).first;
+ }
+ q->second.insert((*p)->name);
+ }
+ }
+ {
+ for(map<string, set<string> >::const_iterator p = servers.begin(); p != servers.end(); ++p)
+ {
+ out << nl << "node '" << p->first << "'";
+ out << sb;
+ for(set<string>::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ out << nl << *q;
+ }
+ out << eb;
+ }
+ }
+ }
+ out << eb;
+ out << nl;
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream s;
+ s << ex << ":\n" << ex.reason;
+ error(s.str());
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
+IcePack::Parser::diffApplication(const list<string>& args)
+{
+ if(args.size() < 1)
+ {
+ error("`application diff' requires at exactly one argument\n(`help' for more info)");
+ return;
+ }
+
+ ApplicationDescriptorPtr newApp;
+ ApplicationDescriptorPtr origApp;
+
+ try
+ {
+ StringSeq targets;
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
string descriptor = *p++;
- _admin->removeApplication(descriptor);
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ newApp = DescriptorParser::parseApplicationDescriptor(descriptor, targets, vars, _communicator);
+ origApp = _admin->getApplicationDescriptor(newApp->name);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream s;
+ s << ex << ":\n" << ex.reason;
+ error(s.str());
+ return;
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ return;
+ }
+
+ Output out(cout);
+ out << "application `" << newApp->name << "'";
+ out << sb;
+
+ ServerDescriptorSeq::const_iterator p;
+ for(p = newApp->servers.begin(); p != newApp->servers.end(); ++p)
+ {
+ ServerDescriptorPtr orig;
+ for(ServerDescriptorSeq::const_iterator q = origApp->servers.begin(); q != origApp->servers.end(); ++q)
+ {
+ if((*q)->name == (*p)->name)
+ {
+ orig = *q;
+ break;
+ }
+ }
+
+ if(orig)
+ {
+ if(!equal(orig, *p))
+ {
+ out << nl << "server `" << orig->name << "' updated";
+ }
+ }
+ else
+ {
+ out << nl << "server `" << (*p)->name << "' added";
+ }
+ }
+
+ for(p = origApp->servers.begin(); p != origApp->servers.end(); ++p)
+ {
+ bool found = false;
+ for(ServerDescriptorSeq::const_iterator q = newApp->servers.begin(); q != newApp->servers.end(); ++q)
+ {
+ if((*q)->name == (*p)->name)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if(!found)
+ {
+ out << nl << "server `" << (*p)->name << "' removed";
+ }
+ }
+
+ out << eb;
+ out << nl;
+}
+
+void
+IcePack::Parser::updateApplication(const list<string>& args)
+{
+ if(args.size() < 1)
+ {
+ error("`application diff' requires at exactly one argument\n(`help' for more info)");
+ return;
+ }
+
+ try
+ {
+ StringSeq targets;
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string descriptor = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ _admin->updateApplication(
+ DescriptorParser::parseApplicationDescriptor(descriptor, targets, vars, _communicator));
+ }
+ catch(const IceXML::ParserException& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
catch(const DeploymentException& ex)
{
ostringstream s;
- s << ex << ": " << ex.component << ":\n" << ex.reason;
+ s << ex << ":\n" << ex.reason;
error(s.str());
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
+IcePack::Parser::listAllApplications()
+{
+ try
+ {
+ Ice::StringSeq names = _admin->getAllApplicationNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ }
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -189,7 +677,7 @@ IcePack::Parser::pingNode(const list<string>& args)
cout << "node is down" << endl;
}
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -210,7 +698,28 @@ IcePack::Parser::shutdownNode(const list<string>& args)
{
_admin->shutdownNode(args.front());
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
+IcePack::Parser::removeNode(const list<string>& args)
+{
+ if(args.size() != 1)
+ {
+ error("`node remove' requires exactly one argument\n(`help' for more info)");
+ return;
+ }
+
+ try
+ {
+ _admin->removeNode(args.front());
+ }
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -226,7 +735,7 @@ IcePack::Parser::listAllNodes()
Ice::StringSeq names = _admin->getAllNodeNames();
copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -245,43 +754,82 @@ IcePack::Parser::addServer(const list<string>& args)
try
{
- list<string>::const_iterator p = args.begin();
- string node = *p++;
- string name = *p++;
- string descriptor = *p++;
- string path;
- string ldpath;
StringSeq targets;
+ map<string, string> vars;
- if(p != args.end())
- {
- path = *p++;
- }
- if(p != args.end())
- {
- ldpath = *p++;
- }
+ list<string>::const_iterator p = args.begin();
+ string descriptor = *p++;
+ vars["node"] = *p++;
for(; p != args.end(); ++p)
{
- targets.push_back(*p);
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
}
- _admin->addServer(node, name, path, ldpath, descriptor, targets);
+ _admin->addServer(DescriptorParser::parseServerDescriptor(descriptor, targets, vars, _communicator));
}
- catch(const ServerDeploymentException& ex)
+ catch(const DeploymentException& ex)
{
ostringstream s;
- s << ex << ": " << ex.server << ":\n" << ex.reason;
+ s << ex << ":\n" << ex.reason;
error(s.str());
}
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
+IcePack::Parser::updateServer(const list<string>& args)
+{
+ if(args.size() < 3)
+ {
+ error("`server add' requires at least three arguments\n(`help' for more info)");
+ return;
+ }
+
+ try
+ {
+ StringSeq targets;
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string descriptor = *p++;
+ vars["node"] = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ _admin->updateServer(DescriptorParser::parseServerDescriptor(descriptor, targets, vars, _communicator));
+ }
catch(const DeploymentException& ex)
{
ostringstream s;
- s << ex << ": " << ex.component << ":\n" << ex.reason;
+ s << ex << ":\n" << ex.reason;
error(s.str());
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -305,7 +853,7 @@ IcePack::Parser::startServer(const list<string>& args)
error("the server didn't start successfully");
}
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -326,7 +874,7 @@ IcePack::Parser::stopServer(const list<string>& args)
{
_admin->stopServer(args.front());
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -349,7 +897,7 @@ IcePack::Parser::signalServer(const list<string>& args)
string server = *p++;
_admin->sendSignal(server, *p);
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -373,7 +921,7 @@ IcePack::Parser::writeMessage(const list<string>& args, int fd)
string server = *p++;
_admin->writeMessage(server, *p, fd);
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -381,21 +929,23 @@ IcePack::Parser::writeMessage(const list<string>& args, int fd)
}
}
-
void
-IcePack::Parser::removeServer(const list<string>& args)
+IcePack::Parser::describeServer(const list<string>& args)
{
if(args.size() != 1)
{
- error("`server remove' requires exactly one argument\n(`help' for more info)");
+ error("`server describe' requires exactly one argument\n(`help' for more info)");
return;
}
-
+
try
{
- _admin->removeServer(args.front());
+ ServerDescriptorPtr desc = _admin->getServerDescriptor(args.front());
+
+ IceUtil::Output out(cout);
+ ServerDescribe(out, _communicator, _admin).describe(desc);
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -404,32 +954,25 @@ IcePack::Parser::removeServer(const list<string>& args)
}
void
-IcePack::Parser::describeServer(const list<string>& args)
+IcePack::Parser::removeServer(const list<string>& args)
{
if(args.size() != 1)
{
- error("`server describe' requires exactly one argument\n(`help' for more info)");
+ error("`server remove' requires exactly one argument\n(`help' for more info)");
return;
}
try
{
- ServerDescription desc = _admin->getServerDescription(args.front());
- ServerActivation activation = _admin->getServerActivation(args.front());
-
- cout << "name = " << desc.name << endl;
- cout << "node = " << desc.node << endl;
- cout << "path = " << desc.path << endl;
- cout << "pwd = " << desc.pwd << endl;
- cout << "activation = " << (activation == OnDemand ? "on-demand" : "manual") << endl;
- cout << "args = ";
- copy(desc.args.begin(), desc.args.end(), ostream_iterator<string>(cout," "));
- cout << endl;
- cout << "envs = ";
- copy(desc.envs.begin(), desc.envs.end(), ostream_iterator<string>(cout," "));
- cout << endl;
+ _admin->removeServer(args.front());
}
- catch(const Exception& ex)
+ catch(const DeploymentException& ex)
+ {
+ ostringstream s;
+ s << ex << ":\n" << ex.reason;
+ error(s.str());
+ }
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -482,7 +1025,7 @@ IcePack::Parser::stateServer(const list<string>& args)
assert(false);
}
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -503,7 +1046,7 @@ IcePack::Parser::pidServer(const list<string>& args)
{
cout << _admin->getServerPid(args.front()) << endl;
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -539,7 +1082,7 @@ IcePack::Parser::activationServer(const list<string>& args)
error("Unknown mode: " + mode);
}
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -555,7 +1098,7 @@ IcePack::Parser::listAllServers()
Ice::StringSeq names = _admin->getAllServerNames();
copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -577,7 +1120,7 @@ IcePack::Parser::endpointsAdapter(const list<string>& args)
string endpoints = _admin->getAdapterEndpoints(args.front());
cout << endpoints << endl;
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -593,7 +1136,7 @@ IcePack::Parser::listAllAdapters()
Ice::StringSeq names = _admin->getAllAdapterIds();
copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -626,19 +1169,13 @@ IcePack::Parser::addObject(const list<string>& args)
_admin->addObject(_communicator->stringToProxy(proxy));
}
}
- catch(const ObjectDeploymentException& ex)
- {
- ostringstream s;
- s << ex << ": " << _communicator->proxyToString(ex.proxy) << ":\n" << ex.reason;
- error(s.str());
- }
catch(const DeploymentException& ex)
{
ostringstream s;
- s << ex << ": " << ex.component << ":\n" << ex.reason;
+ s << ex << ":\n" << ex.reason;
error(s.str());
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -659,7 +1196,7 @@ IcePack::Parser::removeObject(const list<string>& args)
{
_admin->removeObject(_communicator->stringToProxy((*(args.begin()))));
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -684,7 +1221,7 @@ IcePack::Parser::findObject(const list<string>& args)
cout << _communicator->proxyToString(*p) << endl;
}
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;
@@ -699,7 +1236,7 @@ IcePack::Parser::shutdown()
{
_admin->shutdown();
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
ostringstream s;
s << ex;