Example usage for com.amazonaws.services.ec2.model RevokeSecurityGroupIngressRequest setFromPort

List of usage examples for com.amazonaws.services.ec2.model RevokeSecurityGroupIngressRequest setFromPort

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model RevokeSecurityGroupIngressRequest setFromPort.

Prototype


public void setFromPort(Integer fromPort) 

Source Link

Document

The start of port range for the TCP and UDP protocols, or an ICMP type number.

Usage

From source file:com.hpcloud.daas.ec2.AwsConsoleApp.java

License:Open Source License

public static void RevokeSecurityPort(int fromPort, int toPort, String securityGroupName) throws Exception {
    try {/*ww w. ja v a2  s  . co  m*/
        RevokeSecurityGroupIngressRequest revokeRequest = new RevokeSecurityGroupIngressRequest();
        revokeRequest.setFromPort(fromPort);
        revokeRequest.setIpProtocol("tcp");
        revokeRequest.setToPort(toPort);
        revokeRequest.setGroupName(securityGroupName);

        ec2.revokeSecurityGroupIngress(revokeRequest);

        System.out.println(
                "Security port revoked successfully.  from port (" + fromPort + ") - to port(" + toPort + ")");

    } catch (AmazonServiceException ase) {
        System.out.println(
                "Error : revoking security port : from port(" + fromPort + ") - to port(" + toPort + ")");
        System.out.println("Caught Exception: " + ase.getMessage());
        System.out.println("Reponse Status Code: " + ase.getStatusCode());
        System.out.println("Error Code: " + ase.getErrorCode());
        System.out.println("Request ID: " + ase.getRequestId());
    }
}

From source file:org.openinfinity.cloud.service.administrator.EC2Wrapper.java

License:Apache License

public void revokeIPs(String securityGroupName, String cidrIp, Integer fromPort, Integer toPort,
        String protocol) {//ww  w . j a v a  2 s  .c  o  m
    try {
        RevokeSecurityGroupIngressRequest request = new RevokeSecurityGroupIngressRequest();
        request.setGroupName(securityGroupName);
        request.setCidrIp(cidrIp);
        request.setFromPort(fromPort);
        request.setToPort(toPort);
        request.setIpProtocol(protocol);
        ec2.revokeSecurityGroupIngress(request);
    } catch (Exception e) {
        String message = e.getMessage();
        LOG.error("Cloud not revoke IP.s from security group: " + message);
        ExceptionUtil.throwSystemException(message, e);
    }
}