LogstashUI 0.5.5.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AI/__init__.py +0 -0
- AI/integration_factory.py +1392 -0
- AI/migrations/0001_initial.py +58 -0
- AI/migrations/0002_draftdefinition_normalizers.py +23 -0
- AI/migrations/0003_delete_aisettings_delete_draftdefinition.py +19 -0
- AI/migrations/__init__.py +0 -0
- AI/models.py +5 -0
- AI/static/js/integration_factory.js +1102 -0
- AI/system_prompts/dashboard_generator.md +367 -0
- AI/system_prompts/grok_patterns.txt +95 -0
- AI/system_prompts/ingest_pipeline_generator.md +331 -0
- AI/system_prompts/ingest_pipeline_processors.json +2851 -0
- AI/system_prompts/ingest_verifier.md +84 -0
- AI/system_prompts/integrations_list.json +2690 -0
- AI/system_prompts/log_classifier.md +134 -0
- AI/system_prompts/template_creator.md +123 -0
- AI/templates/integration_factory.html +200 -0
- AI/urls.py +16 -0
- AI/views.py +20 -0
- API/__init__.py +0 -0
- API/admin.py +7 -0
- API/api.http +784 -0
- API/apps.py +9 -0
- API/auth.py +101 -0
- API/connections_views.py +312 -0
- API/guides.py +88 -0
- API/mcp/__init__.py +5 -0
- API/mcp/dispatch.py +179 -0
- API/mcp/tools.py +890 -0
- API/mcp/views.py +215 -0
- API/migrations/__init__.py +0 -0
- API/models.py +7 -0
- API/pipelines_views.py +1224 -0
- API/policies_views.py +1015 -0
- API/security_views.py +488 -0
- API/simulation_detail.py +219 -0
- API/snmp_views.py +1539 -0
- API/urls.py +81 -0
- Common/__init__.py +0 -0
- Common/ai/agent_builder.py +690 -0
- Common/context_processors.py +49 -0
- Common/decorators.py +68 -0
- Common/elastic_utils.py +1154 -0
- Common/encryption.py +271 -0
- Common/error_handlers.py +65 -0
- Common/formatters.py +106 -0
- Common/logstash_config_parse.py +1469 -0
- Common/logstash_utils.py +34 -0
- Common/middleware.py +216 -0
- Common/product_ca.py +1124 -0
- Common/validators.py +66 -0
- Documentation/__init__.py +0 -0
- Documentation/admin.py +7 -0
- Documentation/apps.py +9 -0
- Documentation/content/CHANGELOG.md +890 -0
- Documentation/content/docs/getting_started.md +92 -0
- Documentation/content/docs/index.md +124 -0
- Documentation/content/docs/logstashagent/configuration/index.md +60 -0
- Documentation/content/docs/logstashagent/configuration/logstashagent.yml.md +141 -0
- Documentation/content/docs/logstashagent/general/build.md +217 -0
- Documentation/content/docs/logstashagent/general/index.md +38 -0
- Documentation/content/docs/logstashagent/general/roles.md +267 -0
- Documentation/content/docs/logstashagent/index.md +264 -0
- Documentation/content/docs/logstashui/SNMP/Quickstart.md +94 -0
- Documentation/content/docs/logstashui/SNMP/architecture.md +64 -0
- Documentation/content/docs/logstashui/SNMP/configuration.md +147 -0
- Documentation/content/docs/logstashui/SNMP/data_overview.md +59 -0
- Documentation/content/docs/logstashui/SNMP/deploying_changes.md +71 -0
- Documentation/content/docs/logstashui/SNMP/device_support.md +39 -0
- Documentation/content/docs/logstashui/SNMP/discovery.md +48 -0
- Documentation/content/docs/logstashui/SNMP/index.md +58 -0
- Documentation/content/docs/logstashui/SNMP/pipeline_generation.md +63 -0
- Documentation/content/docs/logstashui/SNMP/schema.md +595 -0
- Documentation/content/docs/logstashui/SNMP/testing.md +47 -0
- Documentation/content/docs/logstashui/SNMP/traps.md +45 -0
- Documentation/content/docs/logstashui/SNMP/tsds_implementation.md +82 -0
- Documentation/content/docs/logstashui/agent_guides/concepts.md +25 -0
- Documentation/content/docs/logstashui/agent_guides/deploy.md +30 -0
- Documentation/content/docs/logstashui/agent_guides/pipeline-review.md +24 -0
- Documentation/content/docs/logstashui/agent_guides/simulation.md +55 -0
- Documentation/content/docs/logstashui/agent_guides/snmp.md +57 -0
- Documentation/content/docs/logstashui/agent_guides/troubleshooting.md +21 -0
- Documentation/content/docs/logstashui/architecture.md +11 -0
- Documentation/content/docs/logstashui/compatibility.md +58 -0
- Documentation/content/docs/logstashui/configuration/environment.md +193 -0
- Documentation/content/docs/logstashui/configuration/host_mode.md +94 -0
- Documentation/content/docs/logstashui/configuration/index.md +72 -0
- Documentation/content/docs/logstashui/configuration/logstash_proxy.md +138 -0
- Documentation/content/docs/logstashui/configuration/logstashui.yml.md +16 -0
- Documentation/content/docs/logstashui/configuration/simulation.md +84 -0
- Documentation/content/docs/logstashui/database/examples/README.md +15 -0
- Documentation/content/docs/logstashui/database/examples/create-mariadb.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/create-mysql.sql +12 -0
- Documentation/content/docs/logstashui/database/examples/create-postgresql.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/schema-mysql.sql +502 -0
- Documentation/content/docs/logstashui/database/examples/schema-postgresql.sql +1709 -0
- Documentation/content/docs/logstashui/database/index.md +79 -0
- Documentation/content/docs/logstashui/database/migration.md +75 -0
- Documentation/content/docs/logstashui/general/build.md +154 -0
- Documentation/content/docs/logstashui/general/deploy.md +122 -0
- Documentation/content/docs/logstashui/general/deployment-recs.md +32 -0
- Documentation/content/docs/logstashui/general/index.md +62 -0
- Documentation/content/docs/logstashui/general/offline.md +68 -0
- Documentation/content/docs/logstashui/general/updating.md +50 -0
- Documentation/content/docs/logstashui/index.md +90 -0
- Documentation/content/docs/logstashui/kubernetes/cnpg.md +98 -0
- Documentation/content/docs/logstashui/kubernetes/envoy-gateway.md +112 -0
- Documentation/content/docs/logstashui/kubernetes/examples/README.md +46 -0
- Documentation/content/docs/logstashui/kubernetes/examples/embedded-agent.yaml +122 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +41 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +25 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +42 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +35 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +18 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/index.md +121 -0
- Documentation/content/docs/logstashui/mcp.md +224 -0
- Documentation/content/docs/logstashui/mcp_scenarios.md +234 -0
- Documentation/content/docs/logstashui/rest_api.md +2783 -0
- Documentation/content/docs/logstashui/utilities/dissect_debugger.md +89 -0
- Documentation/content/docs/logstashui/utilities/grok_debugger.md +114 -0
- Documentation/content/docs/logstashui/utilities/index.md +40 -0
- Documentation/content/images/LogstashIcon.png +0 -0
- Documentation/content/images/architecture.png +0 -0
- Documentation/content/images/connection_manager.png +0 -0
- Documentation/content/images/control_plane.png +0 -0
- Documentation/content/images/graph.gif +0 -0
- Documentation/content/images/login.png +0 -0
- Documentation/content/images/monitoring.png +0 -0
- Documentation/content/images/new_connection.gif +0 -0
- Documentation/content/images/simulate.gif +0 -0
- Documentation/content/images/simulate.png +0 -0
- Documentation/content/images/snmp.gif +0 -0
- Documentation/content/images/snmp.png +0 -0
- Documentation/content/images/snmp_architecture.png +0 -0
- Documentation/migrations/__init__.py +0 -0
- Documentation/models.py +9 -0
- Documentation/static/css/markdown.css +250 -0
- Documentation/templates/documentation.html +225 -0
- Documentation/templates/nav_item.html +41 -0
- Documentation/urls.py +11 -0
- Documentation/views.py +442 -0
- LogstashUI/__init__.py +0 -0
- LogstashUI/__main__.py +10 -0
- LogstashUI/asgi.py +16 -0
- LogstashUI/cli.py +626 -0
- LogstashUI/config.py +116 -0
- LogstashUI/database.py +263 -0
- LogstashUI/insecure_http.py +117 -0
- LogstashUI/logging_config.py +99 -0
- LogstashUI/migrate_engine.py +282 -0
- LogstashUI/packaging/__init__.py +3 -0
- LogstashUI/packaging/logstashui.default +68 -0
- LogstashUI/packaging/logstashui.service.in +22 -0
- LogstashUI/paths.py +181 -0
- LogstashUI/settings.py +437 -0
- LogstashUI/telemetry.py +159 -0
- LogstashUI/urls.py +56 -0
- LogstashUI/wsgi.py +77 -0
- Management/__init__.py +0 -0
- Management/apps.py +10 -0
- Management/migrations/0001_initial.py +29 -0
- Management/migrations/0002_settings.py +25 -0
- Management/migrations/0003_settings_agent_ui_url.py +29 -0
- Management/migrations/0004_settings_logstash_artifact_base_url.py +29 -0
- Management/migrations/__init__.py +0 -0
- Management/models.py +92 -0
- Management/templates/api_tokens.html +214 -0
- Management/templates/components/api_token_created.html +38 -0
- Management/templates/components/api_token_row.html +84 -0
- Management/templates/components/logstash_artifact_row.html +100 -0
- Management/templates/components/logstash_artifact_tbody.html +26 -0
- Management/templates/components/user_row.html +67 -0
- Management/templates/logs.html +98 -0
- Management/templates/logstash_artifacts.html +172 -0
- Management/templates/management.html +80 -0
- Management/templates/management_settings.html +320 -0
- Management/templates/registration/login.html +404 -0
- Management/templates/users.html +304 -0
- Management/urls.py +23 -0
- Management/views.py +804 -0
- Monitoring/__init__.py +0 -0
- Monitoring/apps.py +9 -0
- Monitoring/migrations/__init__.py +0 -0
- Monitoring/static/js/monitoring.js +463 -0
- Monitoring/templates/components/node_metrics.html +161 -0
- Monitoring/templates/components/pipeline_metrics.html +189 -0
- Monitoring/templates/monitoring.html +271 -0
- Monitoring/urls.py +16 -0
- Monitoring/views.py +724 -0
- PipelineManager/__init__.py +0 -0
- PipelineManager/agent_api.py +1173 -0
- PipelineManager/agent_client.py +59 -0
- PipelineManager/agent_modes.py +880 -0
- PipelineManager/agent_policies.py +689 -0
- PipelineManager/agent_versions.py +151 -0
- PipelineManager/apps.py +10 -0
- PipelineManager/artifact_metrics.py +171 -0
- PipelineManager/artifacts.py +820 -0
- PipelineManager/connections_crud.py +722 -0
- PipelineManager/data/default_jvm.options +76 -0
- PipelineManager/data/default_log4j2.properties +165 -0
- PipelineManager/data/default_logstash.yml +405 -0
- PipelineManager/data/plugins.json +29109 -0
- PipelineManager/editor_views.py +608 -0
- PipelineManager/forms.py +284 -0
- PipelineManager/manager_views.py +490 -0
- PipelineManager/migrations/0001_initial.py +38 -0
- PipelineManager/migrations/0002_alter_connection_connection_type_and_more.py +38 -0
- PipelineManager/migrations/0003_policy_connection_policy.py +38 -0
- PipelineManager/migrations/0004_policy_current_revision_number_and_more.py +75 -0
- PipelineManager/migrations/0005_apikey_enrollmenttoken.py +38 -0
- PipelineManager/migrations/0006_enrollmenttoken_name.py +18 -0
- PipelineManager/migrations/0007_alter_enrollmenttoken_options_and_more.py +21 -0
- PipelineManager/migrations/0008_connection_agent_id.py +18 -0
- PipelineManager/migrations/0009_connection_last_check_in_policy_jvm_options_hash_and_more.py +33 -0
- PipelineManager/migrations/0010_keystore_revision_number_pipeline_revision_number.py +23 -0
- PipelineManager/migrations/0011_keystore_kv_hash.py +18 -0
- PipelineManager/migrations/0012_policy_binary_path.py +18 -0
- PipelineManager/migrations/0013_connection_status_blob.py +18 -0
- PipelineManager/migrations/0014_pipeline_pipeline_batch_delay_and_more.py +43 -0
- PipelineManager/migrations/0015_add_pipeline_hash.py +18 -0
- PipelineManager/migrations/0016_backfill_pipeline_hash.py +32 -0
- PipelineManager/migrations/0017_policy_keystore_password.py +31 -0
- PipelineManager/migrations/0018_policy_last_deployed_at.py +18 -0
- PipelineManager/migrations/0019_connection_restart_on_next_checkin.py +18 -0
- PipelineManager/migrations/0020_pipeline_no_input_pipeline_non_reloadable.py +23 -0
- PipelineManager/migrations/0021_connection_desired_agent_version.py +18 -0
- PipelineManager/migrations/0022_keystore_managed_by_pipeline_managed_by.py +23 -0
- PipelineManager/migrations/0023_agent_modes_policy_connection.py +89 -0
- PipelineManager/migrations/0024_seed_system_policies.py +173 -0
- PipelineManager/migrations/0025_packaged_managed_policy_types.py +166 -0
- PipelineManager/migrations/0026_normalize_opt_logstash_agent_paths.py +63 -0
- PipelineManager/migrations/0027_packaged_managed_default_ports.py +49 -0
- PipelineManager/migrations/0028_apikey_admin_tokens.py +80 -0
- PipelineManager/migrations/0029_logstash_artifacts.py +45 -0
- PipelineManager/migrations/0030_connection_allow_self_signed_certs.py +33 -0
- PipelineManager/migrations/0031_deploy_system_policies.py +93 -0
- PipelineManager/migrations/0032_connection_agent_inbound_key.py +30 -0
- PipelineManager/migrations/0033_simulation_result.py +26 -0
- PipelineManager/migrations/__init__.py +0 -0
- PipelineManager/models.py +1300 -0
- PipelineManager/pipelines_crud.py +738 -0
- PipelineManager/policies_crud.py +772 -0
- PipelineManager/sim_keystore.py +319 -0
- PipelineManager/simulation.py +1581 -0
- PipelineManager/static/css/codemirror.min.css +1 -0
- PipelineManager/static/css/graph_move.css +79 -0
- PipelineManager/static/css/monokai.min.css +1 -0
- PipelineManager/static/css/move_mode.css +144 -0
- PipelineManager/static/css/show-hint.min.css +1 -0
- PipelineManager/static/images/age.png +0 -0
- PipelineManager/static/images/aggregate.png +0 -0
- PipelineManager/static/images/alter.png +0 -0
- PipelineManager/static/images/azure_event_hubs.png +0 -0
- PipelineManager/static/images/beats.png +0 -0
- PipelineManager/static/images/boundary.png +0 -0
- PipelineManager/static/images/bytes.png +0 -0
- PipelineManager/static/images/cidr.png +0 -0
- PipelineManager/static/images/cipher.png +0 -0
- PipelineManager/static/images/circonus.png +0 -0
- PipelineManager/static/images/clone.png +0 -0
- PipelineManager/static/images/cloudwatch.png +0 -0
- PipelineManager/static/images/comment.png +0 -0
- PipelineManager/static/images/continue.png +0 -0
- PipelineManager/static/images/couchdb_changes.png +0 -0
- PipelineManager/static/images/csv.png +0 -0
- PipelineManager/static/images/datadog.png +0 -0
- PipelineManager/static/images/datadog_metrics.png +0 -0
- PipelineManager/static/images/date.png +0 -0
- PipelineManager/static/images/de_dot.png +0 -0
- PipelineManager/static/images/dead_letter_queue.png +0 -0
- PipelineManager/static/images/dissect.png +0 -0
- PipelineManager/static/images/dns.png +0 -0
- PipelineManager/static/images/drop.png +0 -0
- PipelineManager/static/images/dynatrace.png +0 -0
- PipelineManager/static/images/elapsed.png +0 -0
- PipelineManager/static/images/elastic_agent.png +0 -0
- PipelineManager/static/images/elastic_integration.png +0 -0
- PipelineManager/static/images/elastic_serverless_forwarder.png +0 -0
- PipelineManager/static/images/elastic_workplace_search.png +0 -0
- PipelineManager/static/images/elasticsearch.png +0 -0
- PipelineManager/static/images/else.png +0 -0
- PipelineManager/static/images/else_if.png +0 -0
- PipelineManager/static/images/email.png +0 -0
- PipelineManager/static/images/environment.png +0 -0
- PipelineManager/static/images/exec.png +0 -0
- PipelineManager/static/images/extractnumbers.png +0 -0
- PipelineManager/static/images/file.png +0 -0
- PipelineManager/static/images/fingerprint.png +0 -0
- PipelineManager/static/images/ganglia.png +0 -0
- PipelineManager/static/images/gelf.png +0 -0
- PipelineManager/static/images/generator.png +0 -0
- PipelineManager/static/images/geoip.png +0 -0
- PipelineManager/static/images/github.png +0 -0
- PipelineManager/static/images/google_bigquery.png +0 -0
- PipelineManager/static/images/google_cloud_storage.png +0 -0
- PipelineManager/static/images/google_pubsub.png +0 -0
- PipelineManager/static/images/graphite.png +0 -0
- PipelineManager/static/images/graphtastic.png +0 -0
- PipelineManager/static/images/grok.png +0 -0
- PipelineManager/static/images/heartbeat.png +0 -0
- PipelineManager/static/images/http.png +0 -0
- PipelineManager/static/images/http_poller.png +0 -0
- PipelineManager/static/images/i18n.png +0 -0
- PipelineManager/static/images/if.png +0 -0
- PipelineManager/static/images/imap.png +0 -0
- PipelineManager/static/images/influxdb.png +0 -0
- PipelineManager/static/images/irc.png +0 -0
- PipelineManager/static/images/java_generator.png +0 -0
- PipelineManager/static/images/java_stdin.png +0 -0
- PipelineManager/static/images/java_stdout.png +0 -0
- PipelineManager/static/images/java_uuid.png +0 -0
- PipelineManager/static/images/jdbc.png +0 -0
- PipelineManager/static/images/jdbc_static.png +0 -0
- PipelineManager/static/images/jdbc_streaming.png +0 -0
- PipelineManager/static/images/jms.png +0 -0
- PipelineManager/static/images/jmx.png +0 -0
- PipelineManager/static/images/json.png +0 -0
- PipelineManager/static/images/json_encode.png +0 -0
- PipelineManager/static/images/juggernaut.png +0 -0
- PipelineManager/static/images/kafka.png +0 -0
- PipelineManager/static/images/kinesis.png +0 -0
- PipelineManager/static/images/kv.png +0 -0
- PipelineManager/static/images/librato.png +0 -0
- PipelineManager/static/images/log4j.png +0 -0
- PipelineManager/static/images/loggly.png +0 -0
- PipelineManager/static/images/logstash.png +0 -0
- PipelineManager/static/images/lumberjack.png +0 -0
- PipelineManager/static/images/meetup.png +0 -0
- PipelineManager/static/images/memcached.png +0 -0
- PipelineManager/static/images/metriccatcher.png +0 -0
- PipelineManager/static/images/metricize.png +0 -0
- PipelineManager/static/images/metrics.png +0 -0
- PipelineManager/static/images/mongodb.png +0 -0
- PipelineManager/static/images/mutate.png +0 -0
- PipelineManager/static/images/nagios.png +0 -0
- PipelineManager/static/images/nagios_nsca.png +0 -0
- PipelineManager/static/images/opentsdb.png +0 -0
- PipelineManager/static/images/pagerduty.png +0 -0
- PipelineManager/static/images/pipe.png +0 -0
- PipelineManager/static/images/pipeline.png +0 -0
- PipelineManager/static/images/prune.png +0 -0
- PipelineManager/static/images/puppet_facter.png +0 -0
- PipelineManager/static/images/rabbitmq.png +0 -0
- PipelineManager/static/images/range.png +0 -0
- PipelineManager/static/images/redis.png +0 -0
- PipelineManager/static/images/redmine.png +0 -0
- PipelineManager/static/images/relp.png +0 -0
- PipelineManager/static/images/riak.png +0 -0
- PipelineManager/static/images/riemann.png +0 -0
- PipelineManager/static/images/rss.png +0 -0
- PipelineManager/static/images/ruby.png +0 -0
- PipelineManager/static/images/s3-sns-sqs.png +0 -0
- PipelineManager/static/images/s3.png +0 -0
- PipelineManager/static/images/salesforce.png +0 -0
- PipelineManager/static/images/sink.png +0 -0
- PipelineManager/static/images/sleep.png +0 -0
- PipelineManager/static/images/snmp.png +0 -0
- PipelineManager/static/images/snmptrap.png +0 -0
- PipelineManager/static/images/sns.png +0 -0
- PipelineManager/static/images/solr_http.png +0 -0
- PipelineManager/static/images/split.png +0 -0
- PipelineManager/static/images/sqlite.png +0 -0
- PipelineManager/static/images/sqs.png +0 -0
- PipelineManager/static/images/statsd.png +0 -0
- PipelineManager/static/images/stdin.png +0 -0
- PipelineManager/static/images/stdout.png +0 -0
- PipelineManager/static/images/stomp.png +0 -0
- PipelineManager/static/images/syslog.png +0 -0
- PipelineManager/static/images/syslog_pri.png +0 -0
- PipelineManager/static/images/tcp.png +0 -0
- PipelineManager/static/images/threats_classifier.png +0 -0
- PipelineManager/static/images/throttle.png +0 -0
- PipelineManager/static/images/timber.png +0 -0
- PipelineManager/static/images/tld.png +0 -0
- PipelineManager/static/images/translate.png +0 -0
- PipelineManager/static/images/truncate.png +0 -0
- PipelineManager/static/images/twitter.png +0 -0
- PipelineManager/static/images/udp.png +0 -0
- PipelineManager/static/images/unix.png +0 -0
- PipelineManager/static/images/urldecode.png +0 -0
- PipelineManager/static/images/useragent.png +0 -0
- PipelineManager/static/images/uuid.png +0 -0
- PipelineManager/static/images/varnishlog.png +0 -0
- PipelineManager/static/images/webhdfs.png +0 -0
- PipelineManager/static/images/websocket.png +0 -0
- PipelineManager/static/images/wmi.png +0 -0
- PipelineManager/static/images/wurfl_device_detection.png +0 -0
- PipelineManager/static/images/xml.png +0 -0
- PipelineManager/static/images/xmpp.png +0 -0
- PipelineManager/static/images/zabbix.png +0 -0
- PipelineManager/static/js/agent_inspect_modal.js +141 -0
- PipelineManager/static/js/agent_policies.js +3746 -0
- PipelineManager/static/js/agent_status_sse.js +166 -0
- PipelineManager/static/js/codemirror.min.js +1 -0
- PipelineManager/static/js/connections_table.js +551 -0
- PipelineManager/static/js/d3.v7.js +20625 -0
- PipelineManager/static/js/diff_modal.js +995 -0
- PipelineManager/static/js/expression_editor.js +291 -0
- PipelineManager/static/js/js-yaml.min.js +1 -0
- PipelineManager/static/js/logstashyml_guides.js +1063 -0
- PipelineManager/static/js/move_graph.js +577 -0
- PipelineManager/static/js/move_mode.js +559 -0
- PipelineManager/static/js/pipeline_editor.js +4102 -0
- PipelineManager/static/js/pipeline_graph_editor.js +3542 -0
- PipelineManager/static/js/pipeline_list.js +274 -0
- PipelineManager/static/js/pipeline_settings.js +121 -0
- PipelineManager/static/js/pipeline_text_editor.js +2088 -0
- PipelineManager/static/js/plugin_config_modal.js +2827 -0
- PipelineManager/static/js/policy_deploy_modal.js +1066 -0
- PipelineManager/static/js/show-hint.min.js +1 -0
- PipelineManager/static/js/sim_targets.js +380 -0
- PipelineManager/static/js/simple-comment-mode.js +56 -0
- PipelineManager/static/js/simulation_modal.js +1135 -0
- PipelineManager/static/js/simulation_results.js +2778 -0
- PipelineManager/static/js/stats_strip.js +231 -0
- PipelineManager/static/js/yaml.js +120 -0
- PipelineManager/system_policy_defaults.py +279 -0
- PipelineManager/templates/components/pipeline_editor/diff_modal.html +127 -0
- PipelineManager/templates/components/pipeline_editor/expression_editor.html +160 -0
- PipelineManager/templates/components/pipeline_editor/plugin_config_modal.html +119 -0
- PipelineManager/templates/components/pipeline_editor/plugin_modal.html +1016 -0
- PipelineManager/templates/components/pipeline_editor/simulation_modal.html +394 -0
- PipelineManager/templates/components/pipeline_editor/simulation_results.html +123 -0
- PipelineManager/templates/components/pipeline_editor/stats_strip.html +123 -0
- PipelineManager/templates/components/pipeline_editor/view_code_modal.html +133 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_content.html +805 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_modal.html +40 -0
- PipelineManager/templates/components/pipeline_manager/agent_policies.html +2421 -0
- PipelineManager/templates/components/pipeline_manager/change_policy_modal.html +210 -0
- PipelineManager/templates/components/pipeline_manager/collapsible_row.html +11 -0
- PipelineManager/templates/components/pipeline_manager/connection_modal.html +1361 -0
- PipelineManager/templates/components/pipeline_manager/keystore_modal.html +269 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/centralized_pipeline_management.html +291 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/default.html +166 -0
- PipelineManager/templates/components/pipeline_manager/mcp_modal.html +241 -0
- PipelineManager/templates/components/pipeline_manager/pipeline_list_content.html +586 -0
- PipelineManager/templates/components/pipeline_manager/policy_deploy_modal.html +238 -0
- PipelineManager/templates/pipeline_editor.html +1738 -0
- PipelineManager/templates/pipeline_graph_editor.html +99 -0
- PipelineManager/templates/pipeline_manager.html +584 -0
- PipelineManager/templates/pipeline_text_editor.html +350 -0
- PipelineManager/urls.py +99 -0
- SNMP/__init__.py +0 -0
- SNMP/ai_template_generation.py +232 -0
- SNMP/apps.py +9 -0
- SNMP/assets/device_template_generation/agents/snmp-profile-author.json +15 -0
- SNMP/assets/device_template_generation/skills/snmp-catalog.json +9 -0
- SNMP/data/authoring_instructions.md +65 -0
- SNMP/data/grounding/.gitignore +4 -0
- SNMP/data/grounding/build_grounding.py +35 -0
- SNMP/data/grounding/grounding.json +1 -0
- SNMP/data/grounding/sample_agent_payload.cisco2960x.json +2184 -0
- SNMP/data/mib_reference/std_bgp4_mib.json +43 -0
- SNMP/data/mib_reference/std_entity_sensors.json +28 -0
- SNMP/data/mib_reference/std_host_resources.json +32 -0
- SNMP/data/mib_reference/std_ospf_mib.json +55 -0
- SNMP/data/mib_reference/std_ucd_linux.json +27 -0
- SNMP/data/normalizers.json +103 -0
- SNMP/data/official_device_templates/arista_eos.json +24 -0
- SNMP/data/official_device_templates/aruba_wireless_controller.json +23 -0
- SNMP/data/official_device_templates/brocade_fc_switch.json +20 -0
- SNMP/data/official_device_templates/cisco_ios.json +21 -0
- SNMP/data/official_device_templates/default.json +13 -0
- SNMP/data/official_device_templates/dell_idrac.json +22 -0
- SNMP/data/official_device_templates/dell_x1026.json +16 -0
- SNMP/data/official_device_templates/dlink_dgs1210_switch.json +19 -0
- SNMP/data/official_device_templates/eastpower_ups.json +20 -0
- SNMP/data/official_device_templates/eaton_ups.json +22 -0
- SNMP/data/official_device_templates/epson_printer.json +18 -0
- SNMP/data/official_device_templates/geist_watchdog.json +20 -0
- SNMP/data/official_device_templates/generic_linux.json +18 -0
- SNMP/data/official_device_templates/generic_ont.json +18 -0
- SNMP/data/official_device_templates/generic_ups.json +16 -0
- SNMP/data/official_device_templates/hp_laserjet_mfp_m281cdw.json +18 -0
- SNMP/data/official_device_templates/hpe_nimble.json +17 -0
- SNMP/data/official_device_templates/huawei_ups.json +19 -0
- SNMP/data/official_device_templates/ingrasys_ups.json +19 -0
- SNMP/data/official_device_templates/isilon_onefs.json +22 -0
- SNMP/data/official_device_templates/mellanox_sx6036.json +20 -0
- SNMP/data/official_device_templates/netapp_7mode.json +22 -0
- SNMP/data/official_device_templates/palo_alto_firewall.json +21 -0
- SNMP/data/official_device_templates/phoenixtec_ups.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_ap.json +19 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_udm.json +19 -0
- SNMP/data/official_device_templates/versa_flexvnf_appliance.json +19 -0
- SNMP/data/official_profiles/arista_eos.json +16 -0
- SNMP/data/official_profiles/aruba_wireless_controller.json +145 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_fibre_channel_ports.json +35 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_name_server.json +23 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_system_metrics.json +36 -0
- SNMP/data/official_profiles/cisco_cdp.json +26 -0
- SNMP/data/official_profiles/cisco_fans.json +18 -0
- SNMP/data/official_profiles/cisco_sensors.json +21 -0
- SNMP/data/official_profiles/cisco_system_metrics.json +40 -0
- SNMP/data/official_profiles/dell_idrac_cpu.json +19 -0
- SNMP/data/official_profiles/dell_idrac_fans.json +20 -0
- SNMP/data/official_profiles/dell_idrac_global_status.json +13 -0
- SNMP/data/official_profiles/dell_idrac_memory.json +20 -0
- SNMP/data/official_profiles/dell_idrac_power_supply.json +19 -0
- SNMP/data/official_profiles/dell_idrac_raid_controller.json +19 -0
- SNMP/data/official_profiles/dlink_dgs1210.json +15 -0
- SNMP/data/official_profiles/dlink_dgs1210_system_metrics.json +38 -0
- SNMP/data/official_profiles/eaton_ups.json +40 -0
- SNMP/data/official_profiles/geist_environment.json +50 -0
- SNMP/data/official_profiles/generic_arp.json +19 -0
- SNMP/data/official_profiles/generic_bgp.json +24 -0
- SNMP/data/official_profiles/generic_entity_psu.json +26 -0
- SNMP/data/official_profiles/generic_entity_sensor.json +22 -0
- SNMP/data/official_profiles/generic_host_system_metrics.json +68 -0
- SNMP/data/official_profiles/generic_interfaces.json +86 -0
- SNMP/data/official_profiles/generic_ip_addr.json +19 -0
- SNMP/data/official_profiles/generic_lldp.json +54 -0
- SNMP/data/official_profiles/generic_lm_sensors.json +37 -0
- SNMP/data/official_profiles/generic_mac_table.json +19 -0
- SNMP/data/official_profiles/generic_ont.json +88 -0
- SNMP/data/official_profiles/generic_ospf.json +21 -0
- SNMP/data/official_profiles/generic_printer_mib.json +48 -0
- SNMP/data/official_profiles/generic_rmon.json +38 -0
- SNMP/data/official_profiles/generic_system.json +17 -0
- SNMP/data/official_profiles/generic_ucd_system_metrics.json +63 -0
- SNMP/data/official_profiles/generic_ups_mib.json +154 -0
- SNMP/data/official_profiles/hpe_nimble_volumes.json +59 -0
- SNMP/data/official_profiles/huawei_ups.json +111 -0
- SNMP/data/official_profiles/isilon_performance.json +92 -0
- SNMP/data/official_profiles/isilon_protocols.json +77 -0
- SNMP/data/official_profiles/isilon_system.json +86 -0
- SNMP/data/official_profiles/mellanox_mlnx_os.json +15 -0
- SNMP/data/official_profiles/netapp_7mode_data_protection.json +106 -0
- SNMP/data/official_profiles/netapp_7mode_disks.json +51 -0
- SNMP/data/official_profiles/netapp_7mode_protocols.json +66 -0
- SNMP/data/official_profiles/netapp_7mode_system.json +92 -0
- SNMP/data/official_profiles/netapp_7mode_volumes.json +166 -0
- SNMP/data/official_profiles/paloalto_components.json +36 -0
- SNMP/data/official_profiles/paloalto_system.json +15 -0
- SNMP/data/official_profiles/traps.json +16 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch_system.json +14 -0
- SNMP/data/official_profiles/ubiquiti_unifi_wireless.json +60 -0
- SNMP/data/official_profiles/versa_flexvnf.json +14 -0
- SNMP/data/schema.md +650 -0
- SNMP/data/schema_reference/snmp_field_schema.md +747 -0
- SNMP/data/snmp_template.json +629 -0
- SNMP/data/template_profile_context.md +3986 -0
- SNMP/inline_grounding.py +77 -0
- SNMP/management/__init__.py +1 -0
- SNMP/management/commands/__init__.py +1 -0
- SNMP/management/commands/generate_template_profile_context.py +272 -0
- SNMP/management/commands/load_test_snmp_data.py +240 -0
- SNMP/management/commands/sync_snmp_official_data.py +263 -0
- SNMP/management/commands/unload_test_snmp_data.py +77 -0
- SNMP/migrations/0001_initial.py +101 -0
- SNMP/migrations/0002_devicetemplate.py +34 -0
- SNMP/migrations/0003_remove_devicetemplate_type_remove_profile_type_and_more.py +31 -0
- SNMP/migrations/0004_device_device_template.py +19 -0
- SNMP/migrations/0005_devicetemplate_product_profile_product.py +23 -0
- SNMP/migrations/0006_alter_devicetemplate_model_and_more.py +28 -0
- SNMP/migrations/0007_remove_device_profiles.py +17 -0
- SNMP/migrations/0008_devicetemplate_type.py +18 -0
- SNMP/migrations/0009_alter_device_device_template.py +19 -0
- SNMP/migrations/0010_alter_device_device_template.py +19 -0
- SNMP/migrations/0011_network_namespace.py +18 -0
- SNMP/migrations/0012_profile_normalizers.py +18 -0
- SNMP/migrations/0013_snmpdeploymentstate.py +26 -0
- SNMP/migrations/0014_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0015_alter_snmpdeploymentstate_last_config_change.py +20 -0
- SNMP/migrations/0016_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0017_remove_network_logstash_name.py +17 -0
- SNMP/migrations/0018_add_official_key.py +39 -0
- SNMP/migrations/0019_network_namespace_from_device_template.py +18 -0
- SNMP/migrations/0020_device_hostname_alter_device_ip_address_and_more.py +27 -0
- SNMP/migrations/0021_device_building_device_latitude_device_longitude_and_more.py +43 -0
- SNMP/migrations/0022_alter_device_latitude_alter_device_longitude.py +23 -0
- SNMP/migrations/0023_network_agent_connection_network_deployment_mode_and_more.py +30 -0
- SNMP/migrations/0024_network_credential_mode.py +18 -0
- SNMP/migrations/0025_network_ssl_certificate_authorities.py +18 -0
- SNMP/migrations/__init__.py +0 -0
- SNMP/models.py +892 -0
- SNMP/network_map.py +660 -0
- SNMP/overview.py +394 -0
- SNMP/snmp_crud.py +6082 -0
- SNMP/snmp_grounding.py +146 -0
- SNMP/snmp_normalizers.py +594 -0
- SNMP/snmp_pipeline_generator.py +1658 -0
- SNMP/snmp_test.py +962 -0
- SNMP/static/css/snmp.css +33 -0
- SNMP/static/images/apc.png +0 -0
- SNMP/static/images/arista.png +0 -0
- SNMP/static/images/aruba.png +0 -0
- SNMP/static/images/brocade.png +0 -0
- SNMP/static/images/cisco.png +0 -0
- SNMP/static/images/dell.png +0 -0
- SNMP/static/images/dlink.png +0 -0
- SNMP/static/images/east.png +0 -0
- SNMP/static/images/eaton.png +0 -0
- SNMP/static/images/epson.png +0 -0
- SNMP/static/images/hauwei.png +0 -0
- SNMP/static/images/hp.png +0 -0
- SNMP/static/images/hpe.png +0 -0
- SNMP/static/images/ingrasys.png +0 -0
- SNMP/static/images/linux.png +0 -0
- SNMP/static/images/mellanox.png +0 -0
- SNMP/static/images/netapp.png +0 -0
- SNMP/static/images/paloalto.png +0 -0
- SNMP/static/images/phoenixtec.png +0 -0
- SNMP/static/images/ubiquiti.png +0 -0
- SNMP/static/images/unknown.png +0 -0
- SNMP/static/images/versa.png +0 -0
- SNMP/static/images/vertiv.png +0 -0
- SNMP/static/js/ai_device_template_modal.js +1116 -0
- SNMP/static/js/credentials_table.js +291 -0
- SNMP/static/js/devices_table.js +588 -0
- SNMP/static/js/discovered_devices.js +291 -0
- SNMP/static/js/network_map.js +1657 -0
- SNMP/static/js/networks_table.js +360 -0
- SNMP/static/js/onboarding.js +866 -0
- SNMP/static/js/overview.js +416 -0
- SNMP/static/js/snmp_changes_indicator.js +76 -0
- SNMP/static/js/snmp_commit_modal.js +39 -0
- SNMP/static/js/snmp_credentials_modal.js +217 -0
- SNMP/static/js/snmp_device_template_modal.js +669 -0
- SNMP/static/js/snmp_device_visual_preview.js +1707 -0
- SNMP/static/js/snmp_devices_modal.js +912 -0
- SNMP/static/js/snmp_diff_modal.js +1559 -0
- SNMP/static/js/snmp_network_modal.js +940 -0
- SNMP/static/js/snmp_profile_modal.js +1212 -0
- SNMP/static/js/snmp_profile_modal_helpers.js +17 -0
- SNMP/static/js/snmp_test.js +538 -0
- SNMP/templates/Credentials.html +325 -0
- SNMP/templates/DeviceTemplates.html +1059 -0
- SNMP/templates/Devices.html +274 -0
- SNMP/templates/Networks.html +469 -0
- SNMP/templates/Onboarding.html +521 -0
- SNMP/templates/Overview.html +227 -0
- SNMP/templates/components/ai_device_template_modal.html +46 -0
- SNMP/templates/components/ai_generate_template_content.html +224 -0
- SNMP/templates/components/device_template_profile_modal.html +60 -0
- SNMP/templates/components/discovered_devices_content.html +86 -0
- SNMP/templates/components/discovered_devices_modal.html +43 -0
- SNMP/templates/components/gmaps_latlon_modal.html +93 -0
- SNMP/templates/components/network_map.html +110 -0
- SNMP/templates/components/snmp_commit_modal.html +53 -0
- SNMP/templates/components/snmp_credentials_modal.html +189 -0
- SNMP/templates/components/snmp_device_modal.html +6 -0
- SNMP/templates/components/snmp_device_template_modal.html +129 -0
- SNMP/templates/components/snmp_device_visual_preview.html +347 -0
- SNMP/templates/components/snmp_devices_modal.html +330 -0
- SNMP/templates/components/snmp_diff_modal.html +148 -0
- SNMP/templates/components/snmp_network_modal.html +380 -0
- SNMP/templates/components/snmp_profile_modal.html +147 -0
- SNMP/templates/components/snmp_test_modal.html +398 -0
- SNMP/templatetags/__init__.py +0 -0
- SNMP/templatetags/snmp_extras.py +17 -0
- SNMP/urls.py +94 -0
- SNMP/views.py +913 -0
- Site/__init__.py +0 -0
- Site/apps.py +9 -0
- Site/migrations/__init__.py +0 -0
- Site/product_ca_views.py +41 -0
- Site/static/images/ElasticIcon.png +0 -0
- Site/static/images/LoggyIcon.png +0 -0
- Site/static/images/LoggyWizardIcon.png +0 -0
- Site/static/images/LogstashAgentIcon.png +0 -0
- Site/static/images/LogstashIcon.png +0 -0
- Site/static/js/base.js +192 -0
- Site/static/js/marked.min.js +69 -0
- Site/templates/base.html +52 -0
- Site/templates/error.html +65 -0
- Site/templates/home.html +148 -0
- Site/templates/navigation.html +530 -0
- Site/templates/popup.html +251 -0
- Site/templatetags/__init__.py +0 -0
- Site/templatetags/custom_filters.py +36 -0
- Site/urls.py +21 -0
- Site/views.py +200 -0
- Utilities/__init__.py +0 -0
- Utilities/apps.py +9 -0
- Utilities/data/grok-patterns/LICENSE +202 -0
- Utilities/data/grok-patterns/ecs-v1/aws +33 -0
- Utilities/data/grok-patterns/ecs-v1/bacula +53 -0
- Utilities/data/grok-patterns/ecs-v1/bind +13 -0
- Utilities/data/grok-patterns/ecs-v1/bro +30 -0
- Utilities/data/grok-patterns/ecs-v1/exim +26 -0
- Utilities/data/grok-patterns/ecs-v1/firewalls +111 -0
- Utilities/data/grok-patterns/ecs-v1/grok-patterns +95 -0
- Utilities/data/grok-patterns/ecs-v1/haproxy +40 -0
- Utilities/data/grok-patterns/ecs-v1/httpd +17 -0
- Utilities/data/grok-patterns/ecs-v1/java +34 -0
- Utilities/data/grok-patterns/ecs-v1/junos +13 -0
- Utilities/data/grok-patterns/ecs-v1/linux-syslog +16 -0
- Utilities/data/grok-patterns/ecs-v1/maven +1 -0
- Utilities/data/grok-patterns/ecs-v1/mcollective +4 -0
- Utilities/data/grok-patterns/ecs-v1/mongodb +7 -0
- Utilities/data/grok-patterns/ecs-v1/nagios +124 -0
- Utilities/data/grok-patterns/ecs-v1/postgresql +2 -0
- Utilities/data/grok-patterns/ecs-v1/rails +13 -0
- Utilities/data/grok-patterns/ecs-v1/redis +3 -0
- Utilities/data/grok-patterns/ecs-v1/ruby +2 -0
- Utilities/data/grok-patterns/ecs-v1/squid +6 -0
- Utilities/data/grok-patterns/ecs-v1/zeek +33 -0
- Utilities/data/grok-patterns/legacy/aws +14 -0
- Utilities/data/grok-patterns/legacy/bacula +50 -0
- Utilities/data/grok-patterns/legacy/bind +3 -0
- Utilities/data/grok-patterns/legacy/bro +13 -0
- Utilities/data/grok-patterns/legacy/exim +19 -0
- Utilities/data/grok-patterns/legacy/firewalls +91 -0
- Utilities/data/grok-patterns/legacy/grok-patterns +95 -0
- Utilities/data/grok-patterns/legacy/haproxy +39 -0
- Utilities/data/grok-patterns/legacy/httpd +15 -0
- Utilities/data/grok-patterns/legacy/java +17 -0
- Utilities/data/grok-patterns/legacy/junos +9 -0
- Utilities/data/grok-patterns/legacy/linux-syslog +16 -0
- Utilities/data/grok-patterns/legacy/maven +1 -0
- Utilities/data/grok-patterns/legacy/mcollective +1 -0
- Utilities/data/grok-patterns/legacy/mcollective-patterns +4 -0
- Utilities/data/grok-patterns/legacy/mongodb +7 -0
- Utilities/data/grok-patterns/legacy/nagios +124 -0
- Utilities/data/grok-patterns/legacy/postgresql +3 -0
- Utilities/data/grok-patterns/legacy/rails +13 -0
- Utilities/data/grok-patterns/legacy/redis +3 -0
- Utilities/data/grok-patterns/legacy/ruby +2 -0
- Utilities/data/grok-patterns/legacy/squid +4 -0
- Utilities/dissect.py +302 -0
- Utilities/grok.py +412 -0
- Utilities/migrations/__init__.py +0 -0
- Utilities/static/css/debugger_editor.css +88 -0
- Utilities/static/js/debugger_editor.js +93 -0
- Utilities/static/js/grok_debugger.js +131 -0
- Utilities/templates/dissect_debugger.html +95 -0
- Utilities/templates/grok_debugger.html +99 -0
- Utilities/urls.py +14 -0
- Utilities/views.py +363 -0
- logstashui-0.5.5.dev0.dist-info/METADATA +333 -0
- logstashui-0.5.5.dev0.dist-info/RECORD +762 -0
- logstashui-0.5.5.dev0.dist-info/WHEEL +4 -0
- logstashui-0.5.5.dev0.dist-info/entry_points.txt +2 -0
- logstashui-0.5.5.dev0.dist-info/licenses/LICENSE.txt +93 -0
- logstashui-0.5.5.dev0.dist-info/licenses/NOTICE.txt +2772 -0
- theme/__init__.py +0 -0
- theme/apps.py +9 -0
- theme/package-lock.json +6 -0
- theme/static/css/dist/styles.css +2 -0
- theme/static/images/favicon.ico +0 -0
- theme/static_src/.gitignore +1 -0
- theme/static_src/package-lock.json +1930 -0
- theme/static_src/package.json +26 -0
- theme/static_src/postcss.config.js +7 -0
- theme/static_src/src/styles.css +38 -0
- theme/static_src/tailwind.config.js +43 -0
- theme/templates/base.html +32 -0
|
@@ -0,0 +1,1559 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License;
|
|
4
|
+
* you may not use this file except in compliance with the Elastic License.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ===== INLINE DIFF ALGORITHMS =====
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Compute Longest Common Subsequence using dynamic programming
|
|
11
|
+
*/
|
|
12
|
+
function computeLCS(arr1, arr2) {
|
|
13
|
+
const m = arr1.length;
|
|
14
|
+
const n = arr2.length;
|
|
15
|
+
const dp = Array(m + 1).fill(null).map(() => Array(n + 1).fill(0));
|
|
16
|
+
|
|
17
|
+
for (let i = 1; i <= m; i++) {
|
|
18
|
+
for (let j = 1; j <= n; j++) {
|
|
19
|
+
if (arr1[i - 1] === arr2[j - 1]) {
|
|
20
|
+
dp[i][j] = dp[i - 1][j - 1] + 1;
|
|
21
|
+
} else {
|
|
22
|
+
dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Backtrack to find LCS
|
|
28
|
+
const lcs = [];
|
|
29
|
+
let i = m, j = n;
|
|
30
|
+
while (i > 0 && j > 0) {
|
|
31
|
+
if (arr1[i - 1] === arr2[j - 1]) {
|
|
32
|
+
lcs.unshift(arr1[i - 1]);
|
|
33
|
+
i--;
|
|
34
|
+
j--;
|
|
35
|
+
} else if (dp[i - 1][j] > dp[i][j - 1]) {
|
|
36
|
+
i--;
|
|
37
|
+
} else {
|
|
38
|
+
j--;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return lcs;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Compute line-level diff using LCS algorithm
|
|
47
|
+
*/
|
|
48
|
+
function computeLineDiff(oldLines, newLines) {
|
|
49
|
+
const changes = [];
|
|
50
|
+
const lcs = computeLCS(oldLines, newLines);
|
|
51
|
+
|
|
52
|
+
let i = 0, j = 0, k = 0;
|
|
53
|
+
|
|
54
|
+
while (i < oldLines.length || j < newLines.length) {
|
|
55
|
+
// Check if we're at a common line
|
|
56
|
+
if (k < lcs.length && i < oldLines.length && j < newLines.length &&
|
|
57
|
+
oldLines[i] === lcs[k] && newLines[j] === lcs[k]) {
|
|
58
|
+
// Equal line
|
|
59
|
+
const equalLines = [];
|
|
60
|
+
while (k < lcs.length && i < oldLines.length && j < newLines.length &&
|
|
61
|
+
oldLines[i] === lcs[k] && newLines[j] === lcs[k]) {
|
|
62
|
+
equalLines.push(oldLines[i]);
|
|
63
|
+
i++;
|
|
64
|
+
j++;
|
|
65
|
+
k++;
|
|
66
|
+
}
|
|
67
|
+
if (equalLines.length > 0) {
|
|
68
|
+
changes.push({ type: 'equal', lines: equalLines });
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
// Collect deletions and insertions
|
|
72
|
+
const deletedLines = [];
|
|
73
|
+
const insertedLines = [];
|
|
74
|
+
|
|
75
|
+
while (i < oldLines.length && (k >= lcs.length || oldLines[i] !== lcs[k])) {
|
|
76
|
+
deletedLines.push(oldLines[i]);
|
|
77
|
+
i++;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
while (j < newLines.length && (k >= lcs.length || newLines[j] !== lcs[k])) {
|
|
81
|
+
insertedLines.push(newLines[j]);
|
|
82
|
+
j++;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// If we have both deletions and insertions, treat as replacement
|
|
86
|
+
if (deletedLines.length > 0 && insertedLines.length > 0) {
|
|
87
|
+
changes.push({ type: 'replace', oldLines: deletedLines, newLines: insertedLines });
|
|
88
|
+
} else if (deletedLines.length > 0) {
|
|
89
|
+
changes.push({ type: 'delete', lines: deletedLines });
|
|
90
|
+
} else if (insertedLines.length > 0) {
|
|
91
|
+
changes.push({ type: 'insert', lines: insertedLines });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return changes;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ===== END DIFF ALGORITHMS =====
|
|
100
|
+
|
|
101
|
+
// ===== SNMP INDEX TEMPLATE STATUS =====
|
|
102
|
+
|
|
103
|
+
// connection_ids involved in the current diff (populated after GetDeployDiff)
|
|
104
|
+
let _snmpDiffConnectionIds = [];
|
|
105
|
+
|
|
106
|
+
// true when at least one connection is missing the template (blocks deploy)
|
|
107
|
+
let _snmpTemplateBlocked = false;
|
|
108
|
+
|
|
109
|
+
// true when the "no changes" path has disabled the button
|
|
110
|
+
let _snmpNoChangesBlocked = false;
|
|
111
|
+
|
|
112
|
+
// true when a pre-deploy validation error blocks the whole deploy
|
|
113
|
+
let _snmpConfigBlocked = false;
|
|
114
|
+
|
|
115
|
+
// true when at least one connection had installed_but_outdated status before the
|
|
116
|
+
// last install — used to decide whether to show the rollover prompt afterward
|
|
117
|
+
let _snmpTemplateWasOutdated = false;
|
|
118
|
+
|
|
119
|
+
function _updateDeployButtonState() {
|
|
120
|
+
const btn = document.getElementById('confirmDeployButton');
|
|
121
|
+
if (!btn) return;
|
|
122
|
+
|
|
123
|
+
if (_snmpConfigBlocked) {
|
|
124
|
+
// Misconfiguration (missing keystore password / ES connection) — keep the
|
|
125
|
+
// button visible but disabled so the red banner explains why.
|
|
126
|
+
btn.classList.remove('hidden');
|
|
127
|
+
btn.disabled = true;
|
|
128
|
+
btn.classList.add('opacity-50', 'cursor-not-allowed');
|
|
129
|
+
} else if (_snmpTemplateBlocked) {
|
|
130
|
+
btn.classList.add('hidden');
|
|
131
|
+
btn.disabled = true;
|
|
132
|
+
} else if (_snmpNoChangesBlocked) {
|
|
133
|
+
btn.classList.remove('hidden');
|
|
134
|
+
btn.disabled = true;
|
|
135
|
+
btn.classList.add('opacity-50', 'cursor-not-allowed');
|
|
136
|
+
} else {
|
|
137
|
+
btn.classList.remove('hidden');
|
|
138
|
+
btn.disabled = false;
|
|
139
|
+
btn.classList.remove('opacity-50', 'cursor-not-allowed');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Render the pre-deploy blocking banner. When any blocking error is present the
|
|
145
|
+
* entire deploy is disabled and the user is told (with a fix link) why.
|
|
146
|
+
*/
|
|
147
|
+
function renderSnmpBlockingBanner(errors) {
|
|
148
|
+
const banner = document.getElementById('snmpDiffBlockingBanner');
|
|
149
|
+
if (!banner) return;
|
|
150
|
+
|
|
151
|
+
if (!errors || errors.length === 0) {
|
|
152
|
+
_snmpConfigBlocked = false;
|
|
153
|
+
banner.classList.add('hidden');
|
|
154
|
+
banner.innerHTML = '';
|
|
155
|
+
_updateDeployButtonState();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
_snmpConfigBlocked = true;
|
|
160
|
+
|
|
161
|
+
let items = '';
|
|
162
|
+
errors.forEach(e => {
|
|
163
|
+
let action = '';
|
|
164
|
+
if (e.policy_id) {
|
|
165
|
+
// Inline password prompt — keeps the user on this page.
|
|
166
|
+
// data-policy-id is read by _inlineSetKeystorePassword().
|
|
167
|
+
action = ` <button
|
|
168
|
+
type="button"
|
|
169
|
+
data-policy-id="${escapeHtml(String(e.policy_id))}"
|
|
170
|
+
onclick="_inlineSetKeystorePassword(this)"
|
|
171
|
+
class="inline-flex items-center gap-1 ml-1 underline font-medium text-red-200 hover:text-white cursor-pointer bg-transparent border-0 p-0">
|
|
172
|
+
Set keystore password →
|
|
173
|
+
</button>`;
|
|
174
|
+
}
|
|
175
|
+
items += `<li>${escapeHtml(e.message)}${action}</li>`;
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
banner.innerHTML = `
|
|
179
|
+
<div class="flex items-start gap-3">
|
|
180
|
+
<svg class="w-5 h-5 text-red-400 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
181
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
|
|
182
|
+
</svg>
|
|
183
|
+
<div class="min-w-0">
|
|
184
|
+
<p class="font-semibold text-red-200">Deployment blocked</p>
|
|
185
|
+
<ul class="list-disc pl-5 mt-1 space-y-1 text-sm">${items}</ul>
|
|
186
|
+
</div>
|
|
187
|
+
</div>`;
|
|
188
|
+
banner.classList.remove('hidden');
|
|
189
|
+
_updateDeployButtonState();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Inline keystore password prompt triggered from the blocking banner.
|
|
194
|
+
* Shows the ConfirmationModal password prompt, POSTs to SetKeystorePassword,
|
|
195
|
+
* then re-runs the deploy diff so the banner clears automatically on success.
|
|
196
|
+
*
|
|
197
|
+
* @param {HTMLElement} btn - The button element carrying data-policy-id.
|
|
198
|
+
*/
|
|
199
|
+
async function _inlineSetKeystorePassword(btn) {
|
|
200
|
+
const policyId = btn?.dataset?.policyId;
|
|
201
|
+
if (!policyId) return;
|
|
202
|
+
|
|
203
|
+
const password = await ConfirmationModal.prompt(
|
|
204
|
+
'Please input a keystore password.',
|
|
205
|
+
'',
|
|
206
|
+
'Set Keystore Password',
|
|
207
|
+
'Enter password...',
|
|
208
|
+
true // mask input
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
if (!password) return;
|
|
212
|
+
|
|
213
|
+
try {
|
|
214
|
+
const response = await fetch('/ConnectionManager/SetKeystorePassword/', {
|
|
215
|
+
method: 'POST',
|
|
216
|
+
headers: {
|
|
217
|
+
'Content-Type': 'application/json',
|
|
218
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
219
|
+
},
|
|
220
|
+
body: JSON.stringify({ policy_id: policyId, password }),
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const data = await response.json();
|
|
224
|
+
|
|
225
|
+
if (data.success) {
|
|
226
|
+
showToast(data.message || 'Keystore password set', 'success');
|
|
227
|
+
// Re-run the diff so the blocking banner clears if all issues are resolved
|
|
228
|
+
await prepareSnmpDiffModal();
|
|
229
|
+
} else {
|
|
230
|
+
showToast(data.error || 'Failed to set keystore password', 'error');
|
|
231
|
+
}
|
|
232
|
+
} catch (err) {
|
|
233
|
+
showToast(`Failed to set keystore password: ${err.message}`, 'error');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A small pill describing where a pipeline is deployed (a specific agent or an
|
|
239
|
+
* Elasticsearch CPM connection).
|
|
240
|
+
*/
|
|
241
|
+
function _snmpDestinationPill(entry) {
|
|
242
|
+
if (!entry || !entry.destination_name) return '';
|
|
243
|
+
const isAgent = entry.destination_type === 'agent';
|
|
244
|
+
const cls = isAgent
|
|
245
|
+
? 'bg-teal-600/20 text-teal-300 border-teal-600/40'
|
|
246
|
+
: 'bg-indigo-600/20 text-indigo-300 border-indigo-600/40';
|
|
247
|
+
const label = isAgent ? 'Agent' : 'Elasticsearch CPM';
|
|
248
|
+
return `<span class="inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded border ${cls} flex-shrink-0" title="Deployment destination">
|
|
249
|
+
<span class="opacity-70">${label}</span>
|
|
250
|
+
<span class="font-medium truncate max-w-[16rem]">${escapeHtml(entry.destination_name)}</span>
|
|
251
|
+
</span>`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Reusable eye / eye-slash icon paths (matches keystore_modal.html's toggle icon).
|
|
255
|
+
const _SNMP_EYE_OPEN_PATHS = `
|
|
256
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
257
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />`;
|
|
258
|
+
const _SNMP_EYE_CLOSED_PATHS = `
|
|
259
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />`;
|
|
260
|
+
|
|
261
|
+
const _SNMP_COPY_ICON_SVG = `
|
|
262
|
+
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
263
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/>
|
|
264
|
+
</svg>`;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Group the raw per-pipeline diff entries by network and merge their
|
|
268
|
+
* ${KEY} lists/values, since a single network's keys can be spread across
|
|
269
|
+
* its main/trap/discovery pipeline entries. Preserves first-seen key order.
|
|
270
|
+
*/
|
|
271
|
+
function _aggregateSnmpManualKeystoreEntries(networks) {
|
|
272
|
+
const byNetwork = new Map();
|
|
273
|
+
|
|
274
|
+
for (const entry of networks) {
|
|
275
|
+
const keys = entry.manual_keystore_keys;
|
|
276
|
+
if (!keys || keys.length === 0) continue;
|
|
277
|
+
|
|
278
|
+
const name = entry.network_name;
|
|
279
|
+
if (!byNetwork.has(name)) {
|
|
280
|
+
byNetwork.set(name, { keys: [], values: {}, seen: new Set() });
|
|
281
|
+
}
|
|
282
|
+
const agg = byNetwork.get(name);
|
|
283
|
+
const values = entry.manual_keystore_values || {};
|
|
284
|
+
|
|
285
|
+
for (const key of keys) {
|
|
286
|
+
if (!agg.seen.has(key)) {
|
|
287
|
+
agg.seen.add(key);
|
|
288
|
+
agg.keys.push(key);
|
|
289
|
+
}
|
|
290
|
+
if (values[key] !== undefined) {
|
|
291
|
+
agg.values[key] = values[key];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return byNetwork;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Render the aggregated "manual keystore values required" section at the top
|
|
301
|
+
* of the modal: one collapsed row per network (collapsed by default) that,
|
|
302
|
+
* when expanded, reveals the single `logstash-keystore add key1 key2 ...`
|
|
303
|
+
* command for that network plus the values to paste in when prompted for
|
|
304
|
+
* each key, in order. Doing it once per network (instead of once per
|
|
305
|
+
* pipeline) means a single logstash-keystore/JVM invocation covers every
|
|
306
|
+
* pipeline for that network.
|
|
307
|
+
*/
|
|
308
|
+
function renderSnmpManualKeystoreCommandsSection(networks) {
|
|
309
|
+
const section = document.getElementById('snmpKeystoreCommandsSection');
|
|
310
|
+
if (!section) return;
|
|
311
|
+
|
|
312
|
+
const byNetwork = _aggregateSnmpManualKeystoreEntries(networks);
|
|
313
|
+
if (byNetwork.size === 0) {
|
|
314
|
+
section.classList.add('hidden');
|
|
315
|
+
section.innerHTML = '';
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
let rowsHtml = '';
|
|
320
|
+
for (const [networkName, agg] of byNetwork.entries()) {
|
|
321
|
+
rowsHtml += _snmpManualKeystoreRow(networkName, agg.keys, agg.values);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
section.innerHTML = `
|
|
325
|
+
<div class="border border-yellow-600/30 rounded-lg overflow-hidden divide-y divide-yellow-600/20">
|
|
326
|
+
${rowsHtml}
|
|
327
|
+
</div>`;
|
|
328
|
+
section.classList.remove('hidden');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* A single collapsible row for one network's manual-keystore command.
|
|
333
|
+
* Collapsed by default. The command itself is always visible once expanded;
|
|
334
|
+
* only the credential values underneath are maskable via the eye toggle.
|
|
335
|
+
*
|
|
336
|
+
* The command mirrors ls_keystore_utils' LogstashKeystore._add_batch_keys()
|
|
337
|
+
* exactly: `add KEY1 KEY2 ... --stdin`, fed newline-separated values in the
|
|
338
|
+
* same order as the keys. That helper also prepends a "y" confirmation line
|
|
339
|
+
* before any value whose key it already knows exists in the keystore it
|
|
340
|
+
* manages (logstash-keystore prompts "Overwrite existing entry? [y/N]" for
|
|
341
|
+
* pre-existing keys before it'll accept a new value). We can't reproduce
|
|
342
|
+
* that here: in "manage keystore manually" mode LogstashUI never tracks the
|
|
343
|
+
* contents of the operator's keystore, so we have no way to know which keys
|
|
344
|
+
* (if any) already exist on their node. Blindly prepending "y" would corrupt
|
|
345
|
+
* the paste for brand-new keys (the "y" would be read as the secret value
|
|
346
|
+
* itself), so instead we surface the caveat and let the operator answer any
|
|
347
|
+
* overwrite prompt themselves if one appears.
|
|
348
|
+
*/
|
|
349
|
+
function _snmpManualKeystoreRow(networkName, keys, values) {
|
|
350
|
+
const blockId = `snmpKeystoreRow_${Math.random().toString(36).slice(2)}`;
|
|
351
|
+
const cmd = `logstash-keystore --path.settings /etc/logstash add ${keys.join(' ')} --stdin`;
|
|
352
|
+
const valueLines = keys.map(key => values[key] || '');
|
|
353
|
+
|
|
354
|
+
// What "copy everything" copies: the command followed by each value on
|
|
355
|
+
// its own line — pasted as one block into an interactive terminal, this
|
|
356
|
+
// runs the add command and then answers each value prompt in order.
|
|
357
|
+
const pasteBlock = [cmd, ...valueLines].join('\n');
|
|
358
|
+
|
|
359
|
+
const maskedText = valueLines.map(v => (v ? '••••••••••••' : '(no value set)')).join('\n');
|
|
360
|
+
const revealedText = valueLines.map(v => v || '(no value set)').join('\n');
|
|
361
|
+
|
|
362
|
+
return `
|
|
363
|
+
<div>
|
|
364
|
+
<button type="button" onclick="_toggleSnmpKeystoreRow('${blockId}')"
|
|
365
|
+
class="w-full flex items-center gap-2 px-4 py-2.5 bg-yellow-900/10 hover:bg-yellow-900/20 text-left transition-colors">
|
|
366
|
+
<svg id="${blockId}_chevron" class="w-3.5 h-3.5 text-yellow-400 flex-shrink-0 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
367
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
368
|
+
</svg>
|
|
369
|
+
<svg class="w-4 h-4 text-yellow-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
370
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
|
|
371
|
+
</svg>
|
|
372
|
+
<span class="text-sm text-yellow-200 truncate"><span class="font-semibold">${escapeHtml(networkName)}:</span> manual keystore values required, click here for the keystore command</span>
|
|
373
|
+
</button>
|
|
374
|
+
<div id="${blockId}_body" class="hidden px-4 py-3 bg-gray-900/40 border-t border-yellow-600/20">
|
|
375
|
+
<div class="flex items-center justify-between mb-1.5">
|
|
376
|
+
<p class="text-xs text-gray-400">Run this on the Logstash node. It reads each value below from stdin, in order:</p>
|
|
377
|
+
<div class="flex items-center gap-1 flex-shrink-0">
|
|
378
|
+
<button type="button" onclick="_toggleSnmpKeystoreValues('${blockId}')" title="Show/Hide credential values"
|
|
379
|
+
class="p-1 text-gray-400 hover:text-gray-200">
|
|
380
|
+
<svg id="${blockId}_eye" class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">${_SNMP_EYE_OPEN_PATHS}</svg>
|
|
381
|
+
</button>
|
|
382
|
+
<button type="button" data-cmd="${escapeHtml(pasteBlock)}" onclick="_copySnmpKeystoreCmd(this)" title="Copy command and values"
|
|
383
|
+
class="p-1 text-gray-400 hover:text-gray-200">
|
|
384
|
+
${_SNMP_COPY_ICON_SVG}
|
|
385
|
+
</button>
|
|
386
|
+
</div>
|
|
387
|
+
</div>
|
|
388
|
+
<pre class="text-xs bg-gray-900 text-gray-200 rounded px-2 py-1.5 overflow-x-auto font-mono whitespace-pre">${escapeHtml(cmd)}</pre>
|
|
389
|
+
<pre id="${blockId}_values" data-masked="${escapeHtml(maskedText)}" data-revealed-text="${escapeHtml(revealedText)}" data-revealed="false"
|
|
390
|
+
class="mt-1 text-xs bg-gray-900 text-gray-500 rounded px-2 py-1.5 overflow-x-auto font-mono whitespace-pre select-none">${escapeHtml(maskedText)}</pre>
|
|
391
|
+
<p class="text-xs text-gray-500 mt-1.5">If a key already exists in the keystore, it will prompt to overwrite before reading its value — answer that prompt, then continue pasting the remaining values.</p>
|
|
392
|
+
</div>
|
|
393
|
+
</div>`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Expand/collapse a single network's manual-keystore row.
|
|
398
|
+
*/
|
|
399
|
+
function _toggleSnmpKeystoreRow(blockId) {
|
|
400
|
+
const body = document.getElementById(`${blockId}_body`);
|
|
401
|
+
const chevron = document.getElementById(`${blockId}_chevron`);
|
|
402
|
+
if (!body) return;
|
|
403
|
+
|
|
404
|
+
const isCollapsed = body.classList.contains('hidden');
|
|
405
|
+
body.classList.toggle('hidden');
|
|
406
|
+
if (chevron) chevron.style.transform = isCollapsed ? 'rotate(90deg)' : '';
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Reveal or mask the credential values block for a row (the command line
|
|
411
|
+
* itself is never affected by this toggle).
|
|
412
|
+
*/
|
|
413
|
+
function _toggleSnmpKeystoreValues(blockId) {
|
|
414
|
+
const valuesEl = document.getElementById(`${blockId}_values`);
|
|
415
|
+
const eyeEl = document.getElementById(`${blockId}_eye`);
|
|
416
|
+
if (!valuesEl || !eyeEl) return;
|
|
417
|
+
|
|
418
|
+
const revealed = valuesEl.getAttribute('data-revealed') === 'true';
|
|
419
|
+
|
|
420
|
+
if (revealed) {
|
|
421
|
+
valuesEl.textContent = valuesEl.getAttribute('data-masked') || '';
|
|
422
|
+
valuesEl.classList.add('text-gray-500');
|
|
423
|
+
valuesEl.classList.remove('text-gray-200');
|
|
424
|
+
valuesEl.setAttribute('data-revealed', 'false');
|
|
425
|
+
eyeEl.innerHTML = _SNMP_EYE_OPEN_PATHS;
|
|
426
|
+
} else {
|
|
427
|
+
valuesEl.textContent = valuesEl.getAttribute('data-revealed-text') || '';
|
|
428
|
+
valuesEl.classList.remove('text-gray-500');
|
|
429
|
+
valuesEl.classList.add('text-gray-200');
|
|
430
|
+
valuesEl.setAttribute('data-revealed', 'true');
|
|
431
|
+
eyeEl.innerHTML = _SNMP_EYE_CLOSED_PATHS;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function _copySnmpKeystoreCmd(btn) {
|
|
436
|
+
const cmd = btn.getAttribute('data-cmd') || '';
|
|
437
|
+
navigator.clipboard.writeText(cmd).then(() => {
|
|
438
|
+
const origHtml = btn.innerHTML;
|
|
439
|
+
btn.innerHTML = `<svg class="w-3.5 h-3.5 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>`;
|
|
440
|
+
setTimeout(() => { btn.innerHTML = origHtml; }, 1500);
|
|
441
|
+
}).catch(() => {});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Render a dedicated card for a keystore-drift diff entry (credential/secret
|
|
446
|
+
* rotation). Secret values are never shown — only key names.
|
|
447
|
+
*/
|
|
448
|
+
function _renderKeystoreDriftCard(entry) {
|
|
449
|
+
const drift = entry.keystore_drift || {};
|
|
450
|
+
const added = drift.added || [];
|
|
451
|
+
const changed = drift.changed || [];
|
|
452
|
+
const removed = drift.removed || [];
|
|
453
|
+
|
|
454
|
+
const chip = (name, cls) =>
|
|
455
|
+
`<span class="px-2 py-0.5 text-xs font-mono rounded border ${cls}">${escapeHtml(name)}</span>`;
|
|
456
|
+
let chips = '';
|
|
457
|
+
added.forEach(k => chips += chip(k, 'bg-green-600/20 text-green-300 border-green-600/40'));
|
|
458
|
+
changed.forEach(k => chips += chip(k, 'bg-blue-600/20 text-blue-300 border-blue-600/40'));
|
|
459
|
+
removed.forEach(k => chips += chip(k, 'bg-red-600/20 text-red-300 border-red-600/40'));
|
|
460
|
+
|
|
461
|
+
let legend = [];
|
|
462
|
+
if (added.length) legend.push(`<span class="text-green-300">${added.length} added</span>`);
|
|
463
|
+
if (changed.length) legend.push(`<span class="text-blue-300">${changed.length} changed</span>`);
|
|
464
|
+
if (removed.length) legend.push(`<span class="text-red-300">${removed.length} removed</span>`);
|
|
465
|
+
|
|
466
|
+
return `
|
|
467
|
+
<div class="border border-gray-600 rounded-lg overflow-hidden">
|
|
468
|
+
<div class="bg-gray-700 px-4 py-2 border-b border-gray-600 flex items-start justify-between gap-3">
|
|
469
|
+
<div class="min-w-0">
|
|
470
|
+
<h4 class="text-white font-semibold flex items-center">
|
|
471
|
+
Keystore Values
|
|
472
|
+
<span class="ml-2 px-2 py-0.5 text-xs bg-purple-600 text-white rounded">KEYSTORE</span>
|
|
473
|
+
</h4>
|
|
474
|
+
<p class="text-sm text-gray-400">${legend.join(' · ')}</p>
|
|
475
|
+
</div>
|
|
476
|
+
${_snmpDestinationPill(entry)}
|
|
477
|
+
</div>
|
|
478
|
+
<div class="p-4 bg-gray-800">
|
|
479
|
+
<p class="text-xs text-gray-400 mb-3">These secret values will be (re)provisioned into the agent keystore on deploy. Secret contents are never displayed.</p>
|
|
480
|
+
<div class="flex flex-wrap gap-2">${chips || '<span class="text-xs text-gray-500">No keys</span>'}</div>
|
|
481
|
+
</div>
|
|
482
|
+
</div>`;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function _templateStatusBadge(status) {
|
|
486
|
+
const cfg = {
|
|
487
|
+
installed: { dot: 'bg-green-400', text: 'text-green-300', label: 'Installed' },
|
|
488
|
+
installed_but_outdated: { dot: 'bg-yellow-400', text: 'text-yellow-300', label: 'Needs update' },
|
|
489
|
+
not_installed: { dot: 'bg-red-400', text: 'text-red-300', label: 'Not installed' },
|
|
490
|
+
error: { dot: 'bg-gray-500', text: 'text-gray-400', label: 'Check failed' },
|
|
491
|
+
};
|
|
492
|
+
const c = cfg[status] || cfg.error;
|
|
493
|
+
return `<span class="flex items-center gap-1.5">
|
|
494
|
+
<span class="w-2 h-2 rounded-full ${c.dot} flex-shrink-0"></span>
|
|
495
|
+
<span class="text-xs ${c.text} font-medium">${c.label}</span>
|
|
496
|
+
</span>`;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function _renderTemplateStatusPanel(results) {
|
|
500
|
+
const list = document.getElementById('snmpTemplateStatusList');
|
|
501
|
+
const loading = document.getElementById('snmpTemplateStatusLoading');
|
|
502
|
+
const panel = document.getElementById('snmpTemplateStatusPanel');
|
|
503
|
+
const btn = document.getElementById('snmpTemplateInstallBtn');
|
|
504
|
+
const label = document.getElementById('snmpTemplateInstallBtnLabel');
|
|
505
|
+
|
|
506
|
+
if (loading) loading.classList.add('hidden');
|
|
507
|
+
if (!list) return;
|
|
508
|
+
|
|
509
|
+
list.innerHTML = '';
|
|
510
|
+
|
|
511
|
+
let hasMissing = false;
|
|
512
|
+
let hasOutdated = false;
|
|
513
|
+
|
|
514
|
+
results.forEach(r => {
|
|
515
|
+
if (r.status === 'not_installed') hasMissing = true;
|
|
516
|
+
if (r.status === 'installed_but_outdated') hasOutdated = true;
|
|
517
|
+
|
|
518
|
+
// Track pre-install state so the rollover prompt only appears after an
|
|
519
|
+
// update (not after a first-time install where no old index exists).
|
|
520
|
+
if (r.status === 'installed_but_outdated') _snmpTemplateWasOutdated = true;
|
|
521
|
+
|
|
522
|
+
const diffHint = r.differences && r.differences.length
|
|
523
|
+
? `<span class="text-xs text-gray-500 ml-1">(${r.differences.join(', ')})</span>`
|
|
524
|
+
: '';
|
|
525
|
+
const errorHint = r.error
|
|
526
|
+
? `<span class="text-xs text-red-400 ml-1 truncate" title="${escapeHtml(r.error)}">${escapeHtml(r.error)}</span>`
|
|
527
|
+
: '';
|
|
528
|
+
|
|
529
|
+
const row = document.createElement('div');
|
|
530
|
+
row.className = 'flex items-center justify-between px-4 py-2.5 gap-4';
|
|
531
|
+
row.innerHTML = `
|
|
532
|
+
<div class="flex items-center gap-2 min-w-0">
|
|
533
|
+
<span class="text-sm text-white truncate">${escapeHtml(r.connection_name || String(r.connection_id))}</span>
|
|
534
|
+
${diffHint}${errorHint}
|
|
535
|
+
</div>
|
|
536
|
+
<div class="flex-shrink-0">
|
|
537
|
+
${_templateStatusBadge(r.status)}
|
|
538
|
+
</div>
|
|
539
|
+
`;
|
|
540
|
+
list.appendChild(row);
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
// Show/hide the install button and update its label
|
|
544
|
+
const needsAction = hasMissing || hasOutdated;
|
|
545
|
+
if (btn) {
|
|
546
|
+
if (needsAction) {
|
|
547
|
+
btn.classList.remove('hidden');
|
|
548
|
+
if (label) label.textContent = hasMissing ? 'Install Template' : 'Update Template';
|
|
549
|
+
} else {
|
|
550
|
+
btn.classList.add('hidden');
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Gate the deploy button when any connection is missing the template
|
|
555
|
+
_snmpTemplateBlocked = hasMissing;
|
|
556
|
+
_updateDeployButtonState();
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
async function checkSNMPIndexTemplateStatus(connectionIds) {
|
|
560
|
+
if (!connectionIds || connectionIds.length === 0) return;
|
|
561
|
+
|
|
562
|
+
const panel = document.getElementById('snmpTemplateStatusPanel');
|
|
563
|
+
const loading = document.getElementById('snmpTemplateStatusLoading');
|
|
564
|
+
const list = document.getElementById('snmpTemplateStatusList');
|
|
565
|
+
|
|
566
|
+
if (panel) panel.classList.remove('hidden');
|
|
567
|
+
if (loading) loading.classList.remove('hidden');
|
|
568
|
+
if (list) list.innerHTML = '';
|
|
569
|
+
|
|
570
|
+
try {
|
|
571
|
+
const response = await fetch('/SNMP/CheckSNMPIndexTemplate/', {
|
|
572
|
+
method: 'POST',
|
|
573
|
+
headers: {
|
|
574
|
+
'Content-Type': 'application/json',
|
|
575
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
576
|
+
},
|
|
577
|
+
body: JSON.stringify({ connection_ids: connectionIds }),
|
|
578
|
+
});
|
|
579
|
+
const data = await response.json();
|
|
580
|
+
_renderTemplateStatusPanel(data.results || []);
|
|
581
|
+
} catch (err) {
|
|
582
|
+
if (loading) loading.classList.add('hidden');
|
|
583
|
+
_snmpTemplateBlocked = false;
|
|
584
|
+
_updateDeployButtonState();
|
|
585
|
+
console.error('Error checking SNMP index template:', err);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
async function installSNMPIndexTemplate() {
|
|
590
|
+
if (!_snmpDiffConnectionIds || _snmpDiffConnectionIds.length === 0) return;
|
|
591
|
+
|
|
592
|
+
const btn = document.getElementById('snmpTemplateInstallBtn');
|
|
593
|
+
const label = document.getElementById('snmpTemplateInstallBtnLabel');
|
|
594
|
+
const loading = document.getElementById('snmpTemplateStatusLoading');
|
|
595
|
+
|
|
596
|
+
if (btn) btn.disabled = true;
|
|
597
|
+
if (label) label.textContent = 'Installing…';
|
|
598
|
+
if (loading) loading.classList.remove('hidden');
|
|
599
|
+
|
|
600
|
+
let installSucceeded = false;
|
|
601
|
+
try {
|
|
602
|
+
const response = await fetch('/SNMP/InstallSNMPIndexTemplate/', {
|
|
603
|
+
method: 'POST',
|
|
604
|
+
headers: {
|
|
605
|
+
'Content-Type': 'application/json',
|
|
606
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
607
|
+
},
|
|
608
|
+
body: JSON.stringify({ connection_ids: _snmpDiffConnectionIds }),
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
if (response.status === 403) {
|
|
612
|
+
showToast('Access denied: Admin role required', 'error');
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const result = await response.json();
|
|
617
|
+
|
|
618
|
+
if (!result.success) {
|
|
619
|
+
const firstError = (result.results || []).find(r => !r.success);
|
|
620
|
+
showToast(firstError ? firstError.error : 'Template install failed', 'error');
|
|
621
|
+
} else {
|
|
622
|
+
installSucceeded = true;
|
|
623
|
+
showToast('SNMP index template updated — roll over the data stream to apply new mappings', 'success');
|
|
624
|
+
}
|
|
625
|
+
} catch (err) {
|
|
626
|
+
showToast(`Template install failed: ${err.message}`, 'error');
|
|
627
|
+
} finally {
|
|
628
|
+
if (btn) btn.disabled = false;
|
|
629
|
+
if (loading) loading.classList.add('hidden');
|
|
630
|
+
|
|
631
|
+
if (installSucceeded) {
|
|
632
|
+
// Only prompt for rollover when this was an *update* to an already-installed
|
|
633
|
+
// template. A brand-new install creates a fresh backing index with the
|
|
634
|
+
// correct mappings, so there is nothing to roll over.
|
|
635
|
+
if (_snmpTemplateWasOutdated) {
|
|
636
|
+
const rolloverPanel = document.getElementById('snmpRolloverPanel');
|
|
637
|
+
if (rolloverPanel) rolloverPanel.classList.remove('hidden');
|
|
638
|
+
}
|
|
639
|
+
// Re-check so the status badge reflects "installed" (not "outdated")
|
|
640
|
+
await checkSNMPIndexTemplateStatus(_snmpDiffConnectionIds);
|
|
641
|
+
} else {
|
|
642
|
+
await checkSNMPIndexTemplateStatus(_snmpDiffConnectionIds);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
async function rolloverSNMPDataStream() {
|
|
648
|
+
if (!_snmpDiffConnectionIds || _snmpDiffConnectionIds.length === 0) return;
|
|
649
|
+
|
|
650
|
+
const btn = document.getElementById('snmpRolloverBtn');
|
|
651
|
+
const label = document.getElementById('snmpRolloverBtnLabel');
|
|
652
|
+
const loading = document.getElementById('snmpRolloverLoading');
|
|
653
|
+
const panel = document.getElementById('snmpRolloverPanel');
|
|
654
|
+
|
|
655
|
+
if (btn) btn.disabled = true;
|
|
656
|
+
if (label) label.textContent = 'Rolling over…';
|
|
657
|
+
if (loading) loading.classList.remove('hidden');
|
|
658
|
+
|
|
659
|
+
try {
|
|
660
|
+
const response = await fetch('/SNMP/RolloverSNMPDataStream/', {
|
|
661
|
+
method: 'POST',
|
|
662
|
+
headers: {
|
|
663
|
+
'Content-Type': 'application/json',
|
|
664
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
665
|
+
},
|
|
666
|
+
body: JSON.stringify({ connection_ids: _snmpDiffConnectionIds }),
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
if (response.status === 403) {
|
|
670
|
+
showToast('Access denied: Admin role required', 'error');
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
const result = await response.json();
|
|
675
|
+
|
|
676
|
+
if (!result.success) {
|
|
677
|
+
const firstError = (result.results || []).find(r => !r.success);
|
|
678
|
+
showToast(firstError ? firstError.error : 'Rollover failed', 'error');
|
|
679
|
+
} else {
|
|
680
|
+
showToast('Data stream rolled over — new mappings are now active', 'success');
|
|
681
|
+
// Hide the rollover prompt; the job is done
|
|
682
|
+
if (panel) panel.classList.add('hidden');
|
|
683
|
+
}
|
|
684
|
+
} catch (err) {
|
|
685
|
+
showToast(`Rollover failed: ${err.message}`, 'error');
|
|
686
|
+
} finally {
|
|
687
|
+
if (btn) btn.disabled = false;
|
|
688
|
+
if (label) label.textContent = 'Rollover Data Stream';
|
|
689
|
+
if (loading) loading.classList.add('hidden');
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// ===== END SNMP INDEX TEMPLATE STATUS =====
|
|
694
|
+
|
|
695
|
+
function hideSnmpDiffModal() {
|
|
696
|
+
document.getElementById('snmpDiffModal').classList.add('hidden');
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function showSnmpDiffModal() {
|
|
700
|
+
document.getElementById('snmpDiffModal').classList.remove('hidden');
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Prepare and show the SNMP diff modal
|
|
705
|
+
* This fetches diffs for all networks and displays them
|
|
706
|
+
*/
|
|
707
|
+
async function prepareSnmpDiffModal() {
|
|
708
|
+
// Show the modal first
|
|
709
|
+
showSnmpDiffModal();
|
|
710
|
+
|
|
711
|
+
// Show loading state
|
|
712
|
+
document.getElementById('snmpDiffLoading').classList.remove('hidden');
|
|
713
|
+
document.getElementById('snmpDiffContainer').classList.add('hidden');
|
|
714
|
+
|
|
715
|
+
// Reset template status panel
|
|
716
|
+
_snmpDiffConnectionIds = [];
|
|
717
|
+
_snmpTemplateBlocked = false;
|
|
718
|
+
_snmpNoChangesBlocked = false;
|
|
719
|
+
_snmpConfigBlocked = false;
|
|
720
|
+
_snmpTemplateWasOutdated = false;
|
|
721
|
+
const blockingBanner = document.getElementById('snmpDiffBlockingBanner');
|
|
722
|
+
if (blockingBanner) { blockingBanner.classList.add('hidden'); blockingBanner.innerHTML = ''; }
|
|
723
|
+
const keystoreCommandsSection = document.getElementById('snmpKeystoreCommandsSection');
|
|
724
|
+
if (keystoreCommandsSection) { keystoreCommandsSection.classList.add('hidden'); keystoreCommandsSection.innerHTML = ''; }
|
|
725
|
+
const templatePanel = document.getElementById('snmpTemplateStatusPanel');
|
|
726
|
+
if (templatePanel) templatePanel.classList.add('hidden');
|
|
727
|
+
const templateList = document.getElementById('snmpTemplateStatusList');
|
|
728
|
+
if (templateList) templateList.innerHTML = '';
|
|
729
|
+
const templateBtn = document.getElementById('snmpTemplateInstallBtn');
|
|
730
|
+
if (templateBtn) templateBtn.classList.add('hidden');
|
|
731
|
+
const rolloverPanel = document.getElementById('snmpRolloverPanel');
|
|
732
|
+
if (rolloverPanel) rolloverPanel.classList.add('hidden');
|
|
733
|
+
|
|
734
|
+
// Reset the deploy button to enabled state (in case it was disabled from a previous deployment)
|
|
735
|
+
const confirmButton = document.getElementById('confirmDeployButton');
|
|
736
|
+
confirmButton.classList.remove('hidden');
|
|
737
|
+
confirmButton.disabled = false;
|
|
738
|
+
confirmButton.textContent = 'Confirm & Deploy Changes';
|
|
739
|
+
confirmButton.classList.remove('opacity-50', 'cursor-not-allowed');
|
|
740
|
+
|
|
741
|
+
try {
|
|
742
|
+
// Fetch diff data from the server
|
|
743
|
+
const response = await fetch('/SNMP/GetDeployDiff/', {
|
|
744
|
+
method: 'POST',
|
|
745
|
+
headers: {
|
|
746
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
747
|
+
'Content-Type': 'application/json'
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
if (!response.ok) {
|
|
752
|
+
const errorText = await response.text();
|
|
753
|
+
throw new Error(`Failed to fetch diffs: ${response.status} - ${errorText}`);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
const diffData = await response.json();
|
|
757
|
+
|
|
758
|
+
// Hide loading, show container
|
|
759
|
+
document.getElementById('snmpDiffLoading').classList.add('hidden');
|
|
760
|
+
document.getElementById('snmpDiffContainer').classList.remove('hidden');
|
|
761
|
+
|
|
762
|
+
// Render pre-deploy blocking validation (disables deploy while present)
|
|
763
|
+
renderSnmpBlockingBanner(diffData.blocking_errors);
|
|
764
|
+
|
|
765
|
+
// Render the aggregated manual-keystore command section (one row per network)
|
|
766
|
+
renderSnmpManualKeystoreCommandsSection(diffData.networks);
|
|
767
|
+
|
|
768
|
+
// Display the diffs for each network
|
|
769
|
+
displayNetworkDiffs(diffData.networks);
|
|
770
|
+
|
|
771
|
+
// If backend says no changes, refresh the indicator to clear it immediately
|
|
772
|
+
// (Backend already called mark_deployed() to sync timestamps)
|
|
773
|
+
if (diffData.has_changes === false) {
|
|
774
|
+
if (typeof checkForUndeployedSNMPChanges === 'function') {
|
|
775
|
+
checkForUndeployedSNMPChanges();
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// Store change count for deployment message
|
|
780
|
+
window.snmpChangeCount = diffData.networks.length;
|
|
781
|
+
|
|
782
|
+
// Kick off index template status check for all involved connections
|
|
783
|
+
if (diffData.connections && diffData.connections.length > 0) {
|
|
784
|
+
_snmpDiffConnectionIds = diffData.connections.map(c => c.id);
|
|
785
|
+
checkSNMPIndexTemplateStatus(_snmpDiffConnectionIds);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Display overall stats
|
|
789
|
+
const newPipelines = diffData.networks.filter(n => !n.current || n.current.trim() === '').length;
|
|
790
|
+
document.getElementById('snmpDiffStats').textContent =
|
|
791
|
+
`${newPipelines} new pipeline(s)`;
|
|
792
|
+
|
|
793
|
+
} catch (error) {
|
|
794
|
+
console.error('Error preparing SNMP diff:', error);
|
|
795
|
+
document.getElementById('snmpDiffLoading').innerHTML = `
|
|
796
|
+
<div class="text-center">
|
|
797
|
+
<p class="text-red-400 mb-4">Failed to load pipeline comparison</p>
|
|
798
|
+
<p class="text-gray-400 text-sm">${error.message}</p>
|
|
799
|
+
<button onclick="hideSnmpDiffModal()" class="mt-4 px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-600">
|
|
800
|
+
Close
|
|
801
|
+
</button>
|
|
802
|
+
</div>
|
|
803
|
+
`;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Display diffs for all networks
|
|
809
|
+
*/
|
|
810
|
+
function displayNetworkDiffs(networks) {
|
|
811
|
+
const container = document.getElementById('snmpDiffContainer');
|
|
812
|
+
|
|
813
|
+
let html = '';
|
|
814
|
+
let networksWithChanges = 0;
|
|
815
|
+
let newPipelinesCount = 0;
|
|
816
|
+
let deletedPipelinesCount = 0;
|
|
817
|
+
|
|
818
|
+
for (const network of networks) {
|
|
819
|
+
// Keystore-drift entries (credential/secret rotation) get a dedicated card
|
|
820
|
+
// instead of a line-by-line diff — we only ever show key names, not values.
|
|
821
|
+
if (network.pipeline_type === 'keystore') {
|
|
822
|
+
networksWithChanges++;
|
|
823
|
+
html += _renderKeystoreDriftCard(network);
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Skip main pipeline rendering if network has no devices (pipeline_name will be null)
|
|
828
|
+
const hasMainPipeline = network.pipeline_name !== null;
|
|
829
|
+
|
|
830
|
+
let currentLines = [];
|
|
831
|
+
let newLines = [];
|
|
832
|
+
let isNewPipeline = false;
|
|
833
|
+
let isDeletePipeline = false;
|
|
834
|
+
let hasChanges = false;
|
|
835
|
+
let lineDiff = [];
|
|
836
|
+
|
|
837
|
+
if (hasMainPipeline) {
|
|
838
|
+
currentLines = network.current ? network.current.split('\n') : [];
|
|
839
|
+
newLines = network.new.split('\n');
|
|
840
|
+
|
|
841
|
+
// Check action field first, then fall back to checking current content
|
|
842
|
+
if (network.action === 'create') {
|
|
843
|
+
isNewPipeline = true;
|
|
844
|
+
} else if (network.action === 'delete') {
|
|
845
|
+
isDeletePipeline = true;
|
|
846
|
+
} else if (network.action === 'update') {
|
|
847
|
+
isNewPipeline = false;
|
|
848
|
+
} else {
|
|
849
|
+
// Fallback for backwards compatibility if action field not present
|
|
850
|
+
isNewPipeline = !network.current || network.current.trim() === '';
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// Compute diff
|
|
854
|
+
lineDiff = computeLineDiff(currentLines, newLines);
|
|
855
|
+
|
|
856
|
+
// Check if there are any actual changes (additions or deletions)
|
|
857
|
+
hasChanges = lineDiff.some(change => change.type !== 'equal');
|
|
858
|
+
|
|
859
|
+
// Track counts
|
|
860
|
+
if (isDeletePipeline) {
|
|
861
|
+
deletedPipelinesCount++;
|
|
862
|
+
} else if (isNewPipeline) {
|
|
863
|
+
newPipelinesCount++;
|
|
864
|
+
} else if (hasChanges) {
|
|
865
|
+
networksWithChanges++;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// Skip this network entirely if it has no main pipeline and no trap pipeline
|
|
870
|
+
if (!hasMainPipeline && !network.trap_pipeline) {
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// Skip main pipeline section if no changes and not new (but still show trap pipeline if exists)
|
|
875
|
+
const shouldShowMainPipeline = hasMainPipeline && (isNewPipeline || hasChanges);
|
|
876
|
+
|
|
877
|
+
let currentHtml = '';
|
|
878
|
+
let newHtml = '';
|
|
879
|
+
let currentLineNum = 1;
|
|
880
|
+
let newLineNum = 1;
|
|
881
|
+
|
|
882
|
+
if (isNewPipeline) {
|
|
883
|
+
// For new pipelines, just show the new content on the right
|
|
884
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
885
|
+
const line = escapeHtml(newLines[i]);
|
|
886
|
+
|
|
887
|
+
currentHtml += `<div class="flex bg-gray-800/50">
|
|
888
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
889
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
890
|
+
</div>`;
|
|
891
|
+
|
|
892
|
+
newHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
893
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${newLineNum++}</span>
|
|
894
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
895
|
+
</div>`;
|
|
896
|
+
}
|
|
897
|
+
} else {
|
|
898
|
+
// For existing pipelines, show the diff
|
|
899
|
+
for (const change of lineDiff) {
|
|
900
|
+
if (change.type === 'equal') {
|
|
901
|
+
// Unchanged lines - show on both sides without highlighting
|
|
902
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
903
|
+
const line = escapeHtml(change.lines[i]);
|
|
904
|
+
|
|
905
|
+
currentHtml += `<div class="flex hover:bg-gray-700/30">
|
|
906
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${currentLineNum++}</span>
|
|
907
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
908
|
+
</div>`;
|
|
909
|
+
|
|
910
|
+
newHtml += `<div class="flex hover:bg-gray-700/30">
|
|
911
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${newLineNum++}</span>
|
|
912
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
913
|
+
</div>`;
|
|
914
|
+
}
|
|
915
|
+
} else if (change.type === 'delete') {
|
|
916
|
+
// Deleted lines - show only on left with red background
|
|
917
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
918
|
+
const line = escapeHtml(change.lines[i]);
|
|
919
|
+
|
|
920
|
+
currentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
921
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${currentLineNum++}</span>
|
|
922
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
923
|
+
</div>`;
|
|
924
|
+
|
|
925
|
+
// Empty placeholder on right side
|
|
926
|
+
newHtml += `<div class="flex bg-gray-800/50">
|
|
927
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
928
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
929
|
+
</div>`;
|
|
930
|
+
}
|
|
931
|
+
} else if (change.type === 'insert') {
|
|
932
|
+
// Inserted lines - show only on right with green background
|
|
933
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
934
|
+
const line = escapeHtml(change.lines[i]);
|
|
935
|
+
|
|
936
|
+
// Empty placeholder on left side
|
|
937
|
+
currentHtml += `<div class="flex bg-gray-800/50">
|
|
938
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
939
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
940
|
+
</div>`;
|
|
941
|
+
|
|
942
|
+
newHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
943
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${newLineNum++}</span>
|
|
944
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
945
|
+
</div>`;
|
|
946
|
+
}
|
|
947
|
+
} else if (change.type === 'replace') {
|
|
948
|
+
// Modified lines - show with simple light background highlighting
|
|
949
|
+
const oldLines = change.oldLines;
|
|
950
|
+
const newLines = change.newLines;
|
|
951
|
+
const maxLen = Math.max(oldLines.length, newLines.length);
|
|
952
|
+
|
|
953
|
+
for (let i = 0; i < maxLen; i++) {
|
|
954
|
+
if (i < oldLines.length) {
|
|
955
|
+
const oldLine = escapeHtml(oldLines[i]);
|
|
956
|
+
|
|
957
|
+
currentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
958
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${currentLineNum++}</span>
|
|
959
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${oldLine || ' '}</span>
|
|
960
|
+
</div>`;
|
|
961
|
+
} else {
|
|
962
|
+
currentHtml += `<div class="flex bg-gray-800/50">
|
|
963
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
964
|
+
<span style="white-space: pre; padding-left: 0.5rem;"></span>
|
|
965
|
+
</div>`;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
if (i < newLines.length) {
|
|
969
|
+
const newLine = escapeHtml(newLines[i]);
|
|
970
|
+
|
|
971
|
+
newHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
972
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${newLineNum++}</span>
|
|
973
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${newLine || ' '}</span>
|
|
974
|
+
</div>`;
|
|
975
|
+
} else {
|
|
976
|
+
newHtml += `<div class="flex bg-gray-800/50">
|
|
977
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
978
|
+
<span style="white-space: pre; padding-left: 0.5rem;"></span>
|
|
979
|
+
</div>`;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// Build the network section with badge only if there are changes
|
|
987
|
+
let networkBadge = '';
|
|
988
|
+
if (isDeletePipeline) {
|
|
989
|
+
networkBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-red-600 text-white rounded">DELETE</span>';
|
|
990
|
+
} else if (isNewPipeline) {
|
|
991
|
+
networkBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-green-600 text-white rounded">NEW</span>';
|
|
992
|
+
} else if (hasChanges) {
|
|
993
|
+
networkBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-blue-600 text-white rounded">MODIFIED</span>';
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// Only show main pipeline section if network has devices
|
|
997
|
+
if (shouldShowMainPipeline) {
|
|
998
|
+
html += `
|
|
999
|
+
<div class="border border-gray-600 rounded-lg overflow-hidden">
|
|
1000
|
+
<div class="bg-gray-700 px-4 py-2 border-b border-gray-600 flex items-start justify-between gap-3">
|
|
1001
|
+
<div class="min-w-0">
|
|
1002
|
+
<h4 class="text-white font-semibold">
|
|
1003
|
+
${escapeHtml(network.network_name)}${networkBadge}
|
|
1004
|
+
</h4>
|
|
1005
|
+
<p class="text-sm text-gray-400 truncate">Pipeline: ${escapeHtml(network.pipeline_name)}</p>
|
|
1006
|
+
</div>
|
|
1007
|
+
${_snmpDestinationPill(network)}
|
|
1008
|
+
</div>
|
|
1009
|
+
<div style="display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; height: 400px;">
|
|
1010
|
+
<div class="p-4 bg-gray-700 border-r border-gray-600" style="display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0;">
|
|
1011
|
+
<div class="mb-2" style="flex-shrink: 0;">
|
|
1012
|
+
<h5 class="text-sm font-semibold text-white">${isNewPipeline ? 'No Existing Pipeline' : 'Current Pipeline'}</h5>
|
|
1013
|
+
</div>
|
|
1014
|
+
<div class="bg-gray-800 rounded border border-gray-600 network-diff-scroll-panel" style="flex: 1; overflow-y: auto; overflow-x: auto; min-height: 0; min-width: 0;">
|
|
1015
|
+
<div class="p-2 text-sm text-gray-300 font-mono">${currentHtml}</div>
|
|
1016
|
+
</div>
|
|
1017
|
+
</div>
|
|
1018
|
+
<div class="p-4 bg-gray-700" style="display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0;">
|
|
1019
|
+
<div class="mb-2" style="flex-shrink: 0;">
|
|
1020
|
+
<h5 class="text-sm font-semibold text-white">New Pipeline (After Deploy)</h5>
|
|
1021
|
+
</div>
|
|
1022
|
+
<div class="bg-gray-800 rounded border border-gray-600 network-diff-scroll-panel" style="flex: 1; overflow-y: auto; overflow-x: auto; min-height: 0; min-width: 0;">
|
|
1023
|
+
<div class="p-2 text-sm text-gray-300 font-mono">${newHtml}</div>
|
|
1024
|
+
</div>
|
|
1025
|
+
</div>
|
|
1026
|
+
</div>
|
|
1027
|
+
</div>
|
|
1028
|
+
`;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// Handle trap pipeline if it exists
|
|
1032
|
+
if (network.trap_pipeline) {
|
|
1033
|
+
const trapPipeline = network.trap_pipeline;
|
|
1034
|
+
const trapCurrentLines = trapPipeline.current ? trapPipeline.current.split('\n') : [];
|
|
1035
|
+
const trapNewLines = trapPipeline.new ? trapPipeline.new.split('\n') : [];
|
|
1036
|
+
|
|
1037
|
+
// Check if there are actual changes in the trap pipeline
|
|
1038
|
+
let trapHasChanges = false;
|
|
1039
|
+
if (trapPipeline.action === 'create' || trapPipeline.action === 'delete') {
|
|
1040
|
+
trapHasChanges = true;
|
|
1041
|
+
} else if (trapPipeline.action === 'update') {
|
|
1042
|
+
// Compare current and new to see if there are actual differences
|
|
1043
|
+
const trapLineDiff = computeLineDiff(trapCurrentLines, trapNewLines);
|
|
1044
|
+
trapHasChanges = trapLineDiff.some(change => change.type !== 'equal');
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// Only render trap pipeline if there are actual changes
|
|
1048
|
+
if (trapHasChanges) {
|
|
1049
|
+
// Count trap pipeline in summary only if there are changes
|
|
1050
|
+
if (trapPipeline.action === 'create') {
|
|
1051
|
+
newPipelinesCount++;
|
|
1052
|
+
} else if (trapPipeline.action === 'update') {
|
|
1053
|
+
networksWithChanges++;
|
|
1054
|
+
} else if (trapPipeline.action === 'delete') {
|
|
1055
|
+
deletedPipelinesCount++;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
let trapBadge = '';
|
|
1059
|
+
let trapCurrentHtml = '';
|
|
1060
|
+
let trapNewHtml = '';
|
|
1061
|
+
let trapCurrentLineNum = 1;
|
|
1062
|
+
let trapNewLineNum = 1;
|
|
1063
|
+
|
|
1064
|
+
if (trapPipeline.action === 'create') {
|
|
1065
|
+
trapBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-green-600 text-white rounded">NEW TRAP PIPELINE</span>';
|
|
1066
|
+
|
|
1067
|
+
// Show new trap pipeline
|
|
1068
|
+
for (let i = 0; i < trapNewLines.length; i++) {
|
|
1069
|
+
const line = escapeHtml(trapNewLines[i]);
|
|
1070
|
+
|
|
1071
|
+
trapCurrentHtml += `<div class="flex bg-gray-800/50">
|
|
1072
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1073
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1074
|
+
</div>`;
|
|
1075
|
+
|
|
1076
|
+
trapNewHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
1077
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapNewLineNum++}</span>
|
|
1078
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1079
|
+
</div>`;
|
|
1080
|
+
}
|
|
1081
|
+
} else if (trapPipeline.action === 'delete') {
|
|
1082
|
+
trapBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-red-600 text-white rounded">DELETING TRAP PIPELINE</span>';
|
|
1083
|
+
|
|
1084
|
+
// Show trap pipeline being deleted
|
|
1085
|
+
for (let i = 0; i < trapCurrentLines.length; i++) {
|
|
1086
|
+
const line = escapeHtml(trapCurrentLines[i]);
|
|
1087
|
+
|
|
1088
|
+
trapCurrentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
1089
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapCurrentLineNum++}</span>
|
|
1090
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1091
|
+
</div>`;
|
|
1092
|
+
|
|
1093
|
+
trapNewHtml += `<div class="flex bg-gray-800/50">
|
|
1094
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1095
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1096
|
+
</div>`;
|
|
1097
|
+
}
|
|
1098
|
+
} else if (trapPipeline.action === 'update') {
|
|
1099
|
+
trapBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-blue-600 text-white rounded">UPDATING TRAP PIPELINE</span>';
|
|
1100
|
+
|
|
1101
|
+
// Compute diff for trap pipeline
|
|
1102
|
+
const trapLineDiff = computeLineDiff(trapCurrentLines, trapNewLines);
|
|
1103
|
+
|
|
1104
|
+
for (const change of trapLineDiff) {
|
|
1105
|
+
if (change.type === 'equal') {
|
|
1106
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
1107
|
+
const line = escapeHtml(change.lines[i]);
|
|
1108
|
+
trapCurrentHtml += `<div class="flex hover:bg-gray-700/30">
|
|
1109
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapCurrentLineNum++}</span>
|
|
1110
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1111
|
+
</div>`;
|
|
1112
|
+
trapNewHtml += `<div class="flex hover:bg-gray-700/30">
|
|
1113
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapNewLineNum++}</span>
|
|
1114
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1115
|
+
</div>`;
|
|
1116
|
+
}
|
|
1117
|
+
} else if (change.type === 'delete') {
|
|
1118
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
1119
|
+
const line = escapeHtml(change.lines[i]);
|
|
1120
|
+
trapCurrentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
1121
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapCurrentLineNum++}</span>
|
|
1122
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1123
|
+
</div>`;
|
|
1124
|
+
trapNewHtml += `<div class="flex bg-gray-800/50">
|
|
1125
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1126
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1127
|
+
</div>`;
|
|
1128
|
+
}
|
|
1129
|
+
} else if (change.type === 'insert') {
|
|
1130
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
1131
|
+
const line = escapeHtml(change.lines[i]);
|
|
1132
|
+
trapCurrentHtml += `<div class="flex bg-gray-800/50">
|
|
1133
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1134
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1135
|
+
</div>`;
|
|
1136
|
+
trapNewHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
1137
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapNewLineNum++}</span>
|
|
1138
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1139
|
+
</div>`;
|
|
1140
|
+
}
|
|
1141
|
+
} else if (change.type === 'replace') {
|
|
1142
|
+
const maxLen = Math.max(change.oldLines.length, change.newLines.length);
|
|
1143
|
+
for (let i = 0; i < maxLen; i++) {
|
|
1144
|
+
if (i < change.oldLines.length) {
|
|
1145
|
+
const oldLine = escapeHtml(change.oldLines[i]);
|
|
1146
|
+
trapCurrentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
1147
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapCurrentLineNum++}</span>
|
|
1148
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${oldLine || ' '}</span>
|
|
1149
|
+
</div>`;
|
|
1150
|
+
} else {
|
|
1151
|
+
trapCurrentHtml += `<div class="flex bg-gray-800/50">
|
|
1152
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1153
|
+
<span style="white-space: pre; padding-left: 0.5rem;"></span>
|
|
1154
|
+
</div>`;
|
|
1155
|
+
}
|
|
1156
|
+
if (i < change.newLines.length) {
|
|
1157
|
+
const newLine = escapeHtml(change.newLines[i]);
|
|
1158
|
+
trapNewHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
1159
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${trapNewLineNum++}</span>
|
|
1160
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${newLine || ' '}</span>
|
|
1161
|
+
</div>`;
|
|
1162
|
+
} else {
|
|
1163
|
+
trapNewHtml += `<div class="flex bg-gray-800/50">
|
|
1164
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1165
|
+
<span style="white-space: pre; padding-left: 0.5rem;"></span>
|
|
1166
|
+
</div>`;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// Add trap pipeline section
|
|
1174
|
+
html += `
|
|
1175
|
+
<div class="border border-gray-600 rounded-lg overflow-hidden mt-4">
|
|
1176
|
+
<div class="bg-gray-700 px-4 py-2 border-b border-gray-600">
|
|
1177
|
+
<h4 class="text-white font-semibold">
|
|
1178
|
+
${escapeHtml(network.network_name)} - Trap Pipeline${trapBadge}
|
|
1179
|
+
</h4>
|
|
1180
|
+
<p class="text-sm text-gray-400">Pipeline: ${escapeHtml(trapPipeline.pipeline_name)}</p>
|
|
1181
|
+
</div>
|
|
1182
|
+
<div style="display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; height: 400px;">
|
|
1183
|
+
<div class="p-4 bg-gray-700 border-r border-gray-600" style="display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0;">
|
|
1184
|
+
<div class="mb-2" style="flex-shrink: 0;">
|
|
1185
|
+
<h5 class="text-sm font-semibold text-white">${trapPipeline.action === 'create' ? 'No Existing Trap Pipeline' : 'Current Trap Pipeline'}</h5>
|
|
1186
|
+
</div>
|
|
1187
|
+
<div class="bg-gray-800 rounded border border-gray-600 network-diff-scroll-panel" style="flex: 1; overflow-y: auto; overflow-x: auto; min-height: 0; min-width: 0;">
|
|
1188
|
+
<div class="p-2 text-sm text-gray-300 font-mono">${trapCurrentHtml}</div>
|
|
1189
|
+
</div>
|
|
1190
|
+
</div>
|
|
1191
|
+
<div class="p-4 bg-gray-700" style="display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0;">
|
|
1192
|
+
<div class="mb-2" style="flex-shrink: 0;">
|
|
1193
|
+
<h5 class="text-sm font-semibold text-white">${trapPipeline.action === 'delete' ? 'Pipeline Will Be Deleted' : 'New Trap Pipeline (After Deploy)'}</h5>
|
|
1194
|
+
</div>
|
|
1195
|
+
<div class="bg-gray-800 rounded border border-gray-600 network-diff-scroll-panel" style="flex: 1; overflow-y: auto; overflow-x: auto; min-height: 0; min-width: 0;">
|
|
1196
|
+
<div class="p-2 text-sm text-gray-300 font-mono">${trapNewHtml}</div>
|
|
1197
|
+
</div>
|
|
1198
|
+
</div>
|
|
1199
|
+
</div>
|
|
1200
|
+
</div>
|
|
1201
|
+
`;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// Handle discovery pipeline if it exists
|
|
1206
|
+
if (network.discovery_pipeline) {
|
|
1207
|
+
const discoveryPipeline = network.discovery_pipeline;
|
|
1208
|
+
const discoveryCurrentLines = discoveryPipeline.current ? discoveryPipeline.current.split('\n') : [];
|
|
1209
|
+
const discoveryNewLines = discoveryPipeline.new ? discoveryPipeline.new.split('\n') : [];
|
|
1210
|
+
|
|
1211
|
+
// Check if there are actual changes in the discovery pipeline
|
|
1212
|
+
let discoveryHasChanges = false;
|
|
1213
|
+
if (discoveryPipeline.action === 'create' || discoveryPipeline.action === 'delete') {
|
|
1214
|
+
discoveryHasChanges = true;
|
|
1215
|
+
} else if (discoveryPipeline.action === 'update') {
|
|
1216
|
+
// Compare current and new to see if there are actual differences
|
|
1217
|
+
const discoveryLineDiff = computeLineDiff(discoveryCurrentLines, discoveryNewLines);
|
|
1218
|
+
discoveryHasChanges = discoveryLineDiff.some(change => change.type !== 'equal');
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// Only render discovery pipeline if there are actual changes
|
|
1222
|
+
if (discoveryHasChanges) {
|
|
1223
|
+
// Count discovery pipeline in summary only if there are changes
|
|
1224
|
+
if (discoveryPipeline.action === 'create') {
|
|
1225
|
+
newPipelinesCount++;
|
|
1226
|
+
} else if (discoveryPipeline.action === 'update') {
|
|
1227
|
+
networksWithChanges++;
|
|
1228
|
+
} else if (discoveryPipeline.action === 'delete') {
|
|
1229
|
+
deletedPipelinesCount++;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
let discoveryBadge = '';
|
|
1233
|
+
let discoveryCurrentHtml = '';
|
|
1234
|
+
let discoveryNewHtml = '';
|
|
1235
|
+
let discoveryCurrentLineNum = 1;
|
|
1236
|
+
let discoveryNewLineNum = 1;
|
|
1237
|
+
|
|
1238
|
+
if (discoveryPipeline.action === 'create') {
|
|
1239
|
+
discoveryBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-green-600 text-white rounded">NEW DISCOVERY PIPELINE</span>';
|
|
1240
|
+
|
|
1241
|
+
// Show new discovery pipeline
|
|
1242
|
+
for (let i = 0; i < discoveryNewLines.length; i++) {
|
|
1243
|
+
const line = escapeHtml(discoveryNewLines[i]);
|
|
1244
|
+
|
|
1245
|
+
discoveryCurrentHtml += `<div class="flex bg-gray-800/50">
|
|
1246
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1247
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1248
|
+
</div>`;
|
|
1249
|
+
|
|
1250
|
+
discoveryNewHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
1251
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryNewLineNum++}</span>
|
|
1252
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1253
|
+
</div>`;
|
|
1254
|
+
}
|
|
1255
|
+
} else if (discoveryPipeline.action === 'delete') {
|
|
1256
|
+
discoveryBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-red-600 text-white rounded">DELETING DISCOVERY PIPELINE</span>';
|
|
1257
|
+
|
|
1258
|
+
// Show discovery pipeline being deleted
|
|
1259
|
+
for (let i = 0; i < discoveryCurrentLines.length; i++) {
|
|
1260
|
+
const line = escapeHtml(discoveryCurrentLines[i]);
|
|
1261
|
+
|
|
1262
|
+
discoveryCurrentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
1263
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryCurrentLineNum++}</span>
|
|
1264
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1265
|
+
</div>`;
|
|
1266
|
+
|
|
1267
|
+
discoveryNewHtml += `<div class="flex bg-gray-800/50">
|
|
1268
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1269
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1270
|
+
</div>`;
|
|
1271
|
+
}
|
|
1272
|
+
} else if (discoveryPipeline.action === 'update') {
|
|
1273
|
+
discoveryBadge = '<span class="ml-2 px-2 py-0.5 text-xs bg-blue-600 text-white rounded">UPDATING DISCOVERY PIPELINE</span>';
|
|
1274
|
+
|
|
1275
|
+
// Compute diff for discovery pipeline
|
|
1276
|
+
const discoveryLineDiff = computeLineDiff(discoveryCurrentLines, discoveryNewLines);
|
|
1277
|
+
|
|
1278
|
+
for (const change of discoveryLineDiff) {
|
|
1279
|
+
if (change.type === 'equal') {
|
|
1280
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
1281
|
+
const line = escapeHtml(change.lines[i]);
|
|
1282
|
+
discoveryCurrentHtml += `<div class="flex hover:bg-gray-700/30">
|
|
1283
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryCurrentLineNum++}</span>
|
|
1284
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1285
|
+
</div>`;
|
|
1286
|
+
discoveryNewHtml += `<div class="flex hover:bg-gray-700/30">
|
|
1287
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryNewLineNum++}</span>
|
|
1288
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1289
|
+
</div>`;
|
|
1290
|
+
}
|
|
1291
|
+
} else if (change.type === 'delete') {
|
|
1292
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
1293
|
+
const line = escapeHtml(change.lines[i]);
|
|
1294
|
+
discoveryCurrentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
1295
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryCurrentLineNum++}</span>
|
|
1296
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1297
|
+
</div>`;
|
|
1298
|
+
discoveryNewHtml += `<div class="flex bg-gray-800/50">
|
|
1299
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1300
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1301
|
+
</div>`;
|
|
1302
|
+
}
|
|
1303
|
+
} else if (change.type === 'insert') {
|
|
1304
|
+
for (let i = 0; i < change.lines.length; i++) {
|
|
1305
|
+
const line = escapeHtml(change.lines[i]);
|
|
1306
|
+
discoveryCurrentHtml += `<div class="flex bg-gray-800/50">
|
|
1307
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1308
|
+
<span style="white-space: pre; padding-left: 0.5rem; color: #555;"></span>
|
|
1309
|
+
</div>`;
|
|
1310
|
+
discoveryNewHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
1311
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryNewLineNum++}</span>
|
|
1312
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${line || ' '}</span>
|
|
1313
|
+
</div>`;
|
|
1314
|
+
}
|
|
1315
|
+
} else if (change.type === 'replace') {
|
|
1316
|
+
const maxLen = Math.max(change.oldLines.length, change.newLines.length);
|
|
1317
|
+
for (let i = 0; i < maxLen; i++) {
|
|
1318
|
+
if (i < change.oldLines.length) {
|
|
1319
|
+
const oldLine = escapeHtml(change.oldLines[i]);
|
|
1320
|
+
discoveryCurrentHtml += `<div class="flex bg-red-900/20 hover:bg-red-900/30">
|
|
1321
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryCurrentLineNum++}</span>
|
|
1322
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${oldLine || ' '}</span>
|
|
1323
|
+
</div>`;
|
|
1324
|
+
} else {
|
|
1325
|
+
discoveryCurrentHtml += `<div class="flex bg-gray-800/50">
|
|
1326
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1327
|
+
<span style="white-space: pre; padding-left: 0.5rem;"></span>
|
|
1328
|
+
</div>`;
|
|
1329
|
+
}
|
|
1330
|
+
if (i < change.newLines.length) {
|
|
1331
|
+
const newLine = escapeHtml(change.newLines[i]);
|
|
1332
|
+
discoveryNewHtml += `<div class="flex bg-green-900/20 hover:bg-green-900/30">
|
|
1333
|
+
<span class="inline-block w-12 text-gray-500 text-right pr-3 select-none flex-shrink-0">${discoveryNewLineNum++}</span>
|
|
1334
|
+
<span style="white-space: pre; padding-left: 0.5rem;">${newLine || ' '}</span>
|
|
1335
|
+
</div>`;
|
|
1336
|
+
} else {
|
|
1337
|
+
discoveryNewHtml += `<div class="flex bg-gray-800/50">
|
|
1338
|
+
<span class="inline-block w-12 text-gray-600 text-right pr-3 select-none flex-shrink-0">-</span>
|
|
1339
|
+
<span style="white-space: pre; padding-left: 0.5rem;"></span>
|
|
1340
|
+
</div>`;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
// Add discovery pipeline section
|
|
1348
|
+
html += `
|
|
1349
|
+
<div class="border border-gray-600 rounded-lg overflow-hidden mt-4">
|
|
1350
|
+
<div class="bg-gray-700 px-4 py-2 border-b border-gray-600">
|
|
1351
|
+
<h4 class="text-white font-semibold">
|
|
1352
|
+
${escapeHtml(network.network_name)} - Discovery Pipeline${discoveryBadge}
|
|
1353
|
+
</h4>
|
|
1354
|
+
<p class="text-sm text-gray-400">Pipeline: ${escapeHtml(discoveryPipeline.pipeline_name)}</p>
|
|
1355
|
+
</div>
|
|
1356
|
+
<div style="display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; height: 400px;">
|
|
1357
|
+
<div class="p-4 bg-gray-700 border-r border-gray-600" style="display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0;">
|
|
1358
|
+
<div class="mb-2" style="flex-shrink: 0;">
|
|
1359
|
+
<h5 class="text-sm font-semibold text-white">${discoveryPipeline.action === 'create' ? 'No Existing Discovery Pipeline' : 'Current Discovery Pipeline'}</h5>
|
|
1360
|
+
</div>
|
|
1361
|
+
<div class="bg-gray-800 rounded border border-gray-600 network-diff-scroll-panel" style="flex: 1; overflow-y: auto; overflow-x: auto; min-height: 0; min-width: 0;">
|
|
1362
|
+
<div class="p-2 text-sm text-gray-300 font-mono">${discoveryCurrentHtml}</div>
|
|
1363
|
+
</div>
|
|
1364
|
+
</div>
|
|
1365
|
+
<div class="p-4 bg-gray-700" style="display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0;">
|
|
1366
|
+
<div class="mb-2" style="flex-shrink: 0;">
|
|
1367
|
+
<h5 class="text-sm font-semibold text-white">${discoveryPipeline.action === 'delete' ? 'Pipeline Will Be Deleted' : 'New Discovery Pipeline (After Deploy)'}</h5>
|
|
1368
|
+
</div>
|
|
1369
|
+
<div class="bg-gray-800 rounded border border-gray-600 network-diff-scroll-panel" style="flex: 1; overflow-y: auto; overflow-x: auto; min-height: 0; min-width: 0;">
|
|
1370
|
+
<div class="p-2 text-sm text-gray-300 font-mono">${discoveryNewHtml}</div>
|
|
1371
|
+
</div>
|
|
1372
|
+
</div>
|
|
1373
|
+
</div>
|
|
1374
|
+
</div>
|
|
1375
|
+
`;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// If no networks have changes, show a message
|
|
1381
|
+
if (networksWithChanges === 0 && newPipelinesCount === 0 && deletedPipelinesCount === 0) {
|
|
1382
|
+
container.innerHTML = `
|
|
1383
|
+
<div class="text-center p-8">
|
|
1384
|
+
<div class="inline-flex items-center justify-center w-16 h-16 bg-green-600/20 rounded-full mb-4">
|
|
1385
|
+
<svg class="w-8 h-8 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
1386
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
|
1387
|
+
</svg>
|
|
1388
|
+
</div>
|
|
1389
|
+
<h3 class="text-xl font-semibold text-white mb-2">No Changes Detected</h3>
|
|
1390
|
+
<p class="text-gray-400">All network pipelines are up to date. No changes need to be deployed.</p>
|
|
1391
|
+
</div>
|
|
1392
|
+
`;
|
|
1393
|
+
|
|
1394
|
+
// Disable the deploy button since there's nothing to deploy
|
|
1395
|
+
_snmpNoChangesBlocked = true;
|
|
1396
|
+
_updateDeployButtonState();
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// Add stats at the top
|
|
1401
|
+
let statsHtml = '<div class="mb-4 p-4 bg-gray-700 rounded-lg border border-gray-600">';
|
|
1402
|
+
statsHtml += '<h3 class="text-white font-semibold mb-2">Changes Summary</h3>';
|
|
1403
|
+
statsHtml += '<div class="flex gap-4 text-sm">';
|
|
1404
|
+
|
|
1405
|
+
if (newPipelinesCount > 0) {
|
|
1406
|
+
statsHtml += `<div class="flex items-center gap-2">
|
|
1407
|
+
<span class="px-2 py-0.5 text-xs bg-green-600 text-white rounded">NEW</span>
|
|
1408
|
+
<span class="text-gray-300">${newPipelinesCount} new pipeline${newPipelinesCount !== 1 ? 's' : ''}</span>
|
|
1409
|
+
</div>`;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
if (networksWithChanges > 0) {
|
|
1413
|
+
statsHtml += `<div class="flex items-center gap-2">
|
|
1414
|
+
<span class="px-2 py-0.5 text-xs bg-blue-600 text-white rounded">MODIFIED</span>
|
|
1415
|
+
<span class="text-gray-300">${networksWithChanges} modified pipeline${networksWithChanges !== 1 ? 's' : ''}</span>
|
|
1416
|
+
</div>`;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
if (deletedPipelinesCount > 0) {
|
|
1420
|
+
statsHtml += `<div class="flex items-center gap-2">
|
|
1421
|
+
<span class="px-2 py-0.5 text-xs bg-red-600 text-white rounded">DELETED</span>
|
|
1422
|
+
<span class="text-gray-300">${deletedPipelinesCount} deleted pipeline${deletedPipelinesCount !== 1 ? 's' : ''}</span>
|
|
1423
|
+
</div>`;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
statsHtml += '</div></div>';
|
|
1427
|
+
|
|
1428
|
+
container.innerHTML = statsHtml + html;
|
|
1429
|
+
|
|
1430
|
+
// Synchronize scrolling for each network's diff panels
|
|
1431
|
+
const allSections = container.querySelectorAll('.border.border-gray-600');
|
|
1432
|
+
allSections.forEach(section => {
|
|
1433
|
+
const panels = section.querySelectorAll('.network-diff-scroll-panel');
|
|
1434
|
+
const leftPanel = panels[0];
|
|
1435
|
+
const rightPanel = panels[1];
|
|
1436
|
+
|
|
1437
|
+
if (leftPanel && rightPanel) {
|
|
1438
|
+
let isScrolling = false;
|
|
1439
|
+
|
|
1440
|
+
leftPanel.addEventListener('scroll', () => {
|
|
1441
|
+
if (!isScrolling) {
|
|
1442
|
+
isScrolling = true;
|
|
1443
|
+
rightPanel.scrollTop = leftPanel.scrollTop;
|
|
1444
|
+
rightPanel.scrollLeft = leftPanel.scrollLeft;
|
|
1445
|
+
setTimeout(() => {
|
|
1446
|
+
isScrolling = false;
|
|
1447
|
+
}, 10);
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
|
|
1451
|
+
rightPanel.addEventListener('scroll', () => {
|
|
1452
|
+
if (!isScrolling) {
|
|
1453
|
+
isScrolling = true;
|
|
1454
|
+
leftPanel.scrollTop = rightPanel.scrollTop;
|
|
1455
|
+
leftPanel.scrollLeft = rightPanel.scrollLeft;
|
|
1456
|
+
setTimeout(() => {
|
|
1457
|
+
isScrolling = false;
|
|
1458
|
+
}, 10);
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Confirm and deploy the SNMP configuration
|
|
1467
|
+
*/
|
|
1468
|
+
async function confirmDeployConfiguration() {
|
|
1469
|
+
const confirmButton = document.getElementById('confirmDeployButton');
|
|
1470
|
+
const originalText = confirmButton.textContent;
|
|
1471
|
+
|
|
1472
|
+
// Disable button and show loading state
|
|
1473
|
+
const changeCount = window.snmpChangeCount || 0;
|
|
1474
|
+
const isLargeDeployment = changeCount > 100;
|
|
1475
|
+
|
|
1476
|
+
confirmButton.disabled = true;
|
|
1477
|
+
confirmButton.textContent = isLargeDeployment
|
|
1478
|
+
? 'Deploying... (this may take several minutes)'
|
|
1479
|
+
: 'Deploying...';
|
|
1480
|
+
confirmButton.classList.add('opacity-50', 'cursor-not-allowed');
|
|
1481
|
+
|
|
1482
|
+
// Show progress toast - conditional message based on change count
|
|
1483
|
+
const message = isLargeDeployment
|
|
1484
|
+
? 'Deployment started. This may take several minutes for large configurations...'
|
|
1485
|
+
: 'Deployment started!';
|
|
1486
|
+
showToast(message, 'info');
|
|
1487
|
+
|
|
1488
|
+
try {
|
|
1489
|
+
// Create AbortController with 10-minute timeout for large deployments
|
|
1490
|
+
const controller = new AbortController();
|
|
1491
|
+
const timeoutId = setTimeout(() => controller.abort(), 600000); // 10 minutes
|
|
1492
|
+
|
|
1493
|
+
const response = await fetch('/SNMP/DeployConfiguration/', {
|
|
1494
|
+
method: 'POST',
|
|
1495
|
+
headers: {
|
|
1496
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
1497
|
+
'Content-Type': 'application/json'
|
|
1498
|
+
},
|
|
1499
|
+
signal: controller.signal
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
clearTimeout(timeoutId);
|
|
1503
|
+
|
|
1504
|
+
if (response.status === 403) {
|
|
1505
|
+
showToast('Access denied: Admin role required', 'error');
|
|
1506
|
+
if (confirmButton) confirmButton.disabled = false;
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
if (!response.ok) {
|
|
1511
|
+
const errorText = await response.text();
|
|
1512
|
+
throw new Error(`Failed to deploy configuration: ${response.status} - ${errorText}`);
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
const result = await response.json();
|
|
1516
|
+
|
|
1517
|
+
if (result.success) {
|
|
1518
|
+
// Show success toast
|
|
1519
|
+
let message = result.message || 'Configuration deployed successfully!';
|
|
1520
|
+
showToast(message, 'success');
|
|
1521
|
+
|
|
1522
|
+
// Show warnings as separate toasts if any
|
|
1523
|
+
if (result.errors && result.errors.length > 0) {
|
|
1524
|
+
result.errors.forEach(error => {
|
|
1525
|
+
showToast(error, 'warning');
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// Close the modal
|
|
1530
|
+
hideSnmpDiffModal();
|
|
1531
|
+
|
|
1532
|
+
// Refresh the undeployed changes indicator
|
|
1533
|
+
if (typeof window.triggerUndeployedChangesCheck === 'function') {
|
|
1534
|
+
window.triggerUndeployedChangesCheck();
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// Optionally reload the page to reflect changes
|
|
1538
|
+
// window.location.reload();
|
|
1539
|
+
} else {
|
|
1540
|
+
throw new Error(result.error || 'Unknown error occurred');
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
} catch (error) {
|
|
1544
|
+
console.error('Error deploying configuration:', error);
|
|
1545
|
+
|
|
1546
|
+
// Handle timeout/abort errors specifically
|
|
1547
|
+
if (error.name === 'AbortError') {
|
|
1548
|
+
showToast('Deployment timed out after 10 minutes. Check server logs for status.', 'error');
|
|
1549
|
+
} else {
|
|
1550
|
+
showToast('Failed to deploy configuration: ' + error.message, 'error');
|
|
1551
|
+
}
|
|
1552
|
+
} finally {
|
|
1553
|
+
// Re-enable button
|
|
1554
|
+
confirmButton.disabled = false;
|
|
1555
|
+
confirmButton.textContent = originalText;
|
|
1556
|
+
confirmButton.classList.remove('opacity-50', 'cursor-not-allowed');
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
|