diff --git a/csharp/App/Backend/Backend.csproj b/csharp/App/Backend/Backend.csproj index 7af08ae7c..6959e506d 100644 --- a/csharp/App/Backend/Backend.csproj +++ b/csharp/App/Backend/Backend.csproj @@ -14,6 +14,7 @@ + diff --git a/csharp/App/Backend/DataTypes/Installation.cs b/csharp/App/Backend/DataTypes/Installation.cs index 428ce3dbe..f4620d56b 100644 --- a/csharp/App/Backend/DataTypes/Installation.cs +++ b/csharp/App/Backend/DataTypes/Installation.cs @@ -14,8 +14,7 @@ public class Installation : TreeNode public Double Lat { get; set; } public Double Long { get; set; } - - public String S3Bucket { get; set; } = ""; + public String S3Region { get; set; } = ""; public String S3Provider { get; set; } = ""; public String S3Key { get; set; } = ""; diff --git a/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs index 50be5aafb..d7f5af920 100644 --- a/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs +++ b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs @@ -12,6 +12,8 @@ public static class ExoCmd public static async Task<(String key, String secret)> CreateKey(this Installation installation) { //if (installation.Id != 1) return "help"; //Todo remove me I am for debugging + + var preParse = await Exo .WithArguments("iam access-key create " + installation.BucketName() diff --git a/csharp/App/Backend/Database/Db.cs b/csharp/App/Backend/Database/Db.cs index d9d5ae1cd..ac2a71e90 100644 --- a/csharp/App/Backend/Database/Db.cs +++ b/csharp/App/Backend/Database/Db.cs @@ -1,5 +1,7 @@ using System.Reactive.Concurrency; using System.Reactive.Linq; +using CliWrap; +using CliWrap.Buffered; using InnovEnergy.App.Backend.DataTypes; using InnovEnergy.App.Backend.DataTypes.Methods; using InnovEnergy.App.Backend.Relations; @@ -96,11 +98,22 @@ public static partial class Db Sessions.Delete(s => s.LastSeen < deadline); } - private static Task UpdateS3Urls() + private static async Task UpdateS3Urls() { - return Installations - .Select(i => i.RenewS3BucketUrl()) - .WhenAll(); + var bucketList = await Cli.Wrap("exo") + .WithArguments("storage list -O json") + .ExecuteBufferedAsync(); + + + var installationsToUpdate = Installations + .Select(i => i) + .Where(i => bucketList.StandardOutput.Contains("\"" + i.BucketName())).ToList() + ; + + foreach (var installation in installationsToUpdate) + { + await installation.RenewS3BucketUrl(); + } } } \ No newline at end of file diff --git a/csharp/App/Backend/Properties/launchSettings.json b/csharp/App/Backend/Properties/launchSettings.json index 1729b03cd..dc2ac027a 100644 --- a/csharp/App/Backend/Properties/launchSettings.json +++ b/csharp/App/Backend/Properties/launchSettings.json @@ -1,5 +1,6 @@ { "$schema": "https://json.schemastore.org/launchsettings.json", + "$SdkResolverGlobalJsonPath": "", "profiles": { "Backend": { "commandName": "Project", diff --git a/csharp/App/Backend/db.sqlite b/csharp/App/Backend/db.sqlite index 629857e5c..8e50935f7 100644 Binary files a/csharp/App/Backend/db.sqlite and b/csharp/App/Backend/db.sqlite differ diff --git a/csharp/App/Backend/fakedb.sqlite b/csharp/App/Backend/fakedb.sqlite new file mode 100644 index 000000000..1368f3256 Binary files /dev/null and b/csharp/App/Backend/fakedb.sqlite differ