diff --git a/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_en.properties b/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_en.properties index 59136902182..28389e46e61 100644 --- a/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_en.properties +++ b/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_en.properties @@ -3,9 +3,9 @@ description=Allows for the creation of containers. containerEnabled=Enabled containerEnabledDesc=Enables this container containerImage=Image name -containerImageDesc=The image the container will be created with. The value will need to be expressed in the form registryURL/imagename in case of a custom registry. Please fill the following registry credentials in case of pulling from a custom or authenticated Docker hub registry. +containerImageDesc=Specifies the image reference that will be used to create this container instance. The value has to be expressed in the form registryURL/imagename. If no registryURL is provided, the official Docker Hub registry will be used as default. When pulling the testing/test-image image from a local registry listening on port 5000 (e.g. myregistry.local:5000), the registryURL/imagename field has to be specified as follows: myregistry.local:5000/testing/test-image Default: nginx (the image will be pulled from the Docker Hub registry) containerImageTag=Image tag -containerImageTagDesc=Describes which image version that should be pulled from the container registry. +containerImageTagDesc=Describes which image version should be pulled from the container registry. Default: latest containerSignatureTrustAnchor=Trust anchor containerSignatureTrustAnchorDesc=Trust anchor used to verify the container image signature.|TextArea containerSignatureVerifyTransparencyLog=Verify in transparency log @@ -19,11 +19,11 @@ registryUsernameDesc=Username for container registry. Required only for authenti registryPassword=Password registryPasswordDesc=Password for container registry. Required only for authenticated registries containerImageDownloadRetries=Image Download Retries -containerImageDownloadRetriesDesc=The number of retries to pull the container image. Set to 0 for unlimited retries +containerImageDownloadRetriesDesc=Specifies the number of retries the framework performs when attempting to pull the container image. Set to 0 for unlimited retries. Default: 5 containerImageDownloadInterval=Image Download Retry Interval -containerImageDownloadIntervalDesc=The interval (in milliseconds) between retries to pull the container image +containerImageDownloadIntervalDesc=The interval (in milliseconds) between retries to pull the container image. Default: 30000 containerImageDownloadTimeout=Image Download Timeout -containerImageDownloadTimeoutDesc=Image download timeout. Value specified in seconds +containerImageDownloadTimeoutDesc=Image download timeout. Value specified in seconds. Default: 500 containerPortsInternal=Internal ports containerPortsInternalDesc=A comma-separated list of ports. If no protocol is specified tcp will be used. Note, the number of internal ports must be equal to the number of external ports. A port internet protocol can also be specified with a colon and text after the port number. Example: 80, 443:udp, 8080:tcp. containerPortsExternal=External ports @@ -51,6 +51,6 @@ containerNetworkingModeDesc=Used to specify what networking mode the container w containerLoggingType=Logger Type containerLoggingTypeDesc=Used to specify what logging driver the container will use. By default, containers will log to a JSON-FILE on the gateway. containerLoggerParameters=Logger Parameters -containerLoggerParametersDesc=Used to pass logger parameters to a container's logging driver. Example: max-size=10m, max-file=2. +containerLoggerParametersDesc=Used to pass logger parameters to a container's logging driver. Example: max-size=10m, max-file=2. Default: max-size=10m containerRestartOnfailure=Restart Container On Failure -containerRestartOnfailureDesc=Automatically restart the container when it has failed. \ No newline at end of file +containerRestartOnfailureDesc=Automatically restart the container when it has failed. Default: false \ No newline at end of file diff --git a/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_zh.properties b/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_zh.properties index 6882857f444..7d3079d8865 100644 --- a/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_zh.properties +++ b/kura/org.eclipse.kura.container.provider/OSGI-INF/l10n/ContainerInstance_zh.properties @@ -3,9 +3,9 @@ description=\u5141\u8BB8\u521B\u5EFA\u5BB9\u5668\u3002 containerEnabled=\u542F\u7528 containerEnabledDesc=\u542F\u7528\u8FD9\u4E2A\u5BB9\u5668 containerImage=\u955C\u50CF\u540D\u79F0 -containerImageDesc=\u5C06\u4F7F\u7528\u521B\u5EFA\u5BB9\u5668\u7684\u955C\u50CF\u3002 \u5982\u679C\u662F\u81EA\u5B9A\u4E49\u6CE8\u518C\uFF0C\u5219\u8BE5\u503C\u9700\u8981\u4EE5 registryURL/imagename \u7684\u5F62\u5F0F\u8868\u793A\u3002 \u5982\u679C\u4ECE\u81EA\u5B9A\u4E49\u6216\u7ECF\u8FC7\u8EAB\u4EFD\u9A8C\u8BC1\u7684 Docker \u4E2D\u5FC3\u6CE8\u518C\u4E2D\u63D0\u53D6\uFF0C\u8BF7\u586B\u5199\u4EE5\u4E0B\u6CE8\u518C\u8868\u51ED\u636E\u3002 +containerImageDesc=\u6307\u5B9A\u5C06\u7528\u4E8E\u521B\u5EFA\u6B64\u5BB9\u5668\u5B9E\u4F8B\u7684\u56FE\u50CF\u5F15\u7528\u3002\u8BE5\u503C\u5FC5\u987B\u4EE5 registryURL/imagename \u7684\u5F62\u5F0F\u8868\u793A\u3002 \u5982\u679C\u672A\u63D0\u4F9B registryURL\uFF0C\u5219\u9ED8\u8BA4\u4F7F\u7528\u5B98\u65B9 Docker Hub \u6CE8\u518C\u8868\u3002\u4ECE\u76D1\u542C\u7AEF\u53E3 5000 \u7684\u672C\u5730\u6CE8\u518C\u8868\u4E2D\u63D0\u53D6 testing/test-image \u56FE\u50CF\u65F6\uFF08\u4F8B\u5982 myregistry.local:5000\uFF09\uFF0CregistryURL/imagename \u5B57\u6BB5\u5FC5\u987B\u6307\u5B9A\u5982\u4E0B\uFF1Amyregistry.local:5000/testing/test-image\u9ED8\u8BA4\u503C\uFF1Anginx\uFF08\u56FE\u50CF\u5C06\u4ECE Docker Hub \u6CE8\u518C\u8868\u4E2D\u63D0\u53D6\uFF09 containerImageTag=\u955C\u50CF\u6807\u7B7E -containerImageTagDesc=\u63CF\u8FF0\u5E94\u8BE5\u4ECE\u5BB9\u5668\u6CE8\u518C\u8868\u4E2D\u63D0\u53D6\u7684\u955C\u50CF\u7248\u672C\u3002 +containerImageTagDesc=\u63CF\u8FF0\u5E94\u4ECE\u5BB9\u5668\u6CE8\u518C\u8868\u4E2D\u63D0\u53D6\u54EA\u4E2A\u6620\u50CF\u7248\u672C\u3002\u9ED8\u8BA4\u503C\uFF1Alatest containerSignatureTrustAnchor=\u4FE1\u4EFB\u951A containerSignatureTrustAnchorDesc=\u7528\u4E8E\u9A8C\u8BC1\u5BB9\u5668\u955C\u50CF\u7B7E\u540D\u7684\u4FE1\u4EFB\u951A\u3002|TextArea containerSignatureVerifyTransparencyLog=\u5728\u900F\u660E\u5EA6\u65E5\u5FD7\u4E2D\u9A8C\u8BC1 @@ -20,11 +20,11 @@ registryUsernameDesc=\u5BB9\u5668\u6CE8\u518C\u8868\u7684\u7528\u6237\u540D\u300 registryPassword=\u5BC6\u7801 registryPasswordDesc=\u5BB9\u5668\u6CE8\u518C\u8868\u7684\u5BC6\u7801\u3002 \u4EC5\u5BF9\u7ECF\u8FC7\u8EAB\u4EFD\u9A8C\u8BC1\u7684\u6CE8\u518C\u8868\u9700\u8981 containerImageDownloadRetries=\u955C\u50CF\u4E0B\u8F7D\u91CD\u8BD5 -containerImageDownloadRetriesDesc=\u62C9\u53D6\u5BB9\u5668\u955C\u50CF\u7684\u91CD\u8BD5\u6B21\u6570\u3002\u8BBE\u7F6E\u4E3A 0 \u8868\u793A\u65E0\u9650\u91CD\u8BD5 +containerImageDownloadRetriesDesc=\u6307\u5B9A\u6846\u67B6\u5C1D\u8BD5\u62C9\u53D6\u5BB9\u5668\u6620\u50CF\u65F6\u6267\u884C\u7684\u91CD\u8BD5\u6B21\u6570\u3002\u8BBE\u7F6E\u4E3A 0 \u8868\u793A\u65E0\u9650\u5236\u91CD\u8BD5\u3002\u9ED8\u8BA4\u503C\uFF1A5 containerImageDownloadInterval=\u955C\u50CF\u4E0B\u8F7D\u91CD\u8BD5\u95F4\u9694 -containerImageDownloadIntervalDesc=\u91CD\u8BD5\u62C9\u53D6\u5BB9\u5668\u955C\u50CF\u7684\u65F6\u95F4\u95F4\u9694\uFF08\u4EE5\u6BEB\u79D2\u4E3A\u5355\u4F4D\uFF09 +containerImageDownloadIntervalDesc=\u91CD\u8BD5\u62C9\u53D6\u5BB9\u5668\u955C\u50CF\u7684\u95F4\u9694\uFF08\u4EE5\u6BEB\u79D2\u4E3A\u5355\u4F4D\uFF09\u3002\u9ED8\u8BA4\u503C\uFF1A30000 containerImageDownloadTimeout=\u955C\u50CF\u4E0B\u8F7D\u8D85\u65F6\u65F6\u95F4 -containerImageDownloadTimeoutDesc=\u955C\u50CF\u4E0B\u8F7D\u8D85\u65F6\uFF0C\u4EE5\u79D2\u4E3A\u5355\u4F4D\u6307\u5B9A\u7684\u503C +containerImageDownloadTimeoutDesc=\u955C\u50CF\u4E0B\u8F7D\u8D85\u65F6\u3002\u4EE5\u79D2\u4E3A\u5355\u4F4D\u6307\u5B9A\u503C\u3002\u9ED8\u8BA4\u503C\uFF1A500 containerPortsInternal=\u5185\u90E8\u7AEF\u53E3 containerPortsInternalDesc=\u4EE5\u9017\u53F7\u5206\u9694\u7684\u7AEF\u53E3\u5217\u8868\u3002 \u5982\u679C\u6CA1\u6709\u6307\u5B9A\u534F\u8BAE\uFF0C\u5C06\u4F7F\u7528 tcp\u3002 \u6CE8\u610F\uFF0C\u5185\u90E8\u7AEF\u53E3\u7684\u6570\u91CF\u5FC5\u987B\u7B49\u4E8E\u5916\u90E8\u7AEF\u53E3\u7684\u6570\u91CF\u3002 \u7AEF\u53E3 Internet \u534F\u8BAE\u4E5F\u53EF\u4EE5\u5728\u7AEF\u53E3\u53F7\u540E\u7528\u5192\u53F7\u548C\u6587\u672C\u6307\u5B9A\u3002 \u793A\u4F8B\uFF1A80\u3001443:udp\u30018080:tcp\u3002 containerPortsExternal=\u5916\u90E8\u7AEF\u53E3 @@ -52,6 +52,6 @@ containerNetworkingModeDesc=\u7528\u4E8E\u6307\u5B9A\u5BB9\u5668\u5C06\u4F7F\u75 containerLoggingType=\u8BB0\u5F55\u5668\u7C7B\u578B containerLoggingTypeDesc=\u7528\u4E8E\u6307\u5B9A\u5BB9\u5668\u5C06\u4F7F\u7528\u7684\u65E5\u5FD7\u8BB0\u5F55\u9A71\u52A8\u7A0B\u5E8F\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u5BB9\u5668\u5C06\u8BB0\u5F55\u5230\u7F51\u5173\u4E0A\u7684 JSON\u6587\u4EF6\u3002 containerLoggerParameters=\u65E5\u5FD7\u53C2\u6570 -containerLoggerParametersDesc=\u7528\u4E8E\u5C06\u8BB0\u5F55\u5668\u53C2\u6570\u4F20\u9012\u7ED9\u5BB9\u5668\u7684\u65E5\u5FD7\u8BB0\u5F55\u9A71\u52A8\u7A0B\u5E8F\u3002 \u793A\u4F8B\uFF1A\u6700\u5927\u5927\u5C0F=10m\uFF0C\u6700\u5927\u6587\u4EF6=2\u3002 +containerLoggerParametersDesc=\u7528\u4E8E\u5C06\u8BB0\u5F55\u5668\u53C2\u6570\u4F20\u9012\u7ED9\u5BB9\u5668\u7684\u65E5\u5FD7\u8BB0\u5F55\u9A71\u52A8\u7A0B\u5E8F\u3002\u793A\u4F8B\uFF1Amax-size=10m\u3001max-file=2\u3002\u9ED8\u8BA4\u503C\uFF1Amax-size=10m containerRestartOnfailure=\u5931\u8D25\u65F6\u91CD\u65B0\u542F\u52A8\u5BB9\u5668 -containerRestartOnfailureDesc=\u5BB9\u5668\u5931\u8D25\u65F6\u81EA\u52A8\u91CD\u65B0\u542F\u52A8\u3002 \ No newline at end of file +containerRestartOnfailureDesc=\u5BB9\u5668\u5931\u8D25\u65F6\u81EA\u52A8\u91CD\u542F\u3002\u9ED8\u8BA4\u503C\uFF1Afalse \ No newline at end of file diff --git a/kura/org.eclipse.kura.container.provider/OSGI-INF/metatype/org.eclipse.kura.container.provider.ContainerInstance.xml b/kura/org.eclipse.kura.container.provider/OSGI-INF/metatype/org.eclipse.kura.container.provider.ContainerInstance.xml index 0e6c5edca48..754859296a1 100644 --- a/kura/org.eclipse.kura.container.provider/OSGI-INF/metatype/org.eclipse.kura.container.provider.ContainerInstance.xml +++ b/kura/org.eclipse.kura.container.provider/OSGI-INF/metatype/org.eclipse.kura.container.provider.ContainerInstance.xml @@ -27,21 +27,6 @@ - - - - - - + + + + + + - + - + diff --git a/kura/org.eclipse.kura.linux.position/src/main/java/org/eclipse/kura/linux/position/PositionServiceImpl.java b/kura/org.eclipse.kura.linux.position/src/main/java/org/eclipse/kura/linux/position/PositionServiceImpl.java index 004116f4972..c952bd87c7d 100644 --- a/kura/org.eclipse.kura.linux.position/src/main/java/org/eclipse/kura/linux/position/PositionServiceImpl.java +++ b/kura/org.eclipse.kura.linux.position/src/main/java/org/eclipse/kura/linux/position/PositionServiceImpl.java @@ -21,11 +21,10 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.eclipse.kura.KuraErrorCode; -import org.eclipse.kura.KuraException; import org.eclipse.kura.configuration.ConfigurableComponent; import org.eclipse.kura.linux.position.options.PositionServiceOptions; import org.eclipse.kura.linux.position.provider.GpsDeviceAvailabilityListener; @@ -73,16 +72,20 @@ public void setEventAdmin(final EventAdmin eventAdmin) { this.eventAdmin = eventAdmin; } - public void unsetEventAdmin(final EventAdmin eventAdmin) { - this.eventAdmin = null; - } - - public void setPositionProviders(PositionProvider positionProvider) { + public synchronized void setPositionProviders(PositionProvider positionProvider) { this.positionProviders.add(positionProvider); // ADD NAME TO PROVIDERS + + if (this.options != null && isSelectedProvider(positionProvider, this.options)) { + updateInternal(); + } } - public void unsetPositionProviders(PositionProvider positionProvider) { + public synchronized void unsetPositionProviders(PositionProvider positionProvider) { this.positionProviders.remove(positionProvider); + + if (this.options != null && isSelectedProvider(positionProvider, this.options)) { + updateInternal(); + } } // ---------------------------------------------------------------- @@ -108,13 +111,15 @@ protected void deactivate() { logger.info("Deactivating... Done."); } - public void updated(final Map properties) { + public synchronized void updated(final Map properties) { logger.debug("Updating..."); final PositionServiceOptions newOptions = new PositionServiceOptions(properties); - if (newOptions.equals(this.options)) { + final boolean isProviderBound = this.currentProvider != null && isSelectedProvider(currentProvider, newOptions); + + if (newOptions.equals(this.options) && (newOptions.isStatic() || isProviderBound)) { logger.debug("same configuration, no need ot reconfigure GPS device"); return; } @@ -141,7 +146,7 @@ private synchronized void updateInternal() { } else { try { startPositionProvider(); - } catch (KuraException e) { + } catch (Exception e) { logger.error("Unable to start the chosen Position Provider", e); } } @@ -156,7 +161,8 @@ private synchronized void updateInternal() { @Override public Position getPosition() { if (this.options.isEnabled() && !this.options.isStatic()) { - return this.currentProvider.getPosition(); + return Optional.ofNullable(this.currentProvider).map(PositionProvider::getPosition) + .orElseGet(() -> staticPosition(0, 0, 0)); } else { return this.staticPosition; } @@ -166,7 +172,8 @@ public Position getPosition() { @Override public NmeaPosition getNmeaPosition() { if (this.options.isEnabled() && !this.options.isStatic()) { - return this.currentProvider.getNmeaPosition(); + return Optional.ofNullable(this.currentProvider).map(PositionProvider::getNmeaPosition) + .orElseGet(() -> staticNMEAPosition(0, 0, 0)); } else { return this.staticNmeaPosition; } @@ -180,7 +187,7 @@ public boolean isLocked() { if (this.options.isStatic()) { return true; } - return this.currentProvider.isLocked(); + return Optional.ofNullable(this.currentProvider).map(PositionProvider::isLocked).orElse(false); } @Override @@ -255,19 +262,31 @@ protected PositionServiceOptions getPositionServiceOptions() { return this.options; } - private void startPositionProvider() throws KuraException { + private void startPositionProvider() { stopPositionProvider(); - this.currentProvider = this.positionProviders.stream() - .filter(pp -> pp.getType() == this.options.getPositionProvider()).findAny() - .orElseThrow(() -> new KuraException(KuraErrorCode.CONFIGURATION_ATTRIBUTE_INVALID, " provider", - this.options.getPositionProvider())); + final Optional provider = getSelectedProvider(this.options); + + if (!provider.isPresent()) { + logger.info("PositionProvider {} is not bound", this.options.getPositionProvider()); + return; + } + + this.currentProvider = provider.get(); this.currentProvider.init(options, this, this); this.currentProvider.start(); } + private Optional getSelectedProvider(final PositionServiceOptions options) { + return this.positionProviders.stream().filter(pp -> isSelectedProvider(pp, options)).findAny(); + } + + private boolean isSelectedProvider(final PositionProvider provider, final PositionServiceOptions options) { + return provider.getType() == options.getPositionProvider(); + } + private void stopPositionProvider() { if (this.currentProvider != null) { this.currentProvider.stop(); @@ -291,6 +310,12 @@ private void setLock(boolean hasLock) { private void setStaticPosition(double latitudeDeg, double longitudeDeg, double altitudeNmea, String gnssType) { + this.staticPosition = staticPosition(latitudeDeg, longitudeDeg, altitudeNmea); + this.staticNmeaPosition = staticNMEAPosition(latitudeDeg, longitudeDeg, altitudeNmea); + this.staticGnssType = GNSSType.fromValue(gnssType); + } + + private static Position staticPosition(double latitudeDeg, double longitudeDeg, double altitudeNmea) { final double latitudeRad = Math.toRadians(latitudeDeg); final double longitudeRad = Math.toRadians(longitudeDeg); @@ -301,10 +326,12 @@ private void setStaticPosition(double latitudeDeg, double longitudeDeg, double a // knots final Measurement track = new Measurement(java.lang.Math.toRadians(0), Unit.rad); - this.staticPosition = new Position(latitude, longitude, altitude, speed, track); - this.staticNmeaPosition = new NmeaPosition(latitudeDeg, longitudeDeg, altitudeNmea, 0, 0, 0, 0, 0, 0, 0, 0, 0, - (char) 0, (char) 0, (char) 0); - this.staticGnssType = GNSSType.fromValue(gnssType); + return new Position(latitude, longitude, altitude, speed, track); + } + + private static NmeaPosition staticNMEAPosition(double latitudeDeg, double longitudeDeg, double altitudeNmea) { + return new NmeaPosition(latitudeDeg, longitudeDeg, altitudeNmea, 0, 0, 0, 0, 0, 0, 0, 0, 0, (char) 0, (char) 0, + (char) 0); } @Override diff --git a/kura/org.eclipse.kura.net.configuration/src/main/java/org/eclipse/kura/net/configuration/NetworkConfigurationConstants.java b/kura/org.eclipse.kura.net.configuration/src/main/java/org/eclipse/kura/net/configuration/NetworkConfigurationConstants.java index f30e58040a7..26cdb45996c 100644 --- a/kura/org.eclipse.kura.net.configuration/src/main/java/org/eclipse/kura/net/configuration/NetworkConfigurationConstants.java +++ b/kura/org.eclipse.kura.net.configuration/src/main/java/org/eclipse/kura/net/configuration/NetworkConfigurationConstants.java @@ -64,7 +64,7 @@ public final class NetworkConfigurationConstants { public static final boolean DEFAULT_IPV4_DHCP_CLIENT_ENABLED_VALUE = false; public static final NetInterfaceType DEFAULT_INTERFACE_TYPE_VALUE = NetInterfaceType.UNKNOWN; public static final NetInterfaceStatus DEFAULT_IPV4_STATUS_VALUE = NetInterfaceStatus.netIPv4StatusDisabled; - public static final boolean DEFAULT_AUTOCONNECT_VALUE = false; + public static final boolean DEFAULT_AUTOCONNECT_VALUE = true; public static final int DEFAULT_PROMISC_VALUE = -1; public static final short DEFAULT_IPV4_PREFIX_VALUE = -1; public static final short DEFAULT_IPV6_PREFIX_VALUE = -1; diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/signal/handlers/NMConfigurationEnforcementHandler.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/signal/handlers/NMConfigurationEnforcementHandler.java index e3768f72107..033d2c7f663 100644 --- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/signal/handlers/NMConfigurationEnforcementHandler.java +++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/signal/handlers/NMConfigurationEnforcementHandler.java @@ -43,10 +43,15 @@ public void handle(Device.StateChanged s) { logger.debug("Device state change detected: {} -> {} (reason: {}), for device {}", oldState, newState, reason, s.getPath()); + boolean deviceDisconnectedBecauseOfConfigurationEvent = oldState != NMDeviceState.NM_DEVICE_STATE_FAILED + && oldState != NMDeviceState.NM_DEVICE_STATE_UNAVAILABLE + && newState == NMDeviceState.NM_DEVICE_STATE_DISCONNECTED; boolean deviceIsConnectingToANewNetwork = newState == NMDeviceState.NM_DEVICE_STATE_CONFIG; - if (deviceIsConnectingToANewNetwork) { - logger.info("Network change detected on interface {}. Roll-back to cached configuration", s.getPath()); + if (deviceIsConnectingToANewNetwork || deviceDisconnectedBecauseOfConfigurationEvent) { + logger.info( + "Network change detected on interface {}. Roll-back to cached configuration. Device state change detected: {} -> {} (reason: {})", + s.getPath(), oldState, newState, reason); CompletableFuture.runAsync(() -> { try {