Skip to content

Commit

Permalink
Merge pull request #29 from SpiderOak/bdzim-apply_sql
Browse files Browse the repository at this point in the history
Bdzim apply sql
  • Loading branch information
merickson committed Sep 2, 2013
2 parents fa66335 + ac54abe commit 7f419a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bin/finish_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ sudo mkdir -p /etc/service/openmanage/supervise
sudo ln -s $OPENMANAGE_ROOT/etc/service/openmanage/run /etc/service/openmanage/run
sudo sv start openmanage

python $HOME/netkes/upgrade/apply_sql.py

if [ -e $OPENMANAGE_ROOT/netkes/account_mgr/user_source/ldap_source.py ]; then
echo "Now we're going to start the initial LDAP->SpiderOak account sync.
This may take a while.
Expand Down
6 changes: 3 additions & 3 deletions netkes/account_mgr/user_source/ldap_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _get_group_ou(ldap_conn, config, group):
filterstr = "(|(objectClass=person)(objectClass=user)(objectClass=organizationalUser))",
attrlist=_create_attrlist(config)):

if dn is None:
if dn is None or not result_dict:
continue
if config['dir_username_source'] not in result_dict:
log.info("User %s lacks %s, skipping", dn, config['dir_username_source'])
Expand Down Expand Up @@ -296,7 +296,7 @@ def _build_user_details(ldap_conn, config, group, uid):
return None
log.debug("Appending user %s", user)

return _build_user_dict(user_dict, config, group['group_id'])
return _build_user_dict(config, user_dict, group['group_id'])


def _get_group_group(ldap_conn, config, group):
Expand All @@ -307,7 +307,7 @@ def _get_group_group(ldap_conn, config, group):
base_dn=group['ldap_id'],
scope=ldap.SCOPE_BASE,
attrlist=[config['dir_member_source']]):
if dn is None:
if dn is None or not result_dict:
continue
# Search LDAP to get User entries that match group
for user in result_dict[config['dir_member_source']]:
Expand Down
3 changes: 2 additions & 1 deletion upgrade/apply_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

def apply_sql():
common.set_config(common.read_config_file())
sql_files = glob.glob('/opt/openmanage/net_kes/sql/*.sql')
sql_files = glob.glob('/home/openmanage/netkes/sql/*.sql')
sql_files = [(x.split('/')[-1], open(x).readlines()) for x in sql_files]
sql_files = sorted(sql_files, key=lambda x: x[0])

for sql_file in sql_files:
with get_cursor(common.get_config()) as cur:
cur.execute('select * from sql_updates where name=%s', (sql_file[0], ))
if cur.rowcount == 0:
print "Applying", sql_file[0]
cur.execute(''.join(sql_file[1]))
cur.execute('insert into sql_updates (name) values (%s)', (sql_file[0], ))

Expand Down

0 comments on commit 7f419a8

Please sign in to comment.