def run_bootstrap(args): log.info("Bootstrapping...") if args.data: log.info(f"Custom data store set to: {args.data}") settings.PATHS = settings.Path(data_store=args.data) bootstrap.now(private_key_path=settings.PATHS.key, force_bootstrap=args.forcebootstrap)
def run(self, context, force_bootstrap=False): log.debug("InitState: run()") try: context.config = config.load( local_path=settings.PATHS.local_conf, global_path=settings.PATHS.global_conf, ) log.info(f"Loaded configuration: {context.config}") except config.NoConfigurationFileError: log.error("No configuration files found for the device." " Most likely, the device will not be functional.") identity_data = identity.aggregate( path=settings.PATHS.identity_scripts) context.identity_data = identity_data private_key = bootstrap.now(force_bootstrap=force_bootstrap, private_key_path=settings.PATHS.key) context.private_key = private_key context.inventory_timer = timeutil.IsItTime( context.config.InventoryPollIntervalSeconds) context.update_timer = timeutil.IsItTime( context.config.UpdatePollIntervalSeconds) context.retry_timer = timeutil.IsItTime( context.config.RetryPollIntervalSeconds) log.debug(f"Init set context to: {context}") return context
def run(self, context, force_bootstrap=False): log.debug("InitState: run()") context.config = config.Config({}, {}) try: context.config = config.load( local_path=settings.PATHS.local_conf, global_path=settings.PATHS.global_conf, ) log.info(f"Loaded configuration: {context.config}") except config.NoConfigurationFileError: log.error("No configuration files found for the device." "Most likely, the device will not be functional.") identity_data = identity.aggregate( path=settings.PATHS.identity_scripts) context.identity_data = identity_data private_key = bootstrap.now(force_bootstrap=force_bootstrap, private_key_path=settings.PATHS.key) context.private_key = private_key log.debug(f"Init set context to: {context}") # # We need some way of knowing whether or not a deployment was in # progress, and what the last state was, so that the deployment can be # resumed, and so that we can start the state-machine on the passive # partition, whenever needed. For now though, this is always False. # context.deployment_active = False return context
def test_key_already_generated(self, tmpdir): d = tmpdir.mkdir("test_key_already_generated") key_path = os.path.join(d, "mender-agent.pem") assert bootstrap.now(private_key_path=key_path) assert bootstrap.key_already_generated(key_path) os.unlink(key_path) assert not bootstrap.key_already_generated(key_path)
def test_bootstrap_non_existing_directory(self): key_path = "/foo/bar" key = bootstrap.now(force_bootstrap=False, private_key_path=key_path) assert not key
def test_force_bootstrap(self, tmpdir): d = tmpdir.mkdir("test_force_bootstrap") key_path = os.path.join(d, "mender-agent.pem") assert bootstrap.now(private_key_path=key_path) assert bootstrap.now(force_bootstrap=True, private_key_path=key_path)
def run_bootstrap(args): log.info("Bootstrapping...") bootstrap.now(private_key_path=settings.PATHS.key, force_bootstrap=args.forcebootstrap)
def run_bootstrap(args): log.info("Bootstrapping...") if args.data: log.info(f"Custom data store set to: {args.data}") settings.PATHS = settings.Path(data_store=args.data) bootstrap.now(force_bootstrap=True)