本文整理汇总了Java中com.amazonaws.services.ec2.model.RouteTable类的典型用法代码示例。如果您正苦于以下问题:Java RouteTable类的具体用法?Java RouteTable怎么用?Java RouteTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RouteTable类属于com.amazonaws.services.ec2.model包,在下文中一共展示了RouteTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: RouteTableDTO
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
public RouteTableDTO(final RouteTable routeTable) {
this.routeTableId = routeTable.getRouteTableId();
this.vpcId = routeTable.getVpcId();
this.routes.addAll(
routeTable.getRoutes()
.stream()
.map(RouteDTO::new)
.collect(Collectors.toList()));
this.tags.addAll(
routeTable.getTags()
.stream()
.map(TagDTO::new)
.collect(Collectors.toList()));
this.associations.addAll(
routeTable.getAssociations()
.stream()
.map(RouteTableAssociationDTO::new)
.collect(Collectors.toList()));
this.propagatingVgws.addAll(
routeTable.getPropagatingVgws()
.stream()
.map(PropagatingVgwDTO::new)
.collect(Collectors.toList()));
}
开发者ID:kylesm,项目名称:vpcviewer,代码行数:25,代码来源:RouteTableDTO.java
示例2: getMainRouteTable
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Get the main route table for a given VPC
*/
public RouteTable getMainRouteTable(String vpcId) {
// build filter list
List<Filter> filters = new ArrayList<>();
filters.add(AWSUtils.getFilter(AWSUtils.AWS_FILTER_VPC_ID, vpcId));
filters.add(AWSUtils.getFilter(AWS_MAIN_ROUTE_ASSOCIATION, "true"));
DescribeRouteTablesRequest req = new DescribeRouteTablesRequest()
.withFilters(filters);
DescribeRouteTablesResult res = this.client.describeRouteTables(req);
List<RouteTable> routeTables = res.getRouteTables();
return routeTables.isEmpty() ? null : routeTables.get(0);
}
开发者ID:vmware,项目名称:photon-model,代码行数:16,代码来源:AWSNetworkClient.java
示例3: createRouteTable
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Create a route table
*/
public DeferredResult<String> createRouteTable(String vpcId) {
CreateRouteTableRequest req = new CreateRouteTableRequest()
.withVpcId(vpcId);
String message = "Create AWS Route Table on VPC [" + vpcId + "].";
AWSDeferredResultAsyncHandler<CreateRouteTableRequest, CreateRouteTableResult> handler = new
AWSDeferredResultAsyncHandler<>(this.service, message);
this.client.createRouteTableAsync(req, handler);
return handler.toDeferredResult()
.thenApply(CreateRouteTableResult::getRouteTable)
.thenApply(RouteTable::getRouteTableId);
}
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:AWSNetworkClient.java
示例4: consumeSuccess
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Update the main route table information for the VPC that is being mapped to a network
* state. Query AWS for the main route tables with a list of VPCs. From the result set find
* the relevant route table Id and upda
*/
@Override
protected void consumeSuccess(DescribeRouteTablesRequest request,
DescribeRouteTablesResult result) {
for (RouteTable routeTable : result.getRouteTables()) {
if (this.context.vpcs.containsKey(routeTable.getVpcId())) {
NetworkState networkStateToUpdate = this.context.vpcs
.get(routeTable.getVpcId());
networkStateToUpdate.customProperties.put(AWS_VPC_ROUTE_TABLE_ID,
routeTable.getRouteTableId());
this.context.vpcs.put(routeTable.getVpcId(),
networkStateToUpdate);
}
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:AWSNetworkStateEnumerationAdapterService.java
示例5: testGetMainRouteTable
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
@Test
public void testGetMainRouteTable() throws Throwable {
Vpc defVPC = this.netClient.getDefaultVPC();
assertTrue(defVPC != null);
RouteTable routeTable = this.netClient.getMainRouteTable(defVPC.getVpcId());
assertTrue(routeTable != null);
}
开发者ID:vmware,项目名称:photon-model,代码行数:8,代码来源:TestAWSNetworkService.java
示例6: testEnvironmentCreation
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
@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);
}
开发者ID:vmware,项目名称:photon-model,代码行数:31,代码来源:TestAWSNetworkService.java
示例7: VpcDetailDTO
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
public VpcDetailDTO(final Vpc vpc, final List<Subnet> subnets, final List<RouteTable> routeTables) {
super(vpc);
final Map<String, SubnetDetailDTO> subnetDetails = new HashMap<>();
subnetDetails.putAll(
subnets.stream()
.map(SubnetDetailDTO::new)
.collect(Collectors.toMap(s -> s.getSubnetId(), identity())));
LOG.trace("Details map: {}", subnetDetails);
routeTables.stream()
.map(RouteTableDTO::new)
.forEach(rt ->
rt.getAssociations().forEach(assoc -> {
SubnetDetailDTO dto = subnetDetails.get(assoc.getSubnetId());
if (dto == null) {
if (LOG.isTraceEnabled()) {
LOG.trace("RT: {}, Assoc.SubnetID: {}, Assocs: {}",
rt.getRouteTableId(),
assoc.getSubnetId(),
rt.getAssociations());
}
return;
}
dto.setRouteTableId(rt.getRouteTableId());
dto.getRoutes().addAll(rt.getRoutes());
}));
this.subnets.addAll(subnetDetails.values());
}
开发者ID:kylesm,项目名称:vpcviewer,代码行数:35,代码来源:VpcDetailDTO.java
示例8: SubnetDetailDTO
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
public SubnetDetailDTO(final Subnet subnet, final RouteTable routeTable) {
super(subnet);
routeTableId = routeTable.getRouteTableId();
routes.addAll(
routeTable.getRoutes()
.stream()
.map(RouteDTO::new)
.collect(Collectors.toList()));
}
开发者ID:kylesm,项目名称:vpcviewer,代码行数:11,代码来源:SubnetDetailDTO.java
示例9: getRouteTablesForVpcInRegion
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
@Override
@Cacheable(value = CachingConfiguration.ROUTE_TABLE_CACHE, key = "#vpcId", condition = "#bypassCache == false")
public List<RouteTable> getRouteTablesForVpcInRegion(final String vpcId, final String region, boolean bypassCache) {
LOG.info("Retrieving route tables for VPC {} in region {} ({})", vpcId, region, bypassCache);
DescribeRouteTablesRequest request = new DescribeRouteTablesRequest()
.withFilters(new Filter()
.withName("vpc-id")
.withValues(vpcId));
DescribeRouteTablesResult result = getClientForRegion(region).describeRouteTables(request);
return result.getRouteTables();
}
开发者ID:kylesm,项目名称:vpcviewer,代码行数:12,代码来源:VpcServiceImpl.java
示例10: toVpcRouteTables
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
public List<AbstractResource<?>> toVpcRouteTables(List<RouteTable> routeTables, String accountId, Region region, DateTime dt) {
List<AbstractResource<?>> resources = new ArrayList<>();
for (RouteTable routeTable : routeTables) {
VpcRouteTable vpcRouteTable = new VpcRouteTable();
conf(vpcRouteTable, accountId, region, dt);
vpcRouteTable.setResource(routeTable);
resources.add(vpcRouteTable);
}
log.debug("{} route tables found via api and converted to VpcRouteTable", resources.size());
return resources;
}
开发者ID:veyronfei,项目名称:clouck,代码行数:12,代码来源:Ec2Converter.java
示例11: checkIfRoutesExist
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Checks if routes between the selected VPCs already exist
*
* @param vpnEndpoints
* @return
*/
private boolean checkIfRoutesExist(List<VPNEndpoint> vpnEndpoints) {
boolean routesExist = false;
for (VPNEndpoint vpnEndpoint : vpnEndpoints) {
ec2Client.setEndpoint(vpnEndpoint.getRegion().getEndpoint());
DescribeRouteTablesResult descRouteTableResult = ec2Client.describeRouteTables();
List<RouteTable> routeTables = descRouteTableResult.getRouteTables();
for (RouteTable routeTable : routeTables) {
if (routeTable.getVpcId().equals(vpnEndpoint.getVpc().getVpcId())) {
List<Route> routes = routeTable.getRoutes();
for (Route route : routes) {
for (VPNEndpoint extVpnEndpoint : vpnEndpoints) {
if (!vpnEndpoint.equals(extVpnEndpoint)) {
LOG.debug("Checking if route allows requested traffic: " + route);
if (route.getDestinationCidrBlock().endsWith(extVpnEndpoint.getVpc().getCidrBlock())) {
routesExist = true;
LOG.error("A route already exists between " + vpnEndpoint.getVpc().getCidrBlock() + " and " + extVpnEndpoint.getVpc().getCidrBlock());
}
}
}
}
}
}
}
return routesExist;
}
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:36,代码来源:CreateConnection.java
示例12: createAndAssociateRoutes
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Create routes
*
* @param vpnEndpoints
*/
private void createAndAssociateRoutes(List<VPNEndpoint> vpnEndpoints) {
for (VPNEndpoint vpnEndpoint : vpnEndpoints) {
ec2Client.setEndpoint(vpnEndpoint.getRegion().getEndpoint());
for (VPNEndpoint extVpnEndpoint : vpnEndpoints) {
if (!vpnEndpoint.equals(extVpnEndpoint)) {
// Get route tables
DescribeRouteTablesResult descRouteTablesResult = ec2Client.describeRouteTables();
List<RouteTable> routeTables = descRouteTablesResult.getRouteTables();
for (RouteTable routeTable : routeTables) {
if (routeTable.getVpcId().equals(vpnEndpoint.getVpc().getVpcId())) {
// Create the route
CreateRouteRequest createRouteReq = new CreateRouteRequest();
createRouteReq.setDestinationCidrBlock(extVpnEndpoint.getVpc().getCidrBlock());
createRouteReq.setInstanceId(vpnEndpoint.getInstance().getInstanceId());
createRouteReq.setRouteTableId(routeTable.getRouteTableId());
LOG.debug("About to create a route in " + vpnEndpoint.getVpc().getVpcId() + " to " + extVpnEndpoint.getVpc().getVpcId() + " in route table: " + routeTable.getRouteTableId());
ec2Client.createRoute(createRouteReq);
LOG.debug("Created route in " + vpnEndpoint.getVpc().getVpcId() + " to " + extVpnEndpoint.getVpc().getVpcId() + " in route table: " + routeTable.getRouteTableId());
}
}
}
}
}
}
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:35,代码来源:CreateConnection.java
示例13: listRegionRouteTables
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
public HashMap<Region, List> listRegionRouteTables(AWSCredentials awsCreds) {
AmazonEC2Client ec2Client = new AmazonEC2Client(awsCreds);
List<Region> regions = new ArrayList();
DescribeRegionsResult descRegionsResult = ec2Client.describeRegions();
if (descRegionsResult != null) {
regions = descRegionsResult.getRegions();
}
HashMap<Region, List> regionRouteTablesMap = new HashMap();
ExecutorService listRouteTablesExecutor = Executors.newFixedThreadPool(8);
for (Region region : regions) {
List<RouteTable> routeTables = new ArrayList();
regionRouteTablesMap.put(region, routeTables);
Runnable worker = new ListRouteTableRunnable(awsCreds, region, routeTables);
listRouteTablesExecutor.execute(worker);
}
listRouteTablesExecutor.shutdown();
try {
listRouteTablesExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
LOG.error("Caught InterruptedException: " + e.getMessage());
}
return regionRouteTablesMap;
}
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:30,代码来源:VPCHelper.java
示例14: ListRouteTableRunnable
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
public ListRouteTableRunnable(AWSCredentials awsCreds, Region region, List<RouteTable> routeTables) {
this.region = region;
this.routeTables = routeTables;
ec2Client = new AmazonEC2Client(awsCreds);
ec2Client.setEndpoint(region.getEndpoint());
LOG.debug("Set endpoint to " + region.getEndpoint());
}
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:8,代码来源:VPCHelper.java
示例15: visitRouteTable
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
private void visitRouteTable(VPCDiagramBuilder vpcDiagram, RouteTable routeTable) throws CfnAssistException {
logger.debug("visit routetable " + routeTable.getRouteTableId());
List<Route> routes = routeTable.getRoutes();
List<RouteTableAssociation> usersOfTable = routeTable.getAssociations();
for (RouteTableAssociation usedBy : usersOfTable) {
String subnetId = usedBy.getSubnetId(); // can subnet ever be null in an association?
if (subnetId!=null) {
vpcDiagram.addAsssociatedRouteTable(routeTable, subnetId); // possible duplication if route table reused?
for (Route route : routes) {
vpcDiagram.addRoute(routeTable.getRouteTableId(), subnetId, route);
}
}
}
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:16,代码来源:VPCVisitor.java
示例16: addRouteTable
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
public void addRouteTable(RouteTable routeTable) throws CfnAssistException {
String name = AmazonVPCFacade.getNameFromTags(routeTable.getTags());
String routeTableId = routeTable.getRouteTableId();
String label = AmazonVPCFacade.createLabelFromNameAndID(routeTableId, name);
String diagramIdForTable = formRouteTableIdForDiagram(id, routeTableId);
networkChildDiagram.addRouteTable(diagramIdForTable, label);
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:9,代码来源:SubnetDiagramBuilder.java
示例17: describeRouteTableTest
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Test describing route table.
*/
@Test(timeout = TIMEOUT_LEVEL1)
public final void describeRouteTableTest() {
log.info("Start describing route table test");
createRouteTableTest();
RouteTable routeTable = getRouteTable();
Assert.assertNotNull("route table should not be null", routeTable);
Assert.assertNotNull("route table id should not be null", routeTable.getRouteTableId());
Assert.assertTrue("route table should be deleted", deleteRouteTable(routeTable.getRouteTableId()));
}
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:16,代码来源:Ec2NetworkTest.java
示例18: createRouteTableTest
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Test create route table.
*/
@Test(timeout = TIMEOUT_LEVEL1)
public final void createRouteTableTest() {
log.info("Start create route table test");
Vpc vpc = createVpc(MOCK_CIDR_BLOCK, PROPERTY_TENANCY);
RouteTable routeTable = createRouteTable(vpc.getVpcId());
Assert.assertNotNull("route table should not be null", routeTable);
Assert.assertNotNull("route table id should not be null", routeTable.getRouteTableId());
}
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:14,代码来源:Ec2NetworkTest.java
示例19: deleteRouteTableTest
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Test Delete route table.
*/
@Test(timeout = TIMEOUT_LEVEL1)
public final void deleteRouteTableTest() {
log.info("Start delete route table test");
Vpc vpc = createVpc(MOCK_CIDR_BLOCK, PROPERTY_TENANCY);
RouteTable routeTable = createRouteTable(vpc.getVpcId());
Assert.assertNotNull("route table should not be null", routeTable);
Assert.assertNotNull("route table id should not be null", routeTable.getRouteTableId());
Assert.assertTrue("route table should be deleted", deleteRouteTable(routeTable.getRouteTableId()));
}
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:16,代码来源:Ec2NetworkTest.java
示例20: createNetworkResourcesTest
import com.amazonaws.services.ec2.model.RouteTable; //导入依赖的package包/类
/**
* Test create Volumes.
*/
@Test(timeout = TIMEOUT_LEVEL1)
public final void createNetworkResourcesTest() {
//Create VPCs
for(int i =0 ; i < 2 ; i++)
{
createVpcTest();
}
List<Vpc> vpcs = describeVpcs();
// Create Subnet
for(Vpc vpc : vpcs) {
for(int j=0; j<2; j++)
{
Subnet subnet = createSubnet(MOCK_CIDR_BLOCK, vpc.getVpcId());
RouteTable routeTable = createRouteTable(vpc.getVpcId());
InternetGateway internetGateway = createInternetGateway();
createRoute(routeTable.getRouteTableId(), internetGateway.getInternetGatewayId(), MOCK_CIDR_BLOCK);
attachInternetGateway(internetGateway.getInternetGatewayId(), vpc.getVpcId());
}
}
}
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:30,代码来源:Ec2NetworkTest.java
注:本文中的com.amazonaws.services.ec2.model.RouteTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论