summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Thompson <mattt@defunct.ca>2017-06-23 11:40:13 -0400
committerMatt Thompson <mattt@defunct.ca>2017-06-23 11:56:24 -0400
commit98cb350edc54e3ed1c727c0cafb48da2bbc947f0 (patch)
tree0cec4a76a603f24754ed3d897cc06a36e325c420
parentf6557612121f4c416c99b1dc86321877009d6328 (diff)
Only import os_utils when plugin is called
Currently, if a dependency of one of the os_ plugins is missing, running monitorstack with no args returns (for example): ``` OpenStack plugins require access to the OpenStackSDK. \ Please install "python-openstacksdk". \ ERROR: No module named keystoneauth1.loading ``` This commit moves the os_utils import in the os_ plugins to within cli, similar to what is being done in the kvm module. This allows the monitorstack cli to operate normally even if a plugin cannot be loaded. Change-Id: I2ff1ad8c6365f6592191f09ea9c0d543f81e16ba
Notes
Notes (review): Code-Review+2: Major Hayden <major@mhtx.net> Code-Review+2: Jimmy McCrory <jimmy.mccrory@gmail.com> Workflow+1: Jimmy McCrory <jimmy.mccrory@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 23 Jun 2017 21:40:35 +0000 Reviewed-on: https://review.openstack.org/476963 Project: openstack/monitorstack Branch: refs/heads/master
-rw-r--r--monitorstack/plugins/os_block_pools_totals.py5
-rw-r--r--monitorstack/plugins/os_block_pools_usage.py5
-rw-r--r--monitorstack/plugins/os_vm_quota_cores.py5
-rw-r--r--monitorstack/plugins/os_vm_quota_instance.py5
-rw-r--r--monitorstack/plugins/os_vm_quota_ram.py5
-rw-r--r--monitorstack/plugins/os_vm_used_cores.py5
-rw-r--r--monitorstack/plugins/os_vm_used_disk.py5
-rw-r--r--monitorstack/plugins/os_vm_used_instance.py5
-rw-r--r--monitorstack/plugins/os_vm_used_ram.py5
9 files changed, 36 insertions, 9 deletions
diff --git a/monitorstack/plugins/os_block_pools_totals.py b/monitorstack/plugins/os_block_pools_totals.py
index 94fe228..683a0b1 100644
--- a/monitorstack/plugins/os_block_pools_totals.py
+++ b/monitorstack/plugins/os_block_pools_totals.py
@@ -17,7 +17,6 @@ import click
17 17
18from monitorstack import utils 18from monitorstack import utils
19from monitorstack.cli import pass_context 19from monitorstack.cli import pass_context
20from monitorstack.utils import os_utils as ost
21 20
22 21
23DOC = """Get block storage totals from the available pools.""" 22DOC = """Get block storage totals from the available pools."""
@@ -33,6 +32,10 @@ def cli(ctx, config_file):
33 """Get nova cores quotas.""" 32 """Get nova cores quotas."""
34 setattr(cli, '__doc__', DOC) 33 setattr(cli, '__doc__', DOC)
35 34
35 # Lower level import because we only want to load this module
36 # when this plugin is called.
37 from monitorstack.utils import os_utils as ost
38
36 output = { 39 output = {
37 'measurement_name': COMMAND_NAME, 40 'measurement_name': COMMAND_NAME,
38 'meta': { 41 'meta': {
diff --git a/monitorstack/plugins/os_block_pools_usage.py b/monitorstack/plugins/os_block_pools_usage.py
index 2b566c6..f4635f4 100644
--- a/monitorstack/plugins/os_block_pools_usage.py
+++ b/monitorstack/plugins/os_block_pools_usage.py
@@ -17,7 +17,6 @@ import click
17 17
18from monitorstack import utils 18from monitorstack import utils
19from monitorstack.cli import pass_context 19from monitorstack.cli import pass_context
20from monitorstack.utils import os_utils as ost
21 20
22 21
23DOC = """Get block storage usage from the available pools.""" 22DOC = """Get block storage usage from the available pools."""
@@ -33,6 +32,10 @@ def cli(ctx, config_file):
33 """Get nova cores quotas.""" 32 """Get nova cores quotas."""
34 setattr(cli, '__doc__', DOC) 33 setattr(cli, '__doc__', DOC)
35 34
35 # Lower level import because we only want to load this module
36 # when this plugin is called.
37 from monitorstack.utils import os_utils as ost
38
36 output = { 39 output = {
37 'measurement_name': COMMAND_NAME, 40 'measurement_name': COMMAND_NAME,
38 'meta': { 41 'meta': {
diff --git a/monitorstack/plugins/os_vm_quota_cores.py b/monitorstack/plugins/os_vm_quota_cores.py
index e3fd589..e7fbb19 100644
--- a/monitorstack/plugins/os_vm_quota_cores.py
+++ b/monitorstack/plugins/os_vm_quota_cores.py
@@ -17,7 +17,6 @@ import click
17 17
18from monitorstack import utils 18from monitorstack import utils
19from monitorstack.cli import pass_context 19from monitorstack.cli import pass_context
20from monitorstack.utils import os_utils as ost
21 20
22 21
23DOC = """Get nova cores quotas.""" 22DOC = """Get nova cores quotas."""
@@ -33,6 +32,10 @@ def cli(ctx, config_file):
33 """Get nova cores quotas.""" 32 """Get nova cores quotas."""
34 setattr(cli, '__doc__', DOC) 33 setattr(cli, '__doc__', DOC)
35 34
35 # Lower level import because we only want to load this module
36 # when this plugin is called.
37 from monitorstack.utils import os_utils as ost
38
36 output = { 39 output = {
37 'measurement_name': COMMAND_NAME, 40 'measurement_name': COMMAND_NAME,
38 'meta': { 41 'meta': {
diff --git a/monitorstack/plugins/os_vm_quota_instance.py b/monitorstack/plugins/os_vm_quota_instance.py
index 6b48b9b..652a2a1 100644
--- a/monitorstack/plugins/os_vm_quota_instance.py
+++ b/monitorstack/plugins/os_vm_quota_instance.py
@@ -17,7 +17,6 @@ import click
17 17
18from monitorstack import utils 18from monitorstack import utils
19from monitorstack.cli import pass_context 19from monitorstack.cli import pass_context
20from monitorstack.utils import os_utils as ost
21 20
22 21
23DOC = """Get nova instance quotas.""" 22DOC = """Get nova instance quotas."""
@@ -33,6 +32,10 @@ def cli(ctx, config_file):
33 """Get nova instance quotas.""" 32 """Get nova instance quotas."""
34 setattr(cli, '__doc__', DOC) 33 setattr(cli, '__doc__', DOC)
35 34
35 # Lower level import because we only want to load this module
36 # when this plugin is called.
37 from monitorstack.utils import os_utils as ost
38
36 output = { 39 output = {
37 'measurement_name': COMMAND_NAME, 40 'measurement_name': COMMAND_NAME,
38 'meta': { 41 'meta': {
diff --git a/monitorstack/plugins/os_vm_quota_ram.py b/monitorstack/plugins/os_vm_quota_ram.py
index 54a7e40..125656f 100644
--- a/monitorstack/plugins/os_vm_quota_ram.py
+++ b/monitorstack/plugins/os_vm_quota_ram.py
@@ -17,7 +17,6 @@ import click
17 17
18from monitorstack import utils 18from monitorstack import utils
19from monitorstack.cli import pass_context 19from monitorstack.cli import pass_context
20from monitorstack.utils import os_utils as ost
21 20
22 21
23DOC = """Get nova ram quotas.""" 22DOC = """Get nova ram quotas."""
@@ -33,6 +32,10 @@ def cli(ctx, config_file):
33 """Get nova ram quotas.""" 32 """Get nova ram quotas."""
34 setattr(cli, '__doc__', DOC) 33 setattr(cli, '__doc__', DOC)
35 34
35 # Lower level import because we only want to load this module
36 # when this plugin is called.
37 from monitorstack.utils import os_utils as ost
38
36 output = { 39 output = {
37 'measurement_name': COMMAND_NAME, 40 'measurement_name': COMMAND_NAME,
38 'meta': { 41 'meta': {
diff --git a/monitorstack/plugins/os_vm_used_cores.py b/monitorstack/plugins/os_vm_used_cores.py
index db05f07..8185446 100644
--- a/monitorstack/plugins/os_vm_used_cores.py
+++ b/monitorstack/plugins/os_vm_used_cores.py
@@ -19,7 +19,6 @@ import click
19 19
20from monitorstack import utils 20from monitorstack import utils
21from monitorstack.cli import pass_context 21from monitorstack.cli import pass_context
22from monitorstack.utils import os_utils as ost
23 22
24 23
25DOC = """Get nova used cores.""" 24DOC = """Get nova used cores."""
@@ -35,6 +34,10 @@ def cli(ctx, config_file):
35 """Get nova used cores.""" 34 """Get nova used cores."""
36 setattr(cli, '__doc__', DOC) 35 setattr(cli, '__doc__', DOC)
37 36
37 # Lower level import because we only want to load this module
38 # when this plugin is called.
39 from monitorstack.utils import os_utils as ost
40
38 output = { 41 output = {
39 'measurement_name': COMMAND_NAME, 42 'measurement_name': COMMAND_NAME,
40 'meta': { 43 'meta': {
diff --git a/monitorstack/plugins/os_vm_used_disk.py b/monitorstack/plugins/os_vm_used_disk.py
index a71111e..0d662f6 100644
--- a/monitorstack/plugins/os_vm_used_disk.py
+++ b/monitorstack/plugins/os_vm_used_disk.py
@@ -19,7 +19,6 @@ import click
19 19
20from monitorstack import utils 20from monitorstack import utils
21from monitorstack.cli import pass_context 21from monitorstack.cli import pass_context
22from monitorstack.utils import os_utils as ost
23 22
24 23
25DOC = """Get nova used disk.""" 24DOC = """Get nova used disk."""
@@ -35,6 +34,10 @@ def cli(ctx, config_file):
35 """Get nova used disk.""" 34 """Get nova used disk."""
36 setattr(cli, '__doc__', DOC) 35 setattr(cli, '__doc__', DOC)
37 36
37 # Lower level import because we only want to load this module
38 # when this plugin is called.
39 from monitorstack.utils import os_utils as ost
40
38 output = { 41 output = {
39 'measurement_name': COMMAND_NAME, 42 'measurement_name': COMMAND_NAME,
40 'meta': { 43 'meta': {
diff --git a/monitorstack/plugins/os_vm_used_instance.py b/monitorstack/plugins/os_vm_used_instance.py
index 511f719..9264694 100644
--- a/monitorstack/plugins/os_vm_used_instance.py
+++ b/monitorstack/plugins/os_vm_used_instance.py
@@ -19,7 +19,6 @@ import click
19 19
20from monitorstack import utils 20from monitorstack import utils
21from monitorstack.cli import pass_context 21from monitorstack.cli import pass_context
22from monitorstack.utils import os_utils as ost
23 22
24 23
25DOC = """Get nova used instances.""" 24DOC = """Get nova used instances."""
@@ -35,6 +34,10 @@ def cli(ctx, config_file):
35 """Get nova used instances.""" 34 """Get nova used instances."""
36 setattr(cli, '__doc__', DOC) 35 setattr(cli, '__doc__', DOC)
37 36
37 # Lower level import because we only want to load this module
38 # when this plugin is called.
39 from monitorstack.utils import os_utils as ost
40
38 output = { 41 output = {
39 'measurement_name': COMMAND_NAME, 42 'measurement_name': COMMAND_NAME,
40 'meta': { 43 'meta': {
diff --git a/monitorstack/plugins/os_vm_used_ram.py b/monitorstack/plugins/os_vm_used_ram.py
index 1ce299b..a8967c9 100644
--- a/monitorstack/plugins/os_vm_used_ram.py
+++ b/monitorstack/plugins/os_vm_used_ram.py
@@ -19,7 +19,6 @@ import click
19 19
20from monitorstack import utils 20from monitorstack import utils
21from monitorstack.cli import pass_context 21from monitorstack.cli import pass_context
22from monitorstack.utils import os_utils as ost
23 22
24 23
25DOC = """Get nova used ram.""" 24DOC = """Get nova used ram."""
@@ -35,6 +34,10 @@ def cli(ctx, config_file):
35 """Get nova used ram.""" 34 """Get nova used ram."""
36 setattr(cli, '__doc__', DOC) 35 setattr(cli, '__doc__', DOC)
37 36
37 # Lower level import because we only want to load this module
38 # when this plugin is called.
39 from monitorstack.utils import os_utils as ost
40
38 output = { 41 output = {
39 'measurement_name': COMMAND_NAME, 42 'measurement_name': COMMAND_NAME,
40 'meta': { 43 'meta': {