示例#1
0
        private static void GenerateCertGenConfigFiles(IEphemeralCluster <EphemeralClusterConfiguration> cluster,
                                                       INodeFileSystem fileSystem, string silentModeConfigFile, EphemeralClusterConfiguration config)
        {
            var silentModeConfigFileDuplicate = Path.Combine(fileSystem.ConfigPath, "x-pack", "certgen") + ".yml";
            var files = cluster.ClusterConfiguration.Version >= "6.3.0"
                                ? new[] { silentModeConfigFile }
                                : new[] { silentModeConfigFile, silentModeConfigFileDuplicate };

            cluster.Writer.WriteDiagnostic($"{{{nameof(GenerateCertificatesTask)}}} creating config files");

            foreach (var file in files)
            {
                if (!File.Exists(file))
                {
                    File.WriteAllLines(file,
                                       new[]
                    {
                        "instances:", $"    - name : \"{config.FileSystem.CertificateNodeName}\"", $"      ip:",
                        $"          - \"127.0.0.1\"", $"      dns:", $"          - \"127.0.0.1\"",
                        $"          - \"localhost\"", $"          - \"ipv4.fiddler\"",
                        $"    - name : \"{config.FileSystem.ClientCertificateName}\"", $"      ip:",
                        $"          - \"127.0.0.1\"", $"      dns:", $"          - \"localhost\"",
                        $"          - \"ipv4.fiddler\"",
                        $"      filename : \"{config.FileSystem.ClientCertificateFilename}\"",
                    });
                }
            }
        }
        public ElasticsearchNode(NodeConfiguration config, INodeFileSystem fileSystem)
        {
            this._config    = config;
            this.FileSystem = fileSystem;

            var attr             = this.Version.Major >= 5 ? "attr." : "";
            var indexedOrStored  = this.Version > new ElasticsearchVersion("5.0.0-alpha1") ? "stored" : "indexed";
            var shieldOrSecurity = this.Version > new ElasticsearchVersion("5.0.0-alpha1") ? "security" : "shield";
            var es = this.Version > new ElasticsearchVersion("5.0.0-alpha2") ? "" : "es.";

            this.DefaultNodeSettings = new List <string>
            {
                $"{es}cluster.name={this.FileSystem.ClusterName}",
                $"{es}node.name={this.FileSystem.NodeName}",
                $"{es}path.repo={this.FileSystem.RepositoryPath}",
                $"{es}path.data={Path.Combine(this.FileSystem.DataPath, this.FileSystem.ClusterName)}",
                $"{es}script.inline=true",
                $"{es}script.max_compilations_per_minute=10000",
                $"{es}script.{indexedOrStored}=true",
                $"{es}node.{attr}testingcluster=true"
            };

            if (!this.Version.IsSnapshot)
            {
                this.DefaultNodeSettings.Add($"{es}xpack.{shieldOrSecurity}.enabled={this._config.XPackEnabled.ToString().ToLowerInvariant()}");
            }

            if (this._config.RunIntegrationTests && !this._config.TestAgainstAlreadyRunningElasticsearch)
            {
                return;
            }
            this.Port = 9200;
        }
示例#3
0
        public ElasticsearchNode(NodeConfiguration config, INodeFileSystem fileSystem)
        {
            this._config    = config;
            this.FileSystem = fileSystem;

            var attr             = this.Version.Major >= 5 ? "attr." : "";
            var indexedOrStored  = this.Version > new ElasticsearchVersion("5.0.0-alpha1") ? "stored" : "indexed";
            var shieldOrSecurity = this.Version > new ElasticsearchVersion("5.0.0-alpha1") ? "security" : "shield";

            this.DefaultNodeSettings = new List <string>
            {
                $"es.cluster.name={this.FileSystem.ClusterName}",
                $"es.node.name={this.FileSystem.NodeName}",
                $"es.path.repo={this.FileSystem.RepositoryPath}",
                $"es.script.inline=true",
                $"es.script.{indexedOrStored}=true",
                $"es.node.{attr}testingcluster=true"
            };

            if (!this.Version.IsSnapshot)
            {
                this.DefaultNodeSettings.Add($"es.xpack.{shieldOrSecurity}.enabled=" + (this._config.ShieldEnabled ? "true" : "false"));
            }

            if (this._config.RunIntegrationTests)
            {
                return;
            }
            this.Port = 9200;
        }
        private static string UseHttpPluginLocation(IConsoleLineHandler writer, INodeFileSystem fileSystem, ElasticsearchPlugin plugin, ElasticVersion v)
        {
            var downloadLocation = Path.Combine(fileSystem.LocalFolder, $"{plugin.SubProductName}-{v}.zip");

            DownloadPluginSnapshot(writer, downloadLocation, plugin, v);
            //transform downloadLocation to file uri and use that to install from
            return(new Uri(new Uri("file://"), downloadLocation).AbsoluteUri);
        }
示例#5
0
        private static void PatchPlugin(ElasticVersion v, INodeFileSystem fileSystem)
        {
            var h        = fileSystem.ElasticsearchHome;
            var file     = Path.Combine(h, "bin", "x-pack", ".in.bat");
            var contents = File.ReadAllText(file);

            contents = contents.Replace("set ES_PARAMS=-Des.path.home=\"%ES_HOME%\"", "set ES_PARAMS=-Des.path.home=\"%ES_HOME%\" -Des.path.conf=\"%CONF_DIR%\"");
            File.WriteAllText(file, contents);
        }
 public MachineLearningSeeder(IElasticClient client, INodeFileSystem fileSystem)
 {
     RoamingFolder = fileSystem.LocalFolder;
     Client        = client;
 }
        private static bool AlreadyInstalled(INodeFileSystem fileSystem, string folderName)
        {
            var pluginFolder = Path.Combine(fileSystem.ElasticsearchHome, "plugins", folderName);

            return(Directory.Exists(pluginFolder));
        }
        private static void CopyHomeConfigToEphemeralConfig(IEphemeralCluster <EphemeralClusterConfiguration> cluster, EphemeralFileSystem ephemeralFileSystem, INodeFileSystem fs)
        {
            var target                  = ephemeralFileSystem.ConfigPath;
            var cachedEsHomeFolder      = Path.Combine(fs.LocalFolder, cluster.GetCacheFolderName());
            var cachedElasticsearchYaml = Path.Combine(cachedEsHomeFolder, "config", "elasticsearch.yaml");

            var homeSource = cluster.ClusterConfiguration.CacheEsHomeInstallation && File.Exists(cachedElasticsearchYaml) ? cachedEsHomeFolder : fs.ElasticsearchHome;
            var source     = Path.Combine(homeSource, "config");

            if (!Directory.Exists(source))
            {
                cluster.Writer?.WriteDiagnostic($"{{{nameof(CreateEphemeralDirectory)}}} source config {{{source}}} does not exist nothing to copy");
                return;
            }

            cluster.Writer?.WriteDiagnostic($"{{{nameof(CreateEphemeralDirectory)}}} copying cached {{{source}}} as to [{target}]");
            CopyFolder(source, target);
        }
示例#9
0
 public static AssetNavigator Assets(this INodeFileSystem NFS, SystemNode Host = null)
 => NFS.Nav <AssetNavigator>(Host ?? SystemNode.Local);