Exemplo n.º 1
0
        public EventStoreReader()
        {
            TraceStoreConnectionInformation connectionInfo = null;

            if (ClusterSettingsReader.IsOneBoxEnvironment())
            {
                EventStoreLogger.Logger.LogMessage("One Box Environment. Configuring local Reader");
                connectionInfo = new LocalTraceStoreConnectionInformation(
                    FabricEnvironment.GetDataRoot(),
                    FabricEnvironment.GetLogRoot(),
                    FabricEnvironment.GetCodePath());
            }
            else
            {
                EventStoreLogger.Logger.LogMessage("Cloud Environment. Configuring Cloud Reader");
                var operationalConsumer = ClusterSettingsReader.OperationalConsumer;
                if (operationalConsumer == null)
                {
                    throw new ConnectionParsingException(ErrorCodes.AzureConnectionInformationMissing, "Config is Missing Operational Store Connection information");
                }

                connectionInfo = new AzureTraceStoreConnectionInformation(
                    operationalConsumer.Connection.AccountName,
                    operationalConsumer.Connection.AccountKey,
                    operationalConsumer.TablesPrefix,
                    null,
                    operationalConsumer.DeploymentId,
                    EventStoreLogProvider.LogProvider);
            }

            var connection = new TraceStoreConnection(connectionInfo, EventStoreLogProvider.LogProvider);

            traceStoreReader = connection.EventStoreReader;
        }
Exemplo n.º 2
0
        static Assembly LoadFromFabricCodePath(object sender, ResolveEventArgs args)
        {
            try
            {
                var assemblyToLoad = new AssemblyName(args.Name);

                if (KnownDlls.Contains(assemblyToLoad.Name))
                {
                    var folderPath = FabricEnvironment.GetCodePath();
#if DotNetCoreClr
                    // .NetStandard compatible Data.Impl and its dependencies are located in "NS' subfolder under Fabric.Code folder.
                    folderPath = Path.Combine(folderPath, "NS");
#endif
                    var assemblyPath = Path.Combine(folderPath, assemblyToLoad.Name + ".dll");

                    if (File.Exists(assemblyPath))
                    {
                        return(Assembly.LoadFrom(assemblyPath));
                    }
                }
            }
            catch (Exception)
            {
                // Supress any Exception so that we can continue to
                // load the assembly through other means
            }

            return(null);
        }
Exemplo n.º 3
0
        internal static void InitializeTracing()
        {
            TraceConfig.InitializeFromConfigStore();

            FabricCodePath = FabricEnvironment.GetCodePath();
            FabricLogRoot  = FabricEnvironment.GetLogRoot();
        }
        private void ReplaceDefaultImageStoreConnectionString(ClusterManifestType manifest)
        {
            SettingsOverridesTypeSection managementSection = manifest.FabricSettings.FirstOrDefault(
                section => section.Name.Equals(System.Fabric.FabricDeployer.Constants.SectionNames.Management, StringComparison.OrdinalIgnoreCase));

            SettingsOverridesTypeSectionParameter imageStoreParameter = null;

            if (managementSection != null)
            {
                imageStoreParameter = managementSection.Parameter.FirstOrDefault(
                    parameter => parameter.Name.Equals(System.Fabric.FabricDeployer.Constants.ParameterNames.ImageStoreConnectionString, StringComparison.OrdinalIgnoreCase));
            }

            if (imageStoreParameter == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(imageStoreParameter.Value) ||
                imageStoreParameter.Value.Equals(System.Fabric.FabricDeployer.Constants.DefaultTag, StringComparison.OrdinalIgnoreCase))
            {
                string defaultImageStoreRoot = Path.Combine(FabricEnvironment.GetDataRoot(), System.Fabric.FabricDeployer.Constants.DefaultImageStoreRootFolderName);
                imageStoreParameter.Value = string.Format(CultureInfo.InvariantCulture, "{0}{1}", System.Fabric.FabricValidatorConstants.FileImageStoreConnectionStringPrefix, defaultImageStoreRoot);
            }
        }
