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

Fabnetv4ext route update and add project id for tutorial project #268

Merged
merged 1 commit into from
Jan 19, 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
3 changes: 3 additions & 0 deletions configure_and_validate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"# Update this line to specify your project id\n",
"project_id = \"REPLACE_WITH_YOUR_PROJECT_ID\"\n",
"\n",
"# Uncomment the line below if using 'FABRIC Tutorials' Project\n",
"#project_id=\"a7818636-1fa1-4e77-bb03-d171598b0862\"\n",
"\n",
"fablib = fablib_manager(project_id=project_id)\n"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@
"source": [
"try:\n",
" \n",
" # Enable Public IPv6 make_ip_publicly_routable\n",
" # Enable Public IPv4 make_ip_publicly_routable\n",
" network1.make_ip_publicly_routable(ipv4=[str(network1_available_ips[0])])\n",
"\n",
"\n",
" # Enable Public IPv6 make_ip_publicly_routable\n",
" # Enable Public IPv4 make_ip_publicly_routable\n",
" network2.make_ip_publicly_routable(ipv4=[str(network2_available_ips[0])])\n",
"\n",
" slice.submit()\n",
Expand All @@ -170,6 +170,22 @@
" traceback.print_exc()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get latest Slice topology"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"slice = fablib.get_slice(slice_name)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -184,7 +200,8 @@
"\n",
"\n",
"Optionally, use the `node.execute()` method to show the results of adding the IP address and route.\n",
"\n"
"\n",
"NOTE: If by any chance, routes are mis-configured or you have lost management IP access to your VM, please invoke: `node.os_reboot()` to revert all configuration.\n"
]
},
{
Expand All @@ -198,11 +215,11 @@
"node1_addr = network1.get_public_ips()[0]\n",
"node1_iface.ip_addr_add(addr=node1_addr, subnet=network1.get_subnet())\n",
"\n",
"\n",
"node1.ip_route_add(subnet=network2.get_subnet(), gateway=network1.get_gateway())\n",
"\n",
"# Add route to external network\n",
"stdout, stderr = node1.execute(f'sudo ip route add 0.0.0.0/1 via {network1.get_gateway()}')\n",
"stdout, stderr = node1.execute()\n",
"stdout, stderr = node1.execute(f'sudo ip route add 0.0.0.0/0 via {network1.get_gateway()}')\n",
"\n",
"stdout, stderr = node1.execute(f'ip addr show {node1_iface.get_device_name()}') \n",
"stdout, stderr = node1.execute(f'ip route list')"
Expand Down Expand Up @@ -231,7 +248,7 @@
"node2.ip_route_add(subnet=network1.get_subnet(), gateway=network2.get_gateway())\n",
"\n",
"# Add route to external network\n",
"stdout, stderr = node2.execute(f'sudo ip route add 0.0.0.0/1 via {network2.get_gateway()}')\n",
"stdout, stderr = node2.execute(f'sudo ip route add 0.0.0.0/0 via {network2.get_gateway()}')\n",
"\n",
"\n",
"stdout, stderr = node2.execute(f'ip addr show {node2_iface.get_device_name()}')\n",
Expand Down Expand Up @@ -259,13 +276,56 @@
"node2 = slice.get_node(name=node2_name) \n",
"\n",
"node2_addr = node2.get_interface(network_name=network2_name).get_ip_addr()\n",
"\n",
"stdout, stderr = node1.execute(f'ping -c 5 {node2_addr}') \n",
"\n",
"# Verify external connectivity\n",
"stdout, stderr = node1.execute(f'sudo ping -c 5 -I {node1_iface.get_device_name()} bing.com') \n",
"\n",
"stdout, stderr = node1.execute(f'sudo ping -c 5 -I {node2_iface.get_device_name()} bing.com') "
"node1_addr = node1.get_interface(network_name=network1_name).get_ip_addr()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import subprocess\n",
"\n",
"def ping_ip(ip_address):\n",
" try:\n",
" result = subprocess.run(['ping', '-c', '4', ip_address], capture_output=True, text=True, check=True)\n",
" print(result.stdout)\n",
" return True\n",
" except subprocess.CalledProcessError:\n",
" return False"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Ping Node1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ping_ip(str(node1_addr))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Ping Node2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ping_ip(str(node2_addr))"
]
},
{
Expand Down Expand Up @@ -311,7 +371,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion start_here.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"## Getting Started\n",
"\n",
"- Setup Environment\n",
" - [Configure Environment](./configure.ipynb): Configure you Environment including creating the `fabric_rc` and `ssh_config` files.\n",
" - [Configure Environment](./configure_and_validate.ipynb): Configure you Environment including creating the `fabric_rc` and `ssh_config` files.\n",
"- First Experiment\n",
" - [Hello, FABRIC](./fabric_examples/fablib_api/hello_fabric/hello_fabric.ipynb): Simple First Slice Example.\n",
"\n",
Expand Down