|
Let us consider a situation in which you may need to execute a shell script on a machine. To do this, you have to first transfer the file to the machine through a TFTP task and execute it through a TELNET task. Rather than executing these two tasks sequentially, ConfigServer allows you to create combined tasks.
A Combined Task is a combination of two of more sub tasks. Each sub task is self-contained, that is capable of performing individual configuration. The sub tasks of the combined task may belong to any protocol, meaning one can be a TFTP task and another be a TELNET task.
Executing combined tasks consists of the following steps:
For associating different tasks to different devices, the device array has to be created as shown below using the methods in the Device class.
|
Device d1[] = new Device[3]; d1[0] = new Device("device1", "161"); d1[1] = new Device("device2", "161"); d1[2] = new Device("device3", "161");
Device d2[] = new Device[2]; d2[0] = new Device("device4", "69"); d2[1] = new Device("device5", "69"); |
Before creating the combined tasks, make sure that you have created the individual tasks. Assuming that there exists individual tasks namely t1 and t2, the combined task is created as specified below.
|
TaskGenerator tg = new TaskGenerator(); tg.setTaskName("combinedtask1"); tg.setNewTask(true); tg.setOverwrite(true);
/* t1 and t2 are existing tasks */ Vector subTask = new Vector(1); subTask.addElement("t1"); subTask.addElement("t2");
Vector subDevices - new Vector(1); subDevices.addElement(d1); subDevices.addElement(d2);
tg.setDevices(subTask, subDevices); String taskXML = tg.getTask(); configclientAPI.executeTask(taskXML); |
|
|
Note: Already existing device lists can also be associated with the combined task using the method setDeviceList(Vector subTask, Vector DeviceList) of TaskGenerator. |
Once the combined task is created, it is executed by using the method
executeTask(String taskXML) of
ConfigClientAPI
.
|
TaskGenerator tg = new TaskGenerator(); String taskXML = tg.getTask(); configclientAPI.executeTask(taskXML); |
|