Exemplo n.º 5
0
        static Assembly LoadFromFabricCodePath(object sender, ResolveEventArgs args)
        {
            try
            {
                var assemblyToLoad = new AssemblyName(args.Name);

                if (KnownDlls.Contains(assemblyToLoad.Name))
                {
                    var folderPath   = FabricEnvironment.GetCodePath();
                    var assemblyPath = Path.Combine(folderPath, assemblyToLoad.Name + ".dll");

                    if (File.Exists(assemblyPath))
                    {
                        return(Assembly.LoadFrom(assemblyPath));
                    }
                }
            }
            catch (Exception)
            {
                // Supress any Exception so that we can continue to
                // load the assembly through other means
            }

            return(null);
        }
Exemplo n.º 6
0
        static Assembly LoadFromFabricCodePath(object sender, ResolveEventArgs args)
        {
            try
            {
                var assemblyToLoad = new AssemblyName(args.Name);

                if (string.Compare(SystemFabricBackupRestoreAssemblyName, assemblyToLoad.Name, true) == 0)
                {
                    var folderPath = FabricEnvironment.GetCodePath();

                    // .NetStandard compatible dlls with its dependencies are located in "NS' subfolder under Fabric.Code folder.
                    folderPath = Path.Combine(folderPath, "NS");

                    var assemblyPath = Path.Combine(folderPath, assemblyToLoad.Name + ".dll");

                    if (File.Exists(assemblyPath))
                    {
                        return(Assembly.LoadFrom(assemblyPath));
                    }
                }
            }
            catch (Exception)
            {
                // Supress any Exception so that we can continue to
                // load the assembly through other means
            }

            return(null);
        }
Exemplo n.º 7
0
        private void SetCommonRoots(string backupFabricDataRoot = null)
        {
            if (this.FabricDataRoot == null) // FabricDataRoot not provided
            {
                try
                {
                    this.FabricDataRoot = FabricEnvironment.GetDataRoot(this.MachineName);
                }
                catch
                {
                    if (!string.IsNullOrEmpty(backupFabricDataRoot) && Directory.Exists(backupFabricDataRoot))
                    {
                        // Set FDR based on backup, if no value is retrievable
                        this.FabricDataRoot = backupFabricDataRoot;
                    }
                    else
                    {
                        throw;
                    }
                }

                this.DeploymentSpecification.SetDataRoot(this.FabricDataRoot); // Also sets deployment specification Log Root to [FabricDataRoot]\log

                if (string.IsNullOrEmpty(this.FabricLogRoot))
                {
                    SetFabricLogRoot(); // Tries to get data root from environment, else pulls from deployment specification
                }
            }
            else
            {
                this.DeploymentSpecification.SetDataRoot(this.FabricDataRoot); // Also sets deployment specification Log Root
                this.FabricLogRoot = this.FabricLogRoot ?? this.DeploymentSpecification.GetLogRoot();
            }
            this.DeploymentSpecification.SetLogRoot(this.FabricLogRoot);
        }
