Cisco Cisco Configuration Engine 3.5 开发者指南

下载
页码 344
5-11
Cisco Configuration Engine Software Development Kit API Reference and Programmer Guide 3.5
OL-17661-02
Chapter 5      Web Services: Admin, Config, Image, Exec, NSM
Web Services Model
UpdateConfig _et = new UpdateConfig();
/*
*  Get command line args...
*/
String _sNumDevices = null;
String _sDevType = null;
String _sHostNm = null;
String _sUsername = null;
String _sPassword = null;
if (args.length < 4)
{
p(m_usage);
System.exit(1);
}
_sNumDevices = args[0];
_sDevType = args[1];
_sUsername = args[2];
_sPassword = args[3];
if (args.length == 5)
{
_sHostNm = args[4];
}
/*
*  Initialize service stub...
*/
_et.init(_sHostNm);
/*
*  Set username & password...
*/
_et.setCredentials(_sUsername, _sPassword);
/*
*  Invoke service...
*/
_et.execute(Integer.parseInt(_sNumDevices), _sDevType);
}
public void execute(int numberOfDevices, String type)
{
try
{
Device[] _devices = new Device[numberOfDevices];
for (int i = 0; i < numberOfDevices; i++)
{
Device _device = new Device();
_device.setName(“router1”);
_device.setType(“NON_AGENT_ENABLED_DEVICE”);
// Non-Agent-enabled device
// hostname of the CE hosting the event gateway
_device.setGatewayId("my-ce-host");
_device.setDeviceType("IOS");
// tells the agent proxy to proxy the config agent
_device.setAgentType("Config Agent");
HopInfo[] _hopInfos = new HopInfo[2];
_hopInfos[0] = new HopInfo();
_hopInfos[0].setHopType("IOS_EN");