CLOUDSTACK-1444. Updated EC2SoapService and EC2SoapServiceImpl to be compatible with the java stubs generated from EC2 WSDL 2012-08-15.

- by adding stubs for the new EC2 APIs (unsupported by CS AWSAPI)
 - by setting the new EC2 API response elements
 - by adding support for the new EC2 API request elements
[Support for EC2 API version 2012-08-15]
This commit is contained in:
Likitha Shetty 2012-10-15 18:32:56 +05:30
parent 7d2a33b5cc
commit 9d56244f41
5 changed files with 732 additions and 30 deletions

View File

@ -1259,8 +1259,12 @@ public class EC2RestServlet extends HttpServlet {
String key = (String)names.nextElement();
if ( key.startsWith("SecurityGroup")) {
String[] value = request.getParameterValues(key);
if (null != value && 0 < value.length)
EC2request.addGroupName( value[0]);
if (null != value && 0 < value.length) {
if ( key.startsWith("SecurityGroupId"))
EC2request.addSecuritGroupId( value[0]);
else
EC2request.addSecuritGroupName( value[0]);
}
}
}

View File

@ -568,4 +568,346 @@ public class EC2SoapService implements AmazonEC2SkeletonInterface {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.importVolume(importVolume);
}
}
@Override
public ResetNetworkInterfaceAttributeResponse resetNetworkInterfaceAttribute(
ResetNetworkInterfaceAttribute resetNetworkInterfaceAttribute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.resetNetworkInterfaceAttribute(resetNetworkInterfaceAttribute);
}
@Override
public CreateRouteTableResponse createRouteTable(
CreateRouteTable createRouteTable) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createRouteTable(createRouteTable);
}
@Override
public CreateNetworkAclEntryResponse createNetworkAclEntry(
CreateNetworkAclEntry createNetworkAclEntry) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createNetworkAclEntry(createNetworkAclEntry);
}
@Override
public DescribeVolumeAttributeResponse describeVolumeAttribute(
DescribeVolumeAttribute describeVolumeAttribute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeVolumeAttribute(describeVolumeAttribute);
}
@Override
public DeleteNetworkInterfaceResponse deleteNetworkInterface(
DeleteNetworkInterface deleteNetworkInterface) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.deleteNetworkInterface(deleteNetworkInterface);
}
@Override
public CreateInternetGatewayResponse createInternetGateway(
CreateInternetGateway createInternetGateway) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createInternetGateway(createInternetGateway);
}
@Override
public DisassociateRouteTableResponse disassociateRouteTable(
DisassociateRouteTable disassociateRouteTable) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.disassociateRouteTable(disassociateRouteTable);
}
@Override
public ReplaceNetworkAclEntryResponse replaceNetworkAclEntry(
ReplaceNetworkAclEntry replaceNetworkAclEntry) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.replaceNetworkAclEntry(replaceNetworkAclEntry);
}
@Override
public AuthorizeSecurityGroupEgressResponse authorizeSecurityGroupEgress(
AuthorizeSecurityGroupEgress authorizeSecurityGroupEgress) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.authorizeSecurityGroupEgress(authorizeSecurityGroupEgress);
}
@Override
public DeleteNetworkAclEntryResponse deleteNetworkAclEntry(
DeleteNetworkAclEntry deleteNetworkAclEntry) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.deleteNetworkAclEntry(deleteNetworkAclEntry);
}
@Override
public DeleteRouteTableResponse deleteRouteTable(
DeleteRouteTable deleteRouteTable) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.deleteRouteTable(deleteRouteTable);
}
@Override
public DescribeNetworkInterfaceAttributeResponse describeNetworkInterfaceAttribute(
DescribeNetworkInterfaceAttribute describeNetworkInterfaceAttribute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeNetworkInterfaceAttribute(describeNetworkInterfaceAttribute);
}
@Override
public CreateReservedInstancesListingResponse createReservedInstancesListing(
CreateReservedInstancesListing createReservedInstancesListing) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createReservedInstancesListing(createReservedInstancesListing);
}
@Override
public CreateNetworkAclResponse createNetworkAcl(
CreateNetworkAcl createNetworkAcl) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createNetworkAcl(createNetworkAcl);
}
@Override
public ModifyVolumeAttributeResponse modifyVolumeAttribute(
ModifyVolumeAttribute modifyVolumeAttribute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.modifyVolumeAttribute(modifyVolumeAttribute);
}
@Override
public ReplaceNetworkAclAssociationResponse replaceNetworkAclAssociation(
ReplaceNetworkAclAssociation replaceNetworkAclAssociation) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.replaceNetworkAclAssociation(replaceNetworkAclAssociation);
}
@Override
public EnableVgwRoutePropagationResponse enableVgwRoutePropagation(
EnableVgwRoutePropagation enableVgwRoutePropagation) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.enableVgwRoutePropagation(enableVgwRoutePropagation);
}
@Override
public UnassignPrivateIpAddressesResponse unassignPrivateIpAddresses(
UnassignPrivateIpAddresses unassignPrivateIpAddresses) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.unassignPrivateIpAddresses(unassignPrivateIpAddresses);
}
@Override
public DeleteVpnConnectionRouteResponse deleteVpnConnectionRoute(
DeleteVpnConnectionRoute deleteVpnConnectionRoute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.deleteVpnConnectionRoute(deleteVpnConnectionRoute);
}
@Override
public CancelReservedInstancesListingResponse cancelReservedInstancesListing(
CancelReservedInstancesListing cancelReservedInstancesListing) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.cancelReservedInstancesListing(cancelReservedInstancesListing);
}
@Override
public DescribeNetworkAclsResponse describeNetworkAcls(
DescribeNetworkAcls describeNetworkAcls) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeNetworkAcls(describeNetworkAcls);
}
@Override
public EnableVolumeIOResponse enableVolumeIO(
EnableVolumeIO enableVolumeIO) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.enableVolumeIO(enableVolumeIO);
}
@Override
public DescribeInternetGatewaysResponse describeInternetGateways(
DescribeInternetGateways describeInternetGateways) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeInternetGateways(describeInternetGateways);
}
@Override
public DescribeReservedInstancesListingsResponse describeReservedInstancesListings(
DescribeReservedInstancesListings describeReservedInstancesListings) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeReservedInstancesListings(describeReservedInstancesListings);
}
@Override
public DescribeInstanceStatusResponse describeInstanceStatus(
DescribeInstanceStatus describeInstanceStatus) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeInstanceStatus(describeInstanceStatus);
}
@Override
public ModifyNetworkInterfaceAttributeResponse modifyNetworkInterfaceAttribute(
ModifyNetworkInterfaceAttribute modifyNetworkInterfaceAttribute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.modifyNetworkInterfaceAttribute(modifyNetworkInterfaceAttribute);
}
@Override
public DisableVgwRoutePropagationResponse disableVgwRoutePropagation(
DisableVgwRoutePropagation disableVgwRoutePropagation) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.disableVgwRoutePropagation(disableVgwRoutePropagation);
}
@Override
public DescribeVolumeStatusResponse describeVolumeStatus(
DescribeVolumeStatus describeVolumeStatus) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeVolumeStatus(describeVolumeStatus);
}
@Override
public DetachNetworkInterfaceResponse detachNetworkInterface(
DetachNetworkInterface detachNetworkInterface) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.detachNetworkInterface(detachNetworkInterface);
}
@Override
public DescribeNetworkInterfacesResponse describeNetworkInterfaces(
DescribeNetworkInterfaces describeNetworkInterfaces) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeNetworkInterfaces(describeNetworkInterfaces);
}
@Override
public CancelExportTaskResponse cancelExportTask(
CancelExportTask cancelExportTask) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.cancelExportTask(cancelExportTask);
}
@Override
public CreateRouteResponse createRoute(CreateRoute createRoute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createRoute(createRoute);
}
@Override
public DescribeRouteTablesResponse describeRouteTables(
DescribeRouteTables describeRouteTables) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeRouteTables(describeRouteTables);
}
@Override
public DeleteNetworkAclResponse deleteNetworkAcl(
DeleteNetworkAcl deleteNetworkAcl) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.deleteNetworkAcl(deleteNetworkAcl);
}
@Override
public DeleteRouteResponse deleteRoute(DeleteRoute deleteRoute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.deleteRoute(deleteRoute);
}
@Override
public CreateVpnConnectionRouteResponse createVpnConnectionRoute(
CreateVpnConnectionRoute createVpnConnectionRoute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createVpnConnectionRoute(createVpnConnectionRoute);
}
@Override
public AttachInternetGatewayResponse attachInternetGateway(
AttachInternetGateway attachInternetGateway) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.attachInternetGateway(attachInternetGateway);
}
@Override
public ReplaceRouteTableAssociationResponse replaceRouteTableAssociation(
ReplaceRouteTableAssociation replaceRouteTableAssociation) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.replaceRouteTableAssociation(replaceRouteTableAssociation);
}
@Override
public AssociateRouteTableResponse associateRouteTable(
AssociateRouteTable associateRouteTable) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.associateRouteTable(associateRouteTable);
}
@Override
public DetachInternetGatewayResponse detachInternetGateway(
DetachInternetGateway detachInternetGateway) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.detachInternetGateway(detachInternetGateway);
}
@Override
public DescribeExportTasksResponse describeExportTasks(
DescribeExportTasks describeExportTasks) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.describeExportTasks(describeExportTasks);
}
@Override
public CreateInstanceExportTaskResponse createInstanceExportTask(
CreateInstanceExportTask createInstanceExportTask) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createInstanceExportTask(createInstanceExportTask);
}
@Override
public AssignPrivateIpAddressesResponse assignPrivateIpAddresses(
AssignPrivateIpAddresses assignPrivateIpAddresses) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.assignPrivateIpAddresses(assignPrivateIpAddresses);
}
@Override
public ReportInstanceStatusResponse reportInstanceStatus(
ReportInstanceStatus reportInstanceStatus) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.reportInstanceStatus(reportInstanceStatus);
}
@Override
public DeleteInternetGatewayResponse deleteInternetGateway(
DeleteInternetGateway deleteInternetGateway) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.deleteInternetGateway(deleteInternetGateway);
}
@Override
public AttachNetworkInterfaceResponse attachNetworkInterface(
AttachNetworkInterface attachNetworkInterface) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.attachNetworkInterface(attachNetworkInterface);
}
@Override
public CreateNetworkInterfaceResponse createNetworkInterface(
CreateNetworkInterface createNetworkInterface) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.createNetworkInterface(createNetworkInterface);
}
@Override
public RevokeSecurityGroupEgressResponse revokeSecurityGroupEgress(
RevokeSecurityGroupEgress revokeSecurityGroupEgress) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.revokeSecurityGroupEgress(revokeSecurityGroupEgress);
}
@Override
public ReplaceRouteResponse replaceRoute(ReplaceRoute replaceRoute) {
AmazonEC2SkeletonInterface ec2Service = ServiceProvider.getInstance().getServiceImpl(AmazonEC2SkeletonInterface.class);
return ec2Service.replaceRoute(replaceRoute);
}
}

