Package com.cloud.bridge.service.core.ec2

Examples of com.cloud.bridge.service.core.ec2.EC2IpPermission


    else { response.sendError(530, "Missing GroupName parameter" ); return; }

    // -> not clear how many parameters there are until we fail to get IpPermissions.n.IpProtocol
    int nCount = 1;
    do
    {    EC2IpPermission perm = new EC2IpPermission();        

            String[] protocol = request.getParameterValues( "IpPermissions." + nCount + ".IpProtocol" );
        if ( null != protocol && 0 < protocol.length )
           perm.setProtocol( protocol[0] );
        else break;

            String[] fromPort = request.getParameterValues( "IpPermissions." + nCount + ".FromPort" );
        if (null != fromPort && 0 < fromPort.length) perm.setProtocol( fromPort[0] );

            String[] toPort = request.getParameterValues( "IpPermissions." + nCount + ".ToPort" );
        if (null != toPort && 0 < toPort.length) perm.setProtocol( toPort[0] );
               
            // -> list: IpPermissions.n.IpRanges.m.CidrIp
      int mCount = 1;
          do
          String[] ranges = request.getParameterValues( "IpPermissions." + nCount + ".IpRanges." + mCount + ".CidrIp" );
           if ( null != ranges && 0 < ranges.length)
              perm.addIpRange( ranges[0] );
           else break;
           mCount++;
          
          } while( true );

            // -> list: IpPermissions.n.Groups.m.UserId and IpPermissions.n.Groups.m.GroupName
          mCount = 1;
          do
          String[] user = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".UserId" );
           if ( null == user || 0 == user.length) break;
 
           String[] name = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".GroupName" );
         if ( null == name || 0 == name.length) break;

         EC2SecurityGroup group = new EC2SecurityGroup();
         group.setAccount( user[0] );
         group.setName( name[0] );
         perm.addUser( group );
           mCount++;
          
          } while( true );
         
          // -> multiple IP permissions can be specified per group name
View Full Code Here


        EC2AuthorizeRevokeSecurityGroup request = new  EC2AuthorizeRevokeSecurityGroup();

        request.setName( groupName );
       
        for (IpPermissionType ipPerm : items) {
         EC2IpPermission perm = new EC2IpPermission();        
         perm.setProtocol( ipPerm.getIpProtocol());
         perm.setFromPort( ipPerm.getFromPort());
         perm.setToPort( ipPerm.getToPort());
   
         UserIdGroupPairSetType groups = ipPerm.getGroups();
         if (null != groups && groups.getItem() != null) {
           UserIdGroupPairType[] groupItems = groups.getItem();
           for (UserIdGroupPairType groupPair : groupItems) {
            EC2SecurityGroup user = new EC2SecurityGroup();
            user.setName( groupPair.getGroupName());
            user.setAccount( groupPair.getUserId());
            perm.addUser( user );
           }       
         }      
  
         IpRangeSetType ranges = ipPerm.getIpRanges();
         if (ranges != null && ranges.getItem() != null) {
           IpRangeItemType[] rangeItems = ranges.getItem();
           for (IpRangeItemType ipRange: rangeItems)
            perm.addIpRange( ipRange.getCidrIp() );
        
  
         request.addIpPermission( perm );
        }
        return request;
View Full Code Here

        EC2AuthorizeRevokeSecurityGroup request = new EC2AuthorizeRevokeSecurityGroup();

        request.setName(groupName);

        for (IpPermissionType ipPerm : items) {
            EC2IpPermission perm = new EC2IpPermission();
            perm.setProtocol(ipPerm.getIpProtocol());
            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();
                for (UserIdGroupPairType groupPair : groupItems) {
                    EC2SecurityGroup user = new EC2SecurityGroup();
                    user.setName(groupPair.getGroupName());
                    user.setAccount(groupPair.getUserId());
                    perm.addUser(user);
                }
            }

            IpRangeSetType ranges = ipPerm.getIpRanges();
            if (ranges != null && ranges.getItem() != null) {
                IpRangeItemType[] rangeItems = ranges.getItem();
                for (IpRangeItemType ipRange : rangeItems) {
                    perm.addIpRange(ipRange.getCidrIp());
                    perm.setCIDR(ipRange.getCidrIp());
                }
            }

            request.addIpPermission(perm);
        }
