Skip to content

Commit

Permalink
Add a VMPollerProxy class for creating ZeroMQ proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Aug 20, 2013
1 parent 9855a3e commit 69c42d3
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/vmpollerd/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""
Core module of the VMware vSphere Poller Daemon
Core module for the VMware vSphere Poller
"""

import os
Expand All @@ -32,6 +33,7 @@

import zmq
from vmconnector.core import VMConnector
from vmpollerd.daemon import Daemon
from pysphere import MORTypes

class VMPollerException(Exception):
Expand Down Expand Up @@ -230,3 +232,38 @@ def get_datastore_property(self, name, url, prop):

return { "status": 0, "datastore": name, "property": prop, "value": d[prop] } # Return the requested property

class VMPollerProxy(Daemon):
"""
VMPoller Proxy object.
ZeroMQ proxy which load-balances all client requests to a
pool of connected ZeroMQ workers.
Extends:
Daemon
Overrides:
run() method
"""
def run(self):
# ZeroMQ context
self.zcontext = zmq.Context()

# Socket facing clients
# TODO: The endpoint we bind to should be configurable
self.frontend = self.zcontext.socket(zmq.ROUTER)
self.frontend.bind("tcp://*:11555")

# Socket facing workers
# TODO: The endpoint we bind should be configurable
self.backend = self.zcontext.socket(zmq.DEALER)
self.backend.bind("tcp://*:15556")

# Start the proxy
zmq.proxy(self.frontend, self.backend)

# This is never reached...
self.frontend.close()
self.backend.close()
self.zcontext.term()

0 comments on commit 69c42d3

Please sign in to comment.