Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stitching GCP with AWS via Fabric #148

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cicd/test_configs/fabric_native_aws/config.fab
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ resource:
device_name: agg3.ashb
local_name: TenGigE0/0/0/11/3
site: AWS
labels: ['fabric_network@network']
producer: fabric
consumer: aws
29 changes: 20 additions & 9 deletions examples/demos/cloudlab/clem/config.fab
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable:
- vlan:
default: 3100
default: 3200

provider:
- cloudlab:
Expand All @@ -11,6 +11,10 @@ provider:
- fabric_provider:
credential_file: ~/.fabfed/fabfed_credentials.yml
profile: fabric
- janus:
- janus_provider:
credential_file: ~/.fabfed/fabfed_credentials.yml
profile: janus

config:
- layer3:
Expand All @@ -24,8 +28,15 @@ resource:
- cnet:
provider: '{{cloudlab.cloudlab_provider }}'
layer3: "{{ layer3.my_layer }}"
profile: clem-profile
interface:
- vlan: '{{ var.vlan }}'
- fabric_network:
provider: '{{ fabric.fabric_provider }}'
layer3: "{{ layer3.my_layer }}"
stitch_with: '{{ network.cnet }}'
stitch_option:
device_name: CloudLab-Clemson
- node:
- cloudlab_node:
provider: '{{ cloudlab.cloudlab_provider }}'
Expand All @@ -38,11 +49,11 @@ resource:
nic_model: NIC_Basic
network: "{{ network.fabric_network }}"
count: 1
- network:
- fabric_network:
provider: '{{ fabric.fabric_provider }}'
layer3: "{{ layer3.my_layer }}"
stitch_with: '{{ network.cnet }}'
stitch_option:
device_name: CloudLab-Clemson
count: 1
- service:
- dtn_service:
provider: '{{ janus.janus_provider }}'
node: [ '{{ node.cloudlab_node }}', '{{ node.fabric_node }}' ]
controller: '{{ node.fabric_node }}'
image: dtnaas/tools
profile: fabfed
count: 0
68 changes: 68 additions & 0 deletions examples/demos/native-gcp-aws/config.fab
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
provider:
- gcp:
- gcp_provider:
- credential_file: ~/.fabfed/fabfed_credentials.yml
profile: gcp
- aws:
- aws_provider:
- credential_file: ~/.fabfed/fabfed_credentials.yml
profile: aws
- fabric:
- fabric_provider:
credential_file: ~/.fabfed/fabfed_credentials.yml
profile: fabric
config:
- layer3:
- gcp_layer:
subnet: 10.200.1.0/24 # subnet.cidr and vpc.cidr
- aws_layer:
subnet: 10.0.1.0/24 # 10.200.1.0/24 # subnet.cidr and vpc.cidr
- peering:
- gcp_peering:
# FOR GCP
cloud_region: "us-east4"
cloud_vpc: "vpc-69acc1d9-8c24-47cd-90b8-33be57167dbf"
# cloud_vlan:

# FOR GCP AND FABRIC.
# local_asn: 55038 # customer_asn
remote_asn: 16550 # google_asn

# FOR FABRIC
local_address: "192.168.1.1/30" # customer_ip
remote_address: "192.168.1.2/30" # google_ip
- aws_peering:
cloud_account: "296256999979"
cloud_vpc: "vpc-0936b973cf039f794"
cloud_region: "us-east-1"
# cloud_vlan:

remote_asn: 64512 # amazon_asn
local_asn: 55038 # customer_asn
local_address: "192.168.1.1/30" # customer_ip
remote_address: "192.168.1.2/30" # amazon_ip

resource:
- network:
- gcp_net:
provider: '{{ gcp.gcp_provider }}'
name: gcp-net
layer3: "{{ layer3.gcp_layer }}"
peering: "{{ peering.gcp_peering }}"

- fabric_network:
provider: '{{ fabric.fabric_provider }}'
peering: [ "{{ peering.gcp_peering }}", "{{ peering.aws_peering }}" ]
count: 1
stitch_with:
- network: '{{ network.gcp_net }}'
stitch_option:
group_name: GCP
- network: '{{ network.aws_net }}'
stitch_option:
device_name: agg3.ashb

- aws_net:
provider: '{{ aws.aws_provider }}'
layer3: "{{ layer3.aws_layer }}"
peering: "{{ peering.aws_peering }}"
31 changes: 27 additions & 4 deletions fabfed/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,40 @@ def init(self, *, session: str, provider_factory: ProviderFactory, provider_stat
for networks_with_same_layer3 in layer3_to_network_mapping.values():
partition_layer3_config(networks=networks_with_same_layer3)

# Handle peering labels. The labels are inserted here to match it to a stitch port
for network in networks:
peering_list = network.attributes.get(Constants.RES_PEERING)

if not peering_list:
continue

if not isinstance(peering_list, list):
peering_list = [peering_list]

for peering in peering_list:
if Constants.LABELS not in peering.attributes:
peering.attributes[Constants.LABELS] = []

peering.attributes[Constants.LABELS].append(network.label)
peering.attributes[Constants.LABELS] = sorted(peering.attributes["labels"])

peering_to_network_mapping = {}

for network in networks:
if Constants.RES_PEER_LAYER3 in network.attributes: # This is for testing
continue

network.attributes[Constants.RES_PEER_LAYER3] = []
peering = network.attributes.get(Constants.RES_PEERING)

if peering:
peering_list = network.attributes.get(Constants.RES_PEERING)

if not peering_list:
continue

if not isinstance(peering_list, list):
peering_list = [peering_list]

for peering in peering_list:
if peering.label in peering_to_network_mapping:
peering_to_network_mapping.get(peering.label).append(network)
else:
Expand All @@ -150,7 +174,6 @@ def init(self, *, session: str, provider_factory: ProviderFactory, provider_stat

for network in [net for net in networks if net.attributes.get(Constants.RES_STITCH_INFO)]:
stitch_info = network.attributes.get(Constants.RES_STITCH_INFO)

self.logger.info(f"{network}: stitch_info={stitch_info}")

def plan(self, provider_states: List[ProviderState]):
Expand Down Expand Up @@ -427,7 +450,7 @@ def destroy(self, *, provider_states: List[ProviderState]):
try:
provider.delete_resource(resource=resource.attributes)
except Exception as e:
self.logger.warning(f"Exception occurred while deleting resource: {e} using {provider_label}")
self.logger.warning(f"Exception occurred while deleting resource: {e} using {provider_label}", exc_info=True)
remaining_resources.append(resource)
skip_resources.update([external_state.label for external_state in external_states])
exceptions.append(e)
Expand Down
5 changes: 4 additions & 1 deletion fabfed/policy/policy_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,9 @@ def handle_stitch_info(config, policy, resources):
stitch_info.stitch_port['peer'] = dict()
stitch_info.stitch_port['peer'].update(peer1)

# Handle stitch port labels. The labels are inserted here to match it to a peering config
stitch_info.stitch_port[Constants.LABELS] = sorted([network.label, other_network.label])
network.attributes[Constants.RES_STITCH_INFO].append(stitch_info)

stitch_info = StitchInfo(stitch_port=dict(),
producer=stitch_info.producer, consumer=stitch_info.consumer)

Expand All @@ -556,6 +557,8 @@ def handle_stitch_info(config, policy, resources):
stitch_info.stitch_port.update(peer2)
stitch_info.stitch_port['peer'] = dict()
stitch_info.stitch_port['peer'].update(peer1)
# Handle stitch port labels. The labels are inserted here to match it to a peering config
stitch_info.stitch_port[Constants.LABELS] = sorted([network.label, other_network.label])
other_network.attributes[Constants.RES_STITCH_INFO].append(stitch_info)

for network in [resource for resource in resources if resource.is_network]:
Expand Down
3 changes: 2 additions & 1 deletion fabfed/provider/api/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ def create_resource(self, *, resource: dict):
self.add_resource(resource=internal_dependency)
except Exception as e2:
self.logger.warning(
f"Adding no longer pending internally {internal_dependency_label} failed using {e2}")
f"Adding no longer pending internally {internal_dependency_label} failed using {e2}",
exc_info=True)

if label in self._added:
self.logger.info(f"Create: {label} using {self.label}: {self._added}")
Expand Down
Loading