View File

@ -122,8 +122,9 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
public AuthorizeSecurityGroupIngressResponse authorizeSecurityGroupIngress(AuthorizeSecurityGroupIngress authorizeSecurityGroupIngress) {
AuthorizeSecurityGroupIngressType sgit = authorizeSecurityGroupIngress.getAuthorizeSecurityGroupIngress();
IpPermissionSetType ipPerms = sgit.getIpPermissions();
EC2AuthorizeRevokeSecurityGroup request = toSecurityGroup( sgit.getGroupName(), ipPerms.getItem());
EC2AuthorizeRevokeSecurityGroup request = toSecurityGroup(
sgit.getAuthorizeSecurityGroupIngressTypeChoice_type0().getGroupName(), ipPerms.getItem());
return toAuthorizeSecurityGroupIngressResponse( engine.authorizeSecurityGroup( request ));
}
@ -132,8 +133,9 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
{
RevokeSecurityGroupIngressType sgit = revokeSecurityGroupIngress.getRevokeSecurityGroupIngress();
IpPermissionSetType ipPerms = sgit.getIpPermissions();
EC2AuthorizeRevokeSecurityGroup request = toSecurityGroup( sgit.getGroupName(), ipPerms.getItem());
EC2AuthorizeRevokeSecurityGroup request = toSecurityGroup(
sgit.getRevokeSecurityGroupIngressTypeChoice_type0().getGroupName(), ipPerms.getItem());
return toRevokeSecurityGroupIngressResponse( engine.revokeSecurityGroup( request ));
}
@ -478,8 +480,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
@Override
public ReleaseAddressResponse releaseAddress(ReleaseAddress releaseAddress) {
EC2ReleaseAddress request = new EC2ReleaseAddress();
request.setPublicIp(releaseAddress.getReleaseAddress().getPublicIp());
request.setPublicIp(releaseAddress.getReleaseAddress().getReleaseAddressTypeChoice_type0().getPublicIp());
return toReleaseAddressResponse( engine.releaseAddress( request ) );
}
@ -487,10 +489,12 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
@Override
public AssociateAddressResponse associateAddress(AssociateAddress associateAddress) {
EC2AssociateAddress request = new EC2AssociateAddress();
request.setPublicIp(associateAddress.getAssociateAddress().getPublicIp());
request.setInstanceId(associateAddress.getAssociateAddress().getInstanceId());
request.setPublicIp( associateAddress.getAssociateAddress().
getAssociateAddressTypeChoice_type0().getPublicIp());
request.setInstanceId(associateAddress.getAssociateAddress().
getAssociateAddressTypeChoice_type1().getInstanceId());
return toAssociateAddressResponse( engine.associateAddress( request ) );
}
@ -794,7 +798,12 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
if (null != gst) {
GroupItemType[] items = gst.getItem();
if (null != items) {
for( int i=0; i < items.length; i++ ) request.addGroupName(items[i].getGroupId());
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);
@ -973,6 +982,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
ProductCodesSetType param4 = new ProductCodesSetType();
ProductCodesSetItemType param5 = new ProductCodesSetItemType();
param5.setProductCode( "" );
param5.setType("");
param4.addItem( param5 );
param3.setProductCodes( param4 );
@ -1342,6 +1352,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
param3.setSnapshotId(snapId);
param3.setAvailabilityZone( vol.getZoneName());
param3.setStatus( vol.getState());
param3.setVolumeType("standard");
// -> CloudStack seems to have issues with timestamp formats so just in case
Calendar cal = EC2RestAuth.parseDateString(vol.getCreated());
@ -1427,11 +1438,13 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
if (null == groups || 0 == groups.length) {
GroupItemType param5 = new GroupItemType();
param5.setGroupId("");
param5.setGroupName("");
param4.addItem( param5 );
} else {
for (EC2SecurityGroup group : groups) {
GroupItemType param5 = new GroupItemType();
param5.setGroupId(group.getId());
param5.setGroupName("");
param4.addItem( param5 );
}
}
@ -1458,6 +1471,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
ProductCodesSetType param9 = new ProductCodesSetType();
ProductCodesSetItemType param10 = new ProductCodesSetItemType();
param10.setProductCode( "" );
param10.setType("");
param9.addItem( param10 );
param7.setProductCodes( param9 );
@ -1494,7 +1508,13 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
param7.setRootDeviceType( "" );
String devicePath = engine.cloudDeviceIdToDevicePath( inst.getHypervisor(), inst.getRootDeviceId());
param7.setRootDeviceName( devicePath );
GroupSetType param14 = new GroupSetType();
GroupItemType param15 = new GroupItemType(); // VPC security group
param15.setGroupName("");
param15.setGroupName("");
param14.addItem(param15);
param7.setGroupSet(param14);
param7.setInstanceLifecycle( "" );
param7.setSpotInstanceRequestId( "" );
@ -1542,6 +1562,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
AllocateAddressResponseType param1 = new AllocateAddressResponseType();
param1.setPublicIp(ec2Address.getIpAddress());
param1.setDomain("standard");
param1.setAllocationId("");
param1.setRequestId(UUID.randomUUID().toString());
response.setAllocateAddressResponse(param1);
return response;
@ -1561,7 +1583,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
public static AssociateAddressResponse toAssociateAddressResponse(final boolean result) {
AssociateAddressResponse response = new AssociateAddressResponse();
AssociateAddressResponseType param1 = new AssociateAddressResponseType();
param1.setAssociationId("");
param1.setRequestId(UUID.randomUUID().toString());
param1.set_return(result);
@ -1761,6 +1784,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
ProductCodesSetType param9 = new ProductCodesSetType();
ProductCodesSetItemType param10 = new ProductCodesSetItemType();
param10.setProductCode( "" );
param10.setType("");
param9.addItem( param10 );
param7.setProductCodes( param9 );
@ -1809,7 +1833,14 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
param19.setValue("");
param18.addItem( param19 );
param7.setTagSet( param18 );
GroupSetType param14 = new GroupSetType();
GroupItemType param15 = new GroupItemType();
param15.setGroupId("");
param15.setGroupName("");
param14.addItem(param15);
param7.setGroupSet(param14);
String hypervisor = inst.getHypervisor();
param7.setHypervisor((null != hypervisor ? hypervisor : ""));
param6.addItem( param7 );
@ -1907,6 +1938,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
}
param1.setCreateTime( cal );
param1.setVolumeType("standard");
param1.setRequestId( UUID.randomUUID().toString());
response.setCreateVolumeResponse( param1 );
return response;
@ -2040,6 +2072,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
param3.setGroupName(group.getName());
String desc = group.getDescription();
param3.setGroupDescription((null != desc ? desc : ""));
param3.setGroupId(group.getId());
param3.setVpcId("");
IpPermissionSetType param4 = new IpPermissionSetType();
EC2IpPermission[] perms = group.getIpPermissionSet();
@ -2101,11 +2135,16 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
return response;
}
public static CreateSecurityGroupResponse toCreateSecurityGroupResponse( boolean success ) {
public static CreateSecurityGroupResponse toCreateSecurityGroupResponse( EC2SecurityGroup sg ) {
CreateSecurityGroupResponse response = new CreateSecurityGroupResponse();
CreateSecurityGroupResponseType param1 = new CreateSecurityGroupResponseType();
param1.set_return(success);
param1.setGroupId( sg.getId() );
if ( sg.getId() != null )
param1.set_return(true);
else
param1.set_return(false);
param1.setRequestId( UUID.randomUUID().toString());
response.setCreateSecurityGroupResponse( param1 );
return response;
@ -2540,4 +2579,295 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
public ResetSnapshotAttributeResponse resetSnapshotAttribute(ResetSnapshotAttribute resetSnapshotAttribute) {
throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available");
}
public ResetNetworkInterfaceAttributeResponse resetNetworkInterfaceAttribute(
ResetNetworkInterfaceAttribute resetNetworkInterfaceAttribute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateRouteTableResponse createRouteTable(
CreateRouteTable createRouteTable) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateNetworkAclEntryResponse createNetworkAclEntry(
CreateNetworkAclEntry createNetworkAclEntry) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeVolumeAttributeResponse describeVolumeAttribute(
DescribeVolumeAttribute describeVolumeAttribute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DeleteNetworkInterfaceResponse deleteNetworkInterface(
DeleteNetworkInterface deleteNetworkInterface) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateInternetGatewayResponse createInternetGateway(
CreateInternetGateway createInternetGateway) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DisassociateRouteTableResponse disassociateRouteTable(
DisassociateRouteTable disassociateRouteTable) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public ReplaceNetworkAclEntryResponse replaceNetworkAclEntry(
ReplaceNetworkAclEntry replaceNetworkAclEntry) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public AuthorizeSecurityGroupEgressResponse authorizeSecurityGroupEgress(
AuthorizeSecurityGroupEgress authorizeSecurityGroupEgress) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DeleteNetworkAclEntryResponse deleteNetworkAclEntry(
DeleteNetworkAclEntry deleteNetworkAclEntry) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DeleteRouteTableResponse deleteRouteTable(
DeleteRouteTable deleteRouteTable) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeNetworkInterfaceAttributeResponse describeNetworkInterfaceAttribute(
DescribeNetworkInterfaceAttribute describeNetworkInterfaceAttribute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateReservedInstancesListingResponse createReservedInstancesListing(
CreateReservedInstancesListing createReservedInstancesListing) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateNetworkAclResponse createNetworkAcl(
CreateNetworkAcl createNetworkAcl) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public ModifyVolumeAttributeResponse modifyVolumeAttribute(
ModifyVolumeAttribute modifyVolumeAttribute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public ReplaceNetworkAclAssociationResponse replaceNetworkAclAssociation(
ReplaceNetworkAclAssociation replaceNetworkAclAssociation) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public EnableVgwRoutePropagationResponse enableVgwRoutePropagation(
EnableVgwRoutePropagation enableVgwRoutePropagation) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public UnassignPrivateIpAddressesResponse unassignPrivateIpAddresses(
UnassignPrivateIpAddresses unassignPrivateIpAddresses) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DeleteVpnConnectionRouteResponse deleteVpnConnectionRoute(
DeleteVpnConnectionRoute deleteVpnConnectionRoute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CancelReservedInstancesListingResponse cancelReservedInstancesListing(
CancelReservedInstancesListing cancelReservedInstancesListing) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeNetworkAclsResponse describeNetworkAcls(
DescribeNetworkAcls describeNetworkAcls) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public EnableVolumeIOResponse enableVolumeIO(EnableVolumeIO enableVolumeIO) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeInternetGatewaysResponse describeInternetGateways(
DescribeInternetGateways describeInternetGateways) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeReservedInstancesListingsResponse describeReservedInstancesListings(
DescribeReservedInstancesListings describeReservedInstancesListings) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeInstanceStatusResponse describeInstanceStatus(
DescribeInstanceStatus describeInstanceStatus) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public ModifyNetworkInterfaceAttributeResponse modifyNetworkInterfaceAttribute(
ModifyNetworkInterfaceAttribute modifyNetworkInterfaceAttribute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DisableVgwRoutePropagationResponse disableVgwRoutePropagation(
DisableVgwRoutePropagation disableVgwRoutePropagation) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeVolumeStatusResponse describeVolumeStatus(
DescribeVolumeStatus describeVolumeStatus) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DetachNetworkInterfaceResponse detachNetworkInterface(
DetachNetworkInterface detachNetworkInterface) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeNetworkInterfacesResponse describeNetworkInterfaces(
DescribeNetworkInterfaces describeNetworkInterfaces) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CancelExportTaskResponse cancelExportTask(
CancelExportTask cancelExportTask) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateRouteResponse createRoute(CreateRoute createRoute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeRouteTablesResponse describeRouteTables(
DescribeRouteTables describeRouteTables) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DeleteNetworkAclResponse deleteNetworkAcl(
DeleteNetworkAcl deleteNetworkAcl) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DeleteRouteResponse deleteRoute(DeleteRoute deleteRoute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateVpnConnectionRouteResponse createVpnConnectionRoute(
CreateVpnConnectionRoute createVpnConnectionRoute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public AttachInternetGatewayResponse attachInternetGateway(
AttachInternetGateway attachInternetGateway) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public ReplaceRouteTableAssociationResponse replaceRouteTableAssociation(
ReplaceRouteTableAssociation replaceRouteTableAssociation) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public AssociateRouteTableResponse associateRouteTable(
AssociateRouteTable associateRouteTable) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DetachInternetGatewayResponse detachInternetGateway(
DetachInternetGateway detachInternetGateway) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DescribeExportTasksResponse describeExportTasks(
DescribeExportTasks describeExportTasks) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateInstanceExportTaskResponse createInstanceExportTask(
CreateInstanceExportTask createInstanceExportTask) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public AssignPrivateIpAddressesResponse assignPrivateIpAddresses(
AssignPrivateIpAddresses assignPrivateIpAddresses) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public ReportInstanceStatusResponse reportInstanceStatus(
ReportInstanceStatus reportInstanceStatus) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public DeleteInternetGatewayResponse deleteInternetGateway(
DeleteInternetGateway deleteInternetGateway) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public AttachNetworkInterfaceResponse attachNetworkInterface(
AttachNetworkInterface attachNetworkInterface) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public CreateNetworkInterfaceResponse createNetworkInterface(
CreateNetworkInterface createNetworkInterface) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public RevokeSecurityGroupEgressResponse revokeSecurityGroupEgress(
RevokeSecurityGroupEgress revokeSecurityGroupEgress) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
public ReplaceRouteResponse replaceRoute(ReplaceRoute replaceRoute) {
throw new EC2ServiceException(ClientError.Unsupported,
"This operation is not available");
}
}

View File

@ -236,18 +236,18 @@ public class EC2Engine extends ManagerBase {
* @param groupDesc
* @return
*/
public Boolean createSecurityGroup(String groupName, String groupDesc) {
public EC2SecurityGroup createSecurityGroup(String groupName, String groupDesc) {
EC2SecurityGroup sg = new EC2SecurityGroup();
try {
CloudStackSecurityGroup grp = getApi().createSecurityGroup(groupName, null, groupDesc, null);
if (grp != null && grp.getId() != null) {
return true;
sg.setId(grp.getId());
}
return false;
} catch( Exception e ) {
logger.error( "EC2 CreateSecurityGroup - ", e);
handleException(e);
}
return false;
return sg;
}
/**
@ -1360,6 +1360,8 @@ public class EC2Engine extends ManagerBase {
int createInstances = 0;
int canCreateInstances = -1;
int countCreated = 0;
String groupIds = null;
String groupNames = null;
try {
// ugly...
@ -1401,13 +1403,25 @@ public class EC2Engine extends ManagerBase {
// network
CloudStackNetwork network = findNetwork(zone);
// for EC2 security groups either a group ID or a group name is accepted
String[] sgIdList = request.getSecurityGroupIdSet();
String[] sgNameList = request.getSecurityGroupNameSet();
if ( sgIdList.length != 0 && sgNameList.length != 0 )
throw new EC2ServiceException(ClientError.InvalidParameterCombination,
" for EC2 groups either a group ID or a group name is accepted");
if (sgIdList.length != 0)
groupIds = constructList(sgIdList);
if (sgNameList.length != 0)
groupNames = constructList(sgNameList);
// now actually deploy the vms
for( int i=0; i < createInstances; i++ ) {
try{
CloudStackUserVm resp = getApi().deployVirtualMachine(svcOffering.getId(),
request.getTemplateId(), zoneId, null, null, null, null,
null, null, null, request.getKeyName(), null, (network != null ? network.getId() : null),
null, constructList(request.getGroupSet()), request.getSize().longValue(), request.getUserData());
groupIds, groupNames, request.getSize().longValue(), request.getUserData());
EC2Instance vm = new EC2Instance();
vm.setId(resp.getId().toString());
vm.setName(resp.getName());

View File

@ -30,7 +30,8 @@ public class EC2RunInstances {
private int maxCount;
private int minCount;
private Integer size; // <- in gigs
private List<String> groupSet = new ArrayList<String>();
private List<String> groupIdSet;
private List<String> groupNameSet;
public EC2RunInstances() {
instanceType = null;
@ -42,6 +43,8 @@ public class EC2RunInstances {
maxCount = 0;
minCount = 0;
size = 0;
groupIdSet = new ArrayList<String>();
groupNameSet = new ArrayList<String>();
}
public void setInstanceType( String instanceType ) {
@ -115,12 +118,21 @@ public class EC2RunInstances {
public void setSize(Integer size) {
this.size = size;
}
public void addGroupName( String param ) {
groupSet.add( param );
public void addSecuritGroupId( String param ) {
groupIdSet.add( param );
}
public String[] getGroupSet() {
return groupSet.toArray(new String[0]);
public String[] getSecurityGroupIdSet() {
return groupIdSet.toArray(new String[0]);
}
public void addSecuritGroupName( String param ) {
groupNameSet.add( param );
}
public String[] getSecurityGroupNameSet() {
return groupNameSet.toArray(new String[0]);
}
}