Skip to content

Commit

Permalink
Added instructions for running sample.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Aug 15, 2024
1 parent 0d2c48e commit 8e2f3d2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions guides/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Snapshot Actions
In this guide, we will look at some snapshot actions that allow you to manage and work with snapshots of your indices.

A complete working sample for this guide can be found in [samples/snapshot](../samples/snapshot).

## Setup
Let's create a client instance, and an index named `movies`:
Expand Down
2 changes: 1 addition & 1 deletion samples/Dockerfile → samples/snapshot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ ARG GID=1000

RUN echo 'path.repo: ["/usr/share/opensearch/backups"]' >> $OPENSEARCH_HOME/config/opensearch.yml
RUN mkdir -p $OPENSEARCH_HOME/backups
RUN chown -Rv $UID:$GID $OPENSEARCH_HOME/backups
RUN chown -Rv $UID:$GID $OPENSEARCH_HOME/backups
8 changes: 8 additions & 0 deletions samples/snapshot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Run this sample as follows.

```
cd samples
docker run --rm -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -it $(docker build -q snapshot )
poetry install
poetry run python snapshot/snapshot_sample.py
```
3 changes: 2 additions & 1 deletion samples/snapshot/snapshot_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.

import os
import tempfile

from opensearchpy import OpenSearch
Expand All @@ -17,7 +18,7 @@

HOST = "localhost"
PORT = 9200
auth = ("admin", "admin") # For testing only. Don't store credentials in code.
auth = ("admin", os.getenv("OPENSEARCH_PASSWORD", "admin")) # For testing only. Don't store credentials in code.

client = OpenSearch(
hosts=[{"host": HOST, "port": PORT}],
Expand Down

0 comments on commit 8e2f3d2

Please sign in to comment.