Commit e0db5103 authored by Leigh Stoller's avatar Leigh Stoller

Replace profile.py

parent 9ac87373
"""Spectrum testing
"""
# Disable spectrum requests while debugging
Debugging = 0;
# Import the Portal object.
import geni.portal as portal
# Import the ProtoGENI library.
......@@ -27,13 +24,18 @@ pc.defineParameter("node_id", "Node ID",
pc.defineParameter("iface", "Interface",
portal.ParameterType.STRING, "rf0")
# Lower bound on a single frequency.
pc.defineParameter("lower", "Frequency Low",
portal.ParameterType.STRING, "2684.3")
# Upper bound on a single frequency.
pc.defineParameter("upper", "Frequency High",
portal.ParameterType.STRING, "2685.7")
# Now a structure to define a set of frequency ranges
ps = pc.defineStructParameter(
"Spectrum","Range",[{"lower" : "2684.3", "upper" : "2685.7"}],
multiValue=True,min=0,hide=False,
multiValueTitle="Frequency ranges for over-the-air operation.",
members=[portal.Parameter("lower","Frequency Min",
portal.ParameterType.BANDWIDTH, 0,
longDescription="Values are rounded to the nearest kilohertz."),
portal.Parameter("upper", "Frequency Max",
portal.ParameterType.BANDWIDTH, 0,
longDescription="Values are rounded to the nearest kilohertz."),
])
# Retrieve the values the user specifies during instantiation.
params = pc.bindParameters()
......@@ -43,11 +45,22 @@ if params.node_id.strip() == "":
pc.reportError(portal.ParameterError("You must specify a node.", ["node_id"]))
if params.iface.strip() == "":
pc.reportError(portal.ParameterError("You must specify an interface.", ["iface"]))
if params.lower.strip() == "":
pc.reportError(portal.ParameterError("You must specify lower frequency", ["lower"]))
if params.upper.strip() == "":
pc.reportError(portal.ParameterError("You must specify an upper frequency", ["upper"]))
# Multivalue field errors must reference by index.
index = 0
for range in params.Spectrum:
if range.lower == 0:
pc.reportError(portal.ParameterError("You must specify lower frequency",
[ 'Spectrum[%d].lower' % (index) ]))
pass
if range.upper == 0:
pc.reportError(portal.ParameterError("You must specify an upper frequency",
[ 'Spectrum[%d].upper' % (index) ]))
pass
index = index + 1
pass
# Throw the errors back to the user.
pc.verifyParameters()
......@@ -59,10 +72,12 @@ if params.node_id != "any":
node.disk_image = "urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU18-64-STD"
node.addService(pg.Execute(shell="sh", command="sudo /bin/bash /local/repository/install.sh"))
if Debugging == 0:
# Need to specify an iface.
iface = node.addInterface("rf")
iface.component_id = params.iface
for range in params.Spectrum:
# Request spectrum to use on a specific interface on the node. In MHZ
iface = node.addInterface("rf")
iface.component_id = params.iface
# First arg is frequency low bound, second is high bound, third is max power.
#iface.requestSpectrum(params.lower, params.upper, 0)
......@@ -71,7 +86,7 @@ if Debugging == 0:
#node.requestSpectrum(params.lower, params.upper, 0)
# Request spectrum to use across the all nodes in the experiment.
request.requestSpectrum(params.lower, params.upper, 0)
request.requestSpectrum(range.lower, range.upper, 0)
pass
# Print the RSpec to the enclosing page.
......
Markdown is supported
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