Skip to content

Commit

Permalink
we now support creation aws facility with no nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
abessiari committed Apr 24, 2024
2 parents f79d55f + d3ed4b0 commit 357d30f
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 39 deletions.
7 changes: 6 additions & 1 deletion fabfed/provider/fabric/fabric_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,17 @@ def handle_facility_port(self):
logger.info(f"Creating Facility Port:Labels: {labels}")
logger.info(f"Creating Facility Port:PeerLabels: {peer_labels}")

if cloud == "GCP":
mtu_size = 1460
else:
mtu_size = 9001

facility_port = self.slice_object.add_facility_port(
name='Cloud-Facility-' + cloud,
site=cloud,
labels=labels,
peer_labels=peer_labels,
capacities=Capacities(bw=50, mtu=9001))
capacities=Capacities(bw=50, mtu=mtu_size))

logger.info("CreatedFacilityPort:" + facility_port.toJson())
else:
Expand Down
6 changes: 6 additions & 0 deletions fabfed/provider/gcp/gcp_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def create(self):
region=region,
attachment_name=attachment_name)

# set the MD5 authentication
gcp_utils.patch_router(service_key_path=service_key_path,
project=project,
region=region,
router_name=router_name)

logger.info(f"attachment_details={attachment}")
self.interface.append(dict(id=attachment.pairing_key, provider=self._provider.type))

