in pce/validator/validation_suite.py [0:0]
def validate_route_table(self, pce: PCE) -> ValidationResult:
"""
Make sure there is an entry in the route table for the VPC peer and that it is active
"""
vpc = pce.pce_network.vpc
if not vpc:
return ValidationResult(
ValidationResultCode.ERROR,
ValidationErrorDescriptionTemplate.VPC_PEERING_NO_VPC.value,
)
route_table = pce.pce_network.route_table
if not route_table:
return ValidationResult(
ValidationResultCode.ERROR,
ValidationErrorDescriptionTemplate.VPC_PEERING_NO_ROUTE_TABLE.value,
)
is_vpc_peering_valid = any(
r.state == RouteState.ACTIVE
and r.route_target.route_target_type == RouteTargetType.VPC_PEERING
for r in (route_table.routes if route_table else [])
)
if not is_vpc_peering_valid:
return ValidationResult(
ValidationResultCode.ERROR,
ValidationErrorDescriptionTemplate.ROUTE_TABLE_VPC_PEERING_MISSING.value,
ValidationErrorSolutionHintTemplate.ROUTE_TABLE_VPC_PEERING_MISSING.value,
)
igw_route = None
for route in route_table.routes:
if (
route.route_target.route_target_type == RouteTargetType.INTERNET
and route.destination_cidr_block == IGW_ROUTE_DESTINATION_CIDR_BLOCK
):
igw_route = route
if not igw_route:
return ValidationResult(
ValidationResultCode.ERROR,
ValidationErrorDescriptionTemplate.ROUTE_TABLE_IGW_MISSING.value,
ValidationErrorSolutionHintTemplate.ROUTE_TABLE_IGW_MISSING.value,
)
if igw_route.state != RouteState.ACTIVE:
return ValidationResult(
ValidationResultCode.ERROR,
ValidationErrorDescriptionTemplate.ROUTE_TABLE_IGW_INACTIVE.value,
ValidationErrorSolutionHintTemplate.ROUTE_TABLE_IGW_INACTIVE.value,
)
return ValidationResult(ValidationResultCode.SUCCESS)