Esempio n. 1
0
 def create_master_node_settings(self):
     self.master_node_settings = {
         'master_node_uid': str(uuid.uuid4()),
     }
     self.master_node_settings.update(self.master_node_settings_template)
     MasterNodeSettings.create(self.master_node_settings)
     self.db.commit()
Esempio n. 2
0
 def create_master_node_settings(self):
     self.master_node_settings = {
         'master_node_uid': str(uuid.uuid4()),
     }
     self.master_node_settings.update(self.master_node_settings_template)
     MasterNodeSettings.create(self.master_node_settings)
     self.db.commit()
Esempio n. 3
0
    def test_master_node_in_headers(self, requests_post):
        requests_post.return_value = Mock(status_code=200)
        sender = StatsSender()
        url = ''
        data = {}
        master_node_uid = 'xxx'
        MasterNodeSettings.create({'master_node_uid': master_node_uid})

        sender.send_data_to_url(url=url, data={})
        requests_post.assert_called_once_with(
            url,
            headers={'content-type': 'application/json',
                     'master-node-uid': master_node_uid},
            data=json.dumps(data),
            timeout=settings.COLLECTOR_RESP_TIMEOUT)
Esempio n. 4
0
    def test_master_node_in_headers(self, requests_post):
        requests_post.return_value = Mock(status_code=200)
        sender = StatsSender()
        url = ''
        data = {}
        master_node_uid = 'xxx'
        MasterNodeSettings.create({'master_node_uid': master_node_uid})

        sender.send_data_to_url(url=url, data={})
        requests_post.assert_called_once_with(
            url,
            headers={
                'content-type': 'application/json',
                'master-node-uid': master_node_uid
            },
            data=json.dumps(data),
            timeout=settings.COLLECTOR_RESP_TIMEOUT)
Esempio n. 5
0
def run():
    resource_type = sys.argv[1]
    poll_interval = settings.OSWL_COLLECTORS_POLLING_INTERVAL[resource_type]
    logger.info(
        "Starting OSWL collector for {0} resource".format(resource_type))
    try:
        while True:
            if MasterNodeSettings.must_send_stats():
                collect(resource_type)

            time.sleep(poll_interval)

    except (KeyboardInterrupt, SystemExit):
        logger.info(
            "Stopping OSWL collector for {0} resource".format(resource_type))
Esempio n. 6
0
def run():
    resource_type = sys.argv[1]
    poll_interval = settings.OSWL_COLLECTORS_POLLING_INTERVAL[resource_type]
    logger.info("Starting OSWL collector for {0} resource"
                .format(resource_type))
    try:
        while True:
            if MasterNodeSettings.must_send_stats():
                collect(resource_type)

            time.sleep(poll_interval)

    except (KeyboardInterrupt, SystemExit):
        logger.info("Stopping OSWL collector for {0} resource"
                    .format(resource_type))
Esempio n. 7
0
 def get_user_info(self):
     try:
         stat_settings = MasterNodeSettings.get_one(). \
             settings.get("statistics", {})
         result = {
             "contact_info_provided":
             stat_settings.get("user_choice_saved", {}).get("value", False)
             and stat_settings.get("send_user_info", {}).get("value", False)
         }
         if result["contact_info_provided"]:
             result["name"] = stat_settings.get("name", {}).get("value")
             result["email"] = stat_settings.get("email", {}).get("value")
             result["company"] = stat_settings.get("company", {}).\
                 get("value")
         return result
     except AttributeError:
         return {"contact_info_provided": False}
Esempio n. 8
0
 def get_user_info(self):
     try:
         stat_settings = MasterNodeSettings.get_one(). \
             settings.get("statistics", {})
         result = {
             "contact_info_provided":
             stat_settings.get("user_choice_saved", {}).get("value", False)
             and stat_settings.get("send_user_info", {}).get("value", False)
         }
         if result["contact_info_provided"]:
             result["name"] = stat_settings.get("name", {}).get("value")
             result["email"] = stat_settings.get("email", {}).get("value")
             result["company"] = stat_settings.get("company", {}).\
                 get("value")
         return result
     except AttributeError:
         return {"contact_info_provided": False}
Esempio n. 9
0
def run():
    resource_type = sys.argv[1]

    # add file handler to log collecting for particular resource
    log_file = "oswl_{0}_collectord.log".format(resource_type)
    utils.prepare_logger(logger, log_file)

    poll_interval = settings.OSWL_COLLECTORS_POLLING_INTERVAL[resource_type]
    logger.info("Starting OSWL collector for {0} resource"
                .format(resource_type))
    try:
        while True:
            if MasterNodeSettings.must_send_stats():
                collect(resource_type)

            time.sleep(poll_interval)

    except (KeyboardInterrupt, SystemExit):
        logger.info("Stopping OSWL collector for {0} resource"
                    .format(resource_type))
Esempio n. 10
0
 def get_master_node_uid(self):
     return getattr(MasterNodeSettings.get_one(), 'master_node_uid', None)
Esempio n. 11
0
 def get_master_node_uid(self):
     return getattr(MasterNodeSettings.get_one(), 'master_node_uid', None)