Exemplo n.º 8
0
        private void RemoveNodeConfigurationMsi(bool deleteLog)
        {
            DeployerTrace.WriteInfo("Checking if fabric host is running");
            if (FabricDeployerServiceController.IsRunning(Helpers.GetMachine()))
            {
                DeployerTrace.WriteInfo("Stopping fabric host");
                FabricDeployerServiceController.StopHostSvc(Helpers.GetMachine());
            }

            string fabricCodePath = String.Empty;

            try
            {
                fabricCodePath = FabricEnvironment.GetCodePath();
            }
            catch (FabricException)
            {
                DeployerTrace.WriteError(StringResources.Error_FabricCodePathNotFound);
            }

            string fabricSetupFilepath = Path.Combine(fabricCodePath, "FabricSetup.exe");

            ProcessStartInfo FabricSetupExeStartInfo = new ProcessStartInfo();

            FabricSetupExeStartInfo.FileName         = fabricSetupFilepath;
            FabricSetupExeStartInfo.Arguments        = string.Format("/operation:removenodestate");
            FabricSetupExeStartInfo.WorkingDirectory = fabricCodePath == String.Empty ? Directory.GetCurrentDirectory() : fabricCodePath;

            try
            {
                using (Process exeProcess = Process.Start(FabricSetupExeStartInfo))
                {
                    DeployerTrace.WriteInfo("Starting FabricSetup.exe");
                    exeProcess.WaitForExit();
                }
            }
            catch (Exception e)
            {
                DeployerTrace.WriteError("Starting FabricSetup.exe failed with exception {0}.", e);
            }

            string value = deleteLog ? DeleteLogTrue : DeleteLogFalse;

            using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(FabricConstants.FabricRegistryKeyPath, true))
            {
                regKey.SetValue(Constants.Registry.RemoveNodeConfigurationValue, value);
            }

            DeployerTrace.WriteInfo("Starting fabric host");
            FabricDeployerServiceController.StartHostSvc();

            DeployerTrace.WriteInfo("Stopping fabric host");
            FabricDeployerServiceController.StopHostSvc();

            DeployerTrace.WriteInfo("Cleaning registry value");
            DeleteRemoveNodeConfigurationRegistryValue(string.Empty);

            DeployerTrace.WriteInfo("Done cleaning registry value");
        }
        public async Task <string> ProcessGetClusterConfigurationAsync(string apiVersion, TimeSpan timeout, CancellationToken cancellationToken)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Entering ProcessGetClusterConfigurationAsync.");
            try
            {
                UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Retrieve current cluster resource from StoreManager.");
                StandAloneCluster cluster = await this.storeManager.GetClusterResourceAsync(
                    Constants.ClusterReliableDictionaryKey, this.cancellationToken).ConfigureAwait(false);

                if (cluster == null || cluster.Current == null)
                {
                    // read from fabric data root
                    string fabricDataRoot = FabricEnvironment.GetDataRoot();
                    string jsonConfigPath = Path.Combine(fabricDataRoot, System.Fabric.FabricDeployer.Constants.FileNames.BaselineJsonClusterConfig); // TODO: Needs to come from image store
                    return(File.ReadAllText(jsonConfigPath));
                }
                else
                {
                    var      nodesFromFM = new Dictionary <string, NodeDescription>();
                    NodeList nodes       = await StandaloneUtility.GetNodesFromFMAsync(this.fabricClient, this.cancellationToken).ConfigureAwait(false);

                    for (int i = 0; i < nodes.Count; ++i)
                    {
                        if (nodes[i].NodeStatus != System.Fabric.Query.NodeStatus.Invalid && !UpgradeOrchestrationMessageProcessor.IsGhostNode(nodes[i]))
                        {
                            NodeDescription nodeDesc = new NodeDescription()
                            {
                                FaultDomain   = nodes[i].FaultDomain.ToString(),
                                UpgradeDomain = nodes[i].UpgradeDomain,
                                IPAddress     = nodes[i].IpAddressOrFQDN,
                                NodeTypeRef   = nodes[i].NodeType,
                                NodeName      = nodes[i].NodeName
                            };
                            nodesFromFM.Add(nodes[i].NodeName, nodeDesc);
                        }
                    }

                    cluster.Topology.Nodes = nodesFromFM;

                    UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Construct StandAloneJsonModel from current cluster resource.");
                    var jsonModel = StandAloneInstallerJsonModelBase.ConstructByApiVersion(cluster.Current.CSMConfig, cluster.Topology, cluster.Current.CSMConfig.Version.Version, apiVersion);
                    UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Serializing current json model.");
                    var serializerSettings = new JsonSerializerSettings
                    {
                        Formatting                 = Formatting.Indented,
                        NullValueHandling          = NullValueHandling.Ignore,
                        PreserveReferencesHandling = PreserveReferencesHandling.None
                    };
                    serializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
                    return(JsonConvert.SerializeObject(jsonModel, serializerSettings));
                }
            }
            catch (Exception e)
            {
                UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "ProcessStartUpgradeAsync exception: {0}", e);
                throw UpgradeOrchestrationMessageProcessor.ConvertToComException(e);
            }
        }
Exemplo n.º 10
0
        private void ResolveDataRoot(bool isDataRootProvided)
        {
            if (!isDataRootProvided)
            {
                this.FabricDataRoot = FabricEnvironment.GetDataRoot();
            }

            Helpers.CreateDirectoryIfNotExist(this.FabricDataRoot, this.MachineName);
        }
