/// <summary> /// Performs execution of the command /// </summary> protected override void ProcessRecord() { // Compile a filter from the provided input NPodFilter filter = null; if (ParameterPresent("Guid")) { filter = new NPodFilter(); filter.NPodGuid = new GuidFilter(); filter.NPodGuid.MustEqual = Guid; } PageInput page = PageInput.First; NPodList list = Connection.GetNebNPods(page, filter, null); foreach (NPod item in list.Items) { WriteObject(item); } while (list.More) { // advance the page page.Page = page.Page + 1; list = Connection.GetNebNPods(page, filter, null); foreach (NPod item in list.Items) { WriteObject(item); } } }
/// <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"); } } }