Exemple #1
0
        public async Task TransitionStateAsync(HostInfo host, HostStatus newStatus)
        {
            #region Preconditions

            Validate.NotNull(host, nameof(host));

            if (newStatus == default)
            {
                throw new ArgumentException("Required", nameof(newStatus));
            }

            #endregion

            if (host.Status == newStatus)
            {
                return;                           // no change
            }
            var cluster = await clusterService.GetAsync(host.ClusterId);;

            // from pending | suspended
            if (newStatus == HostStatus.Running)
            {
                // register the host with the cluster
                await clusterManager.RegisterHostAsync(cluster, host);
            }

            await db.Hosts.PatchAsync(host.Id, new[] {
                Change.Replace("status", newStatus)
            });
        }