Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1444 from jkrocil/fix-host-drift-analysis-creds
Browse files Browse the repository at this point in the history
Fix utils.db_queries and utils.update
  • Loading branch information
seandst committed Jan 6, 2015
2 parents 6ee204b + b8bed5b commit 86ee397
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions utils/db_queries.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from utils.db import cfmedb, database_on_server
from utils.db import cfmedb, Db


def get_configuration_details(db=None, ip_address=None):
Expand All @@ -18,7 +18,7 @@ def get_configuration_details(db=None, ip_address=None):
ip_address = cfmedb().hostname

if db is None:
db = database_on_server(ip_address).gen.next()
db = Db(hostname=ip_address)

SEQ_FACT = 1e12
miq_servers = db['miq_servers']
Expand Down Expand Up @@ -55,7 +55,7 @@ def get_zone_description(zone_id, ip_address=None, db=None):
ip_address = cfmedb().hostname

if db is None:
db = database_on_server(ip_address)
db = Db(hostname=ip_address)

zones = list(
db.session.query(db["zones"]).filter(
Expand All @@ -73,7 +73,7 @@ def get_host_id(hostname, ip_address=None, db=None):
ip_address = cfmedb().hostname

if db is None:
db = database_on_server(ip_address)
db = Db(hostname=ip_address)

hosts = list(
db.session.query(db["hosts"]).filter(
Expand Down
6 changes: 4 additions & 2 deletions utils/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ def public_fields(o):
"""
Returns: a dict of fields whose name don't start with underscore.
"""

return dict((key, value) for key, value in o.__dict__.iteritems() if not key.startswith('_'))
if not hasattr(o, '__dict__'):
return dict()
return dict((key, value) for key, value in o.__dict__.iteritems()
if not key.startswith('_'))


def all_public_fields_equal(a, b):
Expand Down

0 comments on commit 86ee397

Please sign in to comment.