private SpotVirtualMachineRequest toSpotVmRequest( @Nonnull Node node ) throws CloudException {
        NodeList el = node.getChildNodes();
        String requestId = null;
        float price = 0.0F;
        SpotVirtualMachineRequestType type = null;
        long createdTs = 0;
        long validFromTs = 0;
        long validUntilTs = 0;
        String fulfillmentDcid = null;
        String launchGroup = null;

        // use to look up the instance
        String instanceId = null;

        // get these from the instance if fulfilled
        String amiId = null;
        String productId = null;
        long fulfillmentTs = 0;

        for( int i = 0; i < el.getLength(); i++ ) {
            Node item = el.item(i);
            String name = item.getNodeName();

            if( "spotInstanceRequestId".equals(name) ) {
                requestId = item.getFirstChild().getNodeValue().trim();
            }
            else if( "spotPrice".equals(name) ) {
                price = AWSCloud.getFloatValue(item);
            }
            else if( "type".equals(name) ) {
                type = SpotVirtualMachineRequestType.ONE_TIME;
                String value = AWSCloud.getTextValue(item);
                if( "persistent".equals(value) ) {
                    type = SpotVirtualMachineRequestType.PERSISTENT;
                }
            }
            else if( "launchGroup".equals(name) ) {
                launchGroup = AWSCloud.getTextValue(item);
            }
            else if( "launchedAvailabilityZone".equals(name) ) {
                fulfillmentDcid = AWSCloud.getTextValue(item);
            }
            else if( "createTime".equals(name) ) {
                createdTs = AWSCloud.getTimestampValue(item);
            }
            else if( "validFrom".equals(name) ) {
                validFromTs = AWSCloud.getTimestampValue(item);
            }
            else if( "validUntil".equals(name) ) {
                validUntilTs = AWSCloud.getTimestampValue(item);
            }
            else if( "instanceId".equals(name) ) {
                instanceId = AWSCloud.getTextValue(item);
            }
        }
        if( instanceId != null ) {
            try {
                // see if the instance is there
                VirtualMachine vm = getVirtualMachine(instanceId);
                productId = vm.getProductId();
                fulfillmentTs = vm.getCreationTimestamp();
                amiId = vm.getProviderMachineImageId();
            } catch (CloudException ce) {
                // ignore
            } catch( InternalException e ) {
                // ignore
            }
        }
        return SpotVirtualMachineRequest.getInstance(requestId, price, type, amiId, productId, createdTs, validFromTs, validUntilTs, fulfillmentTs, fulfillmentDcid, launchGroup);
    }
private SpotVirtualMachineRequest toSpotVmRequest ( @ Nonnull Node node ) throws CloudException { NodeList el = node . getChildNodes ( ) ; String requestId = null ; float price = 0.0F ; SpotVirtualMachineRequestType type = null ; long createdTs = 0 ; long validFromTs = 0 ; long validUntilTs = 0 ; String fulfillmentDcid = null ; String launchGroup = null ; String instanceId = null ; String amiId = null ; String productId = null ; long fulfillmentTs = 0 ; for ( int i = 0 ; i < el . getLength ( ) ; i ++ ) { Node item = el . item ( i ) ; String name = item . getNodeName ( ) ; if ( "spotInstanceRequestId" . equals ( name ) ) { requestId = item . getFirstChild ( ) . getNodeValue ( ) . trim ( ) ; } else if ( "spotPrice" . equals ( name ) ) { price = AWSCloud . getFloatValue ( item ) ; } else if ( "type" . equals ( name ) ) { type = SpotVirtualMachineRequestType . ONE_TIME ; String value = AWSCloud . getTextValue ( item ) ; if ( "persistent" . equals ( value ) ) { type = SpotVirtualMachineRequestType . PERSISTENT ; } } else if ( "launchGroup" . equals ( name ) ) { launchGroup = AWSCloud . getTextValue ( item ) ; } else if ( "launchedAvailabilityZone" . equals ( name ) ) { fulfillmentDcid = AWSCloud . getTextValue ( item ) ; } else if ( "createTime" . equals ( name ) ) { createdTs = AWSCloud . getTimestampValue ( item ) ; } else if ( "validFrom" . equals ( name ) ) { validFromTs = AWSCloud . getTimestampValue ( item ) ; } else if ( "validUntil" . equals ( name ) ) { validUntilTs = AWSCloud . getTimestampValue ( item ) ; } else if ( "instanceId" . equals ( name ) ) { instanceId = AWSCloud . getTextValue ( item ) ; } } if ( instanceId != null ) { try { VirtualMachine vm = getVirtualMachine ( instanceId ) ; productId = vm . getProductId ( ) ; fulfillmentTs = vm . getCreationTimestamp ( ) ; amiId = vm . getProviderMachineImageId ( ) ; } catch ( CloudException ce ) { } catch ( InternalException e ) { } } return SpotVirtualMachineRequest . getInstance ( requestId , price , type , amiId , productId , createdTs , validFromTs , validUntilTs , fulfillmentTs , fulfillmentDcid , launchGroup ) ; }
Parse a SpotVirtualMachineRequest, make a DescribeInstances call if instanceId is returned
to gather more information
@param node
@return
@throws CloudException