Example #1
0
        public ActionResult CollectCredentials(Guid?deploymentId, string environmentName, string machineName, string username)
        {
            if (!deploymentId.HasValue)
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(username))
            {
                return(BadRequest());
            }

            DeploymentState deploymentState =
                _deploymentStateProvider.FindDeploymentState(deploymentId.Value);

            if (deploymentState == null)
            {
                return(Content("FAIL"));
            }

            DeploymentHub.PromptForCredentials(
                deploymentId.Value,
                deploymentState.UserIdentity,
                deploymentState.ProjectName,
                deploymentState.ProjectConfigurationName,
                environmentName,
                machineName,
                username);

            return(Content("OK"));
        }
Example #2
0
        /// <summary>
        /// Creates a deep copy of the passed object.
        /// </summary>
        /// <param name="old">An entity object to create the deep copy from.</param>
        private void CopyMembers(Entity old)
        {
            this.guid = old.guid;
            this.concurrencyVersion = old.concurrencyVersion;
            this.parentReference    = new ParentEntityReference <Entity>(old.parentReference);
            this.EntityType         = old.EntityType; // always use property!
            this.number             = old.number;
            this.name             = old.name;
            this.version          = old.version;
            this.system           = old.system;
            this.hidden           = old.hidden;
            this.readOnly         = old.readOnly;
            this.primary          = old.primary;
            this.deleted          = old.deleted;
            this.lockOwner        = old.lockOwner;
            this.runningState     = old.runningState;
            this.alertState       = old.alertState;
            this.deploymentState  = old.deploymentState;
            this.userGuidOwner    = old.userGuidOwner;
            this.dateCreated      = old.dateCreated;
            this.userGuidCreated  = old.userGuidCreated;
            this.dateModified     = old.dateModified;
            this.userGuidModified = old.userGuidModified;
            this.dateDeleted      = old.dateDeleted;
            this.userGuidDeleted  = old.userGuidDeleted;
            this.settings         = new ParameterCollection(old.settings);
            this.comments         = old.comments;

            CopyEntityReferences(old);
            InitializeChildTypes();
        }
Example #3
0
 /// <summary>Ctor. </summary>
 /// <param name="deploymentId">deployment id</param>
 /// <param name="addedDate">date the deployment was added</param>
 /// <param name="lastUpdateDate">date of last Update to state</param>
 /// <param name="items">module statement-level details</param>
 /// <param name="state">current state</param>
 /// <param name="module">the module</param>
 public DeploymentInformation(String deploymentId, Module module, DateTimeOffset addedDate, DateTimeOffset lastUpdateDate, DeploymentInformationItem[] items, DeploymentState state)
 {
     DeploymentId   = deploymentId;
     Module         = module;
     LastUpdateDate = lastUpdateDate;
     AddedDate      = addedDate;
     Items          = items;
     State          = state;
 }
