Chaffelson / nipyapi

A convenient Python wrapper for Apache NiFi
Other
246 stars 76 forks source link

Establish connection to two different NiFi severs always extracts details from same NiFi server #160

Closed rajarshnaidu closed 3 years ago

rajarshnaidu commented 5 years ago

Description

I am trying to access two different NiFi servers over SSL and extract processors of a certain type. The extracted processors are always from the first NiFi to which the connection is established.

What I Did

Created a class Extract which has functions (establish_connection(), extract_processors()) I have imported the class into a base script and passed the arguments server1="https://$server_1:9091/nifi-api", user, pass and server2="https://$server_1:9091/nifi-api", user, pass

The extract processors are always returning from server1.

I tried to use "nipyapi.security.service_logout(service=’nifi’)" to logout from service for each server before calling the other server. The bool value is always false.

Urgency

I have an alternative way of dumping the data from first extract into a file and then re-using the file in the second script. But wanted to know if this is a bug which could be added enhanced or if this feature is not supported. I tried to look for any specific calls in mozilla dev tools. But this seems to be a simple /nifi/logout get call.

rajarshnaidu commented 5 years ago

Seems a similar issue was already logged and a suggestion was provided to use set_endpoint before re-initiating connection to a different nifi environment. I have tested this for a secured environment and if connection details are passed to a class. But if i try to test this in a same jupyter notebook in below order i get SSL error.

Order: def establishConnection(): def extractRootPGID():

establishConnection(server1,user,password) extract_RootPGID() //Returns the RootPG UUID nipyapi.utils.set_endpoint(endpoint_url=self.server,ssl=True,login=False) //Setting endPoint establishConnection(server2,user,password) //Unable to establish connection with (SSL Error when run in Jupyter notebook)

Alternate way: class ExtractDetails: def connection_details(): def rootPGID(): def logout(): set_endpoint()

importing the class and calling the functions for 2 different NiFi (servers/environments) i was able to extract details from 2 different NiFi instances.

Chaffelson commented 4 years ago

If you get an SSL error it is probably not correctly clearing the client it generates on connection - essentially the nipyapi logout command not only issues the logout but dumps the entire client configuration ready to generate a new one. It's not elegant but it seemed to work in my past testing.

If this is still a concern for you please let me know and I'll add it to my next round of enhancements.