def EstablishChannel(address, port, client_id, user, password): # Open a grpc channel to the device #creds = implementations.ssl_channel_credentials(open('/tmp/host.pem').read(), None, None) channel = implementations.insecure_channel(address, port) # Create stub for authentication login_stub = authentication_service_pb2.beta_create_Login_stub(channel) # Fill the login request message structure login_request = authentication_service_pb2.LoginRequest( user_name=user, password=password, client_id=client_id) # Invoke the login check API login_response = login_stub.LoginCheck(login_request, _TIMEOUT_SECONDS) return channel
def EstablishChannel(address, port, client_id, user, password): # Open a grpc channel to the device creds = implementations.ssl_channel_credentials(open('/tmp/host.pem').read(), None, None) channel = implementations.secure_channel(address, port, creds) # Create stub for authentication login_stub = authentication_service_pb2.beta_create_Login_stub(channel) # Fill the login request message structure login_request = authentication_service_pb2.LoginRequest(user_name=user, password=password, client_id=client_id) # Invoke the login check API login_response = login_stub.LoginCheck(login_request, _TIMEOUT_SECONDS) print login_response return channel
device1 = args.device APP_USER = '******' APP_PASSWORD = '******' port = 9999 client_id = '101' def pause(): programPause = raw_input("Enter to continue...") print "Executing Python app" try: channel = implementations.insecure_channel(host=device1, port=port) stub = authentication_service_pb2.beta_create_Login_stub(channel) login_response = stub.LoginCheck( authentication_service_pb2.LoginRequest(user_name=APP_USER, password=APP_PASSWORD, client_id=client_id), 100) if (login_response.result == 1): print "Login to ", device1, "successful" else: print "Login to ", device1, "failed" raise SystemExit() fw = firewall_service_pb2.beta_create_AclService_stub(channel) pause() flag = 0 res = [] match1 = AclMatchPort(min=0, max=120, match_op=ACL_MATCH_OP_EQUAL)
LOG.debug("SocketIO: Write failed") requestQ.task_done() try: CONNECTION_LIST = list() for i in range(1): t = Thread(target=allRouteApis) t.setDaemon(True) t.start() dispatch_thread = Thread(target=sendtoPS) dispatch_thread.setDaemon(True) dispatch_thread.start() channel = implementations.insecure_channel(host=HOST, port=GRPC_PORT) stub = authentication_service_pb2.beta_create_Login_stub(channel) login_response = stub.LoginCheck(authentication_service_pb2.LoginRequest(user_name=USER, password=PASSWORD, client_id=CLIENT_ID), TIMEOUT) LOG.info("Connected to the JET GRPC request response server") bgp = bgp_route_service_pb2.beta_create_BgpRoute_stub(channel) prpd = prpd_service_pb2.beta_create_Base_stub(channel) purgeTime = 30 # Variables for RouteGet Operation eod = 0 count = 0 getroutelist = [] getwaitflag = 0 # Dictionary of sockets waiting on incomplete data for requests