Exemplo n.º 11
0
 internal static string GetFabricBinRoot(string machineName)
 {
     try
     {
         return(FabricEnvironment.GetBinRoot(machineName));
     }
     catch (System.Fabric.FabricException)
     {
         return(null);
     }
 }
Exemplo n.º 12
0
 internal static string GetFabricCodePath()
 {
     try
     {
         return(FabricEnvironment.GetCodePath());
     }
     catch (System.Fabric.FabricException)
     {
         return(null);
     }
 }
Exemplo n.º 13
0
 private void SetFabricLogRoot()
 {
     try
     {
         this.FabricLogRoot = FabricEnvironment.GetLogRoot(this.MachineName);
     }
     catch (FabricException)
     {
         this.FabricLogRoot = this.DeploymentSpecification.GetLogRoot(); // This is to prevent break in backward compatibility of our internal tools.
     }
 }
Exemplo n.º 14
0
 internal static string GetFabricDataRoot()
 {
     try
     {
         return(FabricEnvironment.GetDataRoot());
     }
     catch (System.Fabric.FabricException)
     {
         return(null);
     }
 }
        private async Task <string> DownloadMsiAsync(Uri targetMsiUri, string targetMsiVersion, string tempPath)
        {
            string clusterMsiPath = null;

#if DotNetCoreClrLinux
            string extension          = String.Empty;
            var    packageManagerType = FabricEnvironment.GetLinuxPackageManagerType();
            switch (packageManagerType)
            {
            case LinuxPackageManagerType.Deb:
                extension = ".deb";
                break;

            case LinuxPackageManagerType.Rpm:
                extension = ".rpm";
                break;

            default:
                Trace.WriteError(TraceType, "Unable to to determine Linux package manager. Type: {0}", packageManagerType);
                extension = ".unknown";
                break;
            }

            clusterMsiPath = Path.Combine(tempPath, string.Format("servicefabric_{0}{1}", targetMsiVersion, extension));
#else
            var pattern = @"(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/(?<Container>[\w-_\W]+\/)*(?<SFFileName>(MicrosoftServiceFabric.Internal|ServiceFabric|WindowsFabric)\.(?<SFVersion>(\d+\.\d+\.\d+\.\d+))\.(?<SFFileExtn>(msi|cab)))[\w\.?=%&=\-@/$,]*";

            var downloadCenterGroup = MatchPattern(pattern, targetMsiUri.ToString());

            if (downloadCenterGroup == null || downloadCenterGroup["SFFileName"] == null || string.IsNullOrEmpty(downloadCenterGroup["SFFileName"].Value))
            {
                throw new ArgumentException($"Invalid target MSI uri format: {targetMsiUri}! Should contain either ServiceFabric or windowsFabric and file extension should be either cab or msi.", nameof(targetMsiUri));
            }

            clusterMsiPath = Path.Combine(tempPath, downloadCenterGroup["SFFileName"].Value);
#endif

#if !DotNetCoreClrLinux
            Trace.WriteInfo(TraceType, "Downloading fabric {2} from {0} to {1}", targetMsiUri, clusterMsiPath, downloadCenterGroup[2].Value);
#endif

            var webClient = new HttpClient();

            using (Stream srcStream = await webClient.GetStreamAsync(targetMsiUri))
                using (Stream dstStream = File.Open(clusterMsiPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    await srcStream.CopyToAsync(dstStream);
                }

            Trace.WriteInfo(TraceType, "Download completed");

            return(clusterMsiPath);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FabricConstruction"/> class.
        /// </summary>
        /// <param name="createServiceCollection">Indicates whether to create a new <see cref="IServiceCollection"/></param>
        public FabricConstruction(bool createServiceCollection = true)
        {
            // Create environment details
            Environment = new FabricEnvironment();

            // If we should create the service collection
            if (createServiceCollection)
            {
                // Create a new list of dependencies
                ServiceCollection = new ServiceCollection();
            }
        }
Exemplo n.º 17
0
 public DeploymentParameters(bool setBinRoot)
 {
     DeploymentSpecification = FabricDeploymentSpecification.Create();
     DeleteTargetFile        = false;
     if (setBinRoot)
     {
         try
         {
             this.FabricBinRoot = FabricEnvironment.GetBinRoot();
         }
         catch (Exception) { }
     }
 }
Exemplo n.º 18
0
        private string GetFabricFilePath(string fileName)
        {
            var fabricfilePath = Path.Combine(FabricEnvironment.GetCodePath(), fileName);

            if (string.IsNullOrEmpty(fabricfilePath) || !File.Exists(fabricfilePath))
            {
                throw new FileNotFoundException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              "FabricCodeFileNotFound: {0}", fabricfilePath));
            }

            return(fabricfilePath);
        }
