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

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


        }   

        // add filters
        EC2Filter[] filterSet = extractFilters( request );
        if ( filterSet != null ) {
            EC2AvailabilityZonesFilterSet afs = new EC2AvailabilityZonesFilterSet();
            for( int i=0; i < filterSet.length; i++ ) {
                afs.addFilter(filterSet[i]);
            }
            EC2request.setFilterSet( afs );
        }

        // -> execute the request
View Full Code Here


        }
        return request;
    }

  public CreateImageResponse createImage(CreateImage createImage) {
    EC2CreateImage request = new EC2CreateImage();
    CreateImageType cit = createImage.getCreateImage();
   
    request.setInstanceId( cit.getInstanceId());
    request.setName( cit.getName());
    request.setDescription( cit.getDescription());
    return toCreateImageResponse( engine.createImage(request));
  }
View Full Code Here

        serializeResponse(response, EC2response);
    }

    private void createImage( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2CreateImage EC2request = new EC2CreateImage();

        String[] instanceId = request.getParameterValues( "InstanceId" );
        if ( null != instanceId && 0 < instanceId.length )
            EC2request.setInstanceId( instanceId[0] );
        else {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
        }

        String[] name = request.getParameterValues( "Name" );
        if ( null != name && 0 < name.length )
            EC2request.setName( name[0] );
        else {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Name");
        }

        String[] description = request.getParameterValues( "Description" );
        if ( null != description && 0 < description.length ) {
            if (description[0].length() > 255)
                throw new EC2ServiceException( ClientError.InvalidParameterValue,
                        "Length of the value of parameter Description should be less than 255");
            EC2request.setDescription( description[0] );
        }


        // -> execute the request
        CreateImageResponse EC2response = EC2SoapServiceImpl.toCreateImageResponse( ServiceProvider.getInstance().getEC2Engine().createImage( EC2request ));
View Full Code Here

   
    return response;
  }
 
  public CreateKeyPairResponse createKeyPair(CreateKeyPair createKeyPair) {
    EC2CreateKeyPair ec2Request = new EC2CreateKeyPair();
      if (ec2Request != null) {
        ec2Request.setKeyName(createKeyPair.getCreateKeyPair().getKeyName());
      }

    return toCreateKeyPair(engine.createKeyPair( ec2Request ));
  }
View Full Code Here

    CreateSnapshotType cst = createSnapshot.getCreateSnapshot();
    return toCreateSnapshotResponse( engine.createSnapshot( cst.getVolumeId()), engine);
  }

  public CreateVolumeResponse createVolume(CreateVolume createVolume) {
    EC2CreateVolume request = new EC2CreateVolume();
    CreateVolumeType cvt = createVolume.getCreateVolume();
   
    request.setSize( cvt.getSize());
    request.setSnapshotId(cvt.getSnapshotId() != null ? cvt.getSnapshotId() : null);
    request.setZoneName( cvt.getAvailabilityZone());
    return toCreateVolumeResponse( engine.createVolume( request ));
  }
View Full Code Here

        serializeResponse(response, EC2response);
    }

    private void createVolume( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2CreateVolume EC2request = new EC2CreateVolume();

        String[] zoneName = request.getParameterValues( "AvailabilityZone" );
        if ( null != zoneName && 0 < zoneName.length )
            EC2request.setZoneName( zoneName[0] );
        else {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing parameter - AvailabilityZone");
        }

        String[] size = request.getParameterValues( "Size" );
        String[] snapshotId = request.getParameterValues("SnapshotId");
        boolean useSnapshot = false;
        boolean useSize = false;

        if (null != size && 0 < size.length)
            useSize = true;

        if (snapshotId != null && snapshotId.length != 0)
            useSnapshot = true;

        if (useSize && !useSnapshot) {
            EC2request.setSize( size[0] );
        } else if (useSnapshot && !useSize) {
            EC2request.setSnapshotId(snapshotId[0]);
        } else if (useSize && useSnapshot) {
            throw new EC2ServiceException( ClientError.InvalidParameterCombination, "Parameters 'Size' and 'SnapshotId' are mutually exclusive");
        } else {
            throw new EC2ServiceException( ClientError.MissingParamter, "Parameter 'Size' or 'SnapshotId' has to be specified");
        }
View Full Code Here

        DeleteVolumeResponse EC2response = EC2SoapServiceImpl.toDeleteVolumeResponse(ServiceProvider.getInstance().getEC2Engine().deleteVolume(EC2request));
        serializeResponse(response, EC2response);
    }

    private void createVolume(HttpServletRequest request, HttpServletResponse response) throws ADBException, XMLStreamException, IOException {
        EC2CreateVolume EC2request = new EC2CreateVolume();

        String[] zoneName = request.getParameterValues("AvailabilityZone");
        if (null != zoneName && 0 < zoneName.length)
            EC2request.setZoneName(zoneName[0]);
        else {
            throw new EC2ServiceException(ClientError.MissingParamter, "Missing parameter - AvailabilityZone");
        }

        String[] size = request.getParameterValues("Size");
        String[] snapshotId = request.getParameterValues("SnapshotId");
        boolean useSnapshot = false;
        boolean useSize = false;

        if (null != size && 0 < size.length)
            useSize = true;

        if (snapshotId != null && snapshotId.length != 0)
            useSnapshot = true;

        if (useSize && !useSnapshot) {
            EC2request.setSize(size[0]);
        } else if (useSnapshot && !useSize) {
            EC2request.setSnapshotId(snapshotId[0]);
        } else if (useSize && useSnapshot) {
            throw new EC2ServiceException(ClientError.InvalidParameterCombination, "Parameters 'Size' and 'SnapshotId' are mutually exclusive");
        } else {
            throw new EC2ServiceException(ClientError.MissingParamter, "Parameter 'Size' or 'SnapshotId' has to be specified");
        }
View Full Code Here

    serializeResponse(response, EC2response);
    }

    private void createVolume( HttpServletRequest request, HttpServletResponse response )
        throws ADBException, XMLStreamException, IOException {
      EC2CreateVolume EC2request = new EC2CreateVolume();
     
        String[] zoneName = request.getParameterValues( "AvailabilityZone" );
        if ( null != zoneName && 0 < zoneName.length )
           EC2request.setZoneName( zoneName[0] );
    else { response.sendError(530, "Missing AvailabilityZone parameter" ); return; }
   
        String[] size = request.getParameterValues( "Size" );
        String[] snapshotId = request.getParameterValues("SnapshotId");
        boolean useSnapshot = false;
        boolean useSize = false;
       
        if (null != size && 0 < size.length)
          useSize = true;
       
        if (snapshotId != null && snapshotId.length != 0)
          useSnapshot = true;
       
    if (useSize && !useSnapshot) {
      EC2request.setSize( size[0] );
    } else if (useSnapshot && !useSize) {
          EC2request.setSnapshotId(snapshotId[0]);
        } else if (useSize && useSnapshot) {
          response.sendError(530, "Size and SnapshotId parameters are mutually exclusive" ); return;
        } else {
          response.sendError(530, "Size or SnapshotId has to be specified" ); return;
        }
View Full Code Here

    CreateSnapshotType cst = createSnapshot.getCreateSnapshot();
    return toCreateSnapshotResponse( engine.createSnapshot( cst.getVolumeId()), engine);
  }

  public CreateVolumeResponse createVolume(CreateVolume createVolume) {
    EC2CreateVolume request = new EC2CreateVolume();
    CreateVolumeType cvt = createVolume.getCreateVolume();
   
    request.setSize( cvt.getSize());
    request.setSnapshotId(cvt.getSnapshotId() != null ? cvt.getSnapshotId() : null);
    request.setZoneName( cvt.getAvailabilityZone());
    return toCreateVolumeResponse( engine.createVolume( request ));
  }
View Full Code Here

        CreateSnapshotType cst = createSnapshot.getCreateSnapshot();
        return toCreateSnapshotResponse(engine.createSnapshot(cst.getVolumeId()), engine);
    }

    public CreateVolumeResponse createVolume(CreateVolume createVolume) {
        EC2CreateVolume request = new EC2CreateVolume();
        CreateVolumeType cvt = createVolume.getCreateVolume();

        request.setSize(cvt.getSize());
        request.setSnapshotId(cvt.getSnapshotId() != null ? cvt.getSnapshotId() : null);
        request.setZoneName(cvt.getAvailabilityZone());
        return toCreateVolumeResponse(engine.createVolume(request));
    }
View Full Code Here

TOP

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

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.