Chaffelson / nipyapi

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

Unable to create controller in apache nifi using nipyapi #221

Closed nitinraj1989 closed 10 months ago

nitinraj1989 commented 3 years ago

Description

I want to create controller in apache nifi using python script to automate the process.

What I Did

-- coding: utf-8 --

""" Created on Mon Oct 12 16:42:29 2020

@author: nitin.jaiswal """

import nipyapi import requests import json nipyapi.config.nifi_config.host = 'http://localhost:8080/nifi/' nipyapi.canvas.get_controller('DistributedMapCacheClientService', identifier_type='name', bool_response=False)

Enable Controler

headers = {'Content-Type': 'application/json'} url = 'http://localhost:8080/nifi-api/flow/process-groups/'+nipyapi.canvas.get_root_pg_id()+'/controller-services' r = requests.get(url) reponse = json.loads(r.text)

controllerId = reponse['controllerServices'][0]['id']

nipyapi.canvas.schedule_controller(controllerId, 'True', refresh=False)

Error line : File "C:\Users\nitin.jaiswal\OneDrive\Qentelli\Sypder-Anaconda-Nipi-Automation\untitled0.py", line 20, in IndexError: list index out of range

create_controller - Copy.txt

Urgency

it is blocking production work and system has been getting on hold. I am unable to detect duplicate

Chaffelson commented 3 years ago

I am unsure why you aren't using canvas.list_all_controllers and filtering to the controller you need here? You may also want to use nipyapi.utils.set_endpoint to connect to the NiFi environment.