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

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


    }
    throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - can only modify image description or launchPermission");
 

    public ModifyInstanceAttributeResponse modifyInstanceAttribute(ModifyInstanceAttribute modifyInstanceAttribute) {
        EC2ModifyInstanceAttribute request = new EC2ModifyInstanceAttribute();

        ModifyInstanceAttributeType modifyInstanceAttribute2 = modifyInstanceAttribute.getModifyInstanceAttribute();
        ModifyInstanceAttributeTypeChoice_type0 mia = modifyInstanceAttribute2.getModifyInstanceAttributeTypeChoice_type0();

        request.setInstanceId(modifyInstanceAttribute2.getInstanceId());

        // we only support instanceType and userData
        if (mia.getInstanceType() != null) {
            request.setInstanceType(mia.getInstanceType().getValue());
        } else if (mia.getUserData() != null) {
            request.setUserData(mia.getUserData().getValue());
        } else {
            throw new EC2ServiceException( ClientError.MissingParamter,
                    "Missing required parameter - InstanceType/UserData should be provided");
        }
        return toModifyInstanceAttributeResponse(engine.modifyInstanceAttribute(request));
View Full Code Here


        serializeResponse(response, EC2response);
    }

    private void rebootInstances( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2RebootInstances EC2request = new EC2RebootInstances();
        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

    response.setMonitorInstancesResponse( param1 );
    return response;
  }

  public RebootInstancesResponse rebootInstances(RebootInstances rebootInstances) {
    EC2RebootInstances request = new EC2RebootInstances();
    RebootInstancesType rit = rebootInstances.getRebootInstances();
   
    // -> toEC2StartInstances
    RebootInstancesInfoType   rist  = rit.getInstancesSet();
    RebootInstancesItemType[] items = rist.getItem();
    if (null != items) {  // -> should not be empty
      for( int i=0; i < items.length; i++ ) request.addInstanceId( items[i].getInstanceId());
    }
    return toRebootInstancesResponse( engine.rebootInstances( request ));
  }
View Full Code Here

        serializeResponse(response, EC2response);
    }

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

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

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

        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 )
            EC2request.setDescription( description[0] );

        // -> execute the request
        RegisterImageResponse EC2response = EC2SoapServiceImpl.toRegisterImageResponse( ServiceProvider.getInstance().getEC2Engine().registerImage( EC2request ));
        serializeResponse(response, EC2response);
    }
View Full Code Here

   * @param
   *
   * @see <a href="http://docs.amazonwebservices.com/AWSEC2/2010-11-15/APIReference/index.html?ApiReference-query-RegisterImage.html">RegisterImage</a>
   */
  public RegisterImageResponse registerImage(RegisterImage registerImage) {
    EC2RegisterImage request = new EC2RegisterImage();
    RegisterImageType rit = registerImage.getRegisterImage();
   
    // -> we redefine the architecture field to hold: "format:zonename:osTypeName",
    //    these are the bare minimum that we need to call the cloud registerTemplate call.
    request.setLocation( rit.getImageLocation());   // -> should be a URL for us
    request.setName( rit.getName());
    request.setDescription( rit.getDescription());
    request.setArchitecture( rit.getArchitecture())
    return toRegisterImageResponse( engine.registerImage( request ));
  }
View Full Code Here

        String publicIp = request.getParameter( "PublicIp" );
        if (publicIp == null) {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - PublicIp");
        }

        EC2ReleaseAddress ec2Request = new EC2ReleaseAddress();
        if (ec2Request != null) {
            ec2Request.setPublicIp(publicIp);
        }

        ReleaseAddressResponse EC2Response = EC2SoapServiceImpl.toReleaseAddressResponse( engine.releaseAddress( ec2Request ));

        serializeResponse(response, EC2Response);
View Full Code Here

      return toAllocateAddressResponse( engine.allocateAddress());
    }

    @Override
    public ReleaseAddressResponse releaseAddress(ReleaseAddress releaseAddress) {
      EC2ReleaseAddress request = new EC2ReleaseAddress();

        request.setPublicIp(releaseAddress.getReleaseAddress().getReleaseAddressTypeChoice_type0().getPublicIp());
     
        return toReleaseAddressResponse( engine.releaseAddress( request ) );
    }
