private void SetOptionalFeatureParameters(SetupSettings settings) { this.EnableCircularTraceSession = settings.EnableCircularTraceSession; DeploymentSpecification.SetEnableCircularTraceSession(this.EnableCircularTraceSession); // Initialize the properties used to reflect state of preview features that need to lightup at runtime this.EnableUnsupportedPreviewFeatures = settings.EnableUnsupportedPreviewFeatures; this.IsSFVolumeDiskServiceEnabled = settings.IsSFVolumeDiskServiceEnabled; }
public void CreateFromFile() { DeleteTargetFile = true; this.FabricDataRoot = FabricEnvironment.GetDataRoot(); this.DeploymentSpecification.SetDataRoot(FabricDataRoot); SetFabricLogRoot(); this.DeploymentSpecification.SetLogRoot(this.FabricLogRoot); var targetInformationFilePath = Path.Combine(this.FabricDataRoot, Constants.FileNames.TargetInformation); if (!File.Exists(targetInformationFilePath)) { this.Operation = DeploymentOperations.None; this.ClusterManifestLocation = Helpers.GetCurrentClusterManifestPath(this.FabricDataRoot); this.InfrastructureManifestLocation = Helpers.GetInfrastructureManifestPath(this.FabricDataRoot); } else { this.Operation = DeploymentOperations.Create; var targetInformation = XmlHelper.ReadXml <TargetInformationType>(targetInformationFilePath, SchemaLocation.GetWindowsFabricSchemaLocation()); var targetInstallation = targetInformation.TargetInstallation; if (targetInstallation == null) { throw new InvalidDeploymentParameterException(StringResources.Error_FabricDeployer_InvalidTargetInstallation_Formatted); } this.InfrastructureManifestLocation = targetInstallation.InfrastructureManifestLocation; this.InstanceId = targetInstallation.InstanceId; this.NodeName = targetInstallation.NodeName; if (string.IsNullOrEmpty(this.InfrastructureManifestLocation) && !string.IsNullOrEmpty(this.NodeName)) { this.InfrastructureManifestLocation = this.DeploymentSpecification.GetInfrastructureManfiestFile(this.NodeName); } this.TargetVersion = targetInstallation.TargetVersion; this.ClusterManifestLocation = targetInstallation.ClusterManifestLocation; } if (!string.IsNullOrEmpty(this.ClusterManifestLocation)) { var manifest = XmlHelper.ReadXml <ClusterManifestType>(this.ClusterManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); var settings = new SetupSettings(manifest); this.SkipFirewallConfiguration = settings.SkipFirewallConfiguration; // Initialize the properties used to reflect state of preview features that need to lightup at runtime this.EnableUnsupportedPreviewFeatures = settings.EnableUnsupportedPreviewFeatures; this.IsSFVolumeDiskServiceEnabled = settings.IsSFVolumeDiskServiceEnabled; } }
private void ConfigureFromManifest(DeploymentParameters parameters, ClusterManifestType clusterManifest, Infrastructure infrastructure) { SetupSettings settings = new SetupSettings(clusterManifest); #if !DotNetCoreClrLinux if (!string.IsNullOrEmpty(settings.ServiceRunAsAccountName)) { FabricDeployerServiceController.SetServiceCredentials(settings.ServiceRunAsAccountName, settings.ServiceRunAsPassword, parameters.MachineName); DeployerTrace.WriteInfo("Set Service Fabric Host Service to run as {0}", settings.ServiceRunAsAccountName); } #endif string clusterManifestTargetLocation = Helpers.GetRemotePath(Path.Combine(parameters.FabricDataRoot, "clusterManifest.xml"), parameters.MachineName); DeployerTrace.WriteInfo("Copying ClusterManifest to {0}", clusterManifestTargetLocation); if (!ArePathesEqual(parameters.ClusterManifestLocation, clusterManifestTargetLocation)) { File.Copy(parameters.ClusterManifestLocation, clusterManifestTargetLocation, true); } #if !DotNetCoreClrLinux string serviceStartupType = "DelayedAutoStart"; if (!string.IsNullOrEmpty(parameters.ServiceStartupType)) { FabricDeployerServiceController.SetStartupType(parameters.ServiceStartupType); serviceStartupType = parameters.ServiceStartupType; } else if (!string.IsNullOrEmpty(settings.ServiceStartupType)) { FabricDeployerServiceController.SetStartupType(settings.ServiceStartupType); serviceStartupType = settings.ServiceStartupType; } else { if (infrastructure is AzureInfrastructure) { FabricDeployerServiceController.SetServiceStartupType(FabricDeployerServiceController.ServiceStartupType.Manual, parameters.MachineName); serviceStartupType = FabricDeployerServiceController.ServiceStartupType.Manual.ToString(); } else { FabricDeployerServiceController.SetStartupTypeDelayedAuto(parameters.MachineName); } } DeployerTrace.WriteInfo("Set Service Fabric Host Service to start up type to {0}", serviceStartupType); #endif }
public void CreateFromFile() { DeleteTargetFile = true; this.FabricDataRoot = FabricEnvironment.GetDataRoot(); this.DeploymentSpecification.SetDataRoot(FabricDataRoot); SetFabricLogRoot(); this.DeploymentSpecification.SetLogRoot(this.FabricLogRoot); var targetInformationFilePath = Path.Combine(this.FabricDataRoot, Constants.FileNames.TargetInformation); if (!File.Exists(targetInformationFilePath)) { this.Operation = DeploymentOperations.None; this.ClusterManifestLocation = Helpers.GetCurrentClusterManifestPath(this.FabricDataRoot); this.InfrastructureManifestLocation = Helpers.GetInfrastructureManifestPath(this.FabricDataRoot); } else { this.Operation = DeploymentOperations.Create; var targetInformation = XmlHelper.ReadXml <TargetInformationType>(targetInformationFilePath, SchemaLocation.GetWindowsFabricSchemaLocation()); var targetInstallation = targetInformation.TargetInstallation; if (targetInstallation == null) { throw new InvalidDeploymentParameterException(StringResources.Error_FabricDeployer_InvalidTargetInstallation_Formatted); } this.InfrastructureManifestLocation = targetInstallation.InfrastructureManifestLocation; this.InstanceId = targetInstallation.InstanceId; this.NodeName = targetInstallation.NodeName; if (string.IsNullOrEmpty(this.InfrastructureManifestLocation) && !string.IsNullOrEmpty(this.NodeName)) { this.InfrastructureManifestLocation = this.DeploymentSpecification.GetInfrastructureManfiestFile(this.NodeName); } this.TargetVersion = targetInstallation.TargetVersion; this.ClusterManifestLocation = targetInstallation.ClusterManifestLocation; } if (!string.IsNullOrEmpty(this.ClusterManifestLocation)) { var manifest = XmlHelper.ReadXml <ClusterManifestType>(this.ClusterManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); var settings = new SetupSettings(manifest); this.SkipFirewallConfiguration = settings.SkipFirewallConfiguration; SetOptionalFeatureParameters(settings); } }
/// <summary> /// This method makes sure FabricLogRoot and FabricDataRoot should not be updated through cluster config upgrade. /// </summary> private void ThrowIfUpdateRoot() { var currentClusterManifestFile = this.nodeSettings.DeploymentFoldersInfo.CurrentClusterManifestFile; if (File.Exists(currentClusterManifestFile)) { // Check if cluster manifest is invalid. See RDBug 14040324. string fileContents = string.Empty; if (new FileInfo(currentClusterManifestFile).Length == 0 || new Func <bool>(() => { fileContents = File.ReadAllText(currentClusterManifestFile); return(string.IsNullOrWhiteSpace(fileContents)); }).Invoke()) { string errorMsg = string.Format(StringResources.ClusterManifestInvalidDeleting_Formatted, currentClusterManifestFile, fileContents); DeployerTrace.WriteError(errorMsg); File.Delete(currentClusterManifestFile); throw new ClusterManifestValidationException(errorMsg); } ClusterManifestType currentManifest = XmlHelper.ReadXml <ClusterManifestType>(currentClusterManifestFile, SchemaLocation.GetWindowsFabricSchemaLocation()); SetupSettings currentSettings = new SetupSettings(currentManifest); SetupSettings targetSettings = new SetupSettings(this.clusterManifest); if (targetSettings.FabricDataRoot != null && targetSettings.FabricDataRoot != currentSettings.FabricDataRoot) { string errorMsg = string.Format(StringResources.UpdateNotAllowed, Constants.ParameterNames.FabricDataRoot); DeployerTrace.WriteError(errorMsg); throw new ClusterManifestValidationException(errorMsg); } if (targetSettings.FabricLogRoot != null && targetSettings.FabricLogRoot != currentSettings.FabricLogRoot) { string errorMsg = string.Format(StringResources.UpdateNotAllowed, Constants.ParameterNames.FabricLogRoot); DeployerTrace.WriteError(errorMsg); throw new ClusterManifestValidationException(errorMsg); } } }
/// <summary> /// This method makes sure FabricLogRoot and FabricDataRoot should not be updated through cluster config upgrade. /// </summary> private void ThrowIfUpdateRoot() { var currentClusterManifestFile = this.nodeSettings.DeploymentFoldersInfo.CurrentClusterManifestFile; if (File.Exists(currentClusterManifestFile)) { ClusterManifestType currentManifest = XmlHelper.ReadXml <ClusterManifestType>(currentClusterManifestFile, SchemaLocation.GetWindowsFabricSchemaLocation()); SetupSettings currentSettings = new SetupSettings(currentManifest); SetupSettings targetSettings = new SetupSettings(this.clusterManifest); if (targetSettings.FabricDataRoot != null && targetSettings.FabricDataRoot != currentSettings.FabricDataRoot) { string errorMsg = string.Format(StringResources.UpdateNotAllowed, Constants.ParameterNames.FabricDataRoot); DeployerTrace.WriteError(errorMsg); throw new ClusterManifestValidationException(errorMsg); } if (targetSettings.FabricLogRoot != null && targetSettings.FabricLogRoot != currentSettings.FabricLogRoot) { string errorMsg = string.Format(StringResources.UpdateNotAllowed, Constants.ParameterNames.FabricLogRoot); DeployerTrace.WriteError(errorMsg); throw new ClusterManifestValidationException(errorMsg); } } }
public void Initialize() { DeploymentOperations operation = Operation; if (operation == DeploymentOperations.Create || operation == DeploymentOperations.Update || operation == DeploymentOperations.Configure) { if (this.ClusterManifestLocation == null || !File.Exists(this.ClusterManifestLocation)) { throw new InvalidDeploymentParameterException(StringResources.Error_FabricDeployer_ClusterManifestNotFound_Formatted); } } switch (operation) { case DeploymentOperations.Configure: { ClusterManifestType manifest = XmlHelper.ReadXml <ClusterManifestType>(this.ClusterManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); SetupSettings settings = new SetupSettings(manifest); this.FabricDataRoot = settings.FabricDataRoot == null ? this.FabricDataRoot : settings.FabricDataRoot; this.FabricLogRoot = settings.FabricLogRoot == null ? this.FabricLogRoot : settings.FabricLogRoot; bool isDataRootProvided = this.FabricDataRoot != null; ResolveDataRoot(isDataRootProvided); DeploymentSpecification.SetDataRoot(this.FabricDataRoot); ResolveLogRoot(isDataRootProvided); DeploymentSpecification.SetLogRoot(this.FabricLogRoot); } break; case DeploymentOperations.RemoveNodeConfig: // for RemoveNodeConfig the user does not pass the data root in, so it has to be determined this.FabricDataRoot = FabricEnvironment.GetDataRoot(this.MachineName); this.FabricLogRoot = FabricEnvironment.GetLogRoot(this.MachineName); DeploymentSpecification.SetDataRoot(this.FabricDataRoot); DeploymentSpecification.SetLogRoot(this.FabricLogRoot); break; case DeploymentOperations.Create: case DeploymentOperations.None: case DeploymentOperations.Remove: case DeploymentOperations.Rollback: case DeploymentOperations.Update: case DeploymentOperations.UpdateNodeState: case DeploymentOperations.UpdateInstanceId: SetCommonRoots(); break; case DeploymentOperations.ValidateClusterManifest: SetCommonRoots(Directory.GetCurrentDirectory()); break; case DeploymentOperations.Validate: if (this.OldClusterManifestLocation != null && File.Exists(this.OldClusterManifestLocation) && this.FabricDataRoot == null) { SetCommonRoots(Path.GetDirectoryName(this.OldClusterManifestLocation)); } else { SetCommonRoots(); } break; case DeploymentOperations.DockerDnsSetup: case DeploymentOperations.DockerDnsCleanup: case DeploymentOperations.ContainerNetworkSetup: case DeploymentOperations.ContainerNetworkCleanup: case DeploymentOperations.IsolatedNetworkSetup: case DeploymentOperations.IsolatedNetworkCleanup: break; default: throw new InvalidOperationException(String.Format("The operation {0} has no explicit deployment criteria.", operation.ToString())); } if (this.InfrastructureManifestLocation == null && this.NodeName != null) { this.InfrastructureManifestLocation = this.DeploymentSpecification.GetInfrastructureManfiestFile(this.NodeName); } if (operation == DeploymentOperations.UpdateNodeState || operation == DeploymentOperations.Remove || operation == DeploymentOperations.UpdateInstanceId || (operation == DeploymentOperations.RemoveNodeConfig && !string.IsNullOrEmpty(this.FabricDataRoot) && Directory.Exists(this.FabricDataRoot))) { this.ClusterManifestLocation = Helpers.GetCurrentClusterManifestPath(this.FabricDataRoot); this.InfrastructureManifestLocation = Helpers.GetInfrastructureManifestPath(this.FabricDataRoot); } if (!string.IsNullOrEmpty(this.ClusterManifestLocation)) { ClusterManifestType manifest = XmlHelper.ReadXml <ClusterManifestType>(this.ClusterManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); SetupSettings settings = new SetupSettings(manifest); this.SkipFirewallConfiguration = settings.SkipFirewallConfiguration; this.ContainerDnsSetup = settings.ContainerDnsSetup; this.ContainerNetworkSetup = settings.ContainerNetworkSetup; this.ContainerNetworkName = settings.ContainerNetworkName; #if !DotNetCoreClrLinux this.SkipContainerNetworkResetOnReboot = settings.SkipContainerNetworkResetOnReboot; this.SkipIsolatedNetworkResetOnReboot = settings.SkipIsolatedNetworkResetOnReboot; #endif this.IsolatedNetworkSetup = settings.IsolatedNetworkSetup; this.IsolatedNetworkName = settings.IsolatedNetworkName; this.IsolatedNetworkInterfaceName = settings.IsolatedNetworkInterfaceName; this.UseContainerServiceArguments = settings.UseContainerServiceArguments; this.ContainerServiceArguments = settings.ContainerServiceArguments; this.EnableContainerServiceDebugMode = settings.EnableContainerServiceDebugMode; SetOptionalFeatureParameters(settings); } else { this.SkipFirewallConfiguration = false; } Validate(); }