Skip to content

Commit

Permalink
Use the 'connector' database backend while spawning the vSphere Agents
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Mar 29, 2014
1 parent 41ad9c1 commit ad8610d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/vpoller/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
import os
import types
import logging
import sqlite3
import ConfigParser
from time import asctime

import zmq
from vpoller.core import VPollerException
from vpoller.agent import VSphereAgent
from vpoller.daemon import Daemon
from vpoller.connector import VConnectorDatabase

class VPollerWorker(Daemon):
"""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit ad8610d

Please sign in to comment.