Example #1
0
def main(argv):
    inputfile = ''
    outputfile = ''
    testNum = '0'
    result = ''

    try:
        opts, args = getopt.getopt(
            argv, "hi:o:t:n:", ["ifile=", "ofile=", "testcase=", "netnode="])
    except getopt.GetoptError:
        print 'test.py -i <inputfile> -o <outputfile>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'test.py -i <inputfile> -o <outputfile> -t <num>'
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-o", "--ofile"):
            outputfile = arg
        elif opt in ("-t", "--testcase"):
            #testNum = int(arg)
            testNum = arg
        else:
            assert False, "unhandled option"

    #workName = raw_input('Please enter a work name:')
    res = util.setupAuthentication()

    if res != constants.OK_STR:
        sys.exit(1)

    if testNum in testCases2_ga.keys():
        print testCases2_ga[testNum][3]
        if testCases2_ga[testNum][0] == put_c:
            result = util.runRequestPUT(testCases2_ga[testNum][1],
                                        json.dumps(testCases2_ga[testNum][2]),
                                        sys._getframe().f_code.co_name)
        elif testCases2_ga[testNum][0] == post_c:
            #print json.dumps(testCases2_ga[testNum][2])
            result = util.runRequestPOST(testCases2_ga[testNum][1],
                                         json.dumps(testCases2_ga[testNum][2]),
                                         sys._getframe().f_code.co_name)
        elif testCases2_ga[testNum][0] == post_data_array_c:
            #print json.dumps(testCases2_ga[testNum][2])
            for inputData in (testCases2_ga[testNum][2]):
                result = util.runRequestPOST(testCases2_ga[testNum][1],
                                             json.dumps(inputData),
                                             sys._getframe().f_code.co_name)
        elif testCases2_ga[testNum][0] == get_c:
            result = util.runRequestGET(testCases2_ga[testNum][1],
                                        sys._getframe().f_code.co_name)
            print result
        elif testCases2_ga[testNum][0] == delete_c:
            result = util.runRequestDELETE(testCases2_ga[testNum][1],
                                           sys._getframe().f_code.co_name)
            print result
    else:
        result = testCases_ga[testNum][0](testCases_ga[testNum][1])
        print result
Example #2
0
def epMigrationDemo(desc):
    # unregister h35-3
    fabricId = "fabric:1"
    mac = "00:00:00:00:35:03"
    ip = "10.0.35.3"
    resp = util.runRequestGET(inputsFabric.get_epList_uri(),
                              sys._getframe().f_code.co_name)
    if resp == constants.ERROR_STR:
        print "ERROR: getOvsdbNodeIdByName() failed"
        return constants.ERROR_STR

    eplist = list()
    lswId = ''
    lport = ''
    endpointResp = json.loads(resp)
    if endpointResp.has_key("endpoints"):
        endpoints = endpointResp["endpoints"]
        if endpoints.has_key("endpoint"):
            for endpoint in endpoints["endpoint"]:
                if endpoint["ip-address"] == ip:
                    eplist.append(endpoint["endpoint-uuid"])
                    logicLocation = endpoint["logic-location"]
                    lswId = logicLocation["node-id"]
                    lport = logicLocation["tp-id"]
                    break

    result = util.runRequestPOST(
        inputsFabric.get_unregister_endpoint_uri(),
        json.dumps(
            inputsFabric.get_unregister_endpoint_data("fabric:1", eplist)),
        sys._getframe().f_code.co_name)

    # register h35-4
    fabricId = "fabric:1"
    mac = "00:00:00:00:35:04"
    ip = "10.0.35.4"
    gw = "10.0.35.1"
    port = "vethl-h35-4"
    nodeid = util.getOvsdbNodeIdByName("sw6")
    nodeRef = BRIDGE_REF_P % (nodeid)
    tpRef = TP_REF_P % (nodeid, port)

    if nodeid == constants.ERROR_STR:
        return constants.ERROR_STR

    result = util.runRequestPOST(
        inputsFabric.get_register_endpoint_uri(),
        json.dumps(
            inputsFabric.get_register_endpoint_data(fabricId, mac, ip, gw,
                                                    lswId, lport, nodeRef,
                                                    tpRef)),
        sys._getframe().f_code.co_name)

    return desc
