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

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


    return response;
  }

  // filtersets
  private EC2AddressFilterSet toAddressFilterSet( FilterSetType fst )  {
    EC2AddressFilterSet vfs = new EC2AddressFilterSet();
   
    FilterType[] items = fst.getItem();
    if (items != null) {
      // -> each filter can have one or more values associated with it
      for (FilterType item : items) {
        EC2Filter oneFilter = new EC2Filter();
        String filterName = item.getName();
        oneFilter.setName( filterName );
       
        ValueSetType vst = item.getValueSet();
        ValueType[] valueItems = vst.getItem();
        for (ValueType valueItem : valueItems) {
          oneFilter.addValueEncoded( valueItem.getValue());
        }
        vfs.addFilter( oneFilter );
      }
    }   
    return vfs;
  }
View Full Code Here


        return toReleaseAddressResponse( engine.releaseAddress( request ) );
    }

    @Override
    public AssociateAddressResponse associateAddress(AssociateAddress associateAddress) {
      EC2AssociateAddress request = new EC2AssociateAddress();
 
        request.setPublicIp( associateAddress.getAssociateAddress().
                getAssociateAddressTypeChoice_type0().getPublicIp());
        request.setInstanceId(associateAddress.getAssociateAddress().
                getAssociateAddressTypeChoice_type1().getInstanceId());

        return toAssociateAddressResponse( engine.associateAddress( request ) );
    }
View Full Code Here

 
  public AuthorizeSecurityGroupIngressResponse authorizeSecurityGroupIngress(AuthorizeSecurityGroupIngress authorizeSecurityGroupIngress) {
        AuthorizeSecurityGroupIngressType sgit = authorizeSecurityGroupIngress.getAuthorizeSecurityGroupIngress();       
        IpPermissionSetType ipPerms = sgit.getIpPermissions();

        EC2AuthorizeRevokeSecurityGroup request = toSecurityGroup(
                sgit.getAuthorizeSecurityGroupIngressTypeChoice_type0().getGroupName(), ipPerms.getItem());
    return toAuthorizeSecurityGroupIngressResponse( engine.authorizeSecurityGroup( request ));
  }
View Full Code Here

  public RevokeSecurityGroupIngressResponse revokeSecurityGroupIngress( RevokeSecurityGroupIngress revokeSecurityGroupIngress )
  {
        RevokeSecurityGroupIngressType sgit = revokeSecurityGroupIngress.getRevokeSecurityGroupIngress();       
        IpPermissionSetType ipPerms = sgit.getIpPermissions();

        EC2AuthorizeRevokeSecurityGroup request = toSecurityGroup(
                sgit.getRevokeSecurityGroupIngressTypeChoice_type0().getGroupName(), ipPerms.getItem());
    return toRevokeSecurityGroupIngressResponse( engine.revokeSecurityGroup( request ));
  }
View Full Code Here

 
  /**
   * Authorize and Revoke Security Group Ingress have the same parameters.
   */
  private EC2AuthorizeRevokeSecurityGroup toSecurityGroup( String groupName, IpPermissionType[] items ) {
        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 );
        }
        return request;
    }
View Full Code Here

        }
        return request;
    }

    private EC2AvailabilityZonesFilterSet toAvailabiltyZonesFilterSet( FilterSetType fst )  {
        EC2AvailabilityZonesFilterSet azfs = new EC2AvailabilityZonesFilterSet();

        FilterType[] items = fst.getItem();
        if (items != null) {
            for (FilterType item : items) {
                EC2Filter oneFilter = new EC2Filter();
                String filterName = item.getName();
                oneFilter.setName( filterName );

                ValueSetType vft = item.getValueSet();
                ValueType[] valueItems = vft.getItem();
                for (ValueType valueItem : valueItems) {
                    oneFilter.addValueEncoded( valueItem.getValue());
                }
                azfs.addFilter( oneFilter );
            }
        }
        return azfs;
    }
View Full Code Here

        else {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - VolumeId");
        }

        // -> execute the request
        EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
        CreateSnapshotResponse EC2response = EC2SoapServiceImpl.toCreateSnapshotResponse( engine.createSnapshot( volumeId ), engine);
        serializeResponse(response, EC2response);
    }
View Full Code Here

                }
            }
        }

        // -> execute the request
        EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
        RunInstancesResponse EC2response = EC2SoapServiceImpl.toRunInstancesResponse( engine.runInstances( EC2request ), engine);
        serializeResponse(response, EC2response);
    }
View Full Code Here

                ifs.addFilter(filterSet[i]);
            }
            EC2request.setFilterSet( ifs );
        }
        // -> execute the request
        EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
        DescribeImagesResponse EC2response = EC2SoapServiceImpl.toDescribeImagesResponse( engine.describeImages( EC2request ));
        serializeResponse(response, EC2response);
    }
View Full Code Here

            for( int i=0; i < filterSet.length; i++ ) ifs.addFilter( filterSet[i] );
            EC2request.setFilterSet( ifs );
        }

        // -> execute the request
        EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
        DescribeInstancesResponse EC2response = EC2SoapServiceImpl.toDescribeInstancesResponse( engine.describeInstances( EC2request ), engine);
        serializeResponse(response, EC2response);
            }
View Full Code Here

TOP

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

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.