/// <summary> /// Retrieves a list of recipes /// /// <para> /// Recipes are the result of mutations of mutations or modifications of /// on-premises infrastructure. As commands may require some time to /// complete, the recipe filter allows the query for their status. /// </para> /// </summary> /// <param name="filter"> /// A filter object to filter the nPod recipes on the server. If /// omitted, the server will return all objects as a paginated response. /// </param> /// <returns> /// A paginated list of nPod recipes /// </returns> public RecipeRecordList GetNPodRecipes(NPodRecipeFilter filter) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("filter", filter, false); return(RunQuery <RecipeRecordList>(@"getNPodRecipes", parameters)); }
/// <summary> /// Allows creation of a new volume /// </summary> /// <param name="input"> /// Configuration definition for the new volume /// </param> /// <returns>The created volume</returns> public Volume CreateVolume(CreateVolumeInput input) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input); TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createVolumeV3", parameters); RecipeRecordIdentifier identifier = DeliverTokenV2(tokenResponse); if (identifier == null) { throw new Exception("Uncomprehensive information returned from server"); } // wait for recipe completion DateTime start = DateTime.UtcNow; // recipe filter NPodRecipeFilter filter = new NPodRecipeFilter(); filter.NPodGuid = identifier.NPodGuid; filter.RecipeGuid = identifier.RecipeGuid; while (true) { Thread.Sleep(1000); // query for recipes RecipeRecordList recipes = GetNPodRecipes(filter); // if there is no record in the cloud wait a few more seconds // this case should not exist. TODO: Remove in next version. if (recipes.Items.Length == 0) { continue; } // based on the query there should be exactly one RecipeRecord recipe = recipes.Items[0]; // execution failed if (recipe.State == RecipeState.Failed) { string error = string.Concat("volume creation failed", recipe.Status); throw new Exception(error); } // execution completed if (recipe.State == RecipeState.Completed) { VolumeFilter volumeFilter = new VolumeFilter(); volumeFilter.Guid = new GuidFilter(); volumeFilter.Guid.MustEqual = tokenResponse.WaitOn; VolumeList list = GetVolumes(null, volumeFilter, null); if (list.FilteredCount >= 0) { return(list.Items[0]); } } // still ongoing double duration = (DateTime.UtcNow - start).TotalSeconds; double timeRemaining = NPOD_CREATE_WAITTIME_SEC - duration; if (timeRemaining <= 0) { throw new Exception("Snapshot creation timed out"); } } }
/// <summary> /// Allows creation of a new nPod /// /// <para> /// A nPod is a collection of network-connected application servers /// with SPUs installed that form an application cluster. Together, the /// SPUs in a nPod serve shared or local storage to the servers in the /// application cluster, e.g.a hypervisor cluster, container platform, /// or clustered bare metal application. /// </para> /// </summary> /// <param name="name"> /// Name of the new nPod /// </param> /// <param name="nPodGroupGuid"> /// The unique identifier of the nPod group this nPod will be added to /// </param> /// <param name="nPodSpuInputs"> /// List of SPU configuration information that will be used in the new /// nPod /// </param> /// <param name="templateGuid"> /// The unique identifier of the nPod template to use for the new nPod /// </param> /// <param name="note"> /// An optional note for the new nPod /// </param> /// <param name="timezone"> /// The timezone to be configured for all SPUs in the nPod /// </param> /// <param name="ignoreWarnings"> /// If specified and set to <c>true</c> the nPod creation will proceed /// even if nebulon ON reports warnings. It is advised to not ignore /// warnings. Consequently, the default behavior is that the nPod /// creation will fail when nebulon ON reports validation errors. /// </param> /// <returns>The new nPod</returns> public NPod CreateNPod( string name, Guid nPodGroupGuid, NPodSpuInput[] nPodSpuInputs, Guid templateGuid, string note, string timezone, bool ignoreWarnings) { // check for potential issues that nebulon ON predicts Issues issues = GetNewNPodIssues(nPodSpuInputs); issues.AssertNoIssues(ignoreWarnings); CreateNPodInput input = new CreateNPodInput(); input.Name = name; input.NPodGroupGuid = nPodGroupGuid; input.Spus = nPodSpuInputs; input.NPodTemplateGuid = templateGuid; input.Note = note; input.Timezone = timezone; // setup parameters for nPod creation GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input, true); // make the request and deliver token TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createNPod", parameters ); RecipeRecordIdentifier identifier = DeliverTokenV2(tokenResponse); if (identifier == null) { throw new Exception("Uncomprehensive information returned from server"); } // wait for recipe completion DateTime start = DateTime.UtcNow; // recipe filter NPodRecipeFilter filter = new NPodRecipeFilter(); filter.NPodGuid = identifier.NPodGuid; filter.RecipeGuid = identifier.RecipeGuid; while (true) { Thread.Sleep(5000); // query for recipes RecipeRecordList recipes = GetNPodRecipes(filter); // if there is no record in the cloud wait a few more seconds // this case should not exist. TODO: Remove in next version. if (recipes.Items.Length == 0) { continue; } // based on the query there should be exactly one RecipeRecord recipe = recipes.Items[0]; // execution failed if (recipe.State == RecipeState.Failed) { string error = string.Concat("nPod creation failed", recipe.Status); throw new Exception(error); } // execution completed if (recipe.State == RecipeState.Completed) { NPodFilter nPodFilter = new NPodFilter(); nPodFilter.NPodGuid = new GuidFilter(); nPodFilter.NPodGuid.MustEqual = identifier.NPodGuid; NPodList nPods = GetNebNPods( PageInput.First, nPodFilter, null ); return(nPods.Items[0]); } // still ongoing double duration = (DateTime.UtcNow - start).TotalSeconds; double timeRemaining = NPOD_CREATE_WAITTIME_SEC - duration; if (timeRemaining <= 0) { throw new Exception("nPod creation timed out"); } } }