Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

intermediate

  • Loading branch information...
commit 8ff7f4171fcc53f1cf8b80080f70b56771d68ba5 1 parent 0dfe9f3
chris grzegorczyk grze authored
3  clc/modules/storage-manager/src/main/java/edu/ucsb/eucalyptus/cloud/ws/WalrusManager.java
View
@@ -1313,6 +1313,7 @@ private void sendObject(Channel channel, MappingHttpResponse httpResponse, Strin
httpResponse.addHeader( HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(size));
}
channel.write(httpResponse);
+// channel.write(file);
ChannelFuture writeFuture = channel.write(file);
writeFuture.addListener(ChannelFutureListener.CLOSE);
} catch(Exception ex) {
@@ -1599,4 +1600,4 @@ public CopyObjectResponseType copyObject(CopyObjectType request) throws Eucalypt
throw new NoSuchBucketException(sourceBucket);
}
}
-}
+}
5 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/handlers/ServiceSinkHandler.java
View
@@ -63,8 +63,8 @@ public void handleUpstream( ChannelHandlerContext ctx, ChannelEvent e ) throws E
MappingHttpResponse response = new MappingHttpResponse( message.getProtocolVersion( ) );
response.setMessage( reply );
if(!(reply instanceof WalrusDataGetResponseType)) {
- ChannelFuture writeFuture = Channels.write( ctx.getChannel( ), response );;
- writeFuture.addListener(ChannelFutureListener.CLOSE);
+ ChannelFuture writeFuture = Channels.write( ctx.getChannel( ), response );
+ writeFuture.addListener( ChannelFutureListener.CLOSE );
}
}
}
@@ -85,6 +85,7 @@ public Dispatcher(ChannelHandlerContext ctx, EucalyptusMessage msg, MappingHttpM
}
public void run() {
+ //:: register endpoint w/ mule specific to this message :://
Messaging.dispatch( "vm://RequestQueue", msg );
EucalyptusMessage reply = ReplyQueue.getReply( msg.getCorrelationId() );
39 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/server/ElasticFoxPipeline.java
View
@@ -0,0 +1,39 @@
+package com.eucalyptus.ws.server;
+
+import java.util.List;
+
+import org.jboss.netty.handler.codec.http.HttpRequest;
+
+import com.eucalyptus.ws.MappingHttpRequest;
+import com.eucalyptus.ws.stages.ElasticFoxMangleStage;
+import com.eucalyptus.ws.stages.UnrollableStage;
+
+public class ElasticFoxPipeline extends EucalyptusQueryPipeline {
+
+ @Override
+ protected void addStages( List<UnrollableStage> stages ) {
+ super.addStages( stages );
+ stages.add( new ElasticFoxMangleStage( ) );
+ }
+
+ @Override
+ protected boolean checkAccepts( HttpRequest message ) {
+ if ( message instanceof MappingHttpRequest ) {
+ MappingHttpRequest httpRequest = ( MappingHttpRequest ) message;
+ String userAgent = httpRequest.getHeader( "User-Agent" );
+ if( userAgent != null && userAgent.matches( ".*Elasticfox.*" )){
+ httpRequest.setServicePath( httpRequest.getServicePath( ).replaceAll( "Eucalyptus/", "Eucalyptus" ) );
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String getPipelineName( ) {
+ return "elasticfox-"+super.getPipelineName( );
+ }
+
+
+
+}
89 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/stages/ElasticFoxMangleHandler.java
View
@@ -0,0 +1,89 @@
+package com.eucalyptus.ws.stages;
+
+import java.util.ArrayList;
+
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.MessageEvent;
+
+import com.eucalyptus.ws.MappingHttpRequest;
+import com.eucalyptus.ws.MappingHttpResponse;
+import com.eucalyptus.ws.handlers.MessageStackHandler;
+import com.google.common.collect.Lists;
+
+import edu.ucsb.eucalyptus.msgs.DeregisterImageType;
+import edu.ucsb.eucalyptus.msgs.DescribeImageAttributeType;
+import edu.ucsb.eucalyptus.msgs.DescribeImagesResponseType;
+import edu.ucsb.eucalyptus.msgs.DescribeImagesType;
+import edu.ucsb.eucalyptus.msgs.DescribeInstancesResponseType;
+import edu.ucsb.eucalyptus.msgs.ImageDetails;
+import edu.ucsb.eucalyptus.msgs.ModifyImageAttributeType;
+import edu.ucsb.eucalyptus.msgs.ReservationInfoType;
+import edu.ucsb.eucalyptus.msgs.ResetImageAttributeType;
+import edu.ucsb.eucalyptus.msgs.RunInstancesType;
+import edu.ucsb.eucalyptus.msgs.RunningInstancesItemType;
+
+public class ElasticFoxMangleHandler extends MessageStackHandler {
+
+ @Override
+ public void incomingMessage( ChannelHandlerContext ctx, MessageEvent event ) throws Exception {
+ if ( event.getMessage( ) instanceof MappingHttpResponse ) {
+ MappingHttpResponse message = ( MappingHttpResponse ) event.getMessage( );
+ if ( message.getMessage( ) instanceof ModifyImageAttributeType ) {
+ ModifyImageAttributeType pure = ( ( ModifyImageAttributeType ) message.getMessage( ) );
+ pure.setImageId( purifyImageIn( pure.getImageId( ) ) );
+ } else if ( message.getMessage( ) instanceof DescribeImageAttributeType ) {
+ DescribeImageAttributeType pure = ( ( DescribeImageAttributeType ) message.getMessage( ) );
+ pure.setImageId( purifyImageIn( pure.getImageId( ) ) );
+ } else if ( message.getMessage( ) instanceof ResetImageAttributeType ) {
+ ResetImageAttributeType pure = ( ( ResetImageAttributeType ) message.getMessage( ) );
+ pure.setImageId( purifyImageIn( pure.getImageId( ) ) );
+ } else if ( message.getMessage( ) instanceof DescribeImagesType ) {
+ ArrayList<String> strs = Lists.newArrayList( );
+ for ( String imgId : ( ( DescribeImagesType ) message.getMessage( ) ).getImagesSet( ) ) {
+ strs.add( purifyImageIn( imgId ) );
+ }
+ ( ( DescribeImagesType ) message.getMessage( ) ).setImagesSet( strs );
+ } else if ( message.getMessage( ) instanceof DeregisterImageType ) {
+ DeregisterImageType pure = ( ( DeregisterImageType ) message.getMessage( ) );
+ pure.setImageId( purifyImageIn( pure.getImageId( ) ) );
+ } else if ( message.getMessage( ) instanceof RunInstancesType ) {
+ RunInstancesType pure = ( ( RunInstancesType ) message.getMessage( ) );
+ pure.setImageId( purifyImageIn( pure.getImageId( ) ) );
+ pure.setKernelId( purifyImageIn( pure.getKernelId( ) ) );
+ pure.setRamdiskId( purifyImageIn( pure.getRamdiskId( ) ) );
+ }
+
+ }
+
+ }
+
+ private String purifyImageIn( String id ) {
+ id = "e" + id.substring( 1, 4 ) + id.substring( 4 ).toUpperCase( );
+ return id;
+ }
+
+ @Override
+ public void outgoingMessage( ChannelHandlerContext ctx, MessageEvent event ) throws Exception {
+ if ( event.getMessage( ) instanceof MappingHttpRequest ) {
+ MappingHttpRequest message = ( MappingHttpRequest ) event.getMessage( );
+ if ( message.getMessage( ) instanceof DescribeImagesResponseType ) {
+ DescribeImagesResponseType purify = ( DescribeImagesResponseType ) message.getMessage( );
+ for ( ImageDetails img : purify.getImagesSet( ) ) {
+ img.setImageId( img.getImageId( ).replaceFirst( "^e", "a" ).toLowerCase( ) );
+ if ( img.getKernelId( ) != null ) img.setKernelId( img.getKernelId( ).replaceFirst( "^e", "a" ).toLowerCase( ) );
+ if ( img.getRamdiskId( ) != null ) img.setRamdiskId( img.getRamdiskId( ).replaceFirst( "^e", "a" ).toLowerCase( ) );
+ }
+ } else if ( message.getMessage( ) instanceof DescribeInstancesResponseType ) {
+ DescribeInstancesResponseType purify = ( DescribeInstancesResponseType ) message.getMessage( );
+ for ( ReservationInfoType rsvInfo : purify.getReservationSet( ) ) {
+ for ( RunningInstancesItemType r : rsvInfo.getInstancesSet( ) ) {
+ r.setImageId( r.getImageId( ).replaceFirst( "^e", "a" ).toLowerCase( ) );
+ if ( r.getKernel( ) != null ) r.setKernel( r.getKernel( ).replaceFirst( "^e", "a" ).toLowerCase( ) );
+ if ( r.getRamdisk( ) != null ) r.setRamdisk( r.getRamdisk( ).replaceFirst( "^e", "a" ).toLowerCase( ) );
+ }
+ }
+ }
+ }
+ }
+
+}
20 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/stages/ElasticFoxMangleStage.java
View
@@ -0,0 +1,20 @@
+package com.eucalyptus.ws.stages;
+import org.jboss.netty.channel.ChannelPipeline;
+
+import com.eucalyptus.ws.handlers.MessageStackHandler;
+
+
+
+public class ElasticFoxMangleStage implements UnrollableStage {
+
+ @Override
+ public String getStageName( ) {
+ return "elasticfox-mangler";
+ }
+
+ @Override
+ public void unrollStage( ChannelPipeline pipeline ) {
+
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.