Commit f8f80b41 authored by David Hancock's avatar David Hancock

Fix t09 and t10 evaluations / add json path arg for create_device

parent 74548335
......@@ -368,7 +368,7 @@ class Administrator(Client):
def do_create_device(self, line):
"""Create device: create_device <name> <ip_addr> <port>
\r<dev_type: bmv2_SSwitch | Agilio> <pre: \'SimplePre\'|\'SimplePreLAG\'|\'None\'>
\r<# entries> <ports>
\r<# entries> [json path] <ports>
"""
resp = self.send_request(self.user + ' create_device ' + line)
self.debug_print(resp)
......
......@@ -18,6 +18,7 @@ import signal
import errno
import traceback
from pathlib2 import Path
import getpass
import code
from inspect import currentframe, getframeinfo
......@@ -101,14 +102,31 @@ class Controller(object):
def create_device(self, parameters):
# parameters:
# <'admin'> <name> <ip_addr> <port> <dev_type: 'bmv2_SSwitch' | 'Agilio'>
# <pre: 'None' | 'SimplePre' | 'SimplePreLAG'> <# entries> <ports>
# <pre: 'None' | 'SimplePre' | 'SimplePreLAG'> <# entries> <json path> <ports>
dev_name = parameters[1]
ip = parameters[2]
port = parameters[3]
dev_type = parameters[4]
pre = parameters[5]
max_entries = int(parameters[6])
ports = parameters[7:]
try:
int(parameters[7])
except ValueError:
json = parameters[7]
ports = parameters[8:]
else:
json = '/home/' + getpass.getuser() + '/hp4-src/hp4/hp4.json'
hjp_check = Path('hp4controller/hp4_json_path')
if hjp_check.is_file():
with open('hp4controller/hp4_json_path', 'r') as hjp:
json = hjp.readline()[:-1]
ports = parameters[7:]
json_check = Path(json)
if json_check.is_file() == False:
return 'Error - ' + json + ' not found'
prelookup = {'None': runtime_CLI.PreType.None,
'SimplePre': runtime_CLI.PreType.SimplePre,
'SimplePreLAG': runtime_CLI.PreType.SimplePreLAG}
......@@ -121,12 +139,6 @@ class Controller(object):
except:
return "Error - create_device(" + dev_name + "): " + str(sys.exc_info()[0])
# TODO: fix this
json = '/home/ubuntu/hp4-src/hp4/hp4.json'
hjp_check = Path('hp4controller/hp4_json_path')
if hjp_check.is_file():
with open('hp4controller/hp4_json_path', 'r') as hjp:
json = hjp.readline()[:-1]
runtime_CLI.load_json_config(std_client, json)
rta = SimpleSwitchAPI(prelookup[pre], std_client, mc_client, sswitch_client)
......@@ -145,7 +157,7 @@ class Controller(object):
def create_slice(self, parameters):
"Create a slice"
hp4slice = parameters[1]
self.slices[hp4slice] = Slice(hp4slice)
self.slices[hp4slice] = Slice(hp4slice, self.debug)
return "Created slice: " + hp4slice
def list_slices(self, parameters):
......@@ -303,12 +315,15 @@ class Controller(object):
def dbugprint(self, msg):
if self.debug:
print(msg)
with open('controller_debug', 'a') as out:
out.write(msg + '\n')
class Slice():
def __init__(self, name):
def __init__(self, name, debug):
self.name = name
self.vdevs = {} # {vdev_name (string): vdev (VirtualDevice)}
self.leases = {} # {dev_name (string): lease (Lease)}
self.debug = debug
def handle_request(self, parameters):
# parameters:
......@@ -383,11 +398,20 @@ class Slice():
return resp
"""
def dbug_print(self, msg):
if self.debug:
with open('controller_debug', 'a') as out:
out.write(msg + '\n')
print(msg)
def vdev_dump(self, parameters):
"Display all pushed entries"
if parameters[0] not in self.vdevs:
return parameters[0] + ' not recognized'
return self.vdevs[parameters[0]].dump()
msg = self.vdevs[parameters[0]].dump()
self.dbug_print('vdev_dump: ' + parameters[0])
self.dbug_print(msg)
return msg
def vdev_info(self, parameters):
if parameters[0] not in self.vdevs:
......@@ -398,19 +422,28 @@ class Slice():
if parameters[0] not in self.vdevs:
return parameters[0] + ' not recognized'
vdev = self.vdevs[parameters[0]]
return vdev.str_hp4code()
msg = vdev.str_hp4code()
self.dbug_print('list_vdev_hp4code: ' + parameters[0])
self.dbug_print(msg)
return msg
def list_vdev_hp4rules(self, parameters):
if parameters[0] not in self.vdevs:
return parameters[0] + ' not recognized'
vdev = self.vdevs[parameters[0]]
return vdev.str_hp4rules()
msg = vdev.str_hp4rules()
self.dbug_print('list_vdev_hp4rules: ' + parameters[0])
self.dbug_print(msg)
return msg
def list_vdev_hp4_code_and_rules(self, parameters):
if parameters[0] not in self.vdevs:
return parameters[0] + ' not recognized'
vdev = self.vdevs[parameters[0]]
return vdev.str_hp4_code_and_rules()
msg = vdev.str_hp4_code_and_rules()
self.dbug_print('list_vdev_hp4_code_and_rules: ' + parameters[0])
self.dbug_print(msg)
return msg
"""
def list_devs(self, parameters):
......
......@@ -48,41 +48,64 @@ echo "Next: xterms for h1, h2, h3, h5, h6"
$pause
ttyecho -n $MININET xterm h2
echo time h2 kicked off:
date
echo start h2 $(date) >> t09/t09r$RUN
sleep 1
wmctrl -r "Node: h2" -e 0,1434,0,-1,-1
ttyecho -n $MININET xterm h3
echo start h3 $(date) >> t09/t09r$RUN
sleep 1
wmctrl -r "Node: h3" -e 0,560,418,-1,-1
ttyecho -n $MININET xterm h1
echo start h1 $(date) >> t09/t09r$RUN
sleep 1
wmctrl -r "Node: h1" -e 0,0,418,-1,-1
ttyecho -n $MININET xterm h6
echo start h6 $(date) >> t09/t09r$RUN
sleep 1
wmctrl -r "Node: h6" -e 0,560,782,-1,-1
ttyecho -n $MININET xterm h5
echo time h5 kicked off:
date
echo start h5 $(date) >> t09/t09r$RUN
echo
sleep 1
wmctrl -r "Node: h5" -e 0,0,782,-1,-1
echo "Next: collect ttys and ips of all xterms"
$pause
H1="$(cat /tmp/pts_h1)"
H2="$(cat /tmp/pts_h2)"
H3="$(cat /tmp/pts_h3)"
H5="$(cat /tmp/pts_h5)"
H6="$(cat /tmp/pts_h6)"
H1ip="10.1.0.101"
H2ip="10.1.0.102"
H3ip="10.1.0.103"
H4ip="10.1.0.104"
H5ip="10.1.0.105"
H6ip="10.1.0.106"
echo "Next: start traffic"
$pause
ttyecho -n $H2 ping $H4ip -i 0.2 -w 120
echo time h2 kicked off:
date
echo start h2 $(date) >> t09/t09r$RUN
sleep 1
ttyecho -n $H3 iperf3 -s
echo start h3 $(date) >> t09/t09r$RUN
sleep 1
ttyecho -n $H1 iperf3 -c $H3ip -t 120 --logfile t09h1iperf
echo start h1 $(date) >> t09/t09r$RUN
sleep 1
ttyecho -n $H6 iperf3 -s
echo start h6 $(date) >> t09/t09r$RUN
sleep 1
ttyecho -n $H5 iperf3 -c $H6ip -t 120 --logfile t09h5iperf
echo time h5 kicked off:
date
echo start h5 $(date) >> t09/t09r$RUN
echo
sleep 1
echo "Next: slice 1 enable VIBRANT protection"
$pause
......
create_device s0 localhost 9090 bmv2_SSwitch SimplePreLAG 10000 1 2 3 4
create_device s1 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 0 1 2
create_device s2 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 0 1 2
create_device s3 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 0 1
create_device s4 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 0 1
create_device s0 localhost 9090 bmv2_SSwitch SimplePreLAG 10000 tests/t10/hp4_d430.json 1 2 3 4
create_device s1 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 tests/t10/hp4_pc3000.json 0 1 2
create_device s2 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 tests/t10/hp4_pc3000.json 0 1 2
create_device s3 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 tests/t10/hp4_pc3000.json 0 1
create_device s4 <ip> <port> bmv2_SSwitch SimplePreLAG 10000 tests/t10/hp4_pc3000.json 0 1
create_slice slice1
create_slice slice2
grant_lease slice1 s0 5000 Chain 1 2
......
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