nipyapi icon indicating copy to clipboard operation
nipyapi copied to clipboard

Unable to create controller in apache nifi using nipyapi

Open nitinraj1989 opened this issue 5 years ago • 1 comments

  • Nipyapi version:
  • NiFi version:1.1.2
  • NiFi-Registry version:0.2.0
  • Python version:3.6
  • Operating System:win 8

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

nitinraj1989 avatar Oct 13 '20 08:10 nitinraj1989

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.

Chaffelson avatar Oct 14 '20 07:10 Chaffelson