From c113fc24c554c5f1632039b2c840578fff3ce0f8 Mon Sep 17 00:00:00 2001 From: Walisson Casonatto Date: Wed, 26 Apr 2023 09:50:41 -0300 Subject: [PATCH] Config S3 SDK tool to allow multiple providers Signed-off-by: Walisson Casonatto --- CONFIGURATION.md | 9 +++++++++ docker-entrypoint.sh | 3 +++ helm/values.yaml | 3 +++ owfms.properties | 2 ++ owfms.properties.tmpl | 3 +++ src/ManifestCreator.cpp | 13 +++++++++++-- src/ManifestCreator.h | 3 +++ ucentralfms.properties.priv | 3 +++ 8 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index ba2b091..85ba8b6 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -30,6 +30,9 @@ s3.secret = ******************************************* s3.key = ******************************************* s3.retry = 60 s3.bucket.uri = ucentral-ap-firmware.s3.amazonaws.com +s3.endpoint.https = true +s3.endpointOverride = "" +s3.useVirtualAdressing = true ``` #### s3.bucketname @@ -44,6 +47,12 @@ The AWS key for access for this S3 bucket The AWS retry window in seconds. #### s3.bucket.uri = ucentral-ap-firmware.s3.amazonaws.com The URI to the S3 bucket +#### s3.endpointOverride = "" +The Endpoint Address to override if you using a different provider that not AWS. +#### s3.endpoint.https = true +The Endpoint Method if you using a HTTP endpoint +#### s3.useVirtualAdressing = true +In a virtual-hosted–style URI, the bucket name is part of the domain name in the URL. (Not supported by all providers) ## Generic OpenWiFi SDK parameters ### REST API External parameters diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index bc5d0ac..4787af2 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -25,6 +25,9 @@ if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then SECURITY_RESTAPI_DISABLE=${SECURITY_RESTAPI_DISABLE:-"false"} \ FIRMWAREDB_REFRESH=${FIRMWAREDB_REFRESH:-"86400"} \ FIRMWAREDB_MAXAGE=${FIRMWAREDB_MAXAGE:-"90"} \ + S3_VIRTUAL_ADRESSING=${S3_VIRTUAL_ADRESSING:-"true"} \ + S3_HTTPS=${S3_HTTPS:-"true"} \ + S3_ENDPOINT=${S3_ENDPOINT:-""} \ S3_BUCKETNAME=${S3_BUCKETNAME:-"ucentral-ap-firmware"} \ S3_REGION=${S3_REGION:-"us-east-1"} \ S3_SECRET=${S3_SECRET:-"*******************************************"} \ diff --git a/helm/values.yaml b/helm/values.yaml index b164c73..3cccc1b 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -143,6 +143,9 @@ configProperties: openwifi.internal.restapi.host.0.cert: $OWFMS_ROOT/certs/restapi-cert.pem openwifi.internal.restapi.host.0.key: $OWFMS_ROOT/certs/restapi-key.pem # Firmware Microservice Specific Section + s3.endpointOverride: "" + s3.useVirtualAdressing: true + s3.endpoint.https: true s3.bucketname: ucentral-ap-firmware s3.region: us-east-1 s3.retry: 60 diff --git a/owfms.properties b/owfms.properties index 53cd3f1..fee20bf 100644 --- a/owfms.properties +++ b/owfms.properties @@ -43,6 +43,8 @@ firmwaredb.maxage = 90 # # Firmware Microservice Specific Section # +s3.useVirtualAdressing = true +s3.endpoint.https = true s3.bucketname = ucentral-ap-firmware s3.region = us-east-1 s3.secret = ******************************************* diff --git a/owfms.properties.tmpl b/owfms.properties.tmpl index 2719220..d481fb4 100644 --- a/owfms.properties.tmpl +++ b/owfms.properties.tmpl @@ -44,6 +44,9 @@ firmwaredb.maxage = ${FIRMWAREDB_MAXAGE} # # Firmware Microservice Specific Section # +s3.useVirtualAdressing = ${S3_VIRTUAL_ADRESSING} +s3.endpointOverride = ${S3_ENDPOINT} +s3.endpoint.https = ${S3_HTTPS} s3.bucketname = ${S3_BUCKETNAME} s3.region = ${S3_REGION} s3.secret = ${S3_SECRET} diff --git a/src/ManifestCreator.cpp b/src/ManifestCreator.cpp index e6ad41b..56c8ca5 100644 --- a/src/ManifestCreator.cpp +++ b/src/ManifestCreator.cpp @@ -148,6 +148,9 @@ namespace OpenWifi { int ManifestCreator::Start() { Running_ = true; + S3EndpointOverride_ = MicroServiceConfigGetString("s3.endpointOverride", ""); + S3EndpointHttps_ = MicroServiceConfigGetBool("s3.endpoint.https", true); + S3UseVirtualAdressing_ = MicroServiceConfigGetBool("s3.useVirtualAdressing", true); S3BucketName_ = MicroServiceConfigGetString("s3.bucketname", ""); S3Region_ = MicroServiceConfigGetString("s3.region", ""); S3Secret_ = MicroServiceConfigGetString("s3.secret", ""); @@ -157,9 +160,15 @@ namespace OpenWifi { DBRefresh_ = MicroServiceConfigGetInt("firmwaredb.refresh", 24 * 60 * 60); MaxAge_ = MicroServiceConfigGetInt("firmwaredb.maxage", 90) * 24 * 60 * 60; - AwsConfig_.enableTcpKeepAlive = true; + AwsConfig_.enableTcpKeepAlive = false; AwsConfig_.enableEndpointDiscovery = true; AwsConfig_.useDualStack = true; + if(!S3EndpointHttps_) + AwsConfig_.scheme = Aws::Http::Scheme::HTTP; + if(!S3EndpointOverride_.empty()) { + AwsConfig_.endpointOverride = Aws::String(S3EndpointOverride_); + AwsConfig_.useDualStack = false; + } if (!S3Region_.empty()) AwsConfig_.region = S3Region_; AwsCreds_.SetAWSAccessKeyId(S3Key_); @@ -214,7 +223,7 @@ namespace OpenWifi { Aws::S3::Model::ListObjectsV2Request Request; Request.WithBucket(S3BucketName_.c_str()); - Aws::S3::S3Client S3Client(AwsCreds_, AwsConfig_); + Aws::S3::S3Client S3Client(AwsCreds_, AwsConfig_, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, S3UseVirtualAdressing_); Request.SetMaxKeys(100); Aws::S3::Model::ListObjectsV2Outcome Outcome; diff --git a/src/ManifestCreator.h b/src/ManifestCreator.h index 454c223..99b8b12 100644 --- a/src/ManifestCreator.h +++ b/src/ManifestCreator.h @@ -54,6 +54,9 @@ namespace OpenWifi { private: std::atomic_bool Running_ = false; + Aws::String S3EndpointOverride_; + bool S3EndpointHttps_; + bool S3UseVirtualAdressing_; Aws::String S3BucketName_; Aws::String S3Region_; Aws::String S3Key_; diff --git a/ucentralfms.properties.priv b/ucentralfms.properties.priv index 8dcb256..09ad868 100644 --- a/ucentralfms.properties.priv +++ b/ucentralfms.properties.priv @@ -39,6 +39,9 @@ ucentral.system.commandchannel = /tmp/app.ucentralfms # # Firmware Microservice Specific Section # +s3.endpointOverride = 172.31.30.127:9000 +s3.endpoint.https = false +s3.useVirtualAdressing = false s3.bucketname = ucentral-ap-firmware s3.region = us-east-1 s3.secret = ****************************