# Path: credentials.py
# NUTANIX_USER = 'youraccount'
# 
# Path: credentials.py
# NUTANIX_PASSWORD = 'yourpassword'


import json
import time
import requests
import logging.config
from credentials import NUTANIX_USER  # Login info now stored in credentials.py
from credentials import NUTANIX_PASSWORD  # Login info now stored in credentials.py
        self.usage_gbytes = 0
        self.capacity_gbytes = 0
        self.cpu_percent = []
        self.ram_percent = []


class MonitorJSON:
    """This is a simple class passed to Monitor threads so we can access the current JSON data in that thread"""
    def __init__(self):
        self.json = ""
        self.session = None
        self.data = NutanixData()


def generate_json(monitor):
    """
    This function will connect to the Nutanix cluster and retrieve performance data, which
    will be stored in json format in the json property.
    """

    logger = logging.getLogger("nutanix_1")
    # Really don't need to hear about connections being brought up again after server has closed it
    logging.getLogger("requests.packages.urllib3.connectionpool").setLevel(logging.WARNING)

    # Check if there is a working session and create a new one if it is not working
    if monitor.session is None:
        logger.debug("No existing REST API session, creating a new one.")
        # Create Session object that will allow us to issue commands without having to login each time
        monitor.session = requests.Session()
        monitor.session.headers.update({'content-type': 'application/json'})

# Path: credentials.py
# NUTANIX_USER = 'youraccount'
# 
# Path: credentials.py
# NUTANIX_PASSWORD = 'yourpassword'


# Path: nutanix_svr.py
import json
import time
import requests
import logging.config
from credentials import NUTANIX_USER  # Login info now stored in credentials.py
from credentials import NUTANIX_PASSWORD  # Login info now stored in credentials.py

        self.usage_gbytes = 0
        self.capacity_gbytes = 0
        self.cpu_percent = []
        self.ram_percent = []


class MonitorJSON:
    """This is a simple class passed to Monitor threads so we can access the current JSON data in that thread"""
    def __init__(self):
        self.json = ""
        self.session = None
        self.data = NutanixData()


def generate_json(monitor):
    """
    This function will connect to the Nutanix cluster and retrieve performance data, which
    will be stored in json format in the json property.
    """

    logger = logging.getLogger("nutanix_1")
    # Really don't need to hear about connections being brought up again after server has closed it
    logging.getLogger("requests.packages.urllib3.connectionpool").setLevel(logging.WARNING)

    # Check if there is a working session and create a new one if it is not working
    if monitor.session is None:
        logger.debug("No existing REST API session, creating a new one.")
        # Create Session object that will allow us to issue commands without having to login each time
        monitor.session = requests.Session()
        monitor.session.headers.update({'content-type': 'application/json'})

        monitor.session.auth = (NUTANIX_USER, NUTANIX_PASSWORD)