Script Examples

Top  Previous  Next

Here is an example of script that changes IP address of a hardware Device Server:

import com.tibbo.aggregate.common.context.*;

import com.tibbo.aggregate.common.datatable.*;

import com.tibbo.aggregate.common.script.*;

 

import com.tibbo.linkserver.*;

import com.tibbo.linkserver.context.*;

import com.tibbo.linkserver.script.*;

 

public class %ScriptClassNamePattern% implements Script

{

  public Object execute(ScriptExecutionEnvironment environment) throws ScriptException

  {

 try

 {

         // Getting context of a Device Server

         Context con = LinkServer.getContextManager().get("users.admin.deviceservers.c1", environment.getCallerController());

         

         if (con == null)

         {

                 throw new ScriptException("Device Server not available");

         }

         

         // Getting IP address variable

         DataTable val = con.getVariable("IP_setting", environment.getCallerController());

         // Changing IP address

         val.rec().setValue("IP_setting", "192.168.1.235");

         // Writing new value of variable

         con.setVariable("IP_setting", environment.getCallerController(), val);

         // Rebooting Device Server

         con.callFunction("reboot", environment.getCallerController());

         return null;

 }

 catch (ScriptException ex)

 {

         throw ex;

 }

 catch (Exception ex)

 {

         throw new ScriptException(ex);

 }

  }

}