protected override void ProcessRecord() { try { TraceConfig.SetDefaultLevel(TraceSinkType.Console, EventLevel.Error); var newClusterManifest = this.ReadXml <ClusterManifestType>(this.GetAbsolutePath(this.ClusterManifestPath), this.GetFabricFilePath(Constants.ServiceModelSchemaFileName)); if (newClusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureWindowsServer) { if (string.IsNullOrEmpty(this.OldClusterManifestPath)) { var parameters = new Dictionary <string, dynamic> { { DeploymentParameters.ClusterManifestString, this.GetAbsolutePath(this.ClusterManifestPath) } }; var deploymentParameters = new DeploymentParameters(); deploymentParameters.SetParameters(parameters, DeploymentOperations.ValidateClusterManifest); DeploymentOperation.ExecuteOperation(deploymentParameters); this.WriteObject(true); } else { var upgradeValidationParameters = new Dictionary <string, dynamic> { { DeploymentParameters.OldClusterManifestString, this.GetAbsolutePath(this.OldClusterManifestPath) }, { DeploymentParameters.ClusterManifestString, this.GetAbsolutePath(this.ClusterManifestPath) } }; var upgradeDeploymentParameters = new DeploymentParameters(); upgradeDeploymentParameters.SetParameters(upgradeValidationParameters, DeploymentOperations.Validate); try { DeploymentOperation.ExecuteOperation(upgradeDeploymentParameters); } catch (Exception exception) { if (exception is FabricHostRestartRequiredException || exception is FabricHostRestartNotRequiredException) { this.WriteObject(true); return; } throw; } } } else { throw new InvalidOperationException(StringResources.Error_NonServerClusterManifestValidationNotSupport); } } catch (Exception exception) { this.WriteObject(false); this.ThrowTerminatingError( exception, Constants.TestClusterManifestErrorId, null); } }
protected void UpdateNodeNodeConfiguration(string clusterManifestPath) { try { var parameters = new Dictionary <string, dynamic> { { DeploymentParameters.ClusterManifestString, this.GetAbsolutePath(clusterManifestPath) }, }; var deploymentParameters = new DeploymentParameters(); deploymentParameters.SetParameters(parameters, DeploymentOperations.Update); DeploymentOperation.ExecuteOperation(deploymentParameters); this.WriteObject(StringResources.Info_UpdateNodeConfigurationSucceeded); } catch (Exception exception) { this.ThrowTerminatingError( exception, Constants.UpdateNodeConfigurationErrorId, null); } }
public void ProvisionFabric( string localCodePath, string localConfigPath, #if !DotNetCoreClrLinux && !DotNetCoreClrIOT string configurationCsvFilePath, #endif string infrastructureManifestFilePath, bool validateOnly, TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); #if DotNetCoreClrLinux || DotNetCoreClrIOT ImageBuilder.TraceSource.WriteInfo( TraceType, "Starting ProvisionFabric. CodePath:{0}, ConfigPath:{1}, InfrastructureManifestFilePath:{2}, Timeout:{3}", localCodePath, localConfigPath, infrastructureManifestFilePath, timeoutHelper.GetRemainingTime()); #else ImageBuilder.TraceSource.WriteInfo( TraceType, "Starting ProvisionFabric. CodePath:{0}, ConfigPath:{1}, ConfigurationCsvFilePath:{2}, InfrastructureManifestFilePath:{3}, Timeout:{4}", localCodePath, localConfigPath, configurationCsvFilePath, infrastructureManifestFilePath, timeoutHelper.GetRemainingTime()); #endif // TODO: Once FabricTest has been modified to generate InfrastructureManifest.xml file, we should not // allow InfrastructureManifest file to be optional if (string.IsNullOrEmpty(infrastructureManifestFilePath) || !FabricFile.Exists(infrastructureManifestFilePath)) { infrastructureManifestFilePath = null; ImageBuilder.TraceSource.WriteWarning( TraceType, "The InfrastrucutreManifestFile:{0} is not found", infrastructureManifestFilePath); } string codeVersion = string.Empty, clusterManifestVersion = string.Empty; if (!string.IsNullOrEmpty(localCodePath)) { codeVersion = GetCodeVersion(localCodePath); } if (!string.IsNullOrEmpty(localConfigPath)) { try { var parameters = new Dictionary <string, dynamic> { { DeploymentParameters.ClusterManifestString, localConfigPath }, { DeploymentParameters.InfrastructureManifestString, infrastructureManifestFilePath } }; var deploymentParameters = new DeploymentParameters(); deploymentParameters.SetParameters(parameters, DeploymentOperations.ValidateClusterManifest); DeploymentOperation.ExecuteOperation(deploymentParameters); } catch (Exception e) { ImageBuilderUtility.TraceAndThrowValidationError( FabricProvisionOperation.TraceType, StringResources.ImageBuilderError_ClusterManifestValidationFailed, e.ToString(), localConfigPath); } } if (!validateOnly) { timeoutHelper.ThrowIfExpired(); WinFabStoreLayoutSpecification winFabLayout = WinFabStoreLayoutSpecification.Create(); if (!string.IsNullOrEmpty(localCodePath)) { // Upload MSP file string destinationCodePath; if (ImageBuilderUtility.IsInstaller(localCodePath)) { destinationCodePath = winFabLayout.GetPatchFile(codeVersion); } else if (ImageBuilderUtility.IsCabFile(localCodePath)) { // Upload CAB file destinationCodePath = winFabLayout.GetCabPatchFile(codeVersion); } else { destinationCodePath = winFabLayout.GetCodePackageFolder(codeVersion); } this.imageStoreWrapper.UploadContent(destinationCodePath, localCodePath, timeoutHelper.GetRemainingTime()); } ClusterManifestType clusterManifest = null; if (!string.IsNullOrEmpty(localConfigPath)) { clusterManifest = ImageBuilderUtility.ReadXml <ClusterManifestType>(localConfigPath, this.validatingXmlReaderSettings); clusterManifestVersion = clusterManifest.Version; } if (clusterManifest != null) { // Upload ClusterManifest file ReplaceDefaultImageStoreConnectionString(clusterManifest); string destinationConfigPath = winFabLayout.GetClusterManifestFile(clusterManifestVersion); imageStoreWrapper.SetToStore <ClusterManifestType>(destinationConfigPath, clusterManifest, timeoutHelper.GetRemainingTime()); } } #if DotNetCoreClrLinux || DotNetCoreClrIOT ImageBuilder.TraceSource.WriteInfo( TraceType, "Completed ProvisionFabric. CodePath:{0}, ConfigPath:{1}", localCodePath, localConfigPath); #else ImageBuilder.TraceSource.WriteInfo( TraceType, "Completed ProvisionFabric. CodePath:{0}, ConfigPath:{1}, ConfigurationCsvFilePath:{2}", localCodePath, localConfigPath, configurationCsvFilePath); #endif }