View Full Code Here

        serializeResponse(response, EC2response);
    }

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

        // -> so in the Amazon docs for this REST call there is no userData even though there is in the SOAP docs
        String[] imageId = request.getParameterValues( "ImageId" );
        if ( null != imageId && 0 < imageId.length )
            EC2request.setTemplateId( imageId[0] );
        else {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ImageId");
        }

        String[] minCount = request.getParameterValues( "MinCount" );
        if ( minCount == null || minCount.length < 1) {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - MinCount");
        } else if ( Integer.parseInt(minCount[0]) < 1) {
            throw new EC2ServiceException(ClientError.InvalidParameterValue,
                    "Value of parameter MinCount should be greater than 0");
        } else {
            EC2request.setMinCount( Integer.parseInt( minCount[0]) );
        }

        String[] maxCount = request.getParameterValues( "MaxCount" );
        if ( maxCount == null || maxCount.length < 1) {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - MaxCount");
        } else if ( Integer.parseInt(maxCount[0]) < 1) {
            throw new EC2ServiceException(ClientError.InvalidParameterValue,
                    "Value of parameter MaxCount should be greater than 0");
        } else {
            EC2request.setMaxCount( Integer.parseInt( maxCount[0]) );
        }

        String[] instanceType = request.getParameterValues( "InstanceType" );
        if ( null != instanceType && 0 < instanceType.length )
            EC2request.setInstanceType( instanceType[0] );

        String[] zoneName = request.getParameterValues( "Placement.AvailabilityZone" );
        if ( null != zoneName && 0 < zoneName.length )
            EC2request.setZoneName( zoneName[0] );

        String[] size = request.getParameterValues("size");
        if (size != null) {
            EC2request.setSize(Integer.valueOf(size[0]));
        }

        String[] keyName = request.getParameterValues("KeyName");
        if (keyName != null) {
            EC2request.setKeyName(keyName[0]);
        }

        String[] userData = request.getParameterValues("UserData");
        if ( userData != null) {
            EC2request.setUserData( userData[0]);
        }

        Enumeration<?> names = request.getParameterNames();
        while( names.hasMoreElements()) {
            String key = (String)names.nextElement();
            if ( key.startsWith("SecurityGroup")) {
                String[] value = request.getParameterValues(key);
                if (null != value && 0 < value.length) {
                    if ( key.startsWith("SecurityGroupId"))
                        EC2request.addSecuritGroupId( value[0]);
                    else
                        EC2request.addSecuritGroupName( value[0]);
                }
            }
        }

        // -> execute the request
View Full Code Here

    PlacementRequestType prt = rit.getPlacement();
    UserDataType userData = rit.getUserData();
    String type = rit.getInstanceType()
    String keyName = rit.getKeyName();
   
    EC2RunInstances request = new EC2RunInstances();
   
    request.setTemplateId(rit.getImageId());

        if (rit.getMinCount() < 1) {
            throw new EC2ServiceException(ClientError.InvalidParameterValue,
                    "Value of parameter MinCount should be greater than 0");
        } else request.setMinCount( rit.getMinCount() );

        if (rit.getMaxCount() < 1) {
            throw new EC2ServiceException(ClientError.InvalidParameterValue,
                    "Value of parameter MaxCount should be greater than 0");
        } else request.setMaxCount(rit.getMaxCount());

    if (null != type) request.setInstanceType(type);
    if (null != prt) request.setZoneName(prt.getAvailabilityZone());
    if (null != userData) request.setUserData(userData.getData());
    if (null != keyName) request.setKeyName(rit.getKeyName() );
   
    // -> we can only support one group per instance
    if (null != gst) {
      GroupItemType[] items = gst.getItem();
      if (null != items) {
                for( int i=0; i < items.length; i++ ) {
                    if ( items[i].getGroupName() != null) // either SG-name or SG-id can be provided
                        request.addSecuritGroupName( items[i].getGroupName());
                    else
                        request.addSecuritGroupId( items[i].getGroupId());
                }
        }
    }
    return toRunInstancesResponse( engine.runInstances( request ), engine);
  }
View Full Code Here

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

TOP

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

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.