Commit abec5870 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add v3 version of the snmpit proxy.

parent 7e3d477f
#! /usr/bin/env python
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004-2010 University of Utah and the Flux Group.
# Copyright (c) 2004-2011 University of Utah and the Flux Group.
# All rights reserved.
#
import sys
......@@ -4799,100 +4799,7 @@ class elabinelab:
return node_instance.console(version, argdict);
#
# vlan control
#
def vlans(self, version, argdict):
if version != self.VERSION:
return EmulabResponse(RESPONSE_BADVERSION,
output="Client version mismatch!")
try:
checknologins()
pass
except NoLoginsError, e:
return EmulabResponse(RESPONSE_REFUSED, output=str(e))
argerror = CheckRequiredArgs(argdict, ("op", "arg"))
if (argerror):
return argerror
verifyerror = self.verifystuff();
if (verifyerror):
return verifyerror
if (argdict["op"] != "setup" and
argdict["op"] != "list" and
argdict["op"] != "trunk" and
argdict["op"] != "destroy"):
return EmulabResponse(RESPONSE_BADARGS,
output="op must be list, trunk, setup or destroy")
argstr = "-p " + self.pid + " -e " + self.eid + " " + argdict["op"];
#
# Figure out how to convert the stuff we got into something we can
# pass on the command line to perl backend.
#
if argdict["op"] == "destroy" or argdict["op"] == "list":
#
# Destroy and list are easy; just pass a list of id numbers out.
# The backend script does all the verification.
#
if (isinstance(argdict["arg"], types.IntType)):
argstr += " " + str(argdict["arg"])
pass
else:
tokens = argdict["arg"].split(",")
for token in tokens:
argstr += " " + escapeshellarg(token)
pass
pass
pass
elif argdict["op"] == "trunk":
#
# Trunk is syntactically like destroy or list with two extra args.
#
info = argdict["arg"]
argstr += " " + str(info["mode"]) + " " + str(info["port"])
tokens = info["vlans"].split(",")
for token in tokens:
argstr += " " + escapeshellarg(token)
pass
pass
else:
#
# Setup is harder. Pass a set of strings to the script,
# consisting of:
#
# id,node:iface,speed,duplex,vtag
#
for id, idval in argdict["arg"].items():
vtag = idval["virtual"]
for port, portarray in idval["members"].items():
speed = portarray["speed"]
duplex = portarray["duplex"]
thisarg = escapeshellarg(str(id) + "," + port + "," +
str(speed) + "," +
duplex + "," + vtag)
argstr += " " + thisarg;
pass
pass
pass
(exitval, output) = runcommand(TBDIR + "/sbin/snmpit.proxy " + argstr)
if exitval:
return EmulabResponse(RESPONSE_ERROR, exitval >> 8, output=output)
return EmulabResponse(RESPONSE_SUCCESS, output=output)
#
# Leave the previous one in place or else existing elabinelabs will break.
#
def vlansnew(self, version, argdict):
def vlansv2(self, version, argdict):
if version != self.VERSION:
return EmulabResponse(RESPONSE_BADVERSION,
output="Client version mismatch!")
......@@ -4920,15 +4827,31 @@ class elabinelab:
if not xmlfilename:
return EmulabResponse(RESPONSE_SERVERERROR, output="Server Error")
argstr = "-p " + self.pid + " -e " + self.eid + " " + xmlfilename;
#
# Create a temporary file for the output.
#
(outfp, outfilename) = writensfile("");
if not outfilename:
return EmulabResponse(RESPONSE_SERVERERROR, output="Server Error")
(exitval, output) = runcommand(TBDIR + "/sbin/snmpit.proxynew " + argstr)
argstr = "-o " + outfilename + " ";
argstr += "-p " + self.pid + " -e " + self.eid + " " + xmlfilename;
(exitval,output) = runcommand(TBDIR + "/sbin/snmpit.proxyv2 " + argstr)
if exitval:
return EmulabResponse(RESPONSE_ERROR, exitval >> 8, output=output)
#
# Results are in the outfile.
#
stuff = ""
for l in outfp:
stuff += l
pass
return EmulabResponse(RESPONSE_SUCCESS, output=output)
def vlansv2(self, version, argdict):
return EmulabResponse(RESPONSE_SUCCESS, value=stuff, output=output)
def vlansv3(self, version, argdict):
if version != self.VERSION:
return EmulabResponse(RESPONSE_BADVERSION,
output="Client version mismatch!")
......@@ -4966,8 +4889,8 @@ class elabinelab:
argstr = "-o " + outfilename + " ";
argstr += "-p " + self.pid + " -e " + self.eid + " " + xmlfilename;
(exitval,output) = runcommand(TBDIR + "/sbin/snmpit.proxyv2 " + argstr)
if exitval:
(exitval,output) = runcommand("/usr/testbed/devel/stoller/sbin/snmpit.proxyv3 " + argstr)
if exitval:
return EmulabResponse(RESPONSE_ERROR, exitval >> 8, output=output)
#
......@@ -4979,6 +4902,7 @@ class elabinelab:
pass
return EmulabResponse(RESPONSE_SUCCESS, value=stuff, output=output)
#
# Fire up a frisbeed for an image,
#
......
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