From c4f258fa8217cca50f48598a116156c840bec2c1 Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Mon, 14 May 2012 13:20:13 +0530 Subject: [PATCH] CS-14728. ec2-revoke: Not able to revoke the icmp rules. Presented with "Server.InternalError:Cannot find matching ruleid" Resolved. ICMP type and code was not correctly set in the request. --- .../com/cloud/bridge/service/EC2SoapServiceImpl.java | 10 +++++++--- .../com/cloud/bridge/service/core/ec2/EC2Engine.java | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index da0b20c11f3..7177c4e5034 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -134,9 +134,13 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { for (IpPermissionType ipPerm : items) { EC2IpPermission perm = new EC2IpPermission(); perm.setProtocol( ipPerm.getIpProtocol()); - perm.setFromPort( ipPerm.getFromPort()); - perm.setToPort( ipPerm.getToPort()); - + if (ipPerm.getIpProtocol().equalsIgnoreCase("icmp")) { + perm.setIcmpType( Integer.toString(ipPerm.getFromPort())); + perm.setIcmpCode( Integer.toString(ipPerm.getToPort())); + } else { + perm.setFromPort( ipPerm.getFromPort()); + perm.setToPort( ipPerm.getToPort()); + } UserIdGroupPairSetType groups = ipPerm.getGroups(); if (null != groups && groups.getItem() != null) { UserIdGroupPairType[] groupItems = groups.getItem(); diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index 70404bccc93..495f2bdd1fa 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -331,7 +331,7 @@ public class EC2Engine { CloudStackSecurityGroupIngress resp = null; if (ipPerm.getProtocol().equalsIgnoreCase("icmp")) { resp = getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null, null, - ipPerm.getToPort().toString(), ipPerm.getFromPort().toString(), ipPerm.getProtocol(), null, + ipPerm.getIcmpCode(), ipPerm.getIcmpType(), ipPerm.getProtocol(), null, request.getName(), null, secGroupList); } else { resp = getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null,