From e1b7b29773b48967bb6666c0fa04719660236bb4 Mon Sep 17 00:00:00 2001 From: Trevor Date: Fri, 23 Jun 2023 21:06:59 -0700 Subject: [PATCH] UDMIS dynamic switching between ClearBlade and GCP for IoT Core (#669) --- .gencode_hash.txt | 15 ++- .../com/google/udmi/util/GeneralUtils.java | 10 +- gencode/docs/configuration_execution.html | 2 +- gencode/docs/configuration_pod.html | 97 +++++++++++--- .../udmi/schema/ExecutionConfiguration.java | 54 +------- gencode/java/udmi/schema/IotAccess.java | 56 +++++++- .../java/udmi/schema/PodConfiguration.java | 4 +- gencode/python/udmi/schema/__init__.py | 1 + gencode/python/udmi/schema/access_iot.py | 42 ++++++ .../python/udmi/schema/configuration_pod.py | 46 +------ pubber/build.gradle | 7 +- schema/access_iot.json | 13 ++ schema/common.json | 2 + schema/configuration_pod.json | 12 +- udmis/.idea/compiler.xml | 4 +- udmis/.idea/misc.xml | 2 +- .../UdmiServicePod_configured.xml | 2 +- udmis/Dockerfile.udmis | 10 +- udmis/bin/container | 6 +- udmis/bin/run | 4 +- udmis/build.gradle | 6 +- udmis/etc/gcp_pod.json | 6 +- udmis/k8s_deployment.yaml | 11 +- udmis/k8s_pod.yaml | 18 +-- .../access/ClearBladeIotAccessProvider.java | 60 ++++++--- .../access/DynamicIotAccessProvider.java | 125 ++++++++++++++++++ .../service/access/GcpIotAccessProvider.java | 44 +++--- .../service/access/IotAccessProvider.java | 39 ++++-- .../udmi/service/core/ReflectProcessor.java | 39 +++--- .../bos/udmi/service/core/StateProcessor.java | 9 +- .../bos/udmi/service/core/UdmisComponent.java | 6 +- .../bos/udmi/service/pod/UdmiServicePod.java | 11 +- udmis/src/test/configs/clearblade_pod.json | 6 +- udmis/src/test/configs/dynamic_pod.json | 30 +++++ udmis/src/test/configs/gcp_pod.json | 6 +- .../ClearBladeIotAccessProviderTest.java | 4 +- .../access/DynamicIotAccessProviderTest.java | 13 ++ .../access/GcpIotAccessProviderTest.java | 9 +- .../service/core/ReflectProcessorTest.java | 54 ++++---- .../udmi/service/pod/UdmiServicePodTest.java | 4 +- udmis/udmis.iml | 2 +- validator/build.gradle | 7 +- .../bos/iot/core/proxy/MqttPublisher.java | 4 +- .../google/daq/mqtt/registrar/Registrar.java | 3 +- .../google/daq/mqtt/util/CloudIotManager.java | 8 +- .../google/daq/mqtt/validator/Validator.java | 2 +- validator/validator.iml | 2 +- 47 files changed, 629 insertions(+), 288 deletions(-) create mode 100644 gencode/python/udmi/schema/access_iot.py create mode 100644 schema/access_iot.json create mode 100644 udmis/src/main/java/com/google/bos/udmi/service/access/DynamicIotAccessProvider.java create mode 100644 udmis/src/test/configs/dynamic_pod.json create mode 100644 udmis/src/test/java/com/google/bos/udmi/service/access/DynamicIotAccessProviderTest.java diff --git a/.gencode_hash.txt b/.gencode_hash.txt index 503584e540..a42e6ef27e 100644 --- a/.gencode_hash.txt +++ b/.gencode_hash.txt @@ -3,8 +3,8 @@ b35646a2f3d7c30fd34e3ea6ab6a1070b39c469fd1de49cab1093ff32faaf06d gencode/docs/c e693079943921c88e24140521637c58bc9aadfb9aee96dfba414bbaa7be958d0 gencode/docs/config.html be1a8f90f09893f0dec4eea418c3134b0f2525a555c64548564ff767abf3cfbe gencode/docs/config_mapping.html 7933c756d45dfb24f9f6e34661b98126654fd58a61e81b7434f7cd0d578226b8 gencode/docs/configuration_endpoint.html -ee5ab92a146772420f511f42db92992c91ca4cd0ee819f3d5e5fb0c584e5b91c gencode/docs/configuration_execution.html -f53ff402d0229a94b6b951ccfe451320a0ce3114c25dca3c390e549cfc87dc19 gencode/docs/configuration_pod.html +a580d0aed508642dfd537540a269b99f56593dde7eadbce82fba2802708c2efa gencode/docs/configuration_execution.html +18eb64d2798022402c0e4cdb56fa6a9f62c1ecb7004b2b17c2395ce287fba612 gencode/docs/configuration_pod.html 732c6acc2116974000ec25bfdfa00ba6e3c5c2af13d0e3a0d71b3d4b8eeda059 gencode/docs/configuration_pubber.html 0428bbfb1c46c66d9ee0c90cb89f36f4f9be5fc535aabace698716978bf50876 gencode/docs/event.html 09bb8486e02f703768a09d5755753fe232d651555a1219d1101a37d21a1368b7 gencode/docs/event_discovery.html @@ -54,7 +54,7 @@ dd2eb479a8e93a851c535c8b40fbd62e152bd60e0473f3b23800ec61f798bed0 gencode/java/u 06758aca1e0043ddf343b504030f47bb19260e99a82e2d66f12e86092a2434ca gencode/java/udmi/schema/Enumerate.java 05e3443f9a9da29ed561310b13be1d14459d9dfe292a438e42af2fbd2165a606 gencode/java/udmi/schema/Envelope.java e9f5c77be81486b6b8c6d88f70f2d50583d8c3fafa2ac09ead80f44b8d5e751e gencode/java/udmi/schema/Event.java -27eb7fb05ca354955392b45584eab2a77bd7d12f099000f69ba3d01d5f62a45b gencode/java/udmi/schema/ExecutionConfiguration.java +a4778cf4ebd7f280f7773cc00528e50b058b7405391856d71b20d2d43294ca41 gencode/java/udmi/schema/ExecutionConfiguration.java 2e77a29988e6c17875d3f781be931e3b835bb310639f60d3bb28f24405a86bed gencode/java/udmi/schema/FamilyDiscoveryConfig.java 9643391d71c6bd206a4ec69ee7b46ba2bf061b85ccd0bc050046a84df85c8414 gencode/java/udmi/schema/FamilyDiscoveryEvent.java 5ad9bf328fa1500250ff8bc75f2044b3815c5c11cb368e1cc228ac8ca16639c2 gencode/java/udmi/schema/FamilyDiscoveryState.java @@ -66,7 +66,7 @@ d3fdb2d8b485c1e61786dfde45cc8be08294339bb31a1b8f02180485789a3ab2 gencode/java/u 60a8115ae1acae7c199b63180823198d38ec50d57b48dd85aca1ccc865058f85 gencode/java/udmi/schema/GatewayConfig.java 56b46f4914ef1f4baa59bf597186ff7901b7c8b607720ec798f4e4e6ad59aa08 gencode/java/udmi/schema/GatewayModel.java e0e7739046e834c0f0ca6a70b38b4579618899be3162887a0fa7ab60bbff22a5 gencode/java/udmi/schema/GatewayState.java -ecfc1d743cef14420b1b637b80b68c4584a58da48986103b6cb426baecc83bef gencode/java/udmi/schema/IotAccess.java +93a37c0fc8d5c59c50e670164109d78e4b7124cd3106fc7c8ebf3497c6f42c27 gencode/java/udmi/schema/IotAccess.java b0d4bff14a65ebddc2dd253c996708a4cce99592e82978f057f32a6d9c7768a1 gencode/java/udmi/schema/Jwt.java a5e5adfc187709e8646a11c92e804acfb67743f9d72149008aaca954df3177f6 gencode/java/udmi/schema/Level.java 07fd4911363437b274c19b024759b04b116152176702da8d4203c4ff4cb55b7f gencode/java/udmi/schema/LocalnetConfig.java @@ -84,7 +84,7 @@ df64e4ddbf543ac70e7c2af9d3fbc20ffe3dff68c6718aa9ceadab7f64d3d171 gencode/java/u b3b7ef6cae004d5fdb4052f860df0aa583df87bb798a027fc769aeaf16489789 gencode/java/udmi/schema/MonitoringMetric.java 3896bacd5b35b37f88bea402947aae7f2f7bab6e63bc30517381158ba0826602 gencode/java/udmi/schema/Operation.java 5e1c5411fae4d7c47391ceb5d19ae864fcd484df75ac6b6db39fd2d12647dec8 gencode/java/udmi/schema/Physical_tag.java -635584cac5f01774bbfc6b2d41f15d5039cbbe1b90c8b0a97fa9133cdbc40962 gencode/java/udmi/schema/PodConfiguration.java +679d530693e6f1a32edc328bb8f62af7c27d24227fdfa919498eac9645578899 gencode/java/udmi/schema/PodConfiguration.java d808259db6bbcd26ecf438844ce286d15d4750906be24588d97acfbe8a4ae315 gencode/java/udmi/schema/PointEnumerationEvent.java eb478a6ebd66b150da8d6dc8fdf05a10d09d6d0ea1df8a0578728703718c5551 gencode/java/udmi/schema/PointPointsetConfig.java 8f3fc1cdc2dcd3e524863f4675aebabc450a35f5fd1cdc3fd37289b5cab7f2ec gencode/java/udmi/schema/PointPointsetEvent.java @@ -120,7 +120,8 @@ ac6f8fd87c8986cce01e872460c15ff6fe71e3816f9bde610acfe25f7d38c8d4 gencode/java/u b1dbcd3f4b5c34651d5a4f22feae54344b5b643226ded921d8fa2c37c3ffd1e7 gencode/java/udmi/schema/ValidationState.java e007ddd1ceeae3603c85110c33e1bb4a418ff9c7a791ca0df25b7ea3caeafd36 gencode/java/udmi/schema/ValidationSummary.java b77d953fd22e655c0f10ae32deeaa222769d971f8c38b3379eba45720fb910cc gencode/java/udmi/schema/VirtualEquipmentLinks.java -02fc67509f185f3556856588645bddbee3458fe365be2b779c3413b54163c45a gencode/python/udmi/schema/__init__.py +a53342802ea70e6529a8502f145c3bd0490bb189ceb1939ae8d123f3e9cde088 gencode/python/udmi/schema/__init__.py +19c37b9957bc0ccfeee77133a275fea8d912b131320c7f45054735ed282fb996 gencode/python/udmi/schema/access_iot.py 4b25dd95f863059b761269f93adcae7049507924a1c6e74d6856849203c179db gencode/python/udmi/schema/ancillary_properties.py dab4f5fca272ec48c2881bca2b6bc43786ada47fa1f6dd935c35f7ce0eb6b0f6 gencode/python/udmi/schema/building_translation.py 470b688984b89b25fcdfa8e08bd95b0c5d8c551d53a6ab5512503ee39419e6fa gencode/python/udmi/schema/category.py @@ -143,7 +144,7 @@ cce623b34fd694880039a1c080214c33e00acaef5bc72276cf11a3bb2de40000 gencode/python 5e615089842674a183a2218b7e518c3581795df3a4cf9cb77ffcebf347dfe0c0 gencode/python/udmi/schema/config_udmi.py c35c1a4d37220b8f3b87d66152253160cfcd5a710fa58af51dfe3abe0a83021a gencode/python/udmi/schema/configuration_endpoint.py da1ca9aec0b35d3af956d7c908b8285d1df5ec545f67a3727c54ccce22f4724c gencode/python/udmi/schema/configuration_execution.py -43280b007ec2af213c72a55540dcad93f2b5ed17024ade033606827d631e086f gencode/python/udmi/schema/configuration_pod.py +498cdf9417f0a6cf832617025b6cc21771809d40cd2887bcd760701443b32e53 gencode/python/udmi/schema/configuration_pod.py 11c8841ed5c2a5bcaf4b44c943c8f70fcb5010f1027a025b46300435353b2432 gencode/python/udmi/schema/configuration_pod_bridge.py 7f4f8c1a6ead34bf72b9134b97a39001752eb0f9647fafaac82ced4bb2f46b88 gencode/python/udmi/schema/configuration_pubber.py fbb4b2c04c170c0da5cdd868612429fe920e44b591fcad2522b2e047d580d537 gencode/python/udmi/schema/entry.py diff --git a/common/src/main/java/com/google/udmi/util/GeneralUtils.java b/common/src/main/java/com/google/udmi/util/GeneralUtils.java index 90873f17cd..ec1669f976 100644 --- a/common/src/main/java/com/google/udmi/util/GeneralUtils.java +++ b/common/src/main/java/com/google/udmi/util/GeneralUtils.java @@ -15,17 +15,18 @@ import java.io.PrintStream; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.security.spec.ECField; import java.util.ArrayList; import java.util.Base64; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; +import java.util.TreeMap; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +import java.util.stream.Collector; import java.util.stream.Collectors; -import javax.annotation.Nullable; public class GeneralUtils { @@ -123,6 +124,11 @@ public static T fromJsonString(String body, Class valueType) { } } + public static Collector, ?, TreeMap> sortedMapCollector( + Function, String> prioritizer) { + return Collectors.toMap(prioritizer, Entry::getKey, GeneralUtils::mapReplace, TreeMap::new); + } + public static String toJsonString(Object object) { try { if (object == null) { diff --git a/gencode/docs/configuration_execution.html b/gencode/docs/configuration_execution.html index 66a9bd98a9..53a20f8340 100644 --- a/gencode/docs/configuration_execution.html +++ b/gencode/docs/configuration_execution.html @@ -352,7 +352,7 @@

Must be one of:

-
  • "gcp_native"
  • "gcp"
  • "clearblade"
+
  • "dynamic"
  • "gcp_native"
  • "gcp"
  • "clearblade_native"
  • "clearblade"
diff --git a/gencode/docs/configuration_pod.html b/gencode/docs/configuration_pod.html index 83023bd0b5..a54aab76c1 100644 --- a/gencode/docs/configuration_pod.html +++ b/gencode/docs/configuration_pod.html @@ -3959,18 +3959,61 @@

-
+
-
+

- +

-
+
+

+ +

+

All property whose name matches the following regular expression must respect the following conditions

+ Property name regular expression: ^[a-z]+$ +
+ + Type: object
+ + + No Additional Properties + + + + + + +
+
+
+

+ +

+
+ +
Type: enum (of string)
+ Iot Access + + + + provider
Type: enum (of string)
-
+

Must be one of:

-
  • "gcp_native"
  • "gcp"
  • "clearblade"
+
  • "dynamic"
  • "gcp_native"
  • "gcp"
  • "clearblade_native"
  • "clearblade"
@@ -4004,18 +4054,18 @@

Must be one of:

-
+
-
+

- +

-
+
Type: string
+ Iot Access + + + + project_id
Type: string
@@ -4048,6 +4105,10 @@

+
+
+
+