Exemplo n.º 19
0
        internal string GetFabricFilePath(string fileName)
        {
            var fabricfilePath = this.JoinPath(FabricEnvironment.GetCodePath(), fileName);

            if (string.IsNullOrEmpty(fabricfilePath) || !this.TestPath(fabricfilePath))
            {
                throw new FileNotFoundException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              StringResources.Error_FabricCodeFileNotFound,
                              fileName));
            }

            return(fabricfilePath);
        }
        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;
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Gets the path of the log root directory from FabricEnvironment
        /// </summary>
        /// <returns>Path of the log root directory</returns>
        private static string GetLogRoot()
        {
            string logroot = FabricEnvironment.GetLogRoot();

            if (string.IsNullOrEmpty(logroot))
            {
                logroot = FabricEnvironment.GetDataRoot() + LogFolder;
            }

            if (string.IsNullOrEmpty(logroot))
            {
                throw new InvalidOperationException(StringResources.EventStoreError_LogrootNotFound);
            }

            return(logroot);
        }
Exemplo n.º 22
0
        private void ResolveLogRoot(bool isDataRootProvided)
        {
            if (this.FabricLogRoot == null)
            {
                if (isDataRootProvided)
                {
                    this.FabricLogRoot = DeploymentSpecification.GetLogRoot();
                }
                else
                {
                    this.FabricLogRoot = FabricEnvironment.GetLogRoot();
                }
            }

            Helpers.CreateDirectoryIfNotExist(this.FabricLogRoot, this.MachineName);
        }
Exemplo n.º 23
0
        private Assembly ResolveHandler(object sender, ResolveEventArgs args)
        {
            // The ResolveHandler is called if the dsts client implementation binaries are not in the
            // same location as the executable.
            string assemblyToLoad = args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll";

            foreach (string assembly in Constants.dSTSKnownDlls)
            {
                if (assembly == assemblyToLoad)
                {
                    string assemblyPath = Path.Combine(FabricEnvironment.GetCodePath(), assemblyToLoad);
                    return(Assembly.LoadFrom(assemblyPath));
                }
            }

            return(null);
        }
 private Config CreateOneBoxConfig(ClusterAnalysisConfiguration configuration)
 {
     return(new Config
     {
         RunMode = RunMode.OneBoxCluster,
         RuntimeContext =
             new RuntimeContext
         {
             FabricCodePath = FabricEnvironment.GetCodePath(),
             FabricDataRoot = FabricEnvironment.GetDataRoot(),
             FabricLogRoot = FabricEnvironment.GetLogRoot()
         },
         IsCrashDumpAnalysisEnabled = false,
         CrashDumpAnalyzerServiceName = string.Empty,
         NamedConfigManager = this.PopulateConfigurationManager(configuration)
     });
 }
Exemplo n.º 25
0
        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);
            }
        }
