diff --git a/src/vpoller-proxy b/src/vpoller-proxy index 737f4a4..6363e2c 100755 --- a/src/vpoller-proxy +++ b/src/vpoller-proxy @@ -30,74 +30,60 @@ between a pool of ZeroMQ workers. """ +import os import json import logging +import multiprocessing from sys import exit from vpoller.client import VPollerClient -from vpoller.proxy import VPollerProxy +from vpoller.proxy import VPollerProxyManager from docopt import docopt -def start(pidfile, config, daemon): +def start(config): """ Start the VPoller Proxy daemon Args: - pidfile (string): Location to the daemon's pidfile - config (string): Configuration file of the VPoller Proxy - daemon (bool): If True daemonize the VPoller Proxy + config (string): Path to the vPoller configuration file """ - proxy = VPollerProxy(pidfile) - - if daemon: - # Run as daemon - proxy.start(config) - else: - # Run in the foreground - proxy.run(config) + manager = VPollerProxyManager(config_file=config) + manager.start() def stop(endpoint): """ - Stops the VPoller Proxy daemon + Stops the VPoller Proxy Args: endpoint (string): The endpoint we send the shutdown message to """ - # The message we send to initiate the shutdown sequence - msg = { "method": "proxy.shutdown" } - - # Send out our message client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3) - result = client.run(msg) + result = client.run({'method': 'shutdown'}) return result def status(endpoint): """ - Get status information from the VPoller Proxy daemon + Get status information from the VPoller Proxy Args: endpoint (string): The endpoint we send the status message to """ - # The message we send to get status information - msg = { "method": "proxy.status" } - - # Send out our message client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3) - result = client.run(msg) + result = client.run({'method': 'status'}) return result def main(): usage=""" -Usage: vpoller-proxy [-d] [-D] [-p ] [-f ] [-o ] start - vpoller-proxy [-D] -e stop - vpoller-proxy [-D] -e status +Usage: vpoller-proxy [-d] [-f ] start + vpoller-proxy [-d] -e stop + vpoller-proxy [-d] -e status vpoller-proxy --help vpoller-proxy --version @@ -109,38 +95,35 @@ Arguments: Options: -h, --help Display this usage info -v, --version Display version and exit - -d, --daemon Start as a daemon, otherwise - run in the foreground - -D, --debug Debug mode, be more verbose - -p , --pidfile Specify pidfile file to use - [default: /var/run/vpoller/vpoller-proxy.pid] - -f , --config Specify config file to use + -d, --debug Debug mode, be more verbose + -f , --file Specify config file to use [default: /etc/vpoller/vpoller.conf] -e , --endpoint Specify the endpoint we connect to - -o , --output Specify the logfile to use - [default: /var/log/vpoller/vpoller-proxy.log] """ args = docopt(usage, version='0.2.9') - level = logging.DEBUG if args['--debug'] else logging.INFO + if not os.path.exists(args['--file']): + raise SystemExit, 'Configuration file %s does not exist' + + if args['--debug']: + level = logging.DEBUG + else: + level = logging.INFO - logging.basicConfig( - filename=args['--output'], - format='%(asctime)s - %(levelname)s - vpoller-proxy[%(process)s]: %(message)s', - level=level - ) + logger = multiprocessing.log_to_stderr() + logger.setLevel(level) result = None rc = 0 - - if args["start"]: - start(args["--pidfile"], args["--config"], args["--daemon"]) - elif args["stop"]: - result = stop(args["--endpoint"]) + + if args['start']: + start(args['--file']) + elif args['stop']: + result = stop(args['--endpoint']) elif args["status"]: - result = status(args["--endpoint"]) + result = status(args['--endpoint']) if result: rc = result['success'] diff --git a/src/vpoller-worker b/src/vpoller-worker index 675e678..b3cd204 100755 --- a/src/vpoller-worker +++ b/src/vpoller-worker @@ -44,18 +44,18 @@ from vpoller.client import VPollerClient from vpoller.worker import VPollerWorkerManager from docopt import docopt -def start(config, workers): +def start(config, concurrency): """ Start the vPoller Worker Args: - config (string): Path to the vPoller configuration file - workers (int): Number of Worker processes to start + config (str): Path to the vPoller configuration file + concurrency (int): Number of Worker processes to start """ manager = VPollerWorkerManager( config_file=config, - num_workers=int(workers) + num_workers=concurrency ) manager.start() @@ -67,12 +67,8 @@ def stop(endpoint): endpoint (string): The endpoint we send the shutdown message to """ - # The message we send to initiate the shutdown sequence - msg = { "method": "shutdown" } - - # Send out our message client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3) - result = client.run(msg) + result = client.run({'method': 'shutdown'}) return result @@ -84,12 +80,8 @@ def status(endpoint): endpoint (string): The endpoint we send the status request to """ - # The message we send to get status information - msg = { "method": "status" } - - # Send out our message client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3) - result = client.run(msg) + result = client.run({'method': 'status'}) return result @@ -132,13 +124,14 @@ Options: logger = multiprocessing.log_to_stderr() logger.setLevel(level) + result = None + rc = 0 + if args['start']: - if not args['--concurrency'] or args['--concurrency'] <= 0: - concurrency = multiprocessing.cpu_count() - else: - concurrency = args['--concurrency'] - - start(config=args['--file'], workers=concurrency) + start( + config=args['--file'], + concurrency=args['--concurrency'] + ) elif args['stop']: result = stop(args['--endpoint']) elif args['status']: diff --git a/src/vpoller/agent.py b/src/vpoller/agent.py index df3aac0..428a7cb 100644 --- a/src/vpoller/agent.py +++ b/src/vpoller/agent.py @@ -35,13 +35,15 @@ """ -import logging +import multiprocessing import zmq import pyVmomi from vpoller.core import VPollerException from vconnector.core import VConnector +logger = multiprocessing.get_logger() + class VSphereAgent(VConnector): """ VSphereAgent class @@ -70,7 +72,7 @@ def _discover_objects(self, properties, obj_type): The discovered objects in JSON format """ - logging.info('[%s] Discovering %s managed objects', self.host, obj_type.__name__) + logger.info('[%s] Discovering %s managed objects', self.host, obj_type.__name__) view_ref = self.get_container_view(obj_type=[obj_type]) try: @@ -90,7 +92,7 @@ def _discover_objects(self, properties, obj_type): 'result': data, } - logging.debug('[%s] Returning result from operation: %s', self.host, result) + logger.debug('[%s] Returning result from operation: %s', self.host, result) return result @@ -114,7 +116,7 @@ def _get_object_properties(self, properties, obj_type, obj_property_name, obj_pr The collected properties for this managed object in JSON format """ - logging.info('[%s] Retrieving properties for %s managed object of type %s', + logger.info('[%s] Retrieving properties for %s managed object of type %s', self.host, obj_property_value, obj_type.__name__ @@ -154,7 +156,7 @@ def _get_object_properties(self, properties, obj_type, obj_property_name, obj_pr 'result': data, } - logging.debug('[%s] Returning result from operation: %s', self.host, result) + logger.debug('[%s] Returning result from operation: %s', self.host, result) return result @@ -174,7 +176,7 @@ def _object_datastore_get(self, obj_type, name): The discovered objects in JSON format """ - logging.debug('[%s] Getting datastores for %s managed object of type %s', + logger.debug('[%s] Getting datastores for %s managed object of type %s', self.host, name, obj_type.__name__ @@ -213,7 +215,7 @@ def _object_datastore_get(self, obj_type, name): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -232,7 +234,7 @@ def event_latest(self, msg): The discovered objects in JSON format """ - logging.info('[%s] Retrieving latest registered event', self.host) + logger.info('[%s] Retrieving latest registered event', self.host) result = { 'msg': 'Successfully retrieved event', @@ -240,7 +242,7 @@ def event_latest(self, msg): 'result': [ {'event': self.si.content.eventManager.latestEvent.fullFormattedMessage} ], } - logging.debug('[%s] Returning result from operation: %s', self.host, result) + logger.debug('[%s] Returning result from operation: %s', self.host, result) return result @@ -271,7 +273,7 @@ def about(self, msg): The discovered objects in JSON format """ - logging.info("[%s] Retrieving 'about' information", self.host) + logger.info("[%s] Retrieving 'about' information", self.host) # If no properties are specified just return the 'fullName' property if not msg.has_key('properties') or not msg['properties']: @@ -285,7 +287,7 @@ def about(self, msg): 'result': [ {prop:getattr(self.si.content.about, prop, None) for prop in properties} ] } - logging.debug('[%s] Returning result from operation: %s', self.host, result) + logger.debug('[%s] Returning result from operation: %s', self.host, result) return result @@ -370,7 +372,7 @@ def net_host_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting Host Systems using %s pyVmomi.vim.Network managed object', self.host, msg['name']) + logger.debug('[%s] Getting Host Systems using %s pyVmomi.vim.Network managed object', self.host, msg['name']) # Find the Network managed object and get the 'host' property data = self._get_object_properties( @@ -404,7 +406,7 @@ def net_host_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -424,7 +426,7 @@ def net_vm_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting Virtual Machines using %s pyVmomi.vim.Network managed object', self.host, msg['name']) + logger.debug('[%s] Getting Virtual Machines using %s pyVmomi.vim.Network managed object', self.host, msg['name']) # Find the Network managed object and get the 'vm' property data = self._get_object_properties( @@ -458,7 +460,7 @@ def net_vm_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -740,7 +742,7 @@ def host_cluster_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting cluster name for %s host', self.host, msg['name']) + logger.debug('[%s] Getting cluster name for %s host', self.host, msg['name']) # Find the HostSystem managed object and get the 'parent' property data = self._get_object_properties( @@ -766,7 +768,7 @@ def host_cluster_get(self, msg): 'result': [ result ], } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -786,7 +788,7 @@ def host_vm_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting VirtualMachine list running on %s host', self.host, msg['name']) + logger.debug('[%s] Getting VirtualMachine list running on %s host', self.host, msg['name']) # Find the HostSystem managed object and get the 'vm' property data = self._get_object_properties( @@ -820,7 +822,7 @@ def host_vm_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -840,7 +842,7 @@ def host_net_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting Network list available for %s host', self.host, msg['name']) + logger.debug('[%s] Getting Network list available for %s host', self.host, msg['name']) # Find the HostSystem managed object and get the 'network' property data = self._get_object_properties( @@ -874,7 +876,7 @@ def host_net_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -964,7 +966,7 @@ def vm_disk_discover(self, msg): The discovered objects in JSON format """ - logging.debug('[%s] Discovering guest disks for VirtualMachine %s', self.host, msg['name']) + logger.debug('[%s] Discovering guest disks for VirtualMachine %s', self.host, msg['name']) # Find the VM and get the guest disks data = self._get_object_properties( @@ -997,7 +999,7 @@ def vm_disk_discover(self, msg): 'result': [ result ], } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1034,7 +1036,7 @@ def vm_guest_net_get(self, msg): The discovered objects in JSON format """ - logging.debug('[%s] Discovering guest network adapters for VirtualMachine %s', self.host, msg['name']) + logger.debug('[%s] Discovering guest network adapters for VirtualMachine %s', self.host, msg['name']) # Find the VM and get the network adapters data = self._get_object_properties( @@ -1067,7 +1069,7 @@ def vm_guest_net_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1087,7 +1089,7 @@ def vm_net_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting Network list available for %s VirtualMachine', self.host, msg['name']) + logger.debug('[%s] Getting Network list available for %s VirtualMachine', self.host, msg['name']) # Find the VirtualMachine managed object and get the 'network' property data = self._get_object_properties( @@ -1121,7 +1123,7 @@ def vm_net_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1173,7 +1175,7 @@ def vm_host_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting HostSystem where %s VirtualMachine is running on', self.host, msg['name']) + logger.debug('[%s] Getting HostSystem where %s VirtualMachine is running on', self.host, msg['name']) data = self._get_object_properties( properties=['name', 'runtime.host'], @@ -1199,7 +1201,7 @@ def vm_host_get(self, msg): 'result': [ result ], } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1258,7 +1260,7 @@ def vm_disk_get(self, msg): The discovered objects in JSON format """ - logging.debug( + logger.debug( '[%s] Getting guest disk info for %s on VirtualMachine %s', self.host, msg['key'], @@ -1296,7 +1298,7 @@ def vm_disk_get(self, msg): 'result': [ result ], } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1336,7 +1338,7 @@ def vm_process_get(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting processes for VirtualMachine %s', self.host, msg['name']) + logger.debug('[%s] Getting processes for VirtualMachine %s', self.host, msg['name']) # Get the VirtualMachine managed object data = self._get_object_properties( @@ -1391,7 +1393,7 @@ def vm_process_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1411,7 +1413,7 @@ def vm_cpu_usage_percent(self, msg): The managed object properties in JSON format """ - logging.debug('[%s] Getting CPU usage percentage for VirtualMachine %s', self.host, msg['name']) + logger.debug('[%s] Getting CPU usage percentage for VirtualMachine %s', self.host, msg['name']) # Get the VirtualMachine managed object and collect the # properties required to calculate the CPU usage in percentage. @@ -1468,7 +1470,7 @@ def vm_cpu_usage_percent(self, msg): 'result': [ result ], } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1551,7 +1553,7 @@ def datastore_host_get(self, msg): } """ - logging.info('[%s] Getting HostSystem list using Datastore %s', self.host, msg['name']) + logger.info('[%s] Getting HostSystem list using Datastore %s', self.host, msg['name']) # Find the Datastore by it's 'info.url' property and get the HostSystem objects using it data = self._get_object_properties( @@ -1590,7 +1592,7 @@ def datastore_host_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r @@ -1607,7 +1609,7 @@ def datastore_vm_get(self, msg): } """ - logging.info('[%s] Getting VirtualMachine list using Datastore %s', self.host, msg['name']) + logger.info('[%s] Getting VirtualMachine list using Datastore %s', self.host, msg['name']) # Find the Datastore by it's 'info.url' property and get the VirtualMachine objects using it data = self._get_object_properties( @@ -1643,6 +1645,6 @@ def datastore_vm_get(self, msg): 'result': result, } - logging.debug('[%s] Returning result from operation: %s', self.host, r) + logger.debug('[%s] Returning result from operation: %s', self.host, r) return r diff --git a/src/vpoller/proxy.py b/src/vpoller/proxy.py index 03a6a17..73027c6 100644 --- a/src/vpoller/proxy.py +++ b/src/vpoller/proxy.py @@ -28,13 +28,14 @@ """ import os -import logging import ConfigParser import multiprocessing import zmq from vpoller.core import VPollerException +logger = multiprocessing.get_logger() + class VPollerProxyManager(object): """ Manager of vPoller Proxy @@ -70,7 +71,7 @@ def start(self): Start the vPoller Proxy processes """ - logging.info('Starting vPoller Proxy Manager') + logger.info('Starting vPoller Proxy Manager') self.load_config() self.create_sockets() @@ -103,7 +104,7 @@ def load_config(self): Load the vPoller Proxy Manager configuration settings """ - logging.debug('Loading config file %s', self.config_file) + logger.debug('Loading config file %s', self.config_file) parser = ConfigParser.ConfigParser(self.config_defaults) parser.read(self.config_file) @@ -117,7 +118,7 @@ def start_proxy_process(self): Start the vPoller Proxy process """ - logging.info('Starting vPoller Proxy process') + logger.info('Starting vPoller Proxy process') self.proxy = VPollerProxy( frontend=self.config.get('frontend'), @@ -131,7 +132,7 @@ def stop_proxy_process(self): Stop the vPoller Proxy process """ - logging.info('Stopping vPoller Proxy process') + logger.info('Stopping vPoller Proxy process') self.proxy.signal_stop() self.proxy.join(3) @@ -152,7 +153,7 @@ def close_sockets(self): Closes the ZeroMQ sockets used by the vPoller Proxy Manager """ - logging.info('Closing vPoller Proxy Manager sockets') + logger.info('Closing vPoller Proxy Manager sockets') self.zpoller.unregister(self.mgmt_socket) self.mgmt_socket.close() @@ -168,7 +169,7 @@ def wait_for_mgmt_task(self): try: msg = self.mgmt_socket.recv_json() except TypeError as e: - logging.warning('Invalid message received on management interface: %s', msg) + logger.warning('Invalid message received on management interface: %s', msg) return result = self.process_mgmt_task(msg) @@ -188,7 +189,7 @@ def process_mgmt_task(self, msg): msg (dict): The client message for processing """ - logging.debug('Processing management message: %s', msg) + logger.debug('Processing management message: %s', msg) if 'method' not in msg: return { 'success': 1, 'msg': 'Missing method name' } @@ -255,7 +256,7 @@ def __init__(self, frontend, backend): self.backend = None def run(self): - logging.info('vPoller Proxy process is starting') + logger.info('vPoller Proxy process is starting') self.create_sockets() @@ -283,7 +284,7 @@ def distribute_tasks(self): Distributes tasks from frontend to backend socket for processing """ - socks = dict(self.zpoller.poll()) + socks = dict(self.zpoller.poll(1000)) # Forward task from frontend to backend socket if socks.get(self.frontend) == zmq.POLLIN: @@ -308,7 +309,7 @@ def create_sockets(self): Creates the ZeroMQ sockets used by the vPoller Proxy process """ - logging.info('Creating vPoller Proxy process sockets') + logger.info('Creating vPoller Proxy process sockets') self.zcontext = zmq.Context() self.frontend = self.zcontext.socket(zmq.ROUTER) @@ -324,7 +325,7 @@ def close_sockets(self): Closes the ZeroMQ sockets used by vPoller Proxy process """ - logging.info('Closing vPoller Proxy process sockets') + logger.info('Closing vPoller Proxy process sockets') self.zpoller.unregister(self.frontend) self.zpoller.unregister(self.backend) diff --git a/src/vpoller/worker.py b/src/vpoller/worker.py index 5fc7144..4ed2752 100644 --- a/src/vpoller/worker.py +++ b/src/vpoller/worker.py @@ -29,10 +29,8 @@ import os import types -import logging import ConfigParser import multiprocessing -from time import time, asctime import zmq from vpoller.core import VPollerException @@ -40,6 +38,8 @@ from vpoller.daemon import Daemon from vconnector.core import VConnectorDatabase +logger = multiprocessing.get_logger() + class VPollerWorkerManager(object): """ Manager of vPoller Workers @@ -77,7 +77,7 @@ def start(self): Start the vPoller Worker Manager and processes """ - logging.info('Starting vPoller Worker Manager') + logger.info('Starting vPoller Worker Manager') self.load_config() self.create_sockets() @@ -110,7 +110,7 @@ def load_config(self): Loads the vPoller Worker Manager configuration settings """ - logging.debug('Loading config file %s', self.config_file) + logger.debug('Loading config file %s', self.config_file) parser = ConfigParser.ConfigParser(self.config_defaults) parser.read(self.config_file) @@ -124,7 +124,7 @@ def start_workers(self): Start the vPoller Worker processes """ - logging.info('Starting vPoller Worker processes') + logger.info('Starting vPoller Worker processes') if self.num_workers <= 0: self.num_workers = multiprocessing.cpu_count() @@ -143,7 +143,7 @@ def stop_workers(self): Stop the vPoller Worker processes """ - logging.info('Stopping vPoller Worker processes') + logger.info('Stopping vPoller Worker processes') for worker in self.workers: worker.signal_stop() @@ -154,7 +154,7 @@ def create_sockets(self): Creates the ZeroMQ sockets used by the vPoller Worker Manager """ - logging.debug('Creating vPoller Worker Manager sockets') + logger.debug('Creating vPoller Worker Manager sockets') self.zcontext = zmq.Context() self.mgmt_socket = self.zcontext.socket(zmq.REP) @@ -167,7 +167,7 @@ def close_sockets(self): Closes the ZeroMQ sockets used by the Manager """ - logging.debug('Closing vPoller Worker Manager sockets') + logger.debug('Closing vPoller Worker Manager sockets') self.zpoller.unregister(self.mgmt_socket) self.mgmt_socket.close() @@ -183,7 +183,7 @@ def wait_for_mgmt_task(self): try: msg = self.mgmt_socket.recv_json() except TypeError as e: - logging.warning('Invalid message received on management interface: %s', msg) + logger.warning('Invalid message received on management interface: %s', msg) return result = self.process_mgmt_task(msg) @@ -203,7 +203,7 @@ def process_mgmt_task(self, msg): msg (dict): The client message for processing """ - logging.debug('Processing management message: %s', msg) + logger.debug('Processing management message: %s', msg) if 'method' not in msg: return { 'success': 1, 'msg': 'Missing method name' } @@ -221,7 +221,7 @@ def status(self): Get status information about the vPoller Worker """ - logging.debug('Getting vPoller Worker status') + logger.debug('Getting vPoller Worker status') result = { 'success': 0, @@ -237,7 +237,7 @@ def status(self): } } - logging.debug('Returning result to client: %s', result) + logger.debug('Returning result to client: %s', result) return result @@ -283,7 +283,7 @@ def run(self): config (str): Path to the confuguration file for vPoller Worker """ - logging.info('vPoller Worker process is starting') + logger.info('vPoller Worker process is starting') self.create_sockets() self.create_agents() @@ -328,7 +328,7 @@ def wait_for_tasks(self): try: msg = self.worker_socket.recv_json() except Exception as e: - logging.warning('Invalid client message received, will be ignored: %s', msg) + logger.warning('Invalid client message received, will be ignored: %s', msg) # Process task and return result to client result = self.process_client_msg(msg) @@ -337,7 +337,7 @@ def wait_for_tasks(self): try: self.worker_socket.send_json(result) except TypeError as e: - logging.warning('Cannot serialize result: %s', e) + logger.warning('Cannot serialize result: %s', e) self.worker_socket.send_json({ 'success': 1, 'msg': 'Cannot serialize result: %s' % e}) def create_sockets(self): @@ -347,7 +347,7 @@ def create_sockets(self): Creates two sockets: """ - logging.debug('Creating vPoller Worker sockets') + logger.debug('Creating vPoller Worker sockets') self.zcontext = zmq.Context() self.worker_socket = self.zcontext.socket(zmq.DEALER) @@ -372,13 +372,13 @@ def create_agents(self): VPollerException """ - logging.debug('Creating vSphere Agents') + logger.debug('Creating vSphere Agents') db = VConnectorDatabase(self.config.get('db')) agents = db.get_agents(only_enabled=True) if not agents: - logging.warning('No registered or enabled vSphere Agents found') + logger.warning('No registered or enabled vSphere Agents found') raise VPollerException, 'No registered or enabled vSphere Agents found' for agent in agents: @@ -394,7 +394,7 @@ def stop_agents(self): Disconnects all vPoller Agents from the VMware vSphere hosts they are connected to """ - logging.debug('Shutting down vSphere Agents') + logger.debug('Shutting down vSphere Agents') for agent in self.agents: self.agents[agent].disconnect() @@ -426,7 +426,7 @@ def process_client_msg(self, msg): msg (dict): Client message for processing """ - logging.debug('Processing client message: %s', msg) + logger.debug('Processing client message: %s', msg) if not isinstance(msg, dict): return { 'success': 1, 'msg': 'Expected a JSON message, received %s' % msg.__class__ } @@ -577,7 +577,7 @@ def process_client_msg(self, msg): agent_method = methods[msg['method']] - logging.debug('Checking client message, required to have: %s', agent_method['msg_attr']) + logger.debug('Checking client message, required to have: %s', agent_method['msg_attr']) # The message attributes type we expect to receive msg_attr_types = {