use of com.amazonaws.services.ec2.model.RouteTable in project photon-model by vmware.
the class TestAWSNetworkService method testEnvironmentCreation.
/*
* Test covers the necessary elements for a successful environment creation
* These environmental elements are necessary before any VM instances can be
* created
*
* - Internet Gateway
* - VPC
* - Subnet
* - Route to IG
*
*/
@Test
public void testEnvironmentCreation() throws Throwable {
boolean attached = false;
String gatewayID = this.netClient.createInternetGateway();
assertTrue(gatewayID != null);
String vpcID = this.netClient.createVPC(AWS_DEFAULT_SUBNET_CIDR);
assertTrue(vpcID != null);
String subnetID = this.netClient.createSubnet(AWS_DEFAULT_SUBNET_CIDR, vpcID).getSubnetId();
this.netClient.attachInternetGateway(vpcID, gatewayID);
InternetGateway gw = this.netClient.getInternetGateway(gatewayID);
List<InternetGatewayAttachment> attachments = gw.getAttachments();
// ensure we are attached to newly created vpc
for (InternetGatewayAttachment attachment : attachments) {
if (attachment.getVpcId().equalsIgnoreCase(vpcID)) {
attached = true;
break;
}
}
assertTrue(attached);
RouteTable routeTable = this.netClient.getMainRouteTable(vpcID);
this.netClient.createInternetRoute(gatewayID, routeTable.getRouteTableId(), "0.0.0.0/0");
// remove resources
this.netClient.detachInternetGateway(vpcID, gatewayID);
this.netClient.deleteInternetGateway(gatewayID);
this.netClient.deleteSubnet(subnetID);
this.netClient.deleteVPC(vpcID);
}
Aggregations