use of com.aws.greengrass.provisioning.DeviceIdentityInterface in project aws-greengrass-nucleus by aws-greengrass.
the class KernelLifecycleTest method createMockProvisioningPlugin.
@BeforeAll
public static void createMockProvisioningPlugin() {
DeviceIdentityInterface mockDeviceIdentityInterfaceImpl = new DeviceIdentityInterface() {
@Override
public ProvisionConfiguration updateIdentityConfiguration(ProvisionContext provisionContext) throws RetryableProvisioningException {
return null;
}
@Override
public String name() {
return null;
}
};
mockPluginClass = mockDeviceIdentityInterfaceImpl.getClass();
}
use of com.aws.greengrass.provisioning.DeviceIdentityInterface in project aws-greengrass-nucleus by aws-greengrass.
the class KernelLifecycle method findProvisioningPlugins.
@SuppressWarnings("PMD.CloseResource")
private List<DeviceIdentityInterface> findProvisioningPlugins() {
List<DeviceIdentityInterface> provisioningPlugins = new ArrayList<>();
Set<String> provisioningPluginNames = new HashSet<>();
EZPlugins ezPlugins = kernel.getContext().get(EZPlugins.class);
try {
ezPlugins.withCacheDirectory(nucleusPaths.pluginPath());
ezPlugins.implementing(DeviceIdentityInterface.class, (c) -> {
try {
if (!provisioningPluginNames.contains(c.getName())) {
provisioningPlugins.add(provisioningPluginFactory.getPluginInstance(c));
provisioningPluginNames.add(c.getName());
}
} catch (InstantiationException | IllegalAccessException e) {
logger.atError().kv("Plugin", c.getName()).setCause(e).log("Error instantiating a provisioning plugin");
}
});
} catch (IOException t) {
logger.atError().log("Error finding provisioning plugins", t);
}
return provisioningPlugins;
}
use of com.aws.greengrass.provisioning.DeviceIdentityInterface in project aws-greengrass-nucleus by aws-greengrass.
the class KernelLifecycle method launch.
/**
* Startup the Kernel and all services.
*/
public void launch() {
logger.atInfo("system-start").kv("version", kernel.getContext().get(DeviceConfiguration.class).getNucleusVersion()).kv("rootPath", nucleusPaths.rootPath()).kv("configPath", nucleusPaths.configPath()).log("Launch Nucleus");
// This guarantees that IPC, for example, is running before any user code
for (Class<? extends Startable> c : startables) {
kernel.getContext().get(c).startup();
}
final List<DeviceIdentityInterface> provisioningPlugins = findProvisioningPlugins();
// Must be called before everything else so that these are available to be
// referenced by main/dependencies of main
// NOPMD
final Queue<String> autostart = findBuiltInServicesAndPlugins();
loadPlugins();
// run the provisioning if device is not provisioned
if (!kernel.getContext().get(DeviceConfiguration.class).isDeviceConfiguredToTalkToCloud() && !provisioningPlugins.isEmpty()) {
// There is also no compelling use case right now for multiple provisioning plugins.
if (provisioningPlugins.size() > 1) {
String errorString = String.format(MULTIPLE_PROVISIONING_PLUGINS_FOUND_EXCEPTION, provisioningPlugins.toString());
throw new RuntimeException(errorString);
}
executeProvisioningPlugin(provisioningPlugins.get(0));
}
mainService = kernel.locateIgnoreError(KernelCommandLine.MAIN_SERVICE_NAME);
autostart.forEach(s -> {
try {
mainService.addOrUpdateDependency(kernel.locate(s), DependencyType.HARD, true);
} catch (ServiceLoadException se) {
logger.atError().log("Unable to load service {}", s, se);
} catch (InputValidationException e) {
logger.atError().log("Unable to add auto-starting dependency {} to main", s, e);
}
});
kernel.writeEffectiveConfig();
logger.atInfo().setEventType("system-start").addKeyValue("main", kernel.getMain()).log();
startupAllServices();
}
Aggregations