Example #3
0
def main(argv):
  inputfile = ''
  outputfile = ''
  testNum = '0'
  result = ''

  try:
      opts, args = getopt.getopt(argv,"hi:o:t:n:",["ifile=","ofile=","testcase=", "netnode="])
  except getopt.GetoptError:
    print 'test.py -i <inputfile> -o <outputfile>'
    sys.exit(2)
  for opt, arg in opts:
    if opt == '-h':
      print 'test.py -i <inputfile> -o <outputfile> -t <num>'
      sys.exit()
    elif opt in ("-i", "--ifile"):
      inputfile = arg
    elif opt in ("-o", "--ofile"):
      outputfile = arg
    elif opt in ("-t", "--testcase"):
      #testNum = int(arg)
      testNum = arg
    else:
      assert False, "unhandled option"

  #workName = raw_input('Please enter a work name:')
  res = util.setupAuthentication()

  if res != constants.OK_STR:
    sys.exit(1)

  if testNum in testCases2_ga.keys():
    print testCases2_ga[testNum][3]
    if testCases2_ga[testNum][0] == put_c:
      result = util.runRequestPUT(testCases2_ga[testNum][1], json.dumps(testCases2_ga[testNum][2]), sys._getframe().f_code.co_name) 
    elif testCases2_ga[testNum][0] == post_c:
      #print json.dumps(testCases2_ga[testNum][2])
      result = util.runRequestPOST(testCases2_ga[testNum][1], json.dumps(testCases2_ga[testNum][2]), sys._getframe().f_code.co_name) 
    elif testCases2_ga[testNum][0] == post_data_array_c:
      #print json.dumps(testCases2_ga[testNum][2])
      for inputData in (testCases2_ga[testNum][2]):
        result = util.runRequestPOST(testCases2_ga[testNum][1], json.dumps(inputData), sys._getframe().f_code.co_name) 
    elif testCases2_ga[testNum][0] == get_c:
      result = util.runRequestGET(testCases2_ga[testNum][1], sys._getframe().f_code.co_name) 
      print result
    elif testCases2_ga[testNum][0] == delete_c:
      result = util.runRequestDELETE(testCases2_ga[testNum][1], sys._getframe().f_code.co_name) 
      print result
  else:
    result = testCases_ga[testNum][0](testCases_ga[testNum][1]) 
    print result
Example #4
0
def registerEndpointLocation_multifabric_mn(desc):

  nodeId1 = util.getOvsdbNodeIdByName("sw11")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId2 = util.getOvsdbNodeIdByName("sw12")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId3 = util.getOvsdbNodeIdByName("sw13")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId4 = util.getOvsdbNodeIdByName("sw21")
  if nodeId4 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId5 = util.getOvsdbNodeIdByName("sw2")
  if nodeId5 == constants.ERROR_STR:
    return constants.ERROR_STR

  for inputData in tenant_3EPG_multifabric_mn.get_endpoint_location_data(nodeId1, nodeId2, nodeId3, nodeId4, nodeId5):
    result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(), json.dumps(inputData), sys._getframe().f_code.co_name)

  return result
Example #5
0
def registerEndpointLocation_multifabric(desc):
  nc_id1a = "vethl-h35-2"
  nc_id1b = "vethl-h35-3"
  nc_id2a = "vethl-h36-4"
  nc_id2b = "vethl-h36-5"
  nc_id3a = "vethl-h37-2"
  nc_id3b = "vethl-h37-3"
  nc_id4a = "vethl-h35-8"
  nc_id4b = "vethl-h36-8"
  nc_id4c = "vethl-h37-8"

  nodeId1 = util.getOvsdbNodeIdByName("sw11")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId2 = util.getOvsdbNodeIdByName("sw12")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId3 = util.getOvsdbNodeIdByName("sw13")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId4 = util.getOvsdbNodeIdByName("sw21")
  if nodeId4 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId5 = util.getOvsdbNodeIdByName("sw2")
  if nodeId5 == constants.ERROR_STR:
    return constants.ERROR_STR

  for inputData in tenant_3EPG_multifabric.get_endpoint_location_data(nc_id1a, nc_id1b, nc_id2a, nc_id2b, nc_id3a, nc_id3b, nc_id4a, nc_id4b, nc_id4c,nodeId1, nodeId2, nodeId3, nodeId4, nodeId5):
    result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(), json.dumps(inputData), sys._getframe().f_code.co_name)

  return result
Example #6
0
def registerEndpointLocation_multifabric_mn(desc):

    nodeId1 = util.getOvsdbNodeIdByName("sw11")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId2 = util.getOvsdbNodeIdByName("sw12")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId3 = util.getOvsdbNodeIdByName("sw13")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId4 = util.getOvsdbNodeIdByName("sw21")
    if nodeId4 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId5 = util.getOvsdbNodeIdByName("sw2")
    if nodeId5 == constants.ERROR_STR:
        return constants.ERROR_STR

    for inputData in tenant_3EPG_multifabric_mn.get_endpoint_location_data(
            nodeId1, nodeId2, nodeId3, nodeId4, nodeId5):
        result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(),
                                     json.dumps(inputData),
                                     sys._getframe().f_code.co_name)

    return result
Example #7
0
def registerEndpointLocation_3epg_sfc_acl(desc):
    nc_id1a = "vethl-h35-2"
    nc_id1b = "vethl-h35-3"
    nc_id2a = "vethl-h36-4"
    nc_id2b = "vethl-h36-5"
    nc_id3a = "vethl-h37-2"
    nc_id3b = "vethl-h37-3"

    nodeId1 = util.getOvsdbNodeIdByName("sw1")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId2 = util.getOvsdbNodeIdByName("sw6")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId3 = util.getOvsdbNodeIdByName("sw7")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    for inputData in tenant_3EPG_demo.get_endpoint_location_data(
            nc_id1a, nc_id1b, nc_id2a, nc_id2b, nc_id3a, nc_id3b, nodeId1,
            nodeId2, nodeId3):
        result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(),
                                     json.dumps(inputData),
                                     sys._getframe().f_code.co_name)

    return result
Example #8
0
def epMigrationDemo(desc):
   # unregister h35-3
   fabricId = "fabric:1" 
   mac = "00:00:00:00:35:03" 
   ip = "10.0.35.3"
   resp = util.runRequestGET(inputsFabric.get_epList_uri(), sys._getframe().f_code.co_name)
   if resp == constants.ERROR_STR:
      print "ERROR: getOvsdbNodeIdByName() failed"
      return constants.ERROR_STR
  
   eplist = list()
   lswId = ''
   lport = ''
   endpointResp=json.loads(resp)
   if endpointResp.has_key("endpoints"):
      endpoints = endpointResp["endpoints"]
      if endpoints.has_key("endpoint"):
         for endpoint in endpoints["endpoint"]:
            if endpoint["ip-address"] == ip:
               eplist.append(endpoint["endpoint-uuid"])
               logicLocation = endpoint["logic-location"]
               lswId = logicLocation["node-id"]
               lport = logicLocation["tp-id"]
               break

   result = util.runRequestPOST(inputsFabric.get_unregister_endpoint_uri(), json.dumps(inputsFabric.get_unregister_endpoint_data("fabric:1", eplist)), sys._getframe().f_code.co_name)

   # register h35-4
   fabricId = "fabric:1"
   mac = "00:00:00:00:35:04"
   ip = "10.0.35.4"
   gw = "10.0.35.1"
   port = "vethl-h35-4"
   nodeid = util.getOvsdbNodeIdByName("sw6")
   nodeRef = BRIDGE_REF_P % (nodeid)
   tpRef = TP_REF_P % (nodeid, port)

   if nodeid == constants.ERROR_STR:
      return constants.ERROR_STR

   result = util.runRequestPOST(inputsFabric.get_register_endpoint_uri(), json.dumps(inputsFabric.get_register_endpoint_data(fabricId, mac, ip, gw, lswId, lport, nodeRef, tpRef)), sys._getframe().f_code.co_name) 

   return desc
Example #9
0
def registerEndpointLocation_sfc(desc):
  nc_id1 = "vethl-h35-2"
  nc_id2 = "vethl-h36-4"
  nodeId1 = util.getOvsdbNodeIdByName("sw1")

  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId2 = util.getOvsdbNodeIdByName("sw6")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  for inputData in tenant_2EPG_SFC.get_endpoint_location_data(nc_id1, nc_id2, nodeId1, nodeId2):
    result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(), json.dumps(inputData), sys._getframe().f_code.co_name)

  return result
Example #10
0
def registerEndpointLocation_acl(desc):
  nc_id1 = "sw1-eth1"
  nc_id2 = "sw2-eth3"
  nodeId1 = util.getOvsdbNodeIdByName("sw1")

  if nodeId1 == constants.ERROR_STR: 
    return constants.ERROR_STR

  nodeId2 = util.getOvsdbNodeIdByName("sw2")
  if nodeId1 == constants.ERROR_STR: 
    return constants.ERROR_STR

  for inputData in inputsGBP.get_endpoint_location_data(nc_id1, nc_id2, nodeId1, nodeId2):
    result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(), json.dumps(inputData), sys._getframe().f_code.co_name) 

  return result
Example #11
0
def registerEndpointLocation_sfc(desc):
    nc_id1 = "vethl-h35-2"
    nc_id2 = "vethl-h36-4"
    nodeId1 = util.getOvsdbNodeIdByName("sw1")

    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId2 = util.getOvsdbNodeIdByName("sw6")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    for inputData in tenant_2EPG_SFC.get_endpoint_location_data(
            nc_id1, nc_id2, nodeId1, nodeId2):
        result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(),
                                     json.dumps(inputData),
                                     sys._getframe().f_code.co_name)

    return result
Example #12
0
def registerEndpointLocation_acl(desc):
    nc_id1 = "sw1-eth1"
    nc_id2 = "sw2-eth3"
    nodeId1 = util.getOvsdbNodeIdByName("sw1")

    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId2 = util.getOvsdbNodeIdByName("sw2")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    for inputData in inputsGBP.get_endpoint_location_data(
            nc_id1, nc_id2, nodeId1, nodeId2):
        result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(),
                                     json.dumps(inputData),
                                     sys._getframe().f_code.co_name)

    return result
Example #13
0
def registerEndpointLocation_multifabric(desc):
    nc_id1a = "vethl-h35-2"
    nc_id1b = "vethl-h35-3"
    nc_id2a = "vethl-h36-4"
    nc_id2b = "vethl-h36-5"
    nc_id3a = "vethl-h37-2"
    nc_id3b = "vethl-h37-3"
    nc_id4a = "vethl-h35-8"
    nc_id4b = "vethl-h36-8"
    nc_id4c = "vethl-h37-8"

    nodeId1 = util.getOvsdbNodeIdByName("sw11")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId2 = util.getOvsdbNodeIdByName("sw12")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId3 = util.getOvsdbNodeIdByName("sw13")
    if nodeId1 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId4 = util.getOvsdbNodeIdByName("sw21")
    if nodeId4 == constants.ERROR_STR:
        return constants.ERROR_STR

    nodeId5 = util.getOvsdbNodeIdByName("sw2")
    if nodeId5 == constants.ERROR_STR:
        return constants.ERROR_STR

    for inputData in tenant_3EPG_multifabric.get_endpoint_location_data(
            nc_id1a, nc_id1b, nc_id2a, nc_id2b, nc_id3a, nc_id3b, nc_id4a,
            nc_id4b, nc_id4c, nodeId1, nodeId2, nodeId3, nodeId4, nodeId5):
        result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(),
                                     json.dumps(inputData),
                                     sys._getframe().f_code.co_name)

    return result
Example #14
0
def registerEndpointLocation_3epg_sfc_acl(desc):
  nc_id1a = "vethl-h35-2"
  nc_id1b = "vethl-h35-3"
  nc_id2a = "vethl-h36-4"
  nc_id2b = "vethl-h36-5"
  nc_id3a = "vethl-h37-2"
  nc_id3b = "vethl-h37-3"

  nodeId1 = util.getOvsdbNodeIdByName("sw1")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId2 = util.getOvsdbNodeIdByName("sw6")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  nodeId3 = util.getOvsdbNodeIdByName("sw7")
  if nodeId1 == constants.ERROR_STR:
    return constants.ERROR_STR

  for inputData in tenant_3EPG_demo.get_endpoint_location_data(nc_id1a, nc_id1b, nc_id2a, nc_id2b, nc_id3a, nc_id3b, nodeId1, nodeId2, nodeId3):
    result = util.runRequestPOST(inputsGBP.get_endpoint_location_uri(), json.dumps(inputData), sys._getframe().f_code.co_name)

  return result