Merge ~hloeung/influxdb-charm:master into influxdb-charm:master

Proposed by Haw Loeung
Status: Rejected
Rejected by: Haw Loeung
Proposed branch: ~hloeung/influxdb-charm:master
Merge into: influxdb-charm:master
Diff against target: 134 lines (+31/-8)
5 files modified
actions/create-database (+7/-2)
actions/create-user (+7/-2)
actions/grant-privilege (+7/-2)
layer.yaml (+6/-2)
reactive/influxdb.py (+4/-0)
Reviewer Review Type Date Requested Status
InfluxDB Charmers Pending
Review via email: mp+333187@code.launchpad.net

Description of the change

Don't run configuration parts on update-status hook

To post a comment you must log in.
Revision history for this message
Tom Haddon (mthaddon) wrote :

Is there a decorator we could use for this? It seems a bit unwieldy as is.

~hloeung/influxdb-charm:master updated
5467c96... by Haw Loeung

Restore virtual env usage removed in commit 392fedea

d9d2d96... by Haw Loeung

Juju actions only available in Xenial and beyond

The juju actions required to interact with InfluxDB uses
python3-influxdb which is only available in Xenial and beyond. This
fixes that to not fail on prior series such as Trusty (LP: #1732015).

Unmerged commits

d9d2d96... by Haw Loeung

Juju actions only available in Xenial and beyond

The juju actions required to interact with InfluxDB uses
python3-influxdb which is only available in Xenial and beyond. This
fixes that to not fail on prior series such as Trusty (LP: #1732015).

5467c96... by Haw Loeung

Restore virtual env usage removed in commit 392fedea

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/actions/create-database b/actions/create-database
index 96c9cb1..d2cd4bd 100755
--- a/actions/create-database
+++ b/actions/create-database
@@ -1,7 +1,6 @@
1#!/usr/bin/python31#!/usr/bin/python3
2# Create a database2# Create a database
33
4import influxdb
5import requests4import requests
6import traceback5import traceback
76
@@ -12,6 +11,12 @@ from charmhelpers.core.hookenv import (
12 log,11 log,
13)12)
1413
14try:
15 import influxdb
16except ImportError:
17 print("Missing python3-influxdb package")
18 exit(1)
19
15action = "create-database"20action = "create-database"
1621
17try:22try:
@@ -33,7 +38,7 @@ try:
33 print("Create database: " + database)38 print("Create database: " + database)
34 client.create_database(database)39 client.create_database(database)
35 action_set({"created": database})40 action_set({"created": database})
36except:41except Exception:
37 action_fail('Unhandled exception')42 action_fail('Unhandled exception')
38 tb = traceback.format_exc()43 tb = traceback.format_exc()
39 action_set(dict(traceback=tb))44 action_set(dict(traceback=tb))
diff --git a/actions/create-user b/actions/create-user
index cae4df9..8ad8db3 100755
--- a/actions/create-user
+++ b/actions/create-user
@@ -1,7 +1,6 @@
1#!/usr/bin/python31#!/usr/bin/python3
2# Create a database2# Create a database
33
4import influxdb
5import random4import random
6import requests5import requests
7import string6import string
@@ -14,6 +13,12 @@ from charmhelpers.core.hookenv import (
14 log,13 log,
15)14)
1615
16try:
17 import influxdb
18except ImportError:
19 print("Missing python3-influxdb package")
20 exit(1)
21
17action = "create-user"22action = "create-user"
18charset = string.ascii_lowercase + string.ascii_uppercase + string.digits23charset = string.ascii_lowercase + string.ascii_uppercase + string.digits
19password = ''.join(random.sample(charset, 16))24password = ''.join(random.sample(charset, 16))
@@ -54,5 +59,5 @@ except influxdb.exceptions.InfluxDBClientError as e:
54 action_fail("User {} already exists".format(user))59 action_fail("User {} already exists".format(user))
55 else:60 else:
56 unhandled_exception()61 unhandled_exception()
57except:62except Exception:
58 unhandled_exception()63 unhandled_exception()
diff --git a/actions/grant-privilege b/actions/grant-privilege
index 62626f1..87cfb0d 100755
--- a/actions/grant-privilege
+++ b/actions/grant-privilege
@@ -1,7 +1,6 @@
1#!/usr/bin/python31#!/usr/bin/python3
2# Create a database2# Create a database
33
4import influxdb
5import requests4import requests
6import traceback5import traceback
76
@@ -12,6 +11,12 @@ from charmhelpers.core.hookenv import (
12 log,11 log,
13)12)
1413
14try:
15 import influxdb
16except ImportError:
17 print("Missing python3-influxdb package")
18 exit(1)
19
15action = "grant-privilege"20action = "grant-privilege"
1621
1722
@@ -45,5 +50,5 @@ try:
45 client.grant_privilege(privilege, database, user)50 client.grant_privilege(privilege, database, user)
46 action_set({"granted": user, "privilege": privilege, "database": database})51 action_set({"granted": user, "privilege": privilege, "database": database})
47 print("Granted {} {} on {}".format(user, privilege, database))52 print("Granted {} {} on {}".format(user, privilege, database))
48except:53except Exception:
49 unhandled_exception()54 unhandled_exception()
diff --git a/layer.yaml b/layer.yaml
index 0dcf45c..c68c892 100644
--- a/layer.yaml
+++ b/layer.yaml
@@ -8,10 +8,14 @@ includes:
8 - interface:influxdb-api8 - interface:influxdb-api
9options:9options:
10 basic:10 basic:
11 # We need to use virtual env:
12 # https://github.com/juju-solutions/charms.reactive/issues/135
13 use_venv: true
14 include_system_packages: true
11 packages:15 packages:
12 # we need to specify these here due to https://github.com/juju-solutions/charms.reactive/issues/8216 # We need to specify essential required packages:
17 # https://github.com/juju-solutions/charms.reactive/issues/82
13 - build-essential18 - build-essential
14 - python3-setuptools19 - python3-setuptools
15 - python3-wheel20 - python3-wheel
16 - python3-yaml21 - python3-yaml
17 - python3-influxdb
diff --git a/reactive/influxdb.py b/reactive/influxdb.py
index ae04df9..24b51bf 100644
--- a/reactive/influxdb.py
+++ b/reactive/influxdb.py
@@ -42,6 +42,10 @@ def install_influx():
42 subprocess.check_call(['influx', '--version'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)42 subprocess.check_call(['influx', '--version'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
43 except OSError:43 except OSError:
44 apt_install('influxdb-client')44 apt_install('influxdb-client')
45 series = host.lsb_release()['DISTRIB_CODENAME']
46 # python3-influxdb only exists in Ubuntu Xenial and beyond - LP: #1732015.
47 if series not in ('precise', 'trusty'):
48 apt_install('python3-influxdb')
4549
4650
47def apply_configs(fh, config):51def apply_configs(fh, config):

Subscribers

People subscribed via source and target branches

to all changes: