Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network.Protocol doesn't support the list of AWS vpc protocols #291

Open
pshafton opened this issue Nov 4, 2014 · 3 comments
Open

network.Protocol doesn't support the list of AWS vpc protocols #291

pshafton opened this issue Nov 4, 2014 · 3 comments

Comments

@pshafton
Copy link

pshafton commented Nov 4, 2014

In Amazon VPC regions the Firewalls support all of the following protocols...

http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

When you try to list the firewalls if one of them has included a protocol that is not in the current enum list

public enum Protocol {
/**
* The TCP protocol.
/
TCP,
/
*
* The UDP datagram protocol.
/
UDP,
/
*
* The ICMP protocol.
/
ICMP,
/
*
* IPsec
/
IPSEC,
/
*
* Any protocol
*/
ANY
}

Then an exception is thrown when we try to map this protocol value to an enum.

@maksimov
Copy link
Contributor

maksimov commented Nov 4, 2014

Hi @pshafton, thanks for your feedback. This may not be a core issue, but dasein-cloud-aws. Would you have the stacktrace from the exception? Thanks.

@pshafton
Copy link
Author

pshafton commented Nov 4, 2014

Yep. Here is the stack trace...

! java.lang.IllegalArgumentException: No enum constant org.dasein.cloud.network.Protocol.51
! at java.lang.Enum.valueOf(Enum.java:236) ~[na:1.7.0_67]
! at org.dasein.cloud.network.Protocol.valueOf(Protocol.java:30) ~[dasein-cloud-core-2014.08.1.jar:na]
! at org.dasein.cloud.aws.network.SecurityGroup.toFirewallRules(SecurityGroup.java:926) ~[dasein-cloud-aws-2014.08.3.jar:na]
! at org.dasein.cloud.aws.network.SecurityGroup.toFirewall(SecurityGroup.java:865) ~[dasein-cloud-aws-2014.08.3.jar:na]
! at org.dasein.cloud.aws.network.SecurityGroup.list(SecurityGroup.java:557) ~[dasein-cloud-aws-2014.08.3.jar:na]

There are kind of 2 issues. The first is that to return a Firewall Object you also need to return a FirewallRule. In the aws code to parse the aws response it needs to create a FirewallRule and the FirewallRule includes a Protocol member variable. So the aws code will somehow have to map the ipProtocol response into a valid Protocol. This is kind of where I thought the core change would have to come in. The aws layer can only map into the valid list of enums that exist.

The code in question lives in the toFirewallRules(@nonnull String securityGroupId, @nullable Node node, @nonnull Direction direction) method in the aws/network/SecurityGroup.java class and this is the code that handles the Protocol...

     if( name.equals("ipProtocol") ) {
            String val = attr.getFirstChild().getNodeValue().trim();

            if( !val.equals("") && !val.equals("-1") ) {
                protocol = Protocol.valueOf(attr.getFirstChild().getNodeValue().trim().toUpperCase());
            } else {
                protocol = Protocol.ANY;
            }
        }

@maksimov
Copy link
Contributor

maksimov commented Nov 4, 2014

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants