From 4e5434626301117a395c03d5e91b507906aaeed2 Mon Sep 17 00:00:00 2001 From: Adam Welle Date: Tue, 13 Dec 2022 14:32:59 -0500 Subject: [PATCH] Set scenarioStatus to ready when copied (#48) * tests for clusters option before using it * uses _hasVms value inside GetStackstormVms * sets scenarioStatus to ready when scenario is copied --- Steamfitter.Api/Services/ScenarioService.cs | 1 + Steamfitter.Api/Services/StackStormService.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Steamfitter.Api/Services/ScenarioService.cs b/Steamfitter.Api/Services/ScenarioService.cs index e7c8d21..e15b2ba 100644 --- a/Steamfitter.Api/Services/ScenarioService.cs +++ b/Steamfitter.Api/Services/ScenarioService.cs @@ -252,6 +252,7 @@ public ScenarioService(SteamfitterContext context, newScenarioEntity.CreatedBy = _user.GetId(); newScenarioEntity.Name = $"{oldScenarioEntity.Name} - {_user.Claims.FirstOrDefault(c => c.Type == "name").Value}"; newScenarioEntity.OnDemand = true; + newScenarioEntity.Status = ScenarioStatus.ready; _context.Scenarios.Add(newScenarioEntity); await _context.SaveChangesAsync(ct); diff --git a/Steamfitter.Api/Services/StackStormService.cs b/Steamfitter.Api/Services/StackStormService.cs index dbea5e9..97832a8 100644 --- a/Steamfitter.Api/Services/StackStormService.cs +++ b/Steamfitter.Api/Services/StackStormService.cs @@ -160,6 +160,11 @@ public async STT.Task GetStackstormVms() var apiParameters = _options.ApiParameters; try { + if (!_hasVms) + { + return; + } + var clusters = apiParameters["clusters"].ToString().Split(","); var vmListResult = await _stackStormConnector.VSphere.GetVmsWithUuid(clusters); // add VM's to _vmList