demo_utils.service_installer module

demo_utils.service_installer.add_nifi_templates()

Add any number of NiFi templates to a running NiFi installation via the REST API

Looks inside configuration/nifi/templates for XML templates to add to the installation

Returns:True if we were successful in uploading every template. False otherwise. An empty directory results in True
Return type:bool
demo_utils.service_installer.add_zeppelin_notebooks()

Add all Zeppelin notes to the current Zeppelin instalation

Looks inside configuration/zeppelin/notes for any *.json files.

Each JSON file will be attempted to be added to the current Zeppelin instance

Returns:True is every Note was added successfully. True is returned on an empty directory. False otherwise.
Return type:bool
demo_utils.service_installer.check_ambari_service_installed(service_name, ambari_config)

Determine whether an Ambari service is installed.

Parameters:
  • service_name (string) – Name of service to look for
  • ambari_config (dict) –

    The entire AMBARI section of global.conf

    read_config('global.conf')['AMBARI']
    
Returns:

True service exists, False if the service does not exist

Return type:

bool

demo_utils.service_installer.get_zeppelin_session(username, password)

Gets the JSESSIONID cookie by POSTing to /api/login

This is required to retrieve the JSESSIONID on Zeppelin instances that have logins and user permissions. Used when POSTing notebooks as well.

Returned in the form of 'JSESSIONID=**

Parameters:
  • username (str) – The username to login with
  • password (str) – The password to login with
Returns:

'' If the request was unsuccessful, or the cookie wasn’t present. Otherwise returns the cookie as a string.

Return type:

str

demo_utils.service_installer.install_hdp_select()

Installs the hdp-select package.

This is used to help install the Ambari Service for NiFi/Zeppelin. Retrieves the currently installed hadoop version.

Typically the Sandbox has hdp-select already, but clusters won’t always have it, which is why we provide this method.

demo_utils.service_installer.install_nifi()

Install NiFi via Ambari. (And Ali’s NiFi service)

Automatically installs NiFi with NO user interaction. Simply just run the method while on the same Ambari machine and NiFi will be installed. You’ll need to start it manually though.

Returns:True if installation is successful. Else, the user specifies whether or not they want to continue setting up the demo without Zeppelin. True if the user specifed Yes (to continue). False if they specified No (do not continue).
Return type:bool
Raises:EnvironmentError – Raised when Ambari is not installed on the current host. Or if hdp-select cannot be installed
demo_utils.service_installer.install_zeppelin()

Install Zeppelin via Ambari.

This requires user interaction. Plans to make installation automatic are in the works...

Returns:True if installation is successful. Else, the user specifies whether or not they want to continue setting up the demo without Zeppelin. True if the user specifed Yes (to continue). False if they specified No (do not continue).
Return type:bool
Raises:EnvironmentError – Raised when Ambari is not installed on the current host. Or if hdp-select cannot be installed
demo_utils.service_installer.is_ambari_installed()

Determines whether or not ambari-server is available (In order to start/stop/restart Ambari)

Returns:True is ambari-server is available as a shell command. False otherwise.
Return type:bool
demo_utils.service_installer.is_hdp_select_installed()

Checks if hdp-select is installed.

Returns:True if installed (available as shell command), False if not installed
Return type:bool
demo_utils.service_installer.post_notebook(notebook_path, session_cookie='')

Add a single notebook to a Zeppelin installation via REST API

Must have a file called global.conf inside of the configuration directory.

Inside that configuration file we use protocol://server:port to connect to a Zeppelin instance and use the API

Parameters:
  • notebook_path (str) – Full file path to the Zeppelin note
  • session_cookie (str, optional) – The cookie used after authentication in order to make authorized API calls. Required on the 2.5 TP Sandbox
Returns:

True if the upload was successful (received 201 created), or False otherwise.

Return type:

bool

demo_utils.service_installer.post_template(template_path)

Add a single template to a NiFi instance via REST API

Parameters:template_path (str) – The full path to the NiFi template
Returns:True if the upload is successful, False otherwise
Return type:bool