Esempio n. 1
0
 def run(self, context):
     log.info("Checking for updates...")
     device_type = devicetype.get(settings.PATHS.device_type)
     artifact_name = artifactinfo.get(settings.PATHS.artifact_info)
     deployment = deployments.request(
         context.config.ServerURL,
         context.JWT,
         device_type=device_type,
         artifact_name=artifact_name,
         server_certificate=context.config.ServerCertificate,
     )
     if deployment:
         context.deployment = deployment
         context.deployment_log_handler.enable()
         return True
     time.sleep(2)
     return False
Esempio n. 2
0
def aggregate(script_path: str, device_type_path: str,
              artifact_info_path: str) -> dict:
    """Runs all the inventory scripts in 'path', and parses the 'key=value' pairs
    into a data-structure ready for passing it on to the Mender server"""
    log.info(f"Aggregating inventory data from {script_path}")
    keyvals: dict = {}
    for inventory_script in inventory_scripts(script_path):
        keyvals.update(inventory_script.run())
    device_type = devicetype.get(device_type_path)
    log.info(f"Found the device type: {device_type}")
    if device_type:
        keyvals.update(device_type)
    artifact_name = artifactinfo.get(artifact_info_path)
    log.info(f"Found the artifact_name: {artifact_name}")
    if artifact_name:
        keyvals.update(artifact_name)
    return keyvals
Esempio n. 3
0
    def run(self, context):
        if not context.update_timer.is_it_time():
            return False

        log.info("Checking for updates...")
        device_type = devicetype.get(settings.PATHS.device_type)
        artifact_name = artifactinfo.get(settings.PATHS.artifact_info)
        deployment = deployments.request(
            context.config.ServerURL,
            context.JWT,
            device_type=device_type,
            artifact_name=artifact_name,
            server_certificate=context.config.ServerCertificate,
        )
        if deployment:
            context.deployment = deployment
            log.parent.deployment_log_handler.enable(reset=True)
            return True
        return False
Esempio n. 4
0
 def test_get_artifact_info(self, data, expected, file_create_fixture):
     fpath = file_create_fixture(data)
     ainfo = artifactinfo.get(fpath)
     assert ainfo == expected