Example usage for com.amazonaws.services.ec2.model UserIdGroupPair setGroupName

List of usage examples for com.amazonaws.services.ec2.model UserIdGroupPair setGroupName

Introduction

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

Prototype


public void setGroupName(String groupName) 

Source Link

Document

The name of the security group.

Usage

From source file:com.norbl.cbp.ppe.SecurityGroupFactory.java

License:Open Source License

private IpPermission createIPPermissionGroup(String protocol, int fromPort, int toPort, String group) {
    IpPermission ipp = new IpPermission();
    ipp.setIpProtocol(protocol);// ww w  .j av a  2s.  co m
    ipp.setFromPort(fromPort);
    ipp.setToPort(toPort);

    List<UserIdGroupPair> gps = new ArrayList<UserIdGroupPair>();
    UserIdGroupPair gp = new UserIdGroupPair();
    gp.setGroupName(group);
    gp.setUserId(params.getAWSUserID());
    gps.add(gp);

    ipp.setUserIdGroupPairs(gps);

    return (ipp);
}

From source file:jp.primecloud.auto.aws.typica.converter.UserIdGroupPairConverter.java

License:Open Source License

@Override
protected UserIdGroupPair convertObject(String[] from) {
    UserIdGroupPair to = new UserIdGroupPair();

    to.setUserId(from[0]);//www  . j  a  v  a2 s .co m
    to.setGroupName(from[1]);

    return to;
}

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

License:Apache License

public void authorizeGroup(String securityGroupName, String sourceGroupName, String sourceGroupOwner,
        Integer fromPort, Integer toPort, String protocol) {
    try {//from w  ww.ja  v a  2 s .co  m
        AuthorizeSecurityGroupIngressRequest request = new AuthorizeSecurityGroupIngressRequest();
        //   if(this.cloudType == InstanceService.CLOUD_TYPE_EUCALYPTUS) {
        /*      request.setFromPort(fromPort);
              request.setToPort(toPort);
              request.setSourceSecurityGroupName(sourceGroupName);
              request.setSourceSecurityGroupOwnerId(sourceGroupOwner);
              request.setIpProtocol(protocol); */
        //      } else {

        UserIdGroupPair pair = new UserIdGroupPair();
        pair.setGroupName(sourceGroupName);
        pair.setUserId(sourceGroupOwner);
        List<UserIdGroupPair> idList = new ArrayList<UserIdGroupPair>();
        idList.add(pair);
        IpPermission perm = new IpPermission();
        perm.setUserIdGroupPairs(idList);
        perm.setFromPort(fromPort);
        perm.setToPort(toPort);
        perm.setIpProtocol(protocol);
        List<IpPermission> permList = new ArrayList<IpPermission>();
        permList.add(perm);
        request.setIpPermissions(permList);
        //      }
        request.setGroupName(securityGroupName);

        ec2.authorizeSecurityGroupIngress(request);
    } catch (Exception e) {
        String message = e.getMessage();
        LOG.error("Could not set authorized IP:s to security group: " + message);
        ExceptionUtil.throwSystemException(message, e);
    }
}

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

License:Apache License

public void revokeGroup(String securityGroupName, String sourceGroupName, String sourceGroupOwner,
        Integer fromPort, Integer toPort, String protocol) {
    try {/*w  ww. j a  v a 2 s.c  om*/
        RevokeSecurityGroupIngressRequest request = new RevokeSecurityGroupIngressRequest();
        UserIdGroupPair pair = new UserIdGroupPair();
        pair.setGroupName(sourceGroupName);
        pair.setUserId(sourceGroupOwner);
        List<UserIdGroupPair> idList = new ArrayList<UserIdGroupPair>();
        idList.add(pair);
        IpPermission perm = new IpPermission();
        perm.setUserIdGroupPairs(idList);
        perm.setFromPort(fromPort);
        perm.setToPort(toPort);
        perm.setIpProtocol(protocol);
        List<IpPermission> permList = new ArrayList<IpPermission>();
        permList.add(perm);
        request.setIpPermissions(permList);

        request.setGroupName(securityGroupName);
        ec2.revokeSecurityGroupIngress(request);
    } catch (Exception e) {
        String message = e.getMessage();
        LOG.error("Could not set authorized IP:s to security group: " + message);
        ExceptionUtil.throwSystemException(message, e);
    }
}