После обновления от 21,01 не работает скрипт по шлюзам версия 5,0 Вот скрипт import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.StringTokenizer; import bitel.billing.common.module.ipn.IPNContractStatus; import bitel.billing.server.ipn.GateWorker; import bitel.billing.server.ipn.UserStatus; import bitel.billing.server.ipn.bean.ManadUtils; import bitel.billing.server.ipn.bean.VlanManager; import bitel.billing.server.util.DefaultServerSetup; import bitel.billing.server.util.Utils; //import bitel.billing.server.util.telnet.OperationTimedoutException; import bitel.billing.server.util.telnet.TelnetSession; import ru.bitel.bgbilling.common.DefaultSetup; import bitel.billing.common.IPUtils; import bitel.billing.server.ipn.bean.GateType; import bitel.billing.server.ipn.bean.RuleType; import bitel.billing.server.ipn.bean.VlanManager; import bitel.billing.server.util.Utils; //import bitel.billing.server.util.telnet.OperationTimedoutException; import bitel.billing.server.util.telnet.TelnetSession; protected void doSync() { try { host = gate.getHost(); port = gate.getPort(); DefaultServerSetup gateSetup = new DefaultServerSetup( gate.getConfig(), "\r\n" );
pswdLogin = gate.getKeyword(); login = gateSetup.getStringValue( "login"); pswdCfg = gateSetup.getStringValue( "cfg.pswd"); timeout = gateSetup.getIntValue( "timeout", 0 );
result = new StringBuffer();
session = new TelnetSession( host, port); session.setTimeout( timeout ); session.setLoginPromptSequence( ":" ); session.connect(); result.append( session.doCommand( login ) ); session.setLoginPromptSequence( "#" ); result.append( session.doCommand( pswdLogin ) );
result.append( session.doCommand( "terminal length 0" ) ); result.append( session.doCommand( "terminal width 0" ) ); result.append( session.doCommand( "configure terminal" ) ); log.debug( "execute commands" ); doCommands( session, result); result.append( session.doCommand( "exit" ) ); session.doCommandAsync( "exit" ); //log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); //log.info( result ); //log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); //log.debug( "ok" ); } catch (Exception e) { throw new RuntimeException ( e ); } //log.info( "end of cisco........................................................"); } protected void add() { } //private void doCommands( TelnetSession session, StringBuffer result) throws IOException, OperationTimedoutException private void doCommands( TelnetSession session, StringBuffer result) throws IOException { for( UserStatus status : statusList ) { VlanManager manager = new VlanManager(status.mid, con); gateId = gate.getId(); //log.info("gateId=" + gateId); vid = manager.getVlan( gateId, status.contractId ); //log.info("vid=" + vid); //TODO - подумать что сделать справилами на добавление rules = null; if (status.status == IPNContractStatus.STATUS_OPEN) { rules = getOpenRules( status, vid ); } else if (status.status == IPNContractStatus.STATUS_REMOVED) { rules = getRemoveRules( status, vid ); } //if closed and etc else { rules = getCloseRules( status, vid ); } if (vid > 0) { for ( String rule : rules ) { result.append( session.doCommand( rule ) ); } } } } getOpenRules( status, vid ) { return getRules( status, "\\[OPEN\\](.*)\\[/OPEN\\]", vid ); } getCloseRules( status, vid ) { return getRules( status, "\\[CLOSE\\](.*)\\[/CLOSE\\]", vid ); } getRemoveRules( UserStatus status, int vid ) { return getRules( status, "\\[REMOVE\\](.*)\\[/REMOVE\\]", vid ); } getRules( status, template, vid ) { // пользовательское правило, без типа - то все оставляем как есть rule = status.rule.getRuleText(); //log.info("rule=" + rule); //типизированное правило if( status.ruleType != null ) { rule = generateRule( rule, status.gateType, status.ruleType, vid ); } //log.info("rule=" + rule); pattern = Pattern.compile( template, Pattern.DOTALL ); m = pattern.matcher( rule ); if (m.find()) { rule = m.group( 1 ); } rule.replaceAll( "\r", "" ); parts = rule.split( "\n" ); result = new ArrayList(); for ( String part : parts ) { if ( !Utils.isEmptyString( part )) { result.add( part ); } } return result; } generateRule( addresses, gateType, ruleType, int vid ) { ruleText = ManadUtils.getRule( gateType, ruleType ); replacements = new HashMap (); if ( vid > 0) { replacements.put( "\\{VID\\}", String.valueOf( vid ) ); } return ManadUtils.generateRule( ruleText, addresses, replacements, ruleType ); }
В логах ошибка 01-25/15:00:02 ERROR [Thread-15] CiscoVlanGateWorker - Gate unaccesible - 10.1.1.11 01-25/15:00:02 ERROR [Thread-15] CiscoVlanGateWorker - ------------------------- 01-25/15:00:02 ERROR [Thread-15] CiscoVlanGateWorker - error: TargetError : at Line: 88 : in file: inline evaluation of: ``import java.io.IOException; import java.util.ArrayList; import java.util.HashMap . . Target exception: java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out java.lang.RuntimeException: TargetError : at Line: 88 : in file: inline evaluation of: ``import java.io.IOException; import java.util.ArrayList; import java.util.HashMap . . . '' : throw new RuntimeException Target exception: java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out at bitel.billing.server.ipn.GateWorker$Scripter.runScriptSync(GateWorker.java:231) at bitel.billing.server.ipn.GateWorker.runSync(GateWorker.java:107) at bitel.billing.server.ipn.GateWorker.run(GateWorker.java:85) Caused by: TargetError : at Line: 88 : in file: inline evaluation of: ``import java.io.IOException; import java.util.ArrayList; import java.util.HashMap . . . '' : throw new RuntimeException ( e ) ; Target exception: java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out at bsh.BSHThrowStatement.eval(Unknown Source) at bsh.BSHBlock.evalBlock(Unknown Source) at bsh.BSHBlock.eval(Unknown Source) at bsh.BSHBlock.eval(Unknown Source) at bsh.BSHTryStatement.eval(Unknown Source) at bsh.BSHBlock.evalBlock(Unknown Source) at bsh.BSHBlock.eval(Unknown Source) at bsh.BshMethod.invokeImpl(Unknown Source) at bsh.BshMethod.invoke(Unknown Source) at bsh.BshMethod.invoke(Unknown Source) at bitel.billing.server.ipn.GateWorker$Scripter.invokeMethod(GateWorker.java:257) at bitel.billing.server.ipn.GateWorker$Scripter.runScriptSync(GateWorker.java:218) ... 2 more
Мы заремили //RuntimeException ( e ) ;, ошибок не появляется но и в шлюз ничего не добавляется.
Скажите что изменилось в api?
|