OpenstackIaasHandler extends AbstractThreadedTargetHandler { static String expandVolumeName( String nameTemplate, String appName, String instanceName ) { String name = nameTemplate.replace( TPL_VOLUME_NAME, instanceName ); name = name.replace( TPL_VOLUME_APP, appName ); name = name.replaceAll( "[\\W_-]", "-" ); return name; }  @Override String getTargetId(); @Override String createMachine( TargetHandlerParameters parameters ); @Override boolean isMachineRunning( TargetHandlerParameters parameters, String machineId ); @Override MachineConfigurator machineConfigurator( TargetHandlerParameters parameters, String machineId ); @Override void terminateMachine( TargetHandlerParameters parameters, String machineId ); @Override String retrievePublicIpAddress( TargetHandlerParameters parameters, String machineId ); static final String TARGET_ID; }
@Test public void testExpandVolumeName() { String name = DEFAULTS.get( VOLUME_NAME_PREFIX ); Assert.assertEquals( "roboconf-app-inst", expandVolumeName( name, "app", "inst" )); name = "cache-" + TPL_VOLUME_NAME; Assert.assertEquals( "cache-inst4", expandVolumeName( name, "app2", "inst4" )); name = "pre-" + TPL_VOLUME_APP + "-post"; Assert.assertEquals( "pre-app2-post", expandVolumeName( name, "app2", "inst" )); name = "pre-" + TPL_VOLUME_APP + "-post 2"; Assert.assertEquals( "pre-app-51--post-2", expandVolumeName( name, "app 51 ", "vm 1" )); }