Example #4
0
 internal DeploymentStatus(DeploymentState deploymentState, int?totalDevices, int?devicesIncompatibleCount, int?devicesInProgressCount, int?devicesCompletedFailedCount, int?devicesCompletedSucceededCount, int?devicesCanceledCount)
 {
     DeploymentState                = deploymentState;
     TotalDevices                   = totalDevices;
     DevicesIncompatibleCount       = devicesIncompatibleCount;
     DevicesInProgressCount         = devicesInProgressCount;
     DevicesCompletedFailedCount    = devicesCompletedFailedCount;
     DevicesCompletedSucceededCount = devicesCompletedSucceededCount;
     DevicesCanceledCount           = devicesCanceledCount;
 }
        async Task UpdateDeployment(
            CompileJob compileJob,
            string description,
            DeploymentState deploymentState,
            CancellationToken cancellationToken)
        {
            if (compileJob == null)
            {
                throw new ArgumentNullException(nameof(compileJob));
            }

            if (!compileJob.GitHubRepoId.HasValue || !compileJob.GitHubDeploymentId.HasValue)
            {
                logger.LogTrace("Not updating deployment as it is missing a repo ID or deployment ID.");
                return;
            }

            logger.LogTrace("Updating deployment {0} to {1}...", compileJob.GitHubDeploymentId.Value, deploymentState);

            string gitHubAccessToken = null;
            await databaseContextFactory.UseContext(
                async databaseContext =>
                gitHubAccessToken = await databaseContext
                .RepositorySettings
                .AsQueryable()
                .Where(x => x.InstanceId == metadata.Id)
                .Select(x => x.AccessToken)
                .FirstAsync(cancellationToken)
                .ConfigureAwait(false))
            .ConfigureAwait(false);

            if (gitHubAccessToken == null)
            {
                logger.LogWarning(
                    "GitHub access token disappeared during deployment, can't update to {0}!",
                    deploymentState);
                return;
            }

            var gitHubClient = gitHubClientFactory.CreateClient(gitHubAccessToken);

            await gitHubClient
            .Repository
            .Deployment
            .Status
            .Create(
                compileJob.GitHubRepoId.Value,
                compileJob.GitHubDeploymentId.Value,
                new NewDeploymentStatus(deploymentState)
            {
                Description = description
            })
            .WithToken(cancellationToken)
            .ConfigureAwait(false);
        }
 public DeploymentStatus(int id, string url, DeploymentState state, User creator, IReadOnlyDictionary <string, string> payload, string targetUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description)
 {
     Id          = id;
     Url         = url;
     State       = state;
     Creator     = creator;
     Payload     = payload;
     TargetUrl   = targetUrl;
     CreatedAt   = createdAt;
     UpdatedAt   = updatedAt;
     Description = description;
 }
 public DeploymentStatus(int id, string url, DeploymentState state, User creator, IReadOnlyDictionary<string, string> payload, string targetUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description)
 {
     Id = id;
     Url = url;
     State = state;
     Creator = creator;
     Payload = payload;
     TargetUrl = targetUrl;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
     Description = description;
 }
Example #8
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (OrigSize.IsZero() || OrigScale.IsZero() || OrigPartSize.IsZero())
     {
         var part_metric = new Metric(part);
         var metric      = default(Metric);
         if (!string.IsNullOrEmpty(MetricMesh))
         {
             var metric_mesh = part.FindModelComponent <MeshFilter>(MetricMesh);
             if (metric_mesh != null)
             {
                 metric = new Metric(metric_mesh, part.transform);
             }
             else
             {
                 this.Warning($"MeshMetric: no such MeshFilter: {MetricMesh.GetID()}");
             }
         }
         if (metric.Empty)
         {
             metric = part_metric;
         }
         OrigSize     = metric.size;
         OrigScale    = model.localScale;
         OrigPartSize = part_metric.size;
         PartCenter   = part_metric.center.Local2Local(part.partTransform, model);
     }
     if (Size.IsZero())
     {
         Size = OrigSize;
     }
     update_model(false);
     //deprecated config conversion
     if (node.HasValue("Deploying"))
     {
         state = DeploymentState.IDLE;
         var val = node.GetValue("Deploying");
         if (bool.TryParse(val, out bool _deploy) && _deploy)
         {
             state = DeploymentState.DEPLOYING;
         }
         else
         {
             val = node.GetValue("Deployed");
             if (bool.TryParse(val, out _deploy) && _deploy)
             {
                 state = DeploymentState.DEPLOYED;
             }
         }
     }
 }
Example #9
0
        public ActionResult CollectDependenciesToDeploy(CollectProjectDependenciesToDeployRequest request)
        {
            if (!request.DeploymentId.HasValue)
            {
                return(BadRequest());
            }

            DeploymentState deploymentState = _deploymentStateProvider.FindDeploymentState(request.DeploymentId.Value);

            DeploymentHub.PromptForProjectDependencies(request.DeploymentId, deploymentState.UserIdentity, request.DependentProjects);

            return(Content("OK"));
        }
Example #10
0
        IEnumerator <YieldInstruction> deploy()
        {
            foreach (var _ in prepare_deployment())
            {
                yield return(null);
            }
            var deployT = get_deploy_transform(Vector3.zero, out _);

            TargetSize = get_deployed_size();
            TargetSize = TargetSize.Local2LocalDir(deployT, model).AbsComponents();
            yield return(slow_resize());

            foreach (var _ in finalize_deployment())
            {
                yield return(null);
            }
            state = DeploymentState.DEPLOYED;
        }
