Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into heyoulin-kura
Browse files Browse the repository at this point in the history
  • Loading branch information
spnettec committed Nov 13, 2024
2 parents 7ec8a34 + 72a2834 commit 62f3bec
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
containerRestartOnfailureDesc=Automatically restart the container when it has failed. Default: false
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
containerRestartOnfailureDesc=\u5BB9\u5668\u5931\u8D25\u65F6\u81EA\u52A8\u91CD\u542F\u3002\u9ED8\u8BA4\u503C\uFF1Afalse
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@
<AD id="container.image.tag" name="%containerImageTag"
description="%containerImageTagDesc" type="String"
cardinality="1" required="true" default="latest" />

<AD id="container.signature.trust.anchor" name="%containerSignatureTrustAnchor"
description="%containerSignatureTrustAnchorDesc" type="String"
cardinality="1" required="false" default="" />

<AD id="container.signature.verify.transparency.log" name="%containerSignatureVerifyTransparencyLog"
description="%containerSignatureVerifyTransparencyLogDesc" type="Boolean"
cardinality="1" required="false" default="true" />

<AD
id="container.signature.enforcement.digest"
name="%containerSignatureEnforcementDigest"
description="%containerSignatureEnforcementDigestDesc"
type="String" cardinality="1" required="false"
default="" />

<AD id="registry.hostname" name="%registryHostname"
description="%registryHostnameDesc"
Expand All @@ -59,6 +44,20 @@
description="%registryPasswordDesc"
type="Password"
cardinality="0" required="false" default="" />

<AD id="container.signature.trust.anchor" name="%containerSignatureTrustAnchor"
description="%containerSignatureTrustAnchorDesc" type="String"
cardinality="1" required="false" default="" />

<AD id="container.signature.verify.transparency.log" name="%containerSignatureVerifyTransparencyLog"
description="%containerSignatureVerifyTransparencyLogDesc" type="Boolean"
cardinality="1" required="false" default="true" />

<AD id="container.signature.enforcement.digest"
name="%containerSignatureEnforcementDigest"
description="%containerSignatureEnforcementDigestDesc"
type="String" cardinality="1" required="false"
default="" />

<AD id="container.image.download.retries"
name="%containerImageDownloadRetries"
Expand Down
4 changes: 2 additions & 2 deletions kura/org.eclipse.kura.linux.position/OSGI-INF/position.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<provide interface="org.eclipse.kura.configuration.ConfigurableComponent"/>
</service>

<reference bind="setPositionProviders" cardinality="1..n" interface="org.eclipse.kura.linux.position.provider.PositionProvider" name="PositionProviders" policy-option="greedy" policy="static" unbind="unsetPositionProviders"/>
<reference bind="setPositionProviders" cardinality="1..n" interface="org.eclipse.kura.linux.position.provider.PositionProvider" name="PositionProviders" policy="dynamic" unbind="unsetPositionProviders"/>

<property name="service.pid" value="org.eclipse.kura.position.PositionService"/>
<reference bind="setEventAdmin" cardinality="1..1" interface="org.osgi.service.event.EventAdmin" name="EventAdmin" policy="static" unbind="unsetEventAdmin"/>
<reference bind="setEventAdmin" cardinality="1..1" interface="org.osgi.service.event.EventAdmin" name="EventAdmin" policy="static"/>
</scr:component>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

// ----------------------------------------------------------------
Expand All @@ -108,13 +111,15 @@ protected void deactivate() {
logger.info("Deactivating... Done.");
}

public void updated(final Map<String, Object> properties) {
public synchronized void updated(final Map<String, Object> 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;
}
Expand All @@ -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);
}
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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<PositionProvider> 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<PositionProvider> 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();
Expand All @@ -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);

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 62f3bec

Please sign in to comment.