Merge ~rgildein/charm-telegraf:update/bootstack-template into charm-telegraf:master

Proposed by Robert Gildein
Status: Merged
Approved by: Eric Chen
Approved revision: b9f7aa60c27a41fbcdac6f95e429f27ac7c9e143
Merged at revision: 3202b0a91d6a3f13ce6946490be7b22d2887b90f
Proposed branch: ~rgildein/charm-telegraf:update/bootstack-template
Merge into: charm-telegraf:master
Diff against target: 739 lines (+216/-156)
26 files modified
.pre-commit-config.yaml (+22/-0)
Makefile (+48/-42)
charmcraft.yaml (+26/-18)
rename.sh (+4/-0)
src/hooks/apache-relation-changed (+3/-0)
src/hooks/exec-relation-changed (+3/-0)
src/hooks/haproxy-relation-changed (+3/-0)
src/hooks/relations/telegraf-exec/interface.yaml (+1/-1)
src/icon.svg (+1/-1)
src/pyproject.toml (+35/-0)
src/reactive/telegraf.py (+4/-9)
src/templates/apache-server-status.tmpl (+0/-1)
src/templates/influxdb-api.conf.tmpl (+1/-2)
src/templates/sudoers/telegraf_intel_rdt.tmpl (+0/-1)
src/templates/sudoers/telegraf_ipmi.tmpl (+0/-1)
src/templates/sudoers/telegraf_iptables.tmpl (+0/-1)
src/templates/sudoers/telegraf_ovs.tmpl (+0/-1)
src/templates/sudoers/telegraf_smart.tmpl (+0/-1)
src/templates/telegraf.conf.tmpl (+3/-3)
src/tests/functional/tests/base.py (+0/-2)
src/tests/functional/tests/test_telegraf.py (+0/-1)
src/tests/functional/tests/tests.yaml (+0/-1)
src/tests/unit/requirements.txt (+1/-10)
src/tests/unit/test_telegraf.py (+4/-8)
src/tests/unit/test_templates_sudoers.py (+13/-8)
src/tox.ini (+44/-44)
Reviewer Review Type Date Requested Status
Eric Chen Approve
Tianqi Xiao (community) Approve
BootStack Reviewers Pending
Review via email: mp+428255@code.launchpad.net

Commit message

Update templates file from bootstack-charms-spec

- update rename.sh, Makefile, charmcraft.yaml, tox.ini and
  .pre-commit-config.yaml from bootstack-charms-spec
- clean requirements
- moved check of sudoers templates from lint to unit tests

Description of the change

Update templates file from bootstack-charms-spec

- update rename.sh, Makefile, charmcraft.yaml, tox.ini and
  .pre-commit-config.yaml from bootstack-charms-spec
- clean requirements
- moved check of sudoers templates from lint to unit tests

To post a comment you must log in.
Revision history for this message
Robert Gildein (rgildein) wrote :

tested with scrip: https://pastebin.ubuntu.com/p/vQ96wzpJt4/
result from tests: https://pastebin.ubuntu.com/p/CJy93VVq7C/
  - tests for focal-postgres failed, so I tried to run
    `make functional FUNC_ARGS="--dev"` <==> run only focal-compute,
    but same result
  - those tested failed because unit is in "maintenance" state with
    "Installing python3-netifaces,python3-yaml,sysstat,telegraf" message
  - I do not think that this changes is responsible for that

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Eric Chen (eric-chen) :
review: Needs Fixing
Revision history for this message
Robert Gildein (rgildein) :
Revision history for this message
Tianqi Xiao (txiao) wrote :

Overall LGTM. Just one small thing that I would need clarification of. Please see my inline command.

review: Needs Information
Revision history for this message
Eric Chen (eric-chen) :
Revision history for this message
Robert Gildein (rgildein) :
Revision history for this message
Robert Gildein (rgildein) :
Revision history for this message
Robert Gildein (rgildein) wrote (last edit ):
Revision history for this message
Robert Gildein (rgildein) wrote :

result from new unit tests: https://pastebin.ubuntu.com/p/dXVz4Khwkv/
couple of tests are broken, but it's not related with my changes
https://bugs.launchpad.net/charm-telegraf/+bug/1987542

