/// <summary> /// Updates a single workbook connection element in the XML to point to a different Postgres database. /// </summary> /// <param name="connectionElement"></param> /// <param name="postgresConnection"></param> /// <param name="databaseName"></param> private void ReplaceSinglePostgresConnection(XmlNode connectionElement, PostgresConnectionInfo postgresConnection, string databaseName) { if (!IsValidPostgresConnectionElement(connectionElement)) { return; } // Construct dictionary of attributes that we need to update. var connectionInfoDictionary = new Dictionary <string, string> { { "dbname", databaseName }, { "port", postgresConnection.Port.ToString() }, { "server", postgresConnection.Hostname }, { "username", postgresConnection.Username }, { "password", postgresConnection.Password } }; // Update the element to reflect the new connection information. foreach (var key in connectionInfoDictionary.Keys) { if (connectionElement.Attributes[key] != null) { // Substitute the old value with the new one. connectionElement.Attributes[key].Value = connectionInfoDictionary[key]; } else { // Attribute does not already exist -- create it and append it. var attribute = WorkbookXml.CreateAttribute(key); attribute.Value = connectionInfoDictionary[key]; connectionElement.Attributes.Append(attribute); } } }
/// <summary> /// Update all the Postgres connection XML nodes to point to a different backing database. /// </summary> /// <param name="postgresConnection">The connection information about the Postgres server.</param> /// <param name="databaseName">The database name to link up to.</param> public XmlDocument UpdatePostgresConnections(PostgresConnectionInfo postgresConnection, string databaseName) { if (WorkbookXml == null) { return(WorkbookXml); } XmlNode root = WorkbookXml.DocumentElement; if (root == null) { return(WorkbookXml); } XmlNodeList connectionElements = root.SelectNodes(ConnectionElementXpath); if (connectionElements == null) { // No connections to edit; nothing to do. return(WorkbookXml); } foreach (XmlNode connectionElement in connectionElements) { UpdatePostgresConnection(connectionElement, postgresConnection, databaseName); } return(WorkbookXml); }
public LogsharkConfiguration(LogsharkConfig config) { MongoConnectionInfo = new MongoConnectionInfo(config.MongoConnection); PostgresConnectionInfo = new PostgresConnectionInfo(config.PostgresConnection); TableauConnectionInfo = new TableauServerConnectionInfo(config.TableauConnection); LocalMongoOptions = new LogsharkLocalMongoOptions(config.RunOptions.LocalMongo); TuningOptions = new LogsharkTuningOptions(config.RunOptions.Tuning); ArtifactProcessorOptions = new LogsharkArtifactProcessorOptions(config.ArtifactProcessorOptions); }
public override string ToString() { var postgresConnectionInfo = PostgresConnectionInfo.Match(connection => connection.ToString(), () => "Unspecified"); return($"[MongoConnectionInfo='{MongoConnectionInfo}', PostgresConnectionInfo='{postgresConnectionInfo}', " + $"TableauServerConnectionInfo='{TableauConnectionInfo}', DataRetentionOptions='{DataRetentionOptions}', " + $"LocalMongoOptions='{LocalMongoOptions}', TuningOptions='{TuningOptions}', " + $"ArtifactProcessorOptions='{ArtifactProcessorOptions}', ApplicationTempDirectory='{ApplicationTempDirectory}']"); }
/// <summary> /// Updates a single workbook connection element in the XML to point to a different Postgres database. /// </summary> private XmlNode UpdatePostgresConnection(XmlNode connectionElement, PostgresConnectionInfo postgresConnection, string databaseName) { if (!IsValidPostgresConnectionElement(connectionElement)) { return(connectionElement); } // Construct dictionary of attributes that we need to update. var connectionInfoDictionary = new Dictionary <string, string> { { "dbname", databaseName }, { "port", postgresConnection.Port.ToString() }, { "server", postgresConnection.Hostname }, { "username", postgresConnection.Username }, { "password", postgresConnection.Password } }; // Workbooks cannot be published to Tableau Server if their datasource is pointing to an explicitly local resource, so we make a good-faith effort to update their connections to a resolved hostname. if (postgresConnection.Hostname.Equals("localhost", StringComparison.OrdinalIgnoreCase) || postgresConnection.Hostname.Equals("127.0.0.1")) { try { IPHostEntry hostEntry = Dns.GetHostEntry(postgresConnection.Hostname); if (!String.IsNullOrWhiteSpace(hostEntry.HostName)) { connectionInfoDictionary["server"] = hostEntry.HostName; } } catch (Exception ex) { Log.WarnFormat("Unable to resolve configured self-referential Postgres hostname '{0}' to an externally-resolvable hostname: {1}. Resulting workbook cannot be published to Tableau Server.", postgresConnection.Hostname, ex.Message); } } // Update the element to reflect the new connection information. foreach (var key in connectionInfoDictionary.Keys) { if (connectionElement.Attributes[key] != null) { // Substitute the old value with the new one. connectionElement.Attributes[key].Value = connectionInfoDictionary[key]; } else { // Attribute does not already exist -- create it and append it. var attribute = WorkbookXml.CreateAttribute(key); attribute.Value = connectionInfoDictionary[key]; connectionElement.Attributes.Append(attribute); } } return(connectionElement); }
public LogsharkConfiguration(LogsharkConfig config) { MongoConnectionInfo = new MongoConnectionInfo(config.MongoConnection); PostgresConnectionInfo = new PostgresConnectionInfo(config.PostgresConnection); TableauConnectionInfo = new TableauConnectionInfo(config.TableauConnection); LocalMongoOptions = new LogsharkLocalMongoOptions(config.RunOptions.LocalMongo); TuningOptions = new LogsharkTuningOptions(config.RunOptions.Tuning); DefaultPlugins = new HashSet <string>(); foreach (Plugin plugin in config.PluginOptions.DefaultPlugins) { DefaultPlugins.Add(plugin.Name); } }
public LogsharkRunMetadataWriter(PostgresConnectionInfo postgresConnectionInfo) { connectionFactory = postgresConnectionInfo.GetConnectionFactory(CoreConstants.LOGSHARK_METADATA_DATABASE_NAME); InitializeTables(); }
public WorkbookPublisher(LogsharkRequest logsharkRequest) { this.logsharkRequest = logsharkRequest; tableauConnectionInfo = logsharkRequest.Configuration.TableauConnectionInfo; postgresConnectionInfo = logsharkRequest.Configuration.PostgresConnectionInfo; }
public PluginExecutor(LogsharkConfiguration config) { mongoConnectionInfo = config.MongoConnectionInfo; postgresConnectionInfo = config.PostgresConnectionInfo; tableauConnectionInfo = config.TableauConnectionInfo; }
public LogsharkRunMetadataPostgresWriter(PostgresConnectionInfo postgresConnectionInfo) { connectionFactory = postgresConnectionInfo.GetConnectionFactory(LogsharkMetadataDatabaseName); }