Skip to content

Commit

Permalink
Added function to decide which node is running on (Compute/Network)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Galkin committed Mar 24, 2016
1 parent 1fd994a commit 74b95c7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions openvswitch.py
Expand Up @@ -26,11 +26,11 @@ def determine_node_role():
"""
Runs virsh list as a simple check if that's a compute or network node.
"""
cmd = Popen(("virsh", "list"),
stdout=PIPE, stderr=PIPE, close_fds=True)
cmd.communicate()

if cmd.returncode != 0:
try:
cmd = Popen(("virsh", "list"),
stdout=PIPE, stderr=PIPE, close_fds=True)
cmd.communicate()
except OSError:
global is_network_node
is_network_node = True

Expand Down Expand Up @@ -226,9 +226,12 @@ def send_data_to_collectd(ovs_data, cpu_usage, vms_running, vxlan_count):

# CPU use; number of VMs; VXLAN count:
dispatch_to_collectd("cpu_usage", (cpu_usage,))
dispatch_to_collectd("running_vms", (vms_running,))
dispatch_to_collectd("total_vxlans", (vxlan_count,))

if not is_network_node:
# compute node -> report amount of VMs
dispatch_to_collectd("running_vms", (vms_running,))

def read_openvswitch_stats():
"""
A callback method used by collectd.
Expand Down

0 comments on commit 74b95c7

Please sign in to comment.