コード例 #1
0
        /// <summary>
        /// Update nPod firmware to specified package
        /// </summary>
        /// <param name="nPodGuid">
        /// The unique identifier of the nPod to update
        /// </param>
        /// <param name="packageName">
        /// The package name to install
        /// </param>
        /// <param name="scheduleAt">
        /// Allows scheduling the installation of a package at the specified
        /// date and time. If omitted, the package will be installed immediately
        /// </param>
        /// <param name="ignoreWarnings">
        /// If specified warnings that are discovered during the update
        /// pre-check are ignored (not recommended). If omitted or set to
        /// <c>false</c> will cause the update to stop.
        /// </param>
        /// <returns></returns>
        public bool UpdateNPodFirmware(
            Guid nPodGuid,
            string packageName,
            DateTime?scheduleAt = null,
            bool ignoreWarnings = false)
        {
            Issues issues = RunUpdatePreCheck(nPodGuid, packageName);

            issues.AssertNoIssues(ignoreWarnings);

            // setup parameters
            GraphQLParameters parameters = new GraphQLParameters();

            parameters.Add(@"podUID", nPodGuid, false);
            parameters.Add(@"packageName", packageName, false);
            parameters.Add(@"scheduled", scheduleAt, true);

            TokenResponse tokenResponse = RunMutation <TokenResponse>(
                @"updatePodFirmware",
                parameters
                );

            return(DeliverToken(tokenResponse));
        }
コード例 #2
0
        /// <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");
                }
            }
        }