@Test public void testExecuteScriptResources_ok() throws Exception { Assume.assumeTrue( TestUtils.isUnix()); File scriptsDir = this.folder.newFolder(); AgentUtils.executeScriptResources( scriptsDir ); Assert.assertEquals(0, scriptsDir.listFiles().length); File script = new File( scriptsDir, "toto.sh" ); Utils.writeStringInto( "#!/bin/bash\necho totototototo > toto.txt", script); Assert.assertEquals( 1, scriptsDir.listFiles().length ); File toto = new File( scriptsDir,"toto.txt" ); Assert.assertFalse( toto.exists()); AgentUtils.executeScriptResources( scriptsDir ); Assert.assertFalse( toto.exists()); Assert.assertEquals( 1, scriptsDir.listFiles().length ); Assert.assertTrue( script.delete()); script = new File( scriptsDir, "toto." + Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX + "sh" ); Utils.writeStringInto( "#!/bin/bash\necho totototototo > toto.txt", script); AgentUtils.executeScriptResources( scriptsDir ); Assert.assertTrue( toto.exists()); Assert.assertEquals( 2, scriptsDir.listFiles().length ); String s = Utils.readFileContent( toto ); Assert.assertEquals( "totototototo", s.trim()); }
public static void executeScriptResources( File scriptsDir ) throws IOException { if( scriptsDir.isDirectory()) { List<File> scriptFiles = Utils.listAllFiles( scriptsDir ); Logger logger = Logger.getLogger( AgentUtils.class.getName()); for( File script : scriptFiles) { if( script.getName().contains( Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX )) { script.setExecutable( true ); String[] command = { script.getAbsolutePath()}; try { ProgramUtils.executeCommand( logger, command, script.getParentFile(), null, null, null ); } catch( InterruptedException e ) { Utils.logException( logger, e ); } } } } }
AgentUtils { public static void executeScriptResources( File scriptsDir ) throws IOException { if( scriptsDir.isDirectory()) { List<File> scriptFiles = Utils.listAllFiles( scriptsDir ); Logger logger = Logger.getLogger( AgentUtils.class.getName()); for( File script : scriptFiles) { if( script.getName().contains( Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX )) { script.setExecutable( true ); String[] command = { script.getAbsolutePath()}; try { ProgramUtils.executeCommand( logger, command, script.getParentFile(), null, null, null ); } catch( InterruptedException e ) { Utils.logException( logger, e ); } } } } } }
AgentUtils { public static void executeScriptResources( File scriptsDir ) throws IOException { if( scriptsDir.isDirectory()) { List<File> scriptFiles = Utils.listAllFiles( scriptsDir ); Logger logger = Logger.getLogger( AgentUtils.class.getName()); for( File script : scriptFiles) { if( script.getName().contains( Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX )) { script.setExecutable( true ); String[] command = { script.getAbsolutePath()}; try { ProgramUtils.executeCommand( logger, command, script.getParentFile(), null, null, null ); } catch( InterruptedException e ) { Utils.logException( logger, e ); } } } } } private  AgentUtils(); }
AgentUtils { public static void executeScriptResources( File scriptsDir ) throws IOException { if( scriptsDir.isDirectory()) { List<File> scriptFiles = Utils.listAllFiles( scriptsDir ); Logger logger = Logger.getLogger( AgentUtils.class.getName()); for( File script : scriptFiles) { if( script.getName().contains( Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX )) { script.setExecutable( true ); String[] command = { script.getAbsolutePath()}; try { ProgramUtils.executeCommand( logger, command, script.getParentFile(), null, null, null ); } catch( InterruptedException e ) { Utils.logException( logger, e ); } } } } } private  AgentUtils(); static boolean isValidIP( String ip ); static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ); static void executeScriptResources( File scriptsDir ); static void deleteInstanceResources( Instance instance ); static void changeRoboconfLogLevel( String logLevel, String etcDir ); static Map<String,byte[]> collectLogs( String karafData ); static String findIpAddress( String networkInterface ); static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ); }
AgentUtils { public static void executeScriptResources( File scriptsDir ) throws IOException { if( scriptsDir.isDirectory()) { List<File> scriptFiles = Utils.listAllFiles( scriptsDir ); Logger logger = Logger.getLogger( AgentUtils.class.getName()); for( File script : scriptFiles) { if( script.getName().contains( Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX )) { script.setExecutable( true ); String[] command = { script.getAbsolutePath()}; try { ProgramUtils.executeCommand( logger, command, script.getParentFile(), null, null, null ); } catch( InterruptedException e ) { Utils.logException( logger, e ); } } } } } private  AgentUtils(); static boolean isValidIP( String ip ); static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ); static void executeScriptResources( File scriptsDir ); static void deleteInstanceResources( Instance instance ); static void changeRoboconfLogLevel( String logLevel, String etcDir ); static Map<String,byte[]> collectLogs( String karafData ); static String findIpAddress( String networkInterface ); static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ); static final String INJECTED_CONFIGS_DIR; }