-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dummy storage charms for testing purposes
- Loading branch information
evanson
committed
Sep 2, 2022
1 parent
a18bf5b
commit 57a8b9a
Showing
43 changed files
with
691 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
options: | ||
# Will be tokens for each storage type. | ||
data-token: | ||
type: string | ||
default: '' | ||
description: Token used to prove data stored is persistent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Getting file fs token details." | ||
status-set maintenance "Getting file fs token details." || true | ||
|
||
function set_token() { | ||
token_name=$1 # i.e. data-token | ||
fs_path=$2 # i.e. /srv/data/ | ||
|
||
token="$(config-get $token_name)" | ||
token_file="$fs_path/token" | ||
|
||
juju-log -l INFO "Token file: $token_file" | ||
|
||
if [ -f $token_file ]; then | ||
juju-log -l INFO "Using stored token details." | ||
|
||
# If we have a token and we have a token file, check the contents if the differ update it otherwise use it. | ||
current_file_token=$(cat $token_file | grep "$token_name" | head -1 | cut -d":" -f2) | ||
if [ "$current_file_token" != "$token" ]; then | ||
token=$token | ||
else | ||
token=$(cat $token_file) | ||
fi | ||
fi | ||
|
||
if [[ -z $token ]]; then | ||
fs_token="not set" | ||
juju-log -l WARNING "$fs_token" | ||
else | ||
fs_token="$token" | ||
echo "$token" > $token_file | ||
juju-log -l INFO "$fs_token" | ||
fi | ||
|
||
# Return the token value. | ||
echo "$fs_token" | ||
} | ||
|
||
# Clear any previous tokens or state. | ||
echo > /tmp/status | ||
|
||
# First the single token | ||
data_token=$(set_token "data-token" "/srv/data") | ||
|
||
juju-log -l INFO "Setting single token details." | ||
echo "data-token:$data_token" >> /tmp/status | ||
|
||
## Then the multi-fs token | ||
#for unit in $(storage-list multi-fs); do | ||
# fs_path=$(storage-get -s $unit | grep "^location:\ " | cut -d: -f2 | tr -d ' ') | ||
# multi_fs_token=$(set_token "multi-fs-token" "$fs_path") | ||
# juju-log -l INFO "Setting multi token details." | ||
# unit_token_number=$(echo $unit | cut -f2 -d"/") | ||
# echo "multi-fs-token/$unit_token_number:$multi_fs_token" >> /tmp/status | ||
#done | ||
|
||
status-set active "Stored token: /tmp/status" || true |
7 changes: 7 additions & 0 deletions
7
testcharms/charms/dummy-storage-fs/hooks/data-storage-attached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Storage is attached." | ||
juju-log -l INFO "Storage details: $(storage-list)" | ||
|
||
status-set active "Started" || true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
status-set maintenance "Removing sshguard" || true | ||
sudo apt-get remove sshguard || true | ||
|
||
juju-log -l INFO "Install" | ||
juju-log -l INFO "Data on drive: $(cat /srv/data/test.txt)" | ||
|
||
for unit in $(storage-list); do | ||
juju-log -l INFO "Storage details for ${unit}: $(storage-get -s $unit)" | ||
done | ||
|
||
# The storage-attached hook has fired so we can write some data there now. | ||
status-set maintenance "Installed" || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Starting, checking what storage we have." | ||
juju-log -l INFO "Storage details: $(storage-list)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: dummy-storage-fs | ||
maintainer: | ||
- Christopher Lee <chris.lee@canonical.com> | ||
- Burton Swan <burton.swan@canonical.com> | ||
- Evanson Mwangi <evanson.wainaina@canonical.com> | ||
summary: Dummy charm that utilises storage. | ||
description: This dummy-storage-fs charm is used for testing charm storage. | ||
categories: | ||
- misc | ||
series: | ||
- trusty | ||
- xenial | ||
- artful | ||
- bionic | ||
- eoan | ||
- focal | ||
- jammy | ||
|
||
storage: | ||
data: | ||
type: filesystem | ||
description: junk storage | ||
minimum-size: 100M | ||
location: /srv/data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
options: | ||
# Will be tokens for each storage type. | ||
data-token: | ||
type: string | ||
default: '' | ||
description: Token used to prove data stored is persistent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Getting file fs token details." | ||
status-set maintenance "Getting file fs token details." || true | ||
|
||
function set_token() { | ||
token_name=$1 # i.e. data-token | ||
fs_path=$2 # i.e. /srv/data/ | ||
|
||
token="$(config-get $token_name)" | ||
token_file="$fs_path/token" | ||
|
||
juju-log -l INFO "Token file: $token_file" | ||
|
||
if [ -f $token_file ]; then | ||
juju-log -l INFO "Using stored token details." | ||
|
||
# If we have a token and we have a token file, check the contents if the differ update it otherwise use it. | ||
current_file_token=$(cat $token_file | grep "$token_name" | head -1 | cut -d":" -f2) | ||
if [ "$current_file_token" != "$token" ]; then | ||
token=$token | ||
else | ||
token=$(cat $token_file) | ||
fi | ||
fi | ||
|
||
if [[ -z $token ]]; then | ||
fs_token="not set" | ||
juju-log -l WARNING "$fs_token" | ||
else | ||
fs_token="$token" | ||
echo "$token" > $token_file | ||
juju-log -l INFO "$fs_token" | ||
fi | ||
|
||
# Return the token value. | ||
echo "$fs_token" | ||
} | ||
|
||
# Clear any previous tokens or state. | ||
echo > /tmp/status | ||
|
||
# First the single token | ||
data_token=$(set_token "data-token" "/srv/data") | ||
|
||
juju-log -l INFO "Setting single token details." | ||
echo "data-token:$data_token" >> /tmp/status | ||
|
||
## Then the multi-fs token | ||
#for unit in $(storage-list multi-fs); do | ||
# fs_path=$(storage-get -s $unit | grep "^location:\ " | cut -d: -f2 | tr -d ' ') | ||
# multi_fs_token=$(set_token "multi-fs-token" "$fs_path") | ||
# juju-log -l INFO "Setting multi token details." | ||
# unit_token_number=$(echo $unit | cut -f2 -d"/") | ||
# echo "multi-fs-token/$unit_token_number:$multi_fs_token" >> /tmp/status | ||
#done | ||
|
||
status-set active "Stored token: /tmp/status" || true |
7 changes: 7 additions & 0 deletions
7
testcharms/charms/dummy-storage-lp/hooks/disks-storage-attached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Storage is attached." | ||
juju-log -l INFO "Storage details: $(storage-list)" | ||
|
||
status-set active "Started" || true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
status-set maintenance "Removing sshguard" || true | ||
sudo apt-get remove sshguard || true | ||
|
||
juju-log -l INFO "Install" | ||
juju-log -l INFO "Data on drive: $(cat /srv/data/test.txt)" | ||
|
||
for unit in $(storage-list); do | ||
juju-log -l INFO "Storage details for ${unit}: $(storage-get -s $unit)" | ||
done | ||
|
||
# The storage-attached hook has fired so we can write some data there now. | ||
status-set maintenance "Installed" || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Starting, checking what storage we have." | ||
juju-log -l INFO "Storage details: $(storage-list)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: dummy-storage-lp | ||
maintainer: | ||
- Christopher Lee <chris.lee@canonical.com> | ||
- Burton Swan <burton.swan@canonical.com> | ||
- Evanson Mwangi <evanson.wainaina@canonical.com> | ||
summary: Dummy charm that utilises storage. | ||
description: This dummy-storage-fs charm is used for testing charm storage. | ||
categories: | ||
- misc | ||
series: | ||
- trusty | ||
- xenial | ||
- artful | ||
- bionic | ||
- eoan | ||
- focal | ||
- jammy | ||
|
||
storage: | ||
disks: | ||
type: block | ||
multiple: | ||
range: 0-10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
options: | ||
# Will be tokens for each storage type. | ||
data-token: | ||
type: string | ||
default: '' | ||
description: Token used to prove data stored is persistent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Getting file fs token details." | ||
status-set maintenance "Getting file fs token details." || true | ||
|
||
function set_token() { | ||
token_name=$1 # i.e. data-token | ||
fs_path=$2 # i.e. /srv/data/ | ||
|
||
token="$(config-get $token_name)" | ||
token_file="$fs_path/token" | ||
|
||
juju-log -l INFO "Token file: $token_file" | ||
|
||
if [ -f $token_file ]; then | ||
juju-log -l INFO "Using stored token details." | ||
|
||
# If we have a token and we have a token file, check the contents if the differ update it otherwise use it. | ||
current_file_token=$(cat $token_file | grep "$token_name" | head -1 | cut -d":" -f2) | ||
if [ "$current_file_token" != "$token" ]; then | ||
token=$token | ||
else | ||
token=$(cat $token_file) | ||
fi | ||
fi | ||
|
||
if [[ -z $token ]]; then | ||
fs_token="not set" | ||
juju-log -l WARNING "$fs_token" | ||
else | ||
fs_token="$token" | ||
echo "$token" > $token_file | ||
juju-log -l INFO "$fs_token" | ||
fi | ||
|
||
# Return the token value. | ||
echo "$fs_token" | ||
} | ||
|
||
# Clear any previous tokens or state. | ||
echo > /tmp/status | ||
|
||
# First the single token | ||
data_token=$(set_token "data-token" "/srv/data") | ||
|
||
juju-log -l INFO "Setting single token details." | ||
echo "data-token:$data_token" >> /tmp/status | ||
|
||
## Then the multi-fs token | ||
#for unit in $(storage-list multi-fs); do | ||
# fs_path=$(storage-get -s $unit | grep "^location:\ " | cut -d: -f2 | tr -d ' ') | ||
# multi_fs_token=$(set_token "multi-fs-token" "$fs_path") | ||
# juju-log -l INFO "Setting multi token details." | ||
# unit_token_number=$(echo $unit | cut -f2 -d"/") | ||
# echo "multi-fs-token/$unit_token_number:$multi_fs_token" >> /tmp/status | ||
#done | ||
|
||
status-set active "Stored token: /tmp/status" || true |
7 changes: 7 additions & 0 deletions
7
testcharms/charms/dummy-storage-mp/hooks/data-storage-attached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Storage is attached." | ||
juju-log -l INFO "Storage details: $(storage-list)" | ||
|
||
status-set active "Started" || true |
7 changes: 7 additions & 0 deletions
7
testcharms/charms/dummy-storage-mp/hooks/disks-storage-attached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Storage is attached." | ||
juju-log -l INFO "Storage details: $(storage-list)" | ||
|
||
status-set active "Started" || true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
status-set maintenance "Removing sshguard" || true | ||
sudo apt-get remove sshguard || true | ||
|
||
juju-log -l INFO "Install" | ||
juju-log -l INFO "Data on drive: $(cat /srv/data/test.txt)" | ||
|
||
for unit in $(storage-list); do | ||
juju-log -l INFO "Storage details for ${unit}: $(storage-get -s $unit)" | ||
done | ||
|
||
# The storage-attached hook has fired so we can write some data there now. | ||
status-set maintenance "Installed" || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
juju-log -l INFO "Starting, checking what storage we have." | ||
juju-log -l INFO "Storage details: $(storage-list)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: dummy-storage-mp | ||
maintainer: | ||
- Christopher Lee <chris.lee@canonical.com> | ||
- Burton Swan <burton.swan@canonical.com> | ||
- Evanson Mwangi <evanson.wainaina@canonical.com> | ||
summary: Dummy charm that utilises storage. | ||
description: This dummy-storage-fs charm is used for testing charm storage. | ||
categories: | ||
- misc | ||
series: | ||
- trusty | ||
- xenial | ||
- artful | ||
- bionic | ||
- eoan | ||
- focal | ||
- jammy | ||
|
||
storage: | ||
data: | ||
type: filesystem | ||
description: junk storage | ||
minimum-size: 100M | ||
location: /srv/data | ||
disks: | ||
type: block | ||
multiple: | ||
range: 0-10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
options: | ||
# Will be tokens for each storage type. | ||
data-token: | ||
type: string | ||
default: '' | ||
description: Token used to prove data stored is persistent |
Oops, something went wrong.