Expand Down
36 changes: 35 additions & 1 deletion fabfed/provider/gcp/gcp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from google.cloud.compute_v1.types import (
Router,
RouterBgp,
RouterBgpPeer,
# RouterBgpPeerBfd,
RouterMd5AuthenticationKey,
InsertRouterRequest,
PatchRouterRequest,
InterconnectAttachment,
)
from google.oauth2 import service_account
Expand Down Expand Up @@ -80,6 +84,35 @@ def create_router(*, service_key_path, project, region, router_name, vpc, bgp_as
check_operation_result(credentials=credentials, project=project, region=region, operation_name=response.name)
logger.info(f'Router {router_name} created successfully.')

def patch_router(*, service_key_path, project, region, router_name):
credentials = service_account.Credentials.from_service_account_file(service_key_path)
compute_client = compute_v1.RoutersClient(credentials=credentials)

# Get the router resource
router = compute_client.get(project=project, region=region, router=router_name)

# Access the BGP peers associated with the router
bgp_peers = router.bgp_peers

# Add md5 authentication
peer = bgp_peers[0]
peer.md5_authentication_key_name = 'md5-key-name-1'

router_resource = Router(
name=router_name,
md5_authentication_keys = [RouterMd5AuthenticationKey(key='0xzsEwC7xk6c1fK_h.xHyAdx', name='md5-key-name-1')],
bgp_peers=[peer]
)
request = PatchRouterRequest(
project=project,
region=region,
router=router_name,
router_resource=router_resource)
response = compute_client.patch(request=request)
logger.info(f'Response={response}')
check_operation_result(credentials=credentials, project=project, region=region, operation_name=response.name)
logger.info(f'Router {router_name} patched successfully.')


def delete_router(*, service_key_path, project, region, router_name):
credentials = service_account.Credentials.from_service_account_file(service_key_path)
Expand Down Expand Up @@ -122,7 +155,8 @@ def create_interconnect_attachment(*, service_key_path, project, region, router_
admin_enabled=True,
encryption=None,
router=f'projects/{project}/regions/{region}/routers/{router_name}',
type_='PARTNER'
type_='PARTNER',
mtu=1460
)

request = compute_v1.InsertInterconnectAttachmentRequest(
Expand Down
2 changes: 2 additions & 0 deletions jupyter/chameleon-lib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
"outputs": [],
"source": [
"try:\n",
" #var_dict = dict(node_count=0)\n",
" #fabfed_manager = FabfedManager(config_dir=fab_file_path,var_dict=var_dict)\n",
" fabfed_manager = FabfedManager(config_dir=fab_file_path)\n",
" fabfed_manager.show_available_stitch_ports(from_provider='chi', to_provider=\"fabric\")\n",
"except Exception as e:\n",
Expand Down
19 changes: 1 addition & 18 deletions jupyter/examples/chameleon/star/config.fab
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
variable:
- node_count:
default: 1

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

config:
- layer3:
- my_layer:
Expand All @@ -29,11 +23,9 @@ resource:
provider: '{{ chi.chi_provider }}'
name: stitch_net
layer3: "{{ layer3.my_layer }}"
count: 1
- fabric_network:
provider: '{{ fabric.fabric_provider }}'
layer3: "{{ layer3.my_layer }}"
count: 1
stitch_with: '{{ network.chi_network }}'
stitch_option:
site: STAR
Expand All @@ -45,15 +37,6 @@ resource:
image: default_rocky_8
- chi_node:
provider: '{{ chi.chi_provider }}'
image: CC-Ubuntu20.04
network: '{{ network.chi_network }}'
count: '{{ var.node_count }}'
flavor: m1.medium
- service:
- dtn_service:
provider: '{{ janus.janus_provider }}'
node: [ '{{ node.chi_node }}', '{{ node.fabric_node }}' ]
controller: '{{ node.fabric_node }}'
image: dtnaas/tools
profile: fabfed
count: 0
7 changes: 4 additions & 3 deletions jupyter/examples/cloudlab/config.fab
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@ resource:
- fabric_network:
provider: '{{ fabric.fabric_provider }}'
layer3: "{{ layer3.my_layer }}"
interface: '{{ node.fabric_node }}'
#interface: '{{ node.fabric_node }}'
stitch_with: '{{ network.cnet }}'
- node:
- fabric_node:
provider: '{{ fabric.fabric_provider }}'
site: '{{ var.site }}'
image: default_rocky_8
nic_model: NIC_Basic
count: 1
network: "{{ network.fabric_network }}"
count: 0
- cnode:
provider: '{{ cloudlab.cloudlab_provider }}'
network: "{{ network.cnet }}"
count: 1
count: 0
- service:
- dtn_service:
provider: '{{ janus.janus_provider }}'
Expand Down
2 changes: 1 addition & 1 deletion jupyter/native-gcp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
20 changes: 5 additions & 15 deletions jupyter/welcom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
"else:\n",
" print(\"The file does not exist.\")\n",
" import shutil\n",
" #source_file = 'fabfed_config/fabfed_credentials_template.yml'\n",
" source_file = '/users/lzhang9/.fabfed/fabfed_credentials.yml'\n",
" source_file = 'fabfed_config/fabfed_credentials_template.yml'\n",
" destination_file = 'fabfed_config/fabfed_credentials.yml'\n",
" shutil.copy(source_file, destination_file)\n",
" print(\"File copied successfully from\", source_file, \"to\", destination_file)"
Expand All @@ -78,30 +77,21 @@
"### Edit credentials in [credential file](./fabfed_config/fabfed_credentials.yml) if needed"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "779c81b2-3260-4222-be63-7084cc386133",
"metadata": {},
"outputs": [],
"source": [
"!cat $file_path"
]
},
{
"cell_type": "markdown",
"id": "8127923d-a615-4472-981a-fc20d01aca35",
"metadata": {},
"source": [
"## Examples of FabFed Workflows\n",
"### Using FabFed CLI:\n",
"\n",
"- [Cloudlab](./cloudlab.ipynb): Stiching Cloudlab and Fabric (network only) around 2 minuates\n",
"- [Chameleon](./chameleon.ipynb): Stiching Chameleon and Fabric (network only) around 2 minuates\n",
"- [Cloudlab](./cloudlab.ipynb): Stiching Cloudlab and Fabric\n",
"- [Chameleon](./chameleon.ipynb): Stiching Chameleon and Fabric\n",
"- [Native aws](./native-aws.ipynb): Stiching native AWS and Fabric\n",
"- [Native gcp](./native-gcp.ipynb): Stiching native GCP and Fabric\n",
"- [SENSE aws](./sense-aws.ipynb): Stiching SENSE AWS and Fabric\n",
"- [SENSE gcp](./sense-gcp.ipynb): Stiching SENSE GCP and Fabric\n",
"- [Cloudlab](./cloudlab.ipynb): Stiching Cloudlab and Fabric\n",
"- [Chameleon](./chameleon.ipynb): Stiching Chameleon and Fabric\n",
"\n",
"### Using FabFed library:\n",
"- [Native aws](./native-aws-lib.ipynb): Stiching native AWS and Fabric\n",
Expand Down

0 comments on commit 357d30f

Please sign in to comment.