Exemplo n.º 26
0
        internal static Assembly LoadFromFabricCodePath(object sender, ResolveEventArgs args)
        {
            try
            {
                string folderPath   = FabricEnvironment.GetCodePath();
                string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
                if (File.Exists(assemblyPath))
                {
                    return(Assembly.LoadFrom(assemblyPath));
                }
            }
            catch (Exception)
            {
                // Suppress any Exception so that we can continue to
                // load the assembly through other means
            }

            return(null);
        }
        private async Task <string> GetCurrentJsonConfigVersionAsync(CancellationToken cancellationToken)
        {
            StandAloneCluster cluster = await this.storeManager.GetClusterResourceAsync(
                Constants.ClusterReliableDictionaryKey, this.cancellationToken).ConfigureAwait(false);

            if (cluster == null || cluster.Current == null)
            {
                // read from fabric data root
                string fabricDataRoot   = FabricEnvironment.GetDataRoot();
                string jsonConfigPath   = Path.Combine(fabricDataRoot, System.Fabric.FabricDeployer.Constants.FileNames.BaselineJsonClusterConfig); // TODO: Needs to come from image store
                string jsonConfigString = File.ReadAllText(jsonConfigPath);
                StandAloneInstallerJsonModelBase targetJsonConfig = StandAloneInstallerJsonModelBase.GetJsonConfigFromString(jsonConfigString);
                return(targetJsonConfig.ClusterConfigurationVersion);
            }
            else
            {
                return(cluster.Current.CSMConfig.Version.Version);
            }
        }
Exemplo n.º 28
0
        internal static string GetNodeConfiguration(string machineName)
        {
            string dataRoot = FabricEnvironment.GetDataRoot(machineName);

            if (!Directory.Exists(dataRoot))
            {
                return(null);
            }

            dataRoot = machineName == null || Helpers.IsLocalIpAddress(machineName)
                ? dataRoot
                : Helpers.GetRemotePath(dataRoot, machineName);
            if (!Directory.Exists(dataRoot))
            {
                return(null);
            }

            var stringwriter = new System.IO.StringWriter();
            var serializer   = new XmlSerializer(typeof(ClusterManifestType));

            if (File.Exists(Path.Combine(dataRoot, Constants.TargetInformationFileName)))
            {
                var targetInformation = Utility.ReadXml <TargetInformationType>(Path.Combine(dataRoot, Constants.TargetInformationFileName), SchemaLocation.GetWindowsFabricSchemaLocation());
                if (!string.IsNullOrEmpty(targetInformation.TargetInstallation.ClusterManifestLocation))
                {
                    var clusterManifestLocation = machineName == null ?
                                                  targetInformation.TargetInstallation.ClusterManifestLocation
                        : Helpers.GetRemotePath(targetInformation.TargetInstallation.ClusterManifestLocation, machineName);
                    serializer.Serialize(stringwriter, Utility.ReadXml <ClusterManifestType>(clusterManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()));
                    return(stringwriter.ToString());
                }
            }

            string clusterManifestFile = Helpers.GetCurrentClusterManifestPath(dataRoot);

            if (clusterManifestFile != null)
            {
                serializer.Serialize(stringwriter, Utility.ReadXml <ClusterManifestType>(clusterManifestFile, SchemaLocation.GetWindowsFabricSchemaLocation()));
                return(stringwriter.ToString());
            }

            return(null);
        }
Exemplo n.º 29
0
        /// <summary>
        /// <remarks>Adapted from DCA</remarks>
        /// </summary>
        private static void LoadManifestCache()
        {
            try
            {
                string manifestFileDirectory = FabricEnvironment.GetCodePath();

                // Get the Windows Fabric manifest file
                string manifestFile = Path.Combine(
                    manifestFileDirectory,
                    WindowsFabricManifestFileName);

                // Load the manifest
                manifestCache = new ManifestCache(Path.Combine(GetLogRoot(), WorkFolder));
                manifestCache.LoadManifest(manifestFile);
            }
            catch (Exception e)
            {
                Console.WriteLine(StringResources.EventStoreError_EventManifestLoadFailure, e.Message);
            }
        }
        private static string GetProductVersionLinux(string codePath)
        {
            var packageManagerType = FabricEnvironment.GetLinuxPackageManagerType();

            switch (packageManagerType)
            {
            case LinuxPackageManagerType.Deb:
                return(GetProductVersionFromFilename(codePath, StringConstants.Deb));

            case LinuxPackageManagerType.Rpm:
                return(GetProductVersionFromFilename(codePath, StringConstants.Rpm));

            default:
                ImageBuilderUtility.TraceAndThrowValidationError(
                    TraceType,
                    StringResources.ImageBuilderError_LinuxPackageManagerUnknown,
                    (int)packageManagerType);
                return(null);    // To please compiler
            }
        }