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

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


        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 );
View Full Code Here


           }
         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();
View Full Code Here

        // -> are there any filters with this request?
        EC2Filter[] filterSet = extractFilters( request );
        if (null != filterSet)
        {
            EC2SnapshotFilterSet sfs = new EC2SnapshotFilterSet();
            for( int i=0; i < filterSet.length; i++ ) sfs.addFilter( filterSet[i] );
            EC2request.setFilterSet( sfs );
        }

        // -> execute the request
        EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
View Full Code Here

        return request;
    }

    private EC2DescribeSnapshots toSnapshotFilterSet( EC2DescribeSnapshots request, FilterSetType fst, String[] timeStrs )
    {
        EC2SnapshotFilterSet sfs = new EC2SnapshotFilterSet();
    boolean timeFilter = false;

    FilterType[] items = fst.getItem();
    if (null != items)
    {
      // -> each filter can have one or more values associated with it
      for( int j=0; j < items.length; j++ )
      {
                String filterName = items[j].getName();
                ValueSetType vst = items[j].getValueSet();
                ValueType[] valueItems = vst.getItem();

                if (filterName.startsWith("tag:")) {
                    String key= filterName.split(":")[1];
                    for (ValueType valueItem : valueItems) {
                        EC2TagKeyValue tag = new EC2TagKeyValue();
                        tag.setKey(key);
                        tag.setValue(valueItem.getValue());
                        request.addResourceTag(tag);
                    }
                }
                else {
                    EC2Filter oneFilter = new EC2Filter();
                    oneFilter.setName( filterName );

                    // -> is the filter one of the xsd:dateTime filters?
                    timeFilter = false;
                    for( int m=0; m < timeStrs.length; m++ ) {
                        timeFilter = filterName.equalsIgnoreCase( timeStrs[m] );
                        if (timeFilter) break;
                    }

                    for( int k=0; k < valueItems.length; k++ ) {
                        // -> time values are not encoded as regexes
                        if ( timeFilter )
                            oneFilter.addValue( valueItems[k].getValue());
                        else
                            oneFilter.addValueEncoded( valueItems[k].getValue());
                    }
                    sfs.addFilter( oneFilter );
                }
            }
            request.setFilterSet(sfs);
        }
        return request;
View Full Code Here

        serializeResponse(response, EC2response);
    }

    private void startInstances( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2StartInstances EC2request = new EC2StartInstances();
        int count = 0;

        // -> load in all the "InstanceId.n" parameters if any
        Enumeration<?> names = request.getParameterNames();
        while( names.hasMoreElements()) {
            String key = (String)names.nextElement();
            if (key.startsWith("InstanceId")) {
                String[] value = request.getParameterValues( key );
                if (null != value && 0 < value.length) {
                    EC2request.addInstanceId( value[0] );
                    count++;
                }
            }
        } 
        if (0 == count) {
View Full Code Here

    }
    return toRunInstancesResponse( engine.runInstances( request ), engine);
  }
 
  public StartInstancesResponse startInstances(StartInstances startInstances) {
    EC2StartInstances request = new EC2StartInstances();
    StartInstancesType sit = startInstances.getStartInstances();
   
    // -> toEC2StartInstances
    InstanceIdSetType iist  = sit.getInstancesSet();
    InstanceIdType[]  items = iist.getItem();
    if (null != items) {  // -> should not be empty
      for( int i=0; i < items.length; i++ ) request.addInstanceId( items[i].getInstanceId());
    }
    return toStartInstancesResponse( engine.startInstances( request ));
  }
View Full Code Here

        serializeResponse(response, EC2response);
    }

    private void stopInstances( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2StopInstances EC2request = new EC2StopInstances();
        int count = 0;

        // -> load in all the "InstanceId.n" parameters if any
        Enumeration<?> names = request.getParameterNames();
        while( names.hasMoreElements()) {
            String key = (String)names.nextElement();
            if (key.startsWith("InstanceId")) {
                String[] value = request.getParameterValues( key );
                if (null != value && 0 < value.length) {
                    EC2request.addInstanceId( value[0] );
                    count++;
                }
            }
        } 
        if (0 == count) {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
        }

        String[] force = request.getParameterValues("Force");
        if ( force != null) {
            EC2request.setForce( Boolean.parseBoolean(force[0]));
        }

        // -> execute the request
        StopInstancesResponse EC2response = EC2SoapServiceImpl.toStopInstancesResponse( ServiceProvider.getInstance().getEC2Engine().stopInstances( EC2request ));
        serializeResponse(response, EC2response);
View Full Code Here

        serializeResponse(response, EC2response);
    }

    private void terminateInstances( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2StopInstances EC2request = new EC2StopInstances();
        int count = 0;

        // -> load in all the "InstanceId.n" parameters if any
        Enumeration<?> names = request.getParameterNames();
        while( names.hasMoreElements()) {
            String key = (String)names.nextElement();
            if (key.startsWith("InstanceId")) {
                String[] value = request.getParameterValues( key );
                if (null != value && 0 < value.length) {
                    EC2request.addInstanceId( value[0] );
                    count++;
                }
            }
        }   
        if (0 == count) {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
        }

        // -> execute the request
        EC2request.setDestroyInstances( true );
        TerminateInstancesResponse EC2response = EC2SoapServiceImpl.toTermInstancesResponse( ServiceProvider.getInstance().getEC2Engine().stopInstances( EC2request ));
        serializeResponse(response, EC2response);
    }
View Full Code Here

    }
    return toStartInstancesResponse( engine.startInstances( request ));
  }
 
  public StopInstancesResponse stopInstances(StopInstances stopInstances) {
    EC2StopInstances request = new EC2StopInstances();
    StopInstancesType sit = stopInstances.getStopInstances();
        Boolean force = sit.getForce();
   
    // -> toEC2StopInstances
    InstanceIdSetType iist  = sit.getInstancesSet();
    InstanceIdType[]  items = iist.getItem();
    if (null != items) {  // -> should not be empty
      for( int i=0; i < items.length; i++ ) request.addInstanceId( items[i].getInstanceId());
    }

        if (force) request.setForce(sit.getForce());
    return toStopInstancesResponse( engine.stopInstances( request ));
  }
View Full Code Here

   * Mapping this to the destroyVirtualMachine cloud API concept.
   * This makes sense since when considering the rebootInstances function.   In reboot
   * any terminated instances are left alone.   We will do the same with destroyed instances.
   */
  public TerminateInstancesResponse terminateInstances(TerminateInstances terminateInstances) {
    EC2StopInstances request = new EC2StopInstances();
    TerminateInstancesType sit = terminateInstances.getTerminateInstances();
   
    // -> toEC2StopInstances
    InstanceIdSetType iist  = sit.getInstancesSet();
    InstanceIdType[]  items = iist.getItem();
    if (null != items) {  // -> should not be empty
      for( int i=0; i < items.length; i++ ) request.addInstanceId( items[i].getInstanceId());
    }

    request.setDestroyInstances( true );
    return toTermInstancesResponse( engine.stopInstances( request ));
  }
View Full Code Here

TOP

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

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.