Revision history for this message
Tianqi Xiao (txiao) :
review: Approve
Revision history for this message
Eric Chen (eric-chen) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 3202b0a91d6a3f13ce6946490be7b22d2887b90f

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
0new file mode 1006440new file mode 100644
index 0000000..18d9070
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,22 @@
1# This is a template `.pre-commit-config.yaml` file for reactive charms
2# This file is managed by bootstack-charms-spec and should not be modified
3# within individual charm repos. https://launchpad.net/bootstack-charms-spec
4
5repos:
6 - repo: https://github.com/pre-commit/pre-commit-hooks
7 rev: v4.3.0
8 hooks:
9 - id: check-executables-have-shebangs
10 - id: check-merge-conflict
11 - id: end-of-file-fixer
12 - id: trailing-whitespace
13 - id: check-added-large-files
14 - id: check-json
15 - id: check-yaml
16 - repo: local
17 hooks:
18 - id: lint
19 name: lint
20 entry: make lint
21 language: system
22 types: [ python ]
diff --git a/Makefile b/Makefile
index dd167dd..b35c74e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,45 +1,42 @@
1# This is a template `Makefile` file for reactive charms
2# This file is managed by bootstack-charms-spec and should not be modified
3# within individual charm repos. https://launchpad.net/bootstack-charms-spec
4
1PYTHON := /usr/bin/python35PYTHON := /usr/bin/python3
26
3PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))7PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
4ifndef CHARM_BUILD_DIR8CHARM_BUILD_DIR:=${PROJECTPATH}.build
5 CHARM_BUILD_DIR=${PROJECTPATH}.build9CHARM_LAYERS_DIR:=${PROJECTPATH}/layers
6endif10CHARM_INTERFACES_DIR:=${PROJECTPATH}/interfaces
7ifndef CHARM_LAYERS_DIR11RELEASE_CHANNEL:=edge
8 CHARM_LAYERS_DIR=${PROJECTPATH}/layers
9endif
10ifndef CHARM_INTERFACES_DIR
11 CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
12endif
13ifdef CONTAINER
14 BUILD_ARGS="--destructive-mode"
15endif
16METADATA_FILE="src/metadata.yaml"12METADATA_FILE="src/metadata.yaml"
17CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')13CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E '^name:' | awk '{print $$2}')
1814
19help:15help:
20 @echo "This project supports the following targets"16 @echo "This project supports the following targets"
21 @echo ""17 @echo ""
22 @echo " make help - show this text"18 @echo " make help - show this text"
23 @echo " make clean - remove unneeded files"19 @echo " make dev-environment - setup the development environment"
24 @echo " make submodules - make sure that the submodules are up-to-date"20 @echo " make pre-commit - run pre-commit checks on all the files"
21 @echo " make submodules - initialize, fetch, and checkout any nested submodules"
25 @echo " make submodules-update - update submodules to latest changes on remote branch"22 @echo " make submodules-update - update submodules to latest changes on remote branch"
23 @echo " make clean - remove unneeded files and clean charmcraft environment"
26 @echo " make build - build the charm"24 @echo " make build - build the charm"
27 @echo " make release - run clean, submodules, and build targets"
28 @echo " make lint - run flake8 and black --check"
29 @echo " make black - run black and reformat files"
30 @echo " make proof - run charm proof"25 @echo " make proof - run charm proof"
26 @echo " make release - run clean, build and proof target and upload charm to channel"
27 @echo " make lint - run flake8, black --check and isort --check"
28 @echo " make reformat - run black and isort and reformat files"
31 @echo " make unittests - run the tests defined in the unittest subdirectory"29 @echo " make unittests - run the tests defined in the unittest subdirectory"
32 @echo " make functional - run the tests defined in the functional subdirectory"30 @echo " make functional - run the tests defined in the functional subdirectory"
33 @echo " make test - run lint, proof, unittests and functional targets"31 @echo " make test - run lint, unittests and functional targets"
34 @echo ""32 @echo ""
3533
36clean:34dev-environment:
37 @echo "Cleaning files"35 @echo "Creating virtualenv with pre-commit installed"
38 @git clean -ffXd -e '!.idea'36 @cd src && tox -r -e dev-environment
39 @echo "Cleaning existing build"37
40 @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}38pre-commit:
41 @rm -rf ${PROJECTPATH}/${CHARM_NAME}*.charm39 @cd src && tox -e pre-commit
42 @charmcraft clean
4340
44submodules:41submodules:
45 @echo "Cloning submodules"42 @echo "Cloning submodules"
@@ -49,39 +46,48 @@ submodules-update:
49 @echo "Pulling latest updates for submodules"46 @echo "Pulling latest updates for submodules"
50 @git submodule update --init --recursive --remote --merge47 @git submodule update --init --recursive --remote --merge
5148
52build: clean submodules-update49clean:
53 @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"50 @echo "Cleaning files"
54 @-git rev-parse --abbrev-ref HEAD > ./src/repo-info51 @git clean -ffXd -e '!.idea' -e '!.vscode'
52 @echo "Cleaning existing build"
53 @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
54 @rm -rf ${PROJECTPATH}/${CHARM_NAME}*.charm
55 @echo "Cleaning charmcraft"
56 @charmcraft clean
57
58build: clean
59 @echo "Building charm"
55 @charmcraft -v pack ${BUILD_ARGS}60 @charmcraft -v pack ${BUILD_ARGS}
56 @bash -c ./rename.sh61 @bash -c ./rename.sh
62
63proof: build
64 @echo "Running charm proof"
57 @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME}65 @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME}
58 @unzip ${PROJECTPATH}/${CHARM_NAME}.charm -d ${CHARM_BUILD_DIR}/${CHARM_NAME}66 @unzip ${PROJECTPATH}/${CHARM_NAME}.charm -d ${CHARM_BUILD_DIR}/${CHARM_NAME}
67 @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
5968
60release: build69release: proof
61 @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"70 @echo "Releasing charm to ${RELEASE_CHANNEL} channel"
71 @charmcraft upload nrpe.charm --release ${RELEASE_CHANNEL}
6272
63lint:73lint:
64 @echo "Running lint checks"74 @echo "Running lint checks"
65 @cd src && tox -e lint75 @cd src && tox -e lint
6676
67black:77reformat:
68 @echo "Reformat files with black"78 @echo "Reformat files with black and isort"
69 @cd src && tox -e black79 @cd src && tox -e reformat
70
71proof: build
72 @echo "Running charm proof"
73 @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
7480
75unittests:81unittests:
76 @echo "Running unit tests"82 @echo "Running unit tests"
77 @cd src && tox -e unit83 @cd src && tox -e unit -- ${UNIT_ARGS}
7884
79functional: build85functional: build
80 @echo "Executing functional tests in ${CHARM_BUILD_DIR}"86 @echo "Executing functional tests using built charm at ${PROJECTPATH}"
81 @cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func87 @cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func -- ${FUNC_ARGS}
8288
83test: lint proof unittests functional89test: lint proof unittests functional
84 @echo "Tests completed for charm ${CHARM_NAME}."90 @echo "Tests completed for charm ${CHARM_NAME}."
8591
86# The targets below don't depend on a file92# The targets below don't depend on a file
87.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test93.PHONY: help dev-environment pre-commit submodules submodules-update clean build lint reformat proof unittests functional
diff --git a/charmcraft.yaml b/charmcraft.yaml
index faaf9a0..4988a80 100644
--- a/charmcraft.yaml
+++ b/charmcraft.yaml
@@ -1,24 +1,32 @@
1# Learn more about charmcraft.yaml configuration at:
2# https://juju.is/docs/sdk/charmcraft-config
3# This is a template `charmcraft.yaml` file for reactive charms
4# This file is managed by bootstack-charms-spec and should not be modified
5# within individual charm repos. https://launchpad.net/bootstack-charms-spec
6
1type: charm7type: charm
8
2parts:9parts:
3 charm:10 charm:
4 source: src11 source: src
5 plugin: reactive12 plugin: reactive
6 build-snaps: [charm]13 build-snaps: [ charm ]
14
7bases:15bases:
8 - build-on:16 - build-on:
9 - name: ubuntu17 - name: ubuntu
10 channel: "20.04"18 channel: "20.04"
11 architectures: ["amd64"]19 architectures: ["amd64"]
12 run-on:20 run-on:
13 - name: ubuntu21 - name: ubuntu
14 channel: "22.04"22 channel: "22.04"
15 architectures:23 architectures:
16 - amd6424 - amd64
17 - name: ubuntu25 - name: ubuntu
18 channel: "20.04"26 channel: "20.04"
19 architectures:27 architectures:
20 - amd6428 - amd64
21 - name: ubuntu29 - name: ubuntu
22 channel: "18.04"30 channel: "18.04"
23 architectures:31 architectures:
24 - amd6432 - amd64
diff --git a/rename.sh b/rename.sh
index bc8697f..88e476f 100755
--- a/rename.sh
+++ b/rename.sh
@@ -1,4 +1,8 @@
1#!/bin/bash1#!/bin/bash
2# This is a template `rename.sh` file for reactive charms
3# This file is managed by bootstack-charms-spec and should not be modified
4# within individual charm repos. https://launchpad.net/bootstack-charms-spec
5
2charm=$(grep -E "^name:" src/metadata.yaml | awk '{print $2}')6charm=$(grep -E "^name:" src/metadata.yaml | awk '{print $2}')
3echo "renaming ${charm}_*.charm to ${charm}.charm"7echo "renaming ${charm}_*.charm to ${charm}.charm"
4echo -n "pwd: "8echo -n "pwd: "
diff --git a/src/hooks/apache-relation-changed b/src/hooks/apache-relation-changed
index 76907b4..f05785f 100755
--- a/src/hooks/apache-relation-changed
+++ b/src/hooks/apache-relation-changed
@@ -18,9 +18,11 @@
1818
19# Load modules from $CHARM_DIR/lib19# Load modules from $CHARM_DIR/lib
20import sys20import sys
21
21sys.path.append('lib')22sys.path.append('lib')
2223
23from charms.layer import basic24from charms.layer import basic
25
24basic.bootstrap_charm_deps()26basic.bootstrap_charm_deps()
25basic.init_config_states()27basic.init_config_states()
2628
@@ -32,4 +34,5 @@ basic.init_config_states()
32# See https://jujucharms.com/docs/stable/authors-charm-building34# See https://jujucharms.com/docs/stable/authors-charm-building
33# for more information on this pattern.35# for more information on this pattern.
34from charms.reactive import main36from charms.reactive import main
37
35main()38main()
diff --git a/src/hooks/exec-relation-changed b/src/hooks/exec-relation-changed
index 76907b4..f05785f 100755
--- a/src/hooks/exec-relation-changed
+++ b/src/hooks/exec-relation-changed
@@ -18,9 +18,11 @@
1818
19# Load modules from $CHARM_DIR/lib19# Load modules from $CHARM_DIR/lib
20import sys20import sys
21
21sys.path.append('lib')22sys.path.append('lib')
2223
23from charms.layer import basic24from charms.layer import basic
25
24basic.bootstrap_charm_deps()26basic.bootstrap_charm_deps()
25basic.init_config_states()27basic.init_config_states()
2628
@@ -32,4 +34,5 @@ basic.init_config_states()
32# See https://jujucharms.com/docs/stable/authors-charm-building34# See https://jujucharms.com/docs/stable/authors-charm-building
33# for more information on this pattern.35# for more information on this pattern.
34from charms.reactive import main36from charms.reactive import main
37
35main()38main()
diff --git a/src/hooks/haproxy-relation-changed b/src/hooks/haproxy-relation-changed
index 76907b4..f05785f 100755
--- a/src/hooks/haproxy-relation-changed
+++ b/src/hooks/haproxy-relation-changed
@@ -18,9 +18,11 @@
1818
19# Load modules from $CHARM_DIR/lib19# Load modules from $CHARM_DIR/lib
20import sys20import sys
21
21sys.path.append('lib')22sys.path.append('lib')
2223
23from charms.layer import basic24from charms.layer import basic
25
24basic.bootstrap_charm_deps()26basic.bootstrap_charm_deps()
25basic.init_config_states()27basic.init_config_states()
2628
@@ -32,4 +34,5 @@ basic.init_config_states()
32# See https://jujucharms.com/docs/stable/authors-charm-building34# See https://jujucharms.com/docs/stable/authors-charm-building
33# for more information on this pattern.35# for more information on this pattern.
34from charms.reactive import main36from charms.reactive import main
37
35main()38main()
diff --git a/src/hooks/relations/telegraf-exec/interface.yaml b/src/hooks/relations/telegraf-exec/interface.yaml
index 4a5a57f..a4fafe5 100644
--- a/src/hooks/relations/telegraf-exec/interface.yaml
+++ b/src/hooks/relations/telegraf-exec/interface.yaml
@@ -1,4 +1,4 @@
1name: telegraf-exec 1name: telegraf-exec
2summary: Interface to configure exec plugin from a service2summary: Interface to configure exec plugin from a service
3version: 13version: 1
4repo: https://git.launchpad.net/~verterok/charms/+source/interface-telegraf-exec4repo: https://git.launchpad.net/~verterok/charms/+source/interface-telegraf-exec
diff --git a/src/icon.svg b/src/icon.svg
index 8f01af7..36d0a10 100644
--- a/src/icon.svg
+++ b/src/icon.svg
@@ -10,4 +10,4 @@
10 <path d="M77.1614039,55.7822278 L71.8347455,32.5131414 C71.5543951,31.2515645 70.3629057,29.9899875 69.1013288,29.6395494 L44.640753,22.1401752 C44.290315,22.0700876 43.9398769,22 43.5894389,22 C42.5381248,22 41.416723,22.4205257 40.7859345,23.0513141 L23.2640321,39.3116395 C22.3528932,40.1526909 21.7921923,41.8347935 22.0725428,43.0963705 L27.7496391,67.9774718 C28.0299896,69.2390488 29.2214789,70.5006258 30.4830559,70.8510638 L53.3316166,77.8598248 C53.6820547,77.9299124 54.0324927,78 54.3829308,78 C55.4342449,78 56.5556467,77.5794743 57.1864351,76.9486859 L75.8998269,59.5669587 C76.951141,58.7259074 77.4417543,57.0438048 77.1614039,55.7822278 Z M47.163907,27.6070088 L63.9148457,32.7234043 C64.5456341,32.9336671 64.5456341,33.2140175 63.9148457,33.3541927 L55.0838069,35.3867334 C54.3829308,35.5269086 53.4717918,35.2465582 53.0512662,34.7559449 L46.8835565,28.097622 C46.3929433,27.6770964 46.5331185,27.4668335 47.163907,27.6070088 Z M57.6069608,57.6745932 C57.747136,58.3754693 57.3266104,58.7259074 56.6958219,58.5156446 L38.6132186,52.9787234 C37.9824301,52.7684606 37.8422549,52.2077597 38.3328682,51.787234 L52.2102149,38.8911139 C52.7008281,38.4005006 53.261529,38.6107635 53.4017042,39.2415519 L57.6069608,57.6745932 Z M27.8197268,41.2740926 L42.5381248,27.6070088 C43.028738,27.1163955 43.7997017,27.1864831 44.290315,27.6770964 L51.649514,35.5969962 C52.1401273,36.0876095 52.0700397,36.8585732 51.5794264,37.3491865 L36.8610284,51.0162703 C36.3704151,51.5068836 35.5994514,51.436796 35.1088381,50.9461827 L27.7496391,43.0262829 C27.3291135,42.5356696 27.3291135,41.7647059 27.8197268,41.2740926 Z M31.3941948,63.0012516 L27.4692887,45.9699625 C27.3291135,45.2690864 27.5393763,45.1989987 28.0299896,45.689612 L34.1976992,52.3479349 C34.6883125,52.8385482 34.8985753,53.8197747 34.6883125,54.4505632 L32.0249833,63.0713392 C31.8848081,63.6320401 31.5343701,63.6320401 31.3941948,63.0012516 Z M52.911091,72.8836045 L33.7771736,66.9962453 C33.1463851,66.7859825 32.7258594,66.0851064 32.9361223,65.4543179 L36.0900647,55.0813517 C36.3003275,54.4505632 37.0012036,54.0300375 37.6319921,54.2403004 L56.7659095,60.1276596 C57.396698,60.3379224 57.8172236,61.0387985 57.6069608,61.669587 L54.4530184,72.0425532 C54.2427555,72.7434293 53.5418795,73.0938673 52.911091,72.8836045 Z M69.9423801,58.9361702 L57.1163475,70.8510638 C56.6257343,71.3416771 56.3453838,71.1314143 56.5556467,70.5006258 L59.2189758,61.8798498 C59.4292386,61.2490613 60.1301147,60.5481852 60.8309908,60.40801 L69.6620296,58.3754693 C70.2928181,58.2352941 70.4329933,58.5156446 69.9423801,58.9361702 Z M71.3441323,56.4130163 L60.7609032,58.795995 C60.0600271,58.9361702 59.4292386,58.5156446 59.2890634,57.8848561 L54.8034564,38.330413 C54.6632812,37.6295369 55.0838069,36.9987484 55.7145953,36.8585732 L66.2978244,34.4755945 C66.9987005,34.3354193 67.629489,34.7559449 67.7696642,35.3867334 L72.2552712,54.9411765 C72.3954464,55.571965 71.9749208,56.2728411 71.3441323,56.4130163 Z" id="symbol_2_" fill="#FFFFFF"></path>10 <path d="M77.1614039,55.7822278 L71.8347455,32.5131414 C71.5543951,31.2515645 70.3629057,29.9899875 69.1013288,29.6395494 L44.640753,22.1401752 C44.290315,22.0700876 43.9398769,22 43.5894389,22 C42.5381248,22 41.416723,22.4205257 40.7859345,23.0513141 L23.2640321,39.3116395 C22.3528932,40.1526909 21.7921923,41.8347935 22.0725428,43.0963705 L27.7496391,67.9774718 C28.0299896,69.2390488 29.2214789,70.5006258 30.4830559,70.8510638 L53.3316166,77.8598248 C53.6820547,77.9299124 54.0324927,78 54.3829308,78 C55.4342449,78 56.5556467,77.5794743 57.1864351,76.9486859 L75.8998269,59.5669587 C76.951141,58.7259074 77.4417543,57.0438048 77.1614039,55.7822278 Z M47.163907,27.6070088 L63.9148457,32.7234043 C64.5456341,32.9336671 64.5456341,33.2140175 63.9148457,33.3541927 L55.0838069,35.3867334 C54.3829308,35.5269086 53.4717918,35.2465582 53.0512662,34.7559449 L46.8835565,28.097622 C46.3929433,27.6770964 46.5331185,27.4668335 47.163907,27.6070088 Z M57.6069608,57.6745932 C57.747136,58.3754693 57.3266104,58.7259074 56.6958219,58.5156446 L38.6132186,52.9787234 C37.9824301,52.7684606 37.8422549,52.2077597 38.3328682,51.787234 L52.2102149,38.8911139 C52.7008281,38.4005006 53.261529,38.6107635 53.4017042,39.2415519 L57.6069608,57.6745932 Z M27.8197268,41.2740926 L42.5381248,27.6070088 C43.028738,27.1163955 43.7997017,27.1864831 44.290315,27.6770964 L51.649514,35.5969962 C52.1401273,36.0876095 52.0700397,36.8585732 51.5794264,37.3491865 L36.8610284,51.0162703 C36.3704151,51.5068836 35.5994514,51.436796 35.1088381,50.9461827 L27.7496391,43.0262829 C27.3291135,42.5356696 27.3291135,41.7647059 27.8197268,41.2740926 Z M31.3941948,63.0012516 L27.4692887,45.9699625 C27.3291135,45.2690864 27.5393763,45.1989987 28.0299896,45.689612 L34.1976992,52.3479349 C34.6883125,52.8385482 34.8985753,53.8197747 34.6883125,54.4505632 L32.0249833,63.0713392 C31.8848081,63.6320401 31.5343701,63.6320401 31.3941948,63.0012516 Z M52.911091,72.8836045 L33.7771736,66.9962453 C33.1463851,66.7859825 32.7258594,66.0851064 32.9361223,65.4543179 L36.0900647,55.0813517 C36.3003275,54.4505632 37.0012036,54.0300375 37.6319921,54.2403004 L56.7659095,60.1276596 C57.396698,60.3379224 57.8172236,61.0387985 57.6069608,61.669587 L54.4530184,72.0425532 C54.2427555,72.7434293 53.5418795,73.0938673 52.911091,72.8836045 Z M69.9423801,58.9361702 L57.1163475,70.8510638 C56.6257343,71.3416771 56.3453838,71.1314143 56.5556467,70.5006258 L59.2189758,61.8798498 C59.4292386,61.2490613 60.1301147,60.5481852 60.8309908,60.40801 L69.6620296,58.3754693 C70.2928181,58.2352941 70.4329933,58.5156446 69.9423801,58.9361702 Z M71.3441323,56.4130163 L60.7609032,58.795995 C60.0600271,58.9361702 59.4292386,58.5156446 59.2890634,57.8848561 L54.8034564,38.330413 C54.6632812,37.6295369 55.0838069,36.9987484 55.7145953,36.8585732 L66.2978244,34.4755945 C66.9987005,34.3354193 67.629489,34.7559449 67.7696642,35.3867334 L72.2552712,54.9411765 C72.3954464,55.571965 71.9749208,56.2728411 71.3441323,56.4130163 Z" id="symbol_2_" fill="#FFFFFF"></path>
11 </g>11 </g>
12 </g>12 </g>
13</svg>
14\ No newline at end of file13\ No newline at end of file
14</svg>
diff --git a/src/pyproject.toml b/src/pyproject.toml
15new file mode 10064415new file mode 100644
index 0000000..7ae7f41
--- /dev/null
+++ b/src/pyproject.toml
@@ -0,0 +1,35 @@
1# This is a template `pyproject.toml` file for reactive charms
2# This file is managed by bootstack-charms-spec and should not be modified
3# within individual charm repos. https://launchpad.net/bootstack-charms-spec
4
5[tool.flake8]
6ignore = ["D100", "D101", "D102", "D103"]
7exclude = ['.eggs', '.git', '.tox', '.venv', '.build', 'report']
8max-line-length = 88
9max-complexity = 10
10
11[tool.black]
12line-length = 88
13exclude = '''
14/(
15 | .eggs
16 | .git
17 | .tox
18 | .venv
19 | .build
20 | report
21)/
22'''
23
24[tool.isort]
25profile = "black"
26skip_glob = '''
27/(
28 | .eggs
29 | .git
30 | .tox
31 | .venv
32 | .build
33 | report
34)/
35'''
diff --git a/src/reactive/telegraf.py b/src/reactive/telegraf.py
index 5548956..61aabcf 100644
--- a/src/reactive/telegraf.py
+++ b/src/reactive/telegraf.py
@@ -30,13 +30,14 @@ import sys
30import time30import time
31from distutils.version import LooseVersion31from distutils.version import LooseVersion
3232
33import charms.promreg
34import netifaces
35import yaml
33from charmhelpers import context, fetch36from charmhelpers import context, fetch
34from charmhelpers.contrib.charmsupport import nrpe37from charmhelpers.contrib.charmsupport import nrpe
35from charmhelpers.core import hookenv, host, kernel, unitdata38from charmhelpers.core import hookenv, host, kernel, unitdata
36from charmhelpers.core.host import is_container39from charmhelpers.core.host import is_container
37from charmhelpers.core.templating import render40from charmhelpers.core.templating import render
38
39import charms.promreg
40from charms import apt41from charms import apt
41from charms.layer import snap42from charms.layer import snap
42from charms.reactive import (43from charms.reactive import (
@@ -50,15 +51,9 @@ from charms.reactive import (
50 when_not,51 when_not,
51)52)
52from charms.reactive.bus import get_states53from charms.reactive.bus import get_states
53
54from files.telegraf_exec_metrics import METRICS
55
56from jinja2 import Environment, FileSystemLoader, Template, exceptions54from jinja2 import Environment, FileSystemLoader, Template, exceptions
5755
58import netifaces56from files.telegraf_exec_metrics import METRICS
59
60import yaml
61
6257
63DEB_BASE_DIR = "/etc/telegraf"58DEB_BASE_DIR = "/etc/telegraf"
64SNAP_BASE_DIR = "/var/snap/telegraf/current"59SNAP_BASE_DIR = "/var/snap/telegraf/current"
diff --git a/src/templates/apache-server-status.tmpl b/src/templates/apache-server-status.tmpl
index 18f8871..38e027c 100644
--- a/src/templates/apache-server-status.tmpl
+++ b/src/templates/apache-server-status.tmpl
@@ -13,4 +13,3 @@
13 Allow from localhost13 Allow from localhost
14 </Location>14 </Location>
15</VirtualHost>15</VirtualHost>
16
diff --git a/src/templates/influxdb-api.conf.tmpl b/src/templates/influxdb-api.conf.tmpl
index 9d76988..0466afe 100644
--- a/src/templates/influxdb-api.conf.tmpl
+++ b/src/templates/influxdb-api.conf.tmpl
@@ -4,7 +4,7 @@
4 # Multiple urls can be specified but it is assumed that they are part of the same4 # Multiple urls can be specified but it is assumed that they are part of the same
5 # cluster, this means that only ONE of the urls will be written to each interval.5 # cluster, this means that only ONE of the urls will be written to each interval.
6 # urls = ["udp://localhost:8089"] # UDP endpoint example6 # urls = ["udp://localhost:8089"] # UDP endpoint example
7 urls = {{ urls }} 7 urls = {{ urls }}
8 # The target database for metrics (telegraf will create it if not exists)8 # The target database for metrics (telegraf will create it if not exists)
9 database = "telegraf" # required9 database = "telegraf" # required
10 # Precision of writes, valid values are n, u, ms, s, m, and h10 # Precision of writes, valid values are n, u, ms, s, m, and h
@@ -20,4 +20,3 @@
20 user_agent = "telegraf"20 user_agent = "telegraf"
21 # Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)21 # Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
22 # udp_payload = 51222 # udp_payload = 512
23
diff --git a/src/templates/sudoers/telegraf_intel_rdt.tmpl b/src/templates/sudoers/telegraf_intel_rdt.tmpl
index 0324a77..fb8edfd 100644
--- a/src/templates/sudoers/telegraf_intel_rdt.tmpl
+++ b/src/templates/sudoers/telegraf_intel_rdt.tmpl
@@ -1,4 +1,3 @@
1Cmnd_Alias PQOS = /usr/sbin/pqos -r --iface-os --mon-file-type=csv --mon-interval=*1Cmnd_Alias PQOS = /usr/sbin/pqos -r --iface-os --mon-file-type=csv --mon-interval=*
2{{ telegraf_user }} ALL=(root) NOPASSWD: PQOS2{{ telegraf_user }} ALL=(root) NOPASSWD: PQOS
3Defaults!PQOS !logfile, !syslog, !pam_session3Defaults!PQOS !logfile, !syslog, !pam_session
4
diff --git a/src/templates/sudoers/telegraf_ipmi.tmpl b/src/templates/sudoers/telegraf_ipmi.tmpl
index 463a608..14e2076 100644
--- a/src/templates/sudoers/telegraf_ipmi.tmpl
+++ b/src/templates/sudoers/telegraf_ipmi.tmpl
@@ -1,4 +1,3 @@
1Cmnd_Alias IPMITOOL = /usr/bin/ipmitool sdr elist1Cmnd_Alias IPMITOOL = /usr/bin/ipmitool sdr elist
2{{ telegraf_user }} ALL=(root) NOPASSWD: IPMITOOL2{{ telegraf_user }} ALL=(root) NOPASSWD: IPMITOOL
3Defaults!IPMITOOL !logfile, !syslog, !pam_session3Defaults!IPMITOOL !logfile, !syslog, !pam_session
4
diff --git a/src/templates/sudoers/telegraf_iptables.tmpl b/src/templates/sudoers/telegraf_iptables.tmpl
index 49354db..8e5f67d 100644
--- a/src/templates/sudoers/telegraf_iptables.tmpl
+++ b/src/templates/sudoers/telegraf_iptables.tmpl
@@ -1,4 +1,3 @@
1Cmnd_Alias IPTABLESSHOW = /sbin/iptables -w 5 -nvL *1Cmnd_Alias IPTABLESSHOW = /sbin/iptables -w 5 -nvL *
2{{ telegraf_user }} ALL=(root) NOPASSWD: IPTABLESSHOW2{{ telegraf_user }} ALL=(root) NOPASSWD: IPTABLESSHOW
3Defaults!IPTABLESSHOW !logfile, !syslog, !pam_session3Defaults!IPTABLESSHOW !logfile, !syslog, !pam_session
4
diff --git a/src/templates/sudoers/telegraf_ovs.tmpl b/src/templates/sudoers/telegraf_ovs.tmpl
index 27087b4..f53f1b7 100644
--- a/src/templates/sudoers/telegraf_ovs.tmpl
+++ b/src/templates/sudoers/telegraf_ovs.tmpl
@@ -8,4 +8,3 @@ Cmnd_Alias OVSAPPCTL = /usr/bin/ovs-appctl
8Defaults!OVSOFCTL !logfile, !syslog, !pam_session8Defaults!OVSOFCTL !logfile, !syslog, !pam_session
9Defaults!OVSVSCTL !logfile, !syslog, !pam_session9Defaults!OVSVSCTL !logfile, !syslog, !pam_session
10Defaults!OVSAPPCTL !logfile, !syslog, !pam_session10Defaults!OVSAPPCTL !logfile, !syslog, !pam_session
11
diff --git a/src/templates/sudoers/telegraf_smart.tmpl b/src/templates/sudoers/telegraf_smart.tmpl
index 1ceaf74..1f8d88c 100644
--- a/src/templates/sudoers/telegraf_smart.tmpl
+++ b/src/templates/sudoers/telegraf_smart.tmpl
@@ -5,4 +5,3 @@ Defaults!SMARTCTL !logfile, !syslog, !pam_session
5Cmnd_Alias NVME = /usr/sbin/nvme5Cmnd_Alias NVME = /usr/sbin/nvme
6{{ telegraf_user }} ALL=(root) NOPASSWD: NVME6{{ telegraf_user }} ALL=(root) NOPASSWD: NVME
7Defaults!NVME !logfile, !syslog, !pam_session7Defaults!NVME !logfile, !syslog, !pam_session
8
diff --git a/src/templates/telegraf.conf.tmpl b/src/templates/telegraf.conf.tmpl
index 966b4a9..fe64b76 100644
--- a/src/templates/telegraf.conf.tmpl
+++ b/src/templates/telegraf.conf.tmpl
@@ -46,7 +46,7 @@
4646
47 # Telegraf will cache metric_buffer_limit metrics for each output, and will47 # Telegraf will cache metric_buffer_limit metrics for each output, and will
48 # flush this buffer on a successful write.48 # flush this buffer on a successful write.
49 metric_buffer_limit = {{ metric_buffer_limit }} 49 metric_buffer_limit = {{ metric_buffer_limit }}
5050
51 # Collection jitter is used to jitter the collection by a random amount.51 # Collection jitter is used to jitter the collection by a random amount.
52 # Each plugin will sleep for a random time within jitter before collecting.52 # Each plugin will sleep for a random time within jitter before collecting.
@@ -63,9 +63,9 @@
63 flush_jitter = "{{ flush_jitter }}"63 flush_jitter = "{{ flush_jitter }}"
6464
65 # Run telegraf in debug mode65 # Run telegraf in debug mode
66 debug = {% if debug %}true{% else %}false{% endif %} 66 debug = {% if debug %}true{% else %}false{% endif %}
67 # Run telegraf in quiet mode67 # Run telegraf in quiet mode
68 quiet = {% if quiet %}true{% else %}false{% endif %} 68 quiet = {% if quiet %}true{% else %}false{% endif %}
69 # Override default hostname, if empty use os.Hostname()69 # Override default hostname, if empty use os.Hostname()
70 hostname = "{{ hostname }}"70 hostname = "{{ hostname }}"
7171
diff --git a/src/tests/functional/tests/base.py b/src/tests/functional/tests/base.py
index 5f097ca..30d5667 100644
--- a/src/tests/functional/tests/base.py
+++ b/src/tests/functional/tests/base.py
@@ -5,11 +5,9 @@ import time
5import unittest5import unittest
66
7import requests7import requests
8
9from zaza import model8from zaza import model
10from zaza.utilities import juju9from zaza.utilities import juju
1110
12
13DEFAULT_HTTPGET_TIMEOUT = 1011DEFAULT_HTTPGET_TIMEOUT = 10
14DEFAULT_RETRIES = 1212DEFAULT_RETRIES = 12
15DEFAULT_RETRIES_TIMEOUT = 513DEFAULT_RETRIES_TIMEOUT = 5
diff --git a/src/tests/functional/tests/test_telegraf.py b/src/tests/functional/tests/test_telegraf.py
index 44e46e6..4ba7202 100644
--- a/src/tests/functional/tests/test_telegraf.py
+++ b/src/tests/functional/tests/test_telegraf.py
@@ -16,7 +16,6 @@
16import logging16import logging
1717
18from tenacity import retry, stop_after_attempt, wait_fixed18from tenacity import retry, stop_after_attempt, wait_fixed
19
20from zaza import model19from zaza import model
2120
22from .base import BaseTelegrafTest21from .base import BaseTelegrafTest
diff --git a/src/tests/functional/tests/tests.yaml b/src/tests/functional/tests/tests.yaml
index a2265ab..7bc01f7 100644
--- a/src/tests/functional/tests/tests.yaml
+++ b/src/tests/functional/tests/tests.yaml
@@ -33,4 +33,3 @@ tests:
33 - tests.test_telegraf.TestTelegraf33 - tests.test_telegraf.TestTelegraf
34 - compute:34 - compute:
35 - tests.test_compute.TestTelegrafCompute35 - tests.test_compute.TestTelegrafCompute
36
diff --git a/src/tests/unit/requirements.txt b/src/tests/unit/requirements.txt
index eddbac0..49e57e1 100644
--- a/src/tests/unit/requirements.txt
+++ b/src/tests/unit/requirements.txt
@@ -1,12 +1,3 @@
1coverage
2flake8
3pytest
4pytest-cov
5pytest-mock1pytest-mock
6pytest-xdist
7netifaces2netifaces
8insights-core3jinja2
9charms.reactive>=1.3.0
10requests
11pbr
12urllib3
diff --git a/src/tests/unit/test_telegraf.py b/src/tests/unit/test_telegraf.py
index 43ffbd0..7f409e4 100644
--- a/src/tests/unit/test_telegraf.py
+++ b/src/tests/unit/test_telegraf.py
@@ -28,21 +28,17 @@ from textwrap import dedent
28from unittest import mock28from unittest import mock
29from unittest.mock import MagicMock, call, patch29from unittest.mock import MagicMock, call, patch
3030
31import charms
32import py
33import pytest
34import yaml
31from charmhelpers import fetch35from charmhelpers import fetch
32from charmhelpers.core import host, kernel36from charmhelpers.core import host, kernel
33from charmhelpers.core.hookenv import Config37from charmhelpers.core.hookenv import Config
34from charmhelpers.core.templating import render38from charmhelpers.core.templating import render
35from charmhelpers.fetch import apt_pkg39from charmhelpers.fetch import apt_pkg
36
37import charms
38from charms.reactive import RelationBase, bus, helpers, set_flag40from charms.reactive import RelationBase, bus, helpers, set_flag
3941
40import py
41
42import pytest
43
44import yaml
45
46# Mock layer modules42# Mock layer modules
47apt = MagicMock()43apt = MagicMock()
48layer = MagicMock()44layer = MagicMock()
diff --git a/src/tests/lint/render_sudoers.py b/src/tests/unit/test_templates_sudoers.py
49similarity index 50%45similarity index 50%
50rename from src/tests/lint/render_sudoers.py46rename from src/tests/lint/render_sudoers.py
51rename to src/tests/unit/test_templates_sudoers.py47rename to src/tests/unit/test_templates_sudoers.py
index 4005ce1..8e50262 100644
--- a/src/tests/lint/render_sudoers.py
+++ b/src/tests/unit/test_templates_sudoers.py
@@ -1,12 +1,17 @@
1import os1import os
2import subprocess
3import tempfile
24
3from jinja2 import Environment, FileSystemLoader5from jinja2 import Environment, FileSystemLoader
46
5template_dir = os.path.join("templates/sudoers")7
6for template in os.listdir(template_dir):8def test_sudoers_templates():
7 environment = Environment(loader=FileSystemLoader(template_dir))9 template_dir = os.path.join("templates/sudoers")
8 template = environment.get_template(template)10 for template in os.listdir(template_dir):
9 # A simple print(telegraf_user="test-user") would append a newline.11 environment = Environment(loader=FileSystemLoader(template_dir))
10 # We want to detect if the rendered template lacks a trailing12 template = environment.get_template(template)
11 # newline, as it would break sudo when deployed. Hence end=''.13 with tempfile.NamedTemporaryFile(mode="w") as tmp:
12 print(template.render(telegraf_user="test-user"), end="")14 tmp.write(template.render(telegraf_user="test-user"))
15 tmp.flush()
16 # check the templates with visudo check-only mode
17 subprocess.check_call(["visudo", "-csf", tmp.name])
diff --git a/src/tox.ini b/src/tox.ini
index 4b7128f..d371a80 100644
--- a/src/tox.ini
+++ b/src/tox.ini
@@ -1,6 +1,9 @@
1# This is a template `tox.ini` file for reactive charms
2# This file is managed by bootstack-charms-spec and should not be modified
3# within individual charm repos. https://launchpad.net/bootstack-charms-spec
4
1[tox]5[tox]
2skipsdist=True6skipsdist=True
3skip_missing_interpreters = True
4envlist = lint, unit, func7envlist = lint, unit, func
58
6[testenv]9[testenv]
@@ -21,68 +24,65 @@ passenv =
21 NO_PROXY24 NO_PROXY
22 SNAP_HTTP_PROXY25 SNAP_HTTP_PROXY
23 SNAP_HTTPS_PROXY26 SNAP_HTTPS_PROXY
24 OS_REGION_NAME27 OS_*
25 OS_AUTH_VERSION28
26 OS_AUTH_URL29[testenv:dev-environment]
27 OS_PROJECT_DOMAIN_NAME30envdir = {toxinidir}/.venv
28 OS_USERNAME31deps =
29 OS_PASSWORD32 pre-commit
30 OS_PROJECT_ID33 {[testenv:lint]deps}
31 OS_USER_DOMAIN_NAME34 {[testenv:unit]deps}
32 OS_PROJECT_NAME35 {[testenv:func]deps}
33 OS_IDENTITY_API_VERSION36
37[testenv:pre-commit]
38envdir = {[testenv:dev-environment]envdir}
39deps = {[testenv:dev-environment]deps} # ensure that dev-environment is installed
40commands = pre-commit run --all-files
3441
35[testenv:lint]42[testenv:lint]
36commands =43commands =
37 flake844 pflake8
38 black --check --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .45 black --check --diff --color .
39 bash -c "python3 tests/lint/render_sudoers.py | visudo -csf -"46 isort --check --diff --color .
47whitelist_externals = bash
40deps =48deps =
41 black49 black
42 flake850 # NOTE(rgildein): It is necessary to limit flake8 with version 5.0.0, due
43 flake8-colors51 # to the problem https://github.com/csachs/pyproject-flake8/issues/13.
52 flake8 < 5.0.0
53 pyproject-flake8
44 flake8-docstrings54 flake8-docstrings
45 flake8-import-order
46 jinja2
47 pep8-naming55 pep8-naming
48whitelist_externals = bash56 flake8-colors
4957 colorama
50[flake8]58 isort
51exclude =
52 .git,
53 __pycache__,
54 .tox,
55 charmhelpers,
56 mod,
57 .build
58#ignore = I100, D101, D102, D103, I201, D205, W504, D400, D401, D403, D209, D100, E403, I101, E501, N803, E226, E128, D200, E741, D202, E261, E402, D104, W503, E231 # TODO
59ignore = D100, D101, D102, D103
60
61max-line-length = 88
62max-complexity = 10
6359
64[testenv:black]60[testenv:reformat]
61envdir = {toxworkdir}/lint
65commands =62commands =
66 black --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .63 black .
67deps =64 isort .
68 black65deps = {[testenv:lint]deps}
6966
70[testenv:unit]67[testenv:unit]
71commands =68commands = pytest {toxinidir}/tests/unit \
72 pytest {posargs:-vvv -s -n auto --ignore {toxinidir}/tests/functional \69 {posargs:-v \
73 --cov=lib \
74 --cov=reactive \70 --cov=reactive \
75 --cov=actions \71 --cov=actions \
76 --cov=hooks \72 --cov=hooks \
77 --cov=src \73 --cov=files \
74 --cov=lib \
78 --cov-report=term \75 --cov-report=term \
79 --cov-report=annotate:report/annotated \
80 --cov-report=html:report/html}76 --cov-report=html:report/html}
81deps = -r{toxinidir}/tests/unit/requirements.txt77deps =
78 -r {toxinidir}/requirements.txt
79 -r {toxinidir}/tests/unit/requirements.txt
80 pytest
81 pytest-cov
8282
83[testenv:func]83[testenv:func]
84changedir = {toxinidir}/tests/functional84changedir = {toxinidir}/tests/functional
85commands = functest-run-suite {posargs:--keep-faulty-model}85commands = functest-run-suite {posargs:--keep-faulty-model}
86deps =86deps =
87 git+https://github.com/openstack-charmers/zaza.git#egg=zaza
88 -r {toxinidir}/tests/functional/requirements.txt87 -r {toxinidir}/tests/functional/requirements.txt
88 git+https://github.com/openstack-charmers/zaza.git#egg=zaza

Subscribers

People subscribed via source and target branches

to all changes: