private RunInstancesResponseType runInstances ( final String imageId , final String instanceType , final int minCount , final int maxCount ) { RunInstancesResponseType ret = new RunInstancesResponseType ( ) ; RunningInstancesSetType instSet = new RunningInstancesSetType ( ) ; Class < ? extends AbstractMockEc2Instance > clazzOfMockEc2Instance = null ; try { // clazzOfMockEc2Instance = (Class<? extends MockEc2Instance>) Class.forName(MOCK_EC2_INSTANCE_CLASS_NAME); clazzOfMockEc2Instance = ( Class . forName ( MOCK_EC2_INSTANCE_CLASS_NAME ) . asSubclass ( AbstractMockEc2Instance . class ) ) ; } catch ( ClassNotFoundException e ) { throw new AwsMockException ( "badly configured class '" + MOCK_EC2_INSTANCE_CLASS_NAME + "' not found" , e ) ; } List < AbstractMockEc2Instance > newInstances = null ; newInstances = mockEc2Controller . runInstances ( clazzOfMockEc2Instance , imageId , instanceType , minCount , maxCount ) ; for ( AbstractMockEc2Instance i : newInstances ) { RunningInstancesItemType instItem = new RunningInstancesItemType ( ) ; instItem . setInstanceId ( i . getInstanceID ( ) ) ; instItem . setImageId ( i . getImageId ( ) ) ; instItem . setInstanceType ( i . getInstanceType ( ) . getName ( ) ) ; InstanceStateType state = new InstanceStateType ( ) ; state . setCode ( i . getInstanceState ( ) . getCode ( ) ) ; state . setName ( i . getInstanceState ( ) . getName ( ) ) ; instItem . setInstanceState ( state ) ; instItem . setDnsName ( i . getPubDns ( ) ) ; instItem . setPlacement ( DEFAULT_MOCK_PLACEMENT ) ; // set network information instItem . setVpcId ( MOCK_VPC_ID ) ; instItem . setPrivateIpAddress ( MOCK_PRIVATE_IP_ADDRESS ) ; instItem . setSubnetId ( MOCK_SUBNET_ID ) ; instSet . getItem ( ) . add ( instItem ) ; } ret . setInstancesSet ( instSet ) ; return ret ; }
Handles runInstances request with only simplified filters of imageId instanceType minCount and maxCount .