Ejemplo n.º 1
0
def get_route_rules(input_route_rules):
    route_rules = []
    for route_rule_dict in input_route_rules:
        route_rule = RouteRule()
        for attribute in route_rule.attribute_map:
            route_rule.__setattr__(attribute, route_rule_dict.get(attribute))

        # This is a temporary fix till deprecated cidr_block parameter gets removed.
        # Right now, the value of destination gets updated in cidr_block and vice-versa
        # after route rule gets created. This causes problem in idempotency. So performing the same
        # while creating input route table.
        if route_rule_dict.get("destination") is None:
            route_rule.__setattr__("destination", route_rule_dict.get("cidr_block"))
        elif (
            route_rule_dict.get("cidr_block") is None
            and route_rule_dict.get("destination_type")
            != RouteRule.DESTINATION_TYPE_SERVICE_CIDR_BLOCK
        ):
            route_rule.__setattr__("cidr_block", route_rule_dict.get("destination"))

        if route_rule_dict.get("destination_type") is None:
            route_rule.__setattr__(
                "destination_type", RouteRule.DESTINATION_TYPE_CIDR_BLOCK
            )

        route_rules.append(route_rule)
    return route_rules
def get_route_rules(input_route_rules):
    route_rules = []
    for route_rule_dict in input_route_rules:
        route_rule = RouteRule()
        for attribute in route_rule.attribute_map:
            route_rule.__setattr__(attribute, route_rule_dict.get(attribute))
        route_rules.append(route_rule)
    return route_rules
Ejemplo n.º 3
0
def _construct_route_rule(cidr, ne_ocid):
    if match(CIDR_RE_PATTERN, cidr):
        route_rule = RouteRule(destination=cidr,
                               destination_type=CIDR_DESTINATION_TYPE,
                               network_entity_id=ne_ocid)
    else:
        route_rule = RouteRule(destination=cidr,
                               destination_type=SERVICE_DESTINATION_TYPE,
                               network_entity_id=ne_ocid)

    return route_rule
def get_route_rules():
    route_rule1 = RouteRule()
    route_rule2 = RouteRule()
    route_rule1.cidr_block = '10.0.0.0/12'
    route_rule1.network_entity_id = 'oci1.internetgateway.ijkl'
    route_rule2.cidr_block = '10.0.0.0/16'
    route_rule2.network_entity_id = 'oci1.internetgateway.efgh'
    return [route_rule1, route_rule2]
Ejemplo n.º 5
0
def get_route_rules():
    route_rule1 = RouteRule()
    route_rule2 = RouteRule()
    route_rule1.cidr_block = "10.0.0.0/12"
    route_rule1.network_entity_id = "oci1.internetgateway.ijkl"
    route_rule2.cidr_block = "10.0.0.0/16"
    route_rule2.network_entity_id = "oci1.internetgateway.efgh"
    return [route_rule1, route_rule2]
Ejemplo n.º 6
0
def get_common_route_rule():
    route_rule = RouteRule()
    route_rule.cidr_block = "0.0.0.0/0"
    route_rule.destination = "0.0.0.0/0"
    route_rule.destination_type = RouteRule.DESTINATION_TYPE_CIDR_BLOCK
    route_rule.network_entity_id = "oci1.internetgateway.abcd"
    return route_rule
def get_common_route_rule():
    route_rule = RouteRule()
    route_rule.cidr_block = '0.0.0.0/0'
    route_rule.network_entity_id = 'oci1.internetgateway.abcd'
    return route_rule
Ejemplo n.º 8
0
def get_service_cidr_route_rule():
    route_rule = RouteRule()
    route_rule.destination = "oci-phx-objectstorage"
    route_rule.destination_type = RouteRule.DESTINATION_TYPE_SERVICE_CIDR_BLOCK
    route_rule.network_entity_id = "oci1.servicegateway.abcd"
    return route_rule
Ejemplo n.º 9
0
from ortu.oci_route_table import check_route
from oci.core.models import RouteTable, RouteRule

SOURCE_ROUTE_RULES = [
    RouteRule(
        destination='0.0.0.0/0',
        destination_type='CIDR_BLOCK',
        network_entity_id='ocid1.internetgateway.oc1.region.somelongstring')
]

SOURCE_ROUTE_TABLE = RouteTable(route_rules=SOURCE_ROUTE_RULES)

NEW_ROUTE_RULES = [
    RouteRule(
        destination='0.0.0.0/0',
        destination_type='CIDR_BLOCK',
        network_entity_id='ocid1.internetgateway.oc1.region.somelongstring'),
    RouteRule(destination='192.168.1.0/24',
              destination_type='CIDR_BLOCK',
              network_entity_id=
              'ocid1.internetgateway.oc1.region.anotherlongcrazystring'),
    RouteRule(destination='all-fra-services-in-oracle-services-network',
              destination_type='SERVICE_CIDR_BLOCK',
              network_entity_id=
              'ocid1.servicegateway.oc1.region.anotherlongcrazystringforsg')
]

NEW_ROUTE_TABLE = RouteTable(route_rules=NEW_ROUTE_RULES)

CIDR = '192.168.1.0/24'
NE_OCID = 'ocid1.internetgateway.oc1.region.anotherlongcrazystring'
Ejemplo n.º 10
0
from ortu.oci_route_table import construct_update_details
from oci.core.models import RouteTable, RouteRule


WO_CIDR_ROUTE_RULES = [
    RouteRule(
        destination='192.168.1.0/24',
        destination_type='CIDR_BLOCK',
        network_entity_id='ocid1.localpeeringgateway.oc1.region.lpgid'
    ),
    RouteRule(
        destination='all-fra-services-in-oracle-services-network',
        destination_type='SERVICE_CIDR_BLOCK',
        network_entity_id='ocid1.servicegateway.oc1.region.sgwid'
    )
]

WO_SERVICE_ROUTE_RULES = [
    RouteRule(
        destination='0.0.0.0/0',
        destination_type='CIDR_BLOCK',
        network_entity_id='ocid1.internetgateway.oc1.region.igid'
    ),
    RouteRule(
        destination='192.168.1.0/24',
        destination_type='CIDR_BLOCK',
        network_entity_id='ocid1.localpeeringgateway.oc1.region.lpgid'
    )
]

CIDR_ROUTE_RULES = [