Example #11
0
        private Guid SetDeploymentState(string environmentName, string projectConfigurationName, string projectName)
        {
            Guid deploymentId = Guid.NewGuid();

            var deploymentState =
                new DeploymentState(
                    deploymentId,
                    UserIdentity,
                    projectName,
                    projectConfigurationName,
                    environmentName);

            _deploymentStateProvider.SetDeploymentState(
                deploymentId,
                deploymentState);

            return(deploymentId);
        }
Example #12
0
        public ActionResult OnCollectCredentialsTimedOut(Guid?deploymentId)
        {
            if (!deploymentId.HasValue)
            {
                return(BadRequest());
            }

            DeploymentState deploymentState =
                _deploymentStateProvider.FindDeploymentState(deploymentId.Value);

            if (deploymentState == null)
            {
                return(Content("FAIL"));
            }

            DeploymentHub.CancelPromptForCredentials(deploymentState.UserIdentity);

            return(Content("OK"));
        }
Example #13
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (modelMetadataCase_ == ModelMetadataOneofCase.TranslationModelMetadata)
            {
                hash ^= TranslationModelMetadata.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (DisplayName.Length != 0)
            {
                hash ^= DisplayName.GetHashCode();
            }
            if (DatasetId.Length != 0)
            {
                hash ^= DatasetId.GetHashCode();
            }
            if (createTime_ != null)
            {
                hash ^= CreateTime.GetHashCode();
            }
            if (updateTime_ != null)
            {
                hash ^= UpdateTime.GetHashCode();
            }
            if (DeploymentState != 0)
            {
                hash ^= DeploymentState.GetHashCode();
            }
            hash ^= Labels.GetHashCode();
            hash ^= (int)modelMetadataCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #14
0
        private void InitializeMembers(StreamingContext context)
        {
            var now = DateTime.Now;

            this.isExisting      = false;
            this.isDeserializing = false;

            this.guid = Guid.Empty;
            this.concurrencyVersion = 0;
            this.parentReference    = new ParentEntityReference <Entity>(this);
            this.entityTypeInternal = EntityType.Unknown;
            this.number             = 0;
            this.name             = string.Empty;
            this.version          = string.Empty;
            this.system           = false;
            this.hidden           = false;
            this.readOnly         = false;
            this.primary          = false;
            this.deleted          = false;
            this.lockOwner        = Guid.Empty;
            this.runningState     = 0;
            this.alertState       = 0;
            this.deploymentState  = DeploymentState.New;
            this.userGuidOwner    = Guid.Empty;
            this.dateCreated      = now;
            this.userGuidCreated  = Guid.Empty;
            this.dateModified     = now;
            this.userGuidModified = Guid.Empty;
            this.dateDeleted      = DateTime.MinValue;
            this.userGuidDeleted  = Guid.Empty;
            this.settings         = new ParameterCollection();
            this.comments         = string.Empty;

            InitializeEntityReferences();
            this.isEntityReferencesLoaded = false;

            InitializeChildTypes();
        }
Example #15
0
        public ActionResult CollectScriptsToRun(CollectScriptsToRunRequest request)
        {
            if (request == null || !request.DeploymentId.HasValue || request.ScriptsToRun == null || request.ScriptsToRun.Length == 0)
            {
                return(BadRequest());
            }

            DeploymentState deploymentState =
                _deploymentStateProvider.FindDeploymentState(request.DeploymentId.Value);

            if (deploymentState == null)
            {
                return(Content("FAIL"));
            }

            DeploymentHub.PromptForScriptsToRun(
                request.DeploymentId.Value,
                deploymentState.UserIdentity,
                deploymentState.ProjectName,
                deploymentState.ProjectConfigurationName,
                request.ScriptsToRun);

            return(Content("OK"));
        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewDeploymentStatus"/> class.
 /// </summary>
 /// <param name="deploymentState">State of the deployment (Required).</param>
 public NewDeploymentStatus(DeploymentState deploymentState)
 {
     State = deploymentState;
 }
Example #17
0
 internal DeploymentStatus(DeploymentState deploymentState)
 {
     DeploymentState = deploymentState;
 }
Example #18
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (modelMetadataCase_ == ModelMetadataOneofCase.TranslationModelMetadata)
            {
                hash ^= TranslationModelMetadata.GetHashCode();
            }
            if (modelMetadataCase_ == ModelMetadataOneofCase.ImageClassificationModelMetadata)
            {
                hash ^= ImageClassificationModelMetadata.GetHashCode();
            }
            if (modelMetadataCase_ == ModelMetadataOneofCase.TextClassificationModelMetadata)
            {
                hash ^= TextClassificationModelMetadata.GetHashCode();
            }
            if (modelMetadataCase_ == ModelMetadataOneofCase.ImageObjectDetectionModelMetadata)
            {
                hash ^= ImageObjectDetectionModelMetadata.GetHashCode();
            }
            if (modelMetadataCase_ == ModelMetadataOneofCase.TextExtractionModelMetadata)
            {
                hash ^= TextExtractionModelMetadata.GetHashCode();
            }
            if (modelMetadataCase_ == ModelMetadataOneofCase.TextSentimentModelMetadata)
            {
                hash ^= TextSentimentModelMetadata.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (DisplayName.Length != 0)
            {
                hash ^= DisplayName.GetHashCode();
            }
            if (DatasetId.Length != 0)
            {
                hash ^= DatasetId.GetHashCode();
            }
            if (createTime_ != null)
            {
                hash ^= CreateTime.GetHashCode();
            }
            if (updateTime_ != null)
            {
                hash ^= UpdateTime.GetHashCode();
            }
            if (DeploymentState != 0)
            {
                hash ^= DeploymentState.GetHashCode();
            }
            if (Etag.Length != 0)
            {
                hash ^= Etag.GetHashCode();
            }
            hash ^= Labels.GetHashCode();
            hash ^= (int)modelMetadataCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #19
0
        private ActionResult DoDeployOrSimulate(bool isSimulation, string projectName, string projectConfigurationName, string projectConfigurationBuildId, string targetEnvironmentName, ProjectType?projectType, List <string> targetMachines = null)
        {
            if (string.IsNullOrEmpty(projectName))
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(projectConfigurationName))
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(projectConfigurationBuildId))
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(targetEnvironmentName))
            {
                return(BadRequest());
            }

            if (!projectType.HasValue)
            {
                return(BadRequest());
            }

            try
            {
                Guid deploymentId = Guid.NewGuid();

                var projectConfigurationModel = new ProjectConfigurationModel(projectConfigurationName);

                var deploymentState =
                    new DeploymentState(
                        deploymentId,
                        UserIdentity,
                        projectName,
                        projectConfigurationModel.ConfigurationName,
                        targetEnvironmentName);

                _deploymentStateProvider.SetDeploymentState(
                    deploymentId,
                    deploymentState);

                _agentService.DeployAsync(
                    deploymentId,
                    _sessionService.UniqueClientId,
                    SecurityUtils.CurrentUsername,
                    CreateDeploymentInfo(
                        deploymentId,
                        isSimulation,
                        projectName,
                        projectConfigurationModel.ConfigurationName,
                        projectConfigurationBuildId,
                        targetEnvironmentName,
                        projectType.Value,
                        targetMachines));

                return(Json(new { Status = "OK" }));
            }
            catch (Exception exc)
            {
                return(HandleAjaxError(exc));
            }
        }
Example #20
0
 protected void start_deployment()
 {
     GroundConstructionScenario.SaveGame(Name + "-before_deployment");
     state = DeploymentState.DEPLOYING;
     StartCoroutine(deploy());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NewDeploymentStatus"/> class.
 /// </summary>
 /// <param name="deploymentState">State of the deployment (Required).</param>
 public NewDeploymentStatus(DeploymentState deploymentState)
 {
     State = deploymentState;
 }
 public static DeploymentStatus DeploymentStatus(DeploymentState deploymentState = default, int?totalDevices = default, int?devicesIncompatibleCount = default, int?devicesInProgressCount = default, int?devicesCompletedFailedCount = default, int?devicesCompletedSucceededCount = default, int?devicesCanceledCount = default)
 {
     return(new DeploymentStatus(deploymentState, totalDevices, devicesIncompatibleCount, devicesInProgressCount, devicesCompletedFailedCount, devicesCompletedSucceededCount, devicesCanceledCount));
 }