Skip to content

Commit

Permalink
Add methods for enabling/disabling vSphere Agents in 'connector' module
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Mar 29, 2014
1 parent ad8610d commit f5432c6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/vpoller/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def __init__(self, db):
self.conn = sqlite3.connect(self.db)
self.cursor = self.conn.cursor()

def db_init(self):
def init_db(self):
"""
Initializes the vConnector Database backend
Expand Down Expand Up @@ -332,3 +332,30 @@ def get_agents(self, only_enabled=False):

return result

def enable_agent(self, host):
"""
Mark a vSphere Agent as enabled
Args:
host (str): Hostname of the vSphere Agent to enable
"""
logging.info('Enabling vSphere Agent %s', host)

self.cursor.execute('UPDATE hosts SET enabled = 1 WHERE host = ?', (host,))
self.conn.commit()
self.cursor.close()

def disable_agent(self, host):
"""
Mark a vSphere Agent as disabled
Args:
host (str): Hostname of the vSphere Agent to disable
"""
logging.info('Disabling vSphere Agent %s', host)

self.cursor.execute('UPDATE hosts SET enabled = 0 WHERE host = ?', (host,))
self.conn.commit()
self.cursor.close()

0 comments on commit f5432c6

Please sign in to comment.