Commit 5b6a3d64 authored by Weixin Deng's avatar Weixin Deng
Browse files

Use switch in network profile

parent d85b32ab
......@@ -13,37 +13,30 @@ import geni.rspec.pg
import geni.urn
# Describe the parameter(s) this profile script can accept.
# geni.portal.context.defineParameter( "NUM_DC", "number of datacenters", geni.portal.ParameterType.INTEGER, 2)
geni.portal.context.defineParameter(
"NUM_WORKERS", "number of total workers", geni.portal.ParameterType.INTEGER, 9
)
geni.portal.context.defineParameter(
"INTRA_BW",
"intra datacenter bandwidth in kbps",
geni.portal.ParameterType.INTEGER,
10000000,
)
geni.portal.context.defineParameter(
"size_mnt", "The size for /mnt (GB)", geni.portal.ParameterType.INTEGER, 32
)
geni.portal.context.defineParameter(
"size_home", "The size for /users (GB)", geni.portal.ParameterType.INTEGER, 16
)
geni.portal.context.defineParameter(
"phystype",
"Switch type",
geni.portal.ParameterType.STRING,
"dell-s4048",
[("mlnx-sn2410", "Mellanox SN2410"), ("dell-s4048", "Dell S4048")],
)
# Retrieve the values the user specifies during instantiation.
params = geni.portal.context.bindParameters()
NUM_WORKERS = params.NUM_WORKERS
# NUM_DC = NUM_WORKERS
FRONTEND_BW = 1000 # 1Mbps
BACKEND_BW = 10000000 # 10Gbps
size_mnt = params.size_mnt
size_home = params.size_home
SIZE_MNT = params.size_mnt
SIZE_HOME = params.size_home
NET_MASK = "255.255.255.0"
# Create a Request object to start building the RSpec.
......@@ -52,14 +45,11 @@ request = geni.portal.context.makeRequestRSpec()
# Create topology
# TODO create the topology.
# BW is enforced on interface, so for each worker, create interface.
# then create a single lan, and add all interface to it.
hosts = [None for _ in range(NUM_WORKERS)]
# lan
lan = request.LAN("lan")
# lan.link_multiplexing = True
# Switch
switch = request.Switch("switch")
switch.hardware_type = params.phystype
# Workers
for i in range(NUM_WORKERS):
......@@ -67,22 +57,18 @@ for i in range(NUM_WORKERS):
hosts[i] = request.RawPC(host_name)
hosts[i].disk_image = geni.urn.Image("emulab.net", "emulab-ops:UBUNTU20-64-STD")
bs_mnt = hosts[i].Blockstore(host_name, "/mnt")
bs_mnt.size = str(size_mnt) + "GB"
bs_home = hosts[i].Blockstore(host_name + "1", "/users")
bs_home.size = str(size_home) + "GB"
hosts[i].hardware_type = "c8220"
bs_mnt.size = str(SIZE_MNT) + "GB"
bs_home = hosts[i].Blockstore(host_name + "home", "/users")
bs_home.size = str(SIZE_HOME) + "GB"
# interface and LAN
ip_worker = geni.rspec.pg.IPv4Address("10.0.0." + str(i + 1), NET_MASK)
if_worker = hosts[i].addInterface("if" + str(i + 1), ip_worker)
if i == 0:
# Frontend
if_worker.bandwidth = FRONTEND_BW
else:
# Backend
if_worker.bandwidth = BACKEND_BW
lan.addInterface(if_worker)
host_iface = hosts[i].addInterface()
host_iface.addAddress(geni.rspec.pg.IPv4Address("10.0.0." + str(i + 1), NET_MASK))
switch_iface = switch.addInterface()
link = request.L1Link("link" + str(i + 1))
link.addInterface(host_iface)
link.addInterface(switch_iface)
# Print the RSpec to the enclosing page.
geni.portal.context.printRequestRSpec()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment