def main(): channel1 = start_grpc('localhost:10240') stub1 = nfa_msg_pb2_grpc.Runtime_RPCStub(channel1) packet_out, packet_dropped, duration_time = test(stub1) print str(packet_out) + ' ' + str(packet_dropped) + ' ' + str( duration_time)
def LivenessCheck(runtime_info): channel = grpc.insecure_channel(runtime_info["rpc_ip"] + ":" + str(runtime_info["rpc_port"])) stub = nfa_msg_pb2_grpc.Runtime_RPCStub(channel) response = stub.LivenessCheck(nfa_msg_pb2.LivenessRequest()) print("LivenessCheck OK!")
def Recover(source_runtime, target_runtime): channel = grpc.insecure_channel( \ source_runtime["rpc_ip"]+":"+str(source_runtime["rpc_port"]) ) stub = nfa_msg_pb2_grpc.Runtime_RPCStub(channel) request = nfa_msg_pb2.RecoverReq() request.addr.rpc_ip = target_runtime["rpc_ip"] request.addr.rpc_port = target_runtime["rpc_port"] response = stub.Recover(request) print("Recover OK!")
def AddOutputMac(source_runtime, target_runtime): channel = grpc.insecure_channel( \ source_runtime["rpc_ip"]+":"+str(source_runtime["rpc_port"]) ) stub = nfa_msg_pb2_grpc.Runtime_RPCStub(channel) request = nfa_msg_pb2.AddOutputMacReq() request.addrs.rpc_ip = target_runtime["rpc_ip"] request.addrs.rpc_port = target_runtime["rpc_port"] response = stub.AddOutputMac(request) print("AddOutputMac OK!")
def AddReplicas(source_runtime, target_runtime): channel = grpc.insecure_channel( \ source_runtime["rpc_ip"]+":"+str(source_runtime["rpc_port"]) ) stub = nfa_msg_pb2_grpc.Runtime_RPCStub(channel) request = nfa_msg_pb2.AddReplicasReq() address = request.addrs.add() address.rpc_ip = target_runtime["rpc_ip"] address.rpc_port = target_runtime["rpc_port"] response = stub.AddReplicas(request) print("AddReplicas OK!")
def MigrateTo(source_runtime, target_runtime, qouta): channel = grpc.insecure_channel( \ source_runtime["rpc_ip"]+":"+str(source_runtime["rpc_port"]) ) stub = nfa_msg_pb2_grpc.Runtime_RPCStub(channel) request = nfa_msg_pb2.MigrateToReq() request.addr.rpc_ip = target_runtime["rpc_ip"] request.addr.rpc_port = target_runtime["rpc_port"] request.quota = qouta response = stub.MigrateTo(request) print("MigrateTo OK!")
def SetMigrationTarget(source_runtime, target_runtime): channel = grpc.insecure_channel( \ source_runtime["rpc_ip"]+":"+str(source_runtime["rpc_port"]) ) stub = nfa_msg_pb2_grpc.Runtime_RPCStub(channel) request = nfa_msg_pb2.SetMigrationTargetReq() address = request.addrs.add() address.rpc_ip = target_runtime["rpc_ip"] address.rpc_port = target_runtime["rpc_port"] response = stub.SetMigrationTarget(request) print("SetMigrationTarget OK!")