From ad8610d0d0a3423e06011f05d345203e85852a35 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Nikolov Date: Sat, 29 Mar 2014 18:52:42 +0200 Subject: [PATCH] Use the 'connector' database backend while spawning the vSphere Agents --- src/vpoller/worker.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/vpoller/worker.py b/src/vpoller/worker.py index 63cd266..2454026 100644 --- a/src/vpoller/worker.py +++ b/src/vpoller/worker.py @@ -30,7 +30,6 @@ import os import types import logging -import sqlite3 import ConfigParser from time import asctime @@ -38,6 +37,7 @@ from vpoller.core import VPollerException from vpoller.agent import VSphereAgent from vpoller.daemon import Daemon +from vpoller.connector import VConnectorDatabase class VPollerWorker(Daemon): """ @@ -137,7 +137,7 @@ def load_worker_config(self, config): parser.read(config) try: - self.worker_db = parser.get('worker', 'db') + self.connector_db = parser.get('worker', 'db') self.proxy_endpoint = parser.get('worker', 'proxy') self.mgmt_endpoint = parser.get('worker', 'mgmt') except ConfigParser.NoOptionError as e: @@ -197,13 +197,14 @@ def spawn_vsphere_agents(self): self.agents = dict() - registered_agents = self.worker_db_get_agents(only_enabled=True) + db = VConnectorDatabase(self.connector_db) + db_agents = db.get_agents(only_enabled=True) - if not registered_agents: - logging.warning('There are no vSphere Agents in the database') - raise VPollerException, 'There are no vSphere Agents in the database' + if not db_agents: + logging.warning('There are no vSphere Agents registered') + raise VPollerException, 'There are no vSphere Agents registered' - for each_agent in registered_agents: + for each_agent in db_agents: agent = VSphereAgent( user=each_agent['user'], pwd=each_agent['pwd'],