diff --git a/csharp/App/Backend/DataTypes/Methods/Installation.cs b/csharp/App/Backend/DataTypes/Methods/Installation.cs index efbbf221a..92ca2a4c7 100644 --- a/csharp/App/Backend/DataTypes/Methods/Installation.cs +++ b/csharp/App/Backend/DataTypes/Methods/Installation.cs @@ -1,5 +1,3 @@ -using CliWrap; -using CliWrap.Buffered; using InnovEnergy.App.Backend.Database; using InnovEnergy.App.Backend.S3; using InnovEnergy.Lib.Utils; @@ -19,7 +17,11 @@ public static class InstallationMethods public static async Task RenewS3BucketUrl(this Installation installation) { installation.RevokeKey(); - installation.S3KeySecret = await installation.CreateKey(); + var (key, secret) = await installation.CreateKey(); + + installation.S3Key = key; + installation.S3Secret = secret; + return Db.Update(installation); } @@ -124,41 +126,4 @@ public static class InstallationMethods return installation; } -} - -public static class ExoCmd -{ - private static readonly Command Exo = Cli.Wrap("exo"); - private static String ConfigFile = "./exoscale.toml"; - - public static async Task 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() - + " --operation get-sos-object" - + " --resource sos/bucket:" + installation.BucketName() - + " -C " + ConfigFile - + " -O text") - .ExecuteBufferedAsync(); - - return $"{preParse.StandardOutput.Split("\t")[2]};{preParse.StandardOutput.Split("\t")[3]}"; - } - - public static async void RevokeKey(this Installation installation) - { - try - { - await Exo - .WithArguments("iam access-key revoke " + installation.S3KeySecret.Split(";", 2)[0] + " -f " + " -C " + ConfigFile) - .ExecuteAsync(); - - } - catch - { - // todo Fill me there is no key for this installation - } - } - -} - +} \ No newline at end of file