View Full Code Here

        String[] groupName = request.getParameterValues( "GroupName" );
    if ( null != groupName && 0 < groupName.length )
       EC2request.setName( groupName[0] );
    else { response.sendError(530, "Missing GroupName parameter" ); return; }

    EC2IpPermission perm = new EC2IpPermission();        

        String[] protocol = request.getParameterValues( "IpProtocol" );
    if ( null != protocol && 0 < protocol.length )
         perm.setProtocol( protocol[0] );
    else { response.sendError(530, "Missing IpProtocol parameter" ); return; }

        String[] fromPort = request.getParameterValues( "FromPort" );
      if ( null != fromPort && 0 < fromPort.length )
         perm.setProtocol( fromPort[0] );
    else { response.sendError(530, "Missing FromPort parameter" ); return; }

        String[] toPort = request.getParameterValues( "ToPort" );
    if ( null != toPort && 0 < toPort.length )
       perm.setProtocol( toPort[0] );
    else { response.sendError(530, "Missing ToPort parameter" ); return; }
               
      String[] ranges = request.getParameterValues( "CidrIp" );
    if ( null != ranges && 0 < ranges.length)
        perm.addIpRange( ranges[0] );
    else { response.sendError(530, "Missing CidrIp parameter" ); return; }
   
      String[] user = request.getParameterValues( "SourceSecurityGroupOwnerId" );
    if ( null == user || 0 == user.length) {
         response.sendError(530, "Missing SourceSecurityGroupOwnerId parameter" );
         return;
    }
 
    String[] name = request.getParameterValues( "SourceSecurityGroupName" );
    if ( null == name || 0 == name.length) {
         response.sendError(530, "Missing SourceSecurityGroupName parameter" );
         return;    
    }

    EC2SecurityGroup group = new EC2SecurityGroup();
    group.setAccount( user[0] );
    group.setName( name[0] );
    perm.addUser( group );
      EC2request.addIpPermission( perm )
   
      // -> execute the request
        RevokeSecurityGroupIngressResponse EC2response = EC2SoapServiceImpl.toRevokeSecurityGroupIngressResponse(
            ServiceProvider.getInstance().getEC2Engine().revokeSecurityGroup( EC2request ));
View Full Code Here

    else { response.sendError(530, "Missing GroupName parameter" ); return; }

    // -> not clear how many parameters there are until we fail to get IpPermissions.n.IpProtocol
    int nCount = 1;
    do
    {    EC2IpPermission perm = new EC2IpPermission();        

            String[] protocol = request.getParameterValues( "IpPermissions." + nCount + ".IpProtocol" );
        if ( null != protocol && 0 < protocol.length )
           perm.setProtocol( protocol[0] );
        else break;

            String[] fromPort = request.getParameterValues( "IpPermissions." + nCount + ".FromPort" );
        if (null != fromPort && 0 < fromPort.length) perm.setProtocol( fromPort[0] );

            String[] toPort = request.getParameterValues( "IpPermissions." + nCount + ".ToPort" );
        if (null != toPort && 0 < toPort.length) perm.setProtocol( toPort[0] );
               
            // -> list: IpPermissions.n.IpRanges.m.CidrIp
      int mCount = 1;
          do
          String[] ranges = request.getParameterValues( "IpPermissions." + nCount + ".IpRanges." + mCount + ".CidrIp" );
           if ( null != ranges && 0 < ranges.length)
              perm.addIpRange( ranges[0] );
           else break;
           mCount++;
          
          } while( true );

            // -> list: IpPermissions.n.Groups.m.UserId and IpPermissions.n.Groups.m.GroupName
          mCount = 1;
          do
          String[] user = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".UserId" );
           if ( null == user || 0 == user.length) break;
 
           String[] name = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".GroupName" );
         if ( null == name || 0 == name.length) break;

         EC2SecurityGroup group = new EC2SecurityGroup();
         group.setAccount( user[0] );
         group.setName( name[0] );
         perm.addUser( group );
           mCount++;
          
          } while( true );
         
          // -> multiple IP permissions can be specified per group name
