示例#1
0
 initialize_test_data(conn)
 
 '''
 db2.clear(conn, 'role_authority', 'authority_resource', 'menus', 'authorities', 'resources', )#, 'metadatas')
 
 apps = ['SC-CORE']
 
 for app in apps:
     populate_resources(conn, get_resources(conn, app))
     populate_authorities(conn, get_authorities(conn))
     populate_authority_resource(conn, get_authority_resource(conn, app))
     populate_role_authority(conn, get_role_authority(conn))
     populate_menus(conn, get_menus(conn, app))
     populate_metadata(conn, get_metadatas(src_conn))
 '''
 
 '''
 stmt = ibm_db.columns(conn, None, 'DB2INST1', 'USERS')
 row = ibm_db.fetch_assoc(stmt)
 while row:
     print row
     row = ibm_db.fetch_assoc(stmt)
 '''
 
 
 db2.commit(conn)
 db2.disconnect(conn)
 
 #db2.disconnect(src_conn)
 
 
示例#2
0
文件: sso_init.py 项目: rafoul/pytest
    roles = ('sso_admin',)
    
    for role in roles:
        yield (user['USER_KEY'], get_role(conn, role)['ROLE_KEY'])



if __name__ == '__main__':
    src_conn = db2.connect('HAIAN', '10.3.1.249', '60000', 'db2inst1', '1qaz2wsx')
    dest_conn = db2.connect('KBMASTER', '10.98.0.192', '50000', 'db2inst1', 'password')
  
    ibm_db.exec_immediate(dest_conn, 'set schema db2inst1')
    
    # Truncate target database tables.
    ibm_db.exec_immediate(dest_conn, 'delete from sso_user_role')
    ibm_db.exec_immediate(dest_conn, 'delete from sso_roles')
    ibm_db.exec_immediate(dest_conn, 'delete from sso_users')
    ibm_db.exec_immediate(dest_conn, 'delete from SSO_TENANTS')

    populate_tenant(dest_conn, sso_tenants(src_conn))
    populate_user(dest_conn, sso_users(src_conn))
    populate_role(dest_conn, sso_roles(src_conn))
    populate_user_role(dest_conn, sso_user_role(src_conn))
    
    populate_role(dest_conn, extra_roles(dest_conn))
    populate_user_role(dest_conn, extra_user_role(dest_conn))
    
    db2.commit(dest_conn)
    db2.disconnect(dest_conn)
    db2.disconnect(src_conn)