t_node_proxy = Thread(target=cephadmlib.node_proxy.server.main,
kwargs={'host': result_json['result']['addr'],
'username': result_json['result']['username'],
- 'password': result_json['result']['password'])
+ 'password': result_json['result']['password'],
+ 'data': node_proxy_data})
t_node_proxy.start()
try:
import requests
import time
from .util import Logger
-from typing import Any
+from typing import Dict, Any
log = Logger(__name__)
class Reporter:
- def __init__(self, system: Any, observer_url: str) -> None:
+ def __init__(self, system: Any, data: Dict[str, Any], observer_url: str) -> None:
self.system = system
self.observer_url = observer_url
self.finish = False
+ self.data = data
def stop(self) -> None:
self.finish = True
log.logger.info('data ready to be sent to the mgr.')
if not self.system.get_system() == self.system.previous_data:
log.logger.info('data has changed since last iteration.')
- d = self.system.get_system()
+ self.data['data'] = self.system.get_system()
try:
# TODO: add a timeout parameter to the reporter in the config file
- requests.post(f"{self.observer_url}/", json=d, timeout=5)
- except requests.exceptions.RequestException as e:
+ log.logger.info(f"sending data to {self.observer_url}")
+ r = requests.post(f"{self.observer_url}", json=self.data, timeout=5, verify=False)
+ except (requests.exceptions.RequestException,
+ requests.exceptions.ConnectionError) as e:
log.logger.error(f"The reporter couldn't send data to the mgr: {e}")
# Need to add a new parameter 'max_retries' to the reporter if it can't
# send the data for more than x times, maybe the daemon should stop altogether
from .basesystem import BaseSystem
import sys
import argparse
+import json
DEFAULT_CONFIG = {
'reporter': {
def main(host: str = '',
username: str = '',
- password: str = '') -> None:
+ password: str = '',
+ data: str = '') -> None:
# TODO: add a check and fail if host/username/password/data aren't passed
# parser = argparse.ArgumentParser(
host = host
username = username
password = password
+ data = json.loads(data)
# create the redfish system and the obsever
log.logger.info("Server initialization...")
password=password,
system_endpoint='/Systems/System.Embedded.1',
config=config)
- reporter_agent = Reporter(system, config.__dict__['reporter']['endpoint'])
+ reporter_agent = Reporter(system, data, config.__dict__['reporter']['endpoint'])
cherrypy.config.update({
'node_proxy': config,
'server.socket_port': config.__dict__['server']['port']