View Full Code Here

        EC2AuthorizeRevokeSecurityGroup request = new  EC2AuthorizeRevokeSecurityGroup();

        request.setName( groupName );
       
        for (IpPermissionType ipPerm : items) {
         EC2IpPermission perm = new EC2IpPermission();        
         perm.setProtocol( ipPerm.getIpProtocol());
           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();
           for (UserIdGroupPairType groupPair : groupItems) {
            EC2SecurityGroup user = new EC2SecurityGroup();
            user.setName( groupPair.getGroupName());
            user.setAccount( groupPair.getUserId());
            perm.addUser( user );
           }       
         }      
  
         IpRangeSetType ranges = ipPerm.getIpRanges();
         if (ranges != null && ranges.getItem() != null) {
           IpRangeItemType[] rangeItems = ranges.getItem();
                for (IpRangeItemType ipRange: rangeItems) {
                    perm.addIpRange( ipRange.getCidrIp() );
                    perm.setCIDR(ipRange.getCidrIp());
                }
         } 
  
         request.addIpPermission( perm );
        }
View Full Code Here

        }

        // -> not clear how many parameters there are until we fail to get IpPermissions.n.IpProtocol
        int nCount = 1, mCount;
        do  {
        EC2IpPermission perm = new EC2IpPermission();        

            String[] protocol = request.getParameterValues( "IpPermissions." + nCount + ".IpProtocol" );
        if ( null != protocol && 0 < protocol.length )
                perm.setProtocol( protocol[0]);
            else break;

            String[] fromPort = request.getParameterValues( "IpPermissions." + nCount + ".FromPort" );
            if ( null != fromPort && 0 < fromPort.length ) {
                if ( protocol[0].equalsIgnoreCase("icmp") )
                    perm.setIcmpType( fromPort[0] ) ;
                else
                    perm.setFromPort( Integer.parseInt( fromPort[0]) );
            }

            String[] toPort = request.getParameterValues( "IpPermissions." + nCount + ".ToPort" );
            if ( null != toPort && 0 < toPort.length ) {
                if ( protocol[0].equalsIgnoreCase("icmp") )
                    perm.setIcmpCode( toPort[0] );
                else
                    perm.setToPort( Integer.parseInt( toPort[0]) );
            }

            // -> list: IpPermissions.n.IpRanges.m.CidrIp
            mCount = 1;
            do {
                String[] ranges = request.getParameterValues( "IpPermissions." + nCount + ".IpRanges." + mCount + ".CidrIp" );
        if ( null != ranges && 0 < ranges.length)
                    perm.addIpRange( ranges[0]);
                else break;
                mCount++;
            } while( true );

            // -> list: IpPermissions.n.Groups.m.UserId and IpPermissions.n.Groups.m.GroupName
            mCount = 1;
            do {
                EC2SecurityGroup group = new EC2SecurityGroup();

                String[] user = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".UserId" );
                if ( null != user && 0 < user.length)
                    group.setAccount( user[0]);
                else break;

                String[] name = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".GroupName" );
                if ( null != name && 0 < name.length)
                    group.setName( name[0]);
                else break;

                perm.addUser( group);
                mCount++;
            } while( true );

            // -> multiple IP permissions can be specified per group name
            EC2request.addIpPermission( perm);
View Full Code Here

        }

        // -> not clear how many parameters there are until we fail to get IpPermissions.n.IpProtocol
        int nCount = 1;
        do
        {    EC2IpPermission perm = new EC2IpPermission();        

        String[] protocol = request.getParameterValues( "IpPermissions." + nCount + ".IpProtocol" );
        if ( null != protocol && 0 < protocol.length )
            perm.setProtocol( protocol[0] );
        else break;

        String[] fromPort = request.getParameterValues( "IpPermissions." + nCount + ".FromPort" );
            if ( null != fromPort && 0 < fromPort.length ) {
                if ( protocol[0].equalsIgnoreCase("icmp") )
                    perm.setIcmpType( fromPort[0] ) ;
                else
                    perm.setFromPort( Integer.parseInt( fromPort[0]) );
            }

        String[] toPort = request.getParameterValues( "IpPermissions." + nCount + ".ToPort" );
            if ( null != toPort && 0 < toPort.length ) {
                if ( protocol[0].equalsIgnoreCase("icmp") )
                    perm.setIcmpCode( toPort[0] );
                else
                    perm.setToPort( Integer.parseInt( toPort[0]) );
            }

        // -> list: IpPermissions.n.IpRanges.m.CidrIp
        int mCount = 1;
        do
        String[] ranges = request.getParameterValues( "IpPermissions." + nCount + ".IpRanges." + mCount + ".CidrIp" );
        if ( null != ranges && 0 < ranges.length)
            perm.addIpRange( ranges[0] );
        else break;
        mCount++;

        } while( true );

        // -> list: IpPermissions.n.Groups.m.UserId and IpPermissions.n.Groups.m.GroupName
        mCount = 1;
        do
        String[] user = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".UserId" );
        if ( null == user || 0 == user.length) break;

        String[] name = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".GroupName" );
        if ( null == name || 0 == name.length) break;

        EC2SecurityGroup group = new EC2SecurityGroup();
        group.setAccount( user[0] );
        group.setName( name[0] );
        perm.addUser( group );
        mCount++;

        } while( true );

        // -> multiple IP permissions can be specified per group name
