Merge Hackfest material into Develop

Merge Hackfest material into Develop

Edited by Lluis Gifre Renom

Merge request reports

Loading
+17 −0
Changes for hackfest/gnmi/commands.txt: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
== GNMI
$ cd /usr/share/gocode/src/ 
$ export GOPATH=/usr/share/gocode/
$ go run github.com/openconfig/ygot/generator/generator.go -generate_fakeroot -output_file github.com/google/gnxi/gnmi/modeldata/gostruct/generated.go -package_name gostruct github.com/rvilalta/OFC_SC472/yang/topology.yang 
$ cd /usr/share/gocode/src/github.com/google/gnxi/gnmi_target
$ go run gnmi_target.go -bind_address :10161 -config ~/tfs-ctrl/hackfest/gnmi/topology.json --notls -alsologtostderr

RUN CLIENT (in another window)
$ export GOPATH=/usr/share/gocode/
$ cd /usr/share/gocode/src/github.com/google/gnxi/gnmi_get
$ go run gnmi_get.go -notls -xpath "/topology/" -target_addr localhost:10161 -alsologtostderr 
$ go run gnmi_get.go -notls -xpath "/topology/node[node-id=A]" -target_addr localhost:10161 -alsologtostderr

USE PYTHON CLIENT
$ cd /usr/share/gocode/src/github.com/google/gnxi/gnmi_cli_py
$ python py_gnmicli.py -n -m get -t localhost -p 10161 -x /topology -u foo -pass bar
+8 −0
Changes for hackfest/gnmi/topology.json: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
  "topology" : {
     "node" : [
       { "node-id" : "A" , "port" : [ { "port-id" : "portA1" } ] },
       { "node-id" : "B" , "port" : [ { "port-id" : "portB1" } ] }
     ]
  }
}
+176 −0

File added.

Generated files are collapsed by default. To change this behavior, edit the .gitattributes file. Learn more.

+48 −0
Changes for hackfest/grpc/connection/create.py: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
#! /usr/bin/env python3
import connection_pb2
import sys

try:
  raw_input          # Python 2
except NameError:
  raw_input = input  # Python 3


# This function fills in a Connection message based on user input.
def PromptForConnection(connection):
  connection.connectionId = raw_input("Enter connectionID: ")
  connection.sourceNode = raw_input("Enter sourceNode: ")  
  connection.targetNode = raw_input("Enter targetNode: ")
  connection.sourcePort = raw_input("Enter sourcePort: ")  
  connection.targetPort = raw_input("Enter targetPort: ") 
  connection.bandwidth = int( raw_input("Enter bandwidth: ") )
  
  type = raw_input("Is this a eth or optical connection? ")
  if type == "eth":
    connection.layerProtocolName = connection_pb2.Connection.ETH
  elif type == "optical":
    connection.layerProtocolName = connection_pb2.Connection.OPTICAL
  else:
    print("Unknown layerProtocolName type; leaving as default value.")


if __name__ == '__main__':
  if len(sys.argv) != 2:
    print("Usage:", sys.argv[0], "CONNECTION_FILE")
    sys.exit(-1)
  
  connectionList = connection_pb2.ConnectionList()
  
  # Read the existing address book.
  try:
    with open(sys.argv[1], "rb") as f:
      connectionList.ParseFromString(f.read())
  except IOError:
    print(sys.argv[1] + ": File not found.  Creating a new file.")
  
  # Add an address.
  PromptForConnection(connectionList.connection.add())
  
  # Write the new address book back to disk.
  with open(sys.argv[1], "wb") as f:
    f.write(connectionList.SerializeToString())
+33 −0
Changes for hackfest/grpc/connection/list.py: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
#! /usr/bin/env python3
from __future__ import print_function
import connection_pb2
import sys


# Iterates though all connections in the ConnectionList and prints info about them.
def ListConnections(connectionList):
  for connection in connectionList.connection:
    print("connectionID:", connection.connectionId)
    print("  sourceNode:", connection.sourceNode)
    print("  targetNode:", connection.targetNode)
    print("  sourcePort:", connection.sourcePort)  
    print("  targetPort:", connection.targetPort)
    print("  bandwidth:", connection.bandwidth)       
    if connection.layerProtocolName == connection_pb2.Connection.ETH:
      print("  layerProtocolName:ETH")
    elif connection.layerProtocolName == connection_pb2.Connection.OPTICAL:
      print("  layerProtocolName:OPTICAL")


if __name__ == '__main__':
  if len(sys.argv) != 2:
    print("Usage:", sys.argv[0], "CONNECTION_FILE")
    sys.exit(-1)
  
  connectionList = connection_pb2.ConnectionList()
  
  # Read the existing address book.
  with open(sys.argv[1], "rb") as f:
    connectionList.ParseFromString(f.read())
  
  ListConnections(connectionList)
Loading
Loading