View Full Code Here

        EC2AuthorizeRevokeSecurityGroup request = new  EC2AuthorizeRevokeSecurityGroup();

        request.setName( groupName );
       
        for (IpPermissionType ipPerm : items) {
         EC2IpPermission perm = new EC2IpPermission();        
         perm.setProtocol( ipPerm.getIpProtocol());
           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();
           for (UserIdGroupPairType groupPair : groupItems) {
            EC2SecurityGroup user = new EC2SecurityGroup();
            user.setName( groupPair.getGroupName());
            user.setAccount( groupPair.getUserId());
            perm.addUser( user );
           }       
         }      
  
         IpRangeSetType ranges = ipPerm.getIpRanges();
         if (ranges != null && ranges.getItem() != null) {
           IpRangeItemType[] rangeItems = ranges.getItem();
                for (IpRangeItemType ipRange: rangeItems) {
                    perm.addIpRange( ipRange.getCidrIp() );
                    perm.setCIDR(ipRange.getCidrIp());
                }
         } 
  
         request.addIpPermission( perm );
        }
View Full Code Here

        else { response.sendError(530, "Missing GroupName parameter" ); return; }

        // -> not clear how many parameters there are until we fail to get IpPermissions.n.IpProtocol
        int nCount = 1, mCount;
        do  {
        EC2IpPermission perm = new EC2IpPermission();        

            String[] protocol = request.getParameterValues( "IpPermissions." + nCount + ".IpProtocol" );
        if ( null != protocol && 0 < protocol.length )
                perm.setProtocol( protocol[0]);
            else break;

            String[] fromPort = request.getParameterValues( "IpPermissions." + nCount + ".FromPort" );
            if ( null != fromPort && 0 < fromPort.length ) {
                if ( protocol[0].equalsIgnoreCase("icmp") )
                    perm.setIcmpType( fromPort[0] ) ;
                else
                    perm.setFromPort( Integer.parseInt( fromPort[0]) );
            }

            String[] toPort = request.getParameterValues( "IpPermissions." + nCount + ".ToPort" );
            if ( null != toPort && 0 < toPort.length ) {
                if ( protocol[0].equalsIgnoreCase("icmp") )
                    perm.setIcmpCode( toPort[0] );
                else
                    perm.setToPort( Integer.parseInt( toPort[0]) );
            }

            // -> list: IpPermissions.n.IpRanges.m.CidrIp
            mCount = 1;
            do {
                String[] ranges = request.getParameterValues( "IpPermissions." + nCount + ".IpRanges." + mCount + ".CidrIp" );
        if ( null != ranges && 0 < ranges.length)
                    perm.addIpRange( ranges[0]);
                else break;
                mCount++;
            } while( true );

            // -> list: IpPermissions.n.Groups.m.UserId and IpPermissions.n.Groups.m.GroupName
            mCount = 1;
            do {
                EC2SecurityGroup group = new EC2SecurityGroup();

                String[] user = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".UserId" );
                if ( null != user && 0 < user.length)
                    group.setAccount( user[0]);
                else break;

                String[] name = request.getParameterValues( "IpPermissions." + nCount + ".Groups." + mCount + ".GroupName" );
                if ( null != name && 0 < name.length)
                    group.setName( name[0]);
                else break;

                perm.addUser( group);
                mCount++;
            } while( true );

            // -> multiple IP permissions can be specified per group name
            EC2request.addIpPermission( perm);
View Full Code Here

TOP

Related Classes of com.cloud.bridge.service.core.ec2.EC2IpPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.