def free_slave(**connection_args):
 slave_db = _connect(**connection_args)
 if (slave_db is None):
  return ''
 slave_cur = slave_db.cursor(MySQLdb.cursors.DictCursor)
 slave_cur.execute('show slave status')
 slave_status = slave_cur.fetchone()
 master = {'host': slave_status['Master_Host']}
 try:
  master_db = _connect(**master)
  if (master_db is None):
   return ''
  master_cur = master_db.cursor()
  master_cur.execute('flush logs')
  master_db.close()
 except MySQLdb.OperationalError:
  pass
 slave_cur.execute('stop slave')
 slave_cur.execute('reset master')
 slave_cur.execute('change master to MASTER_HOST=')
 slave_cur.execute('show slave status')
 results = slave_cur.fetchone()
 if (results is None):
  return 'promoted'
 else:
  return 'failed'

def free_slave ( ** connection_args ) : slave_db = _connect ( ** connection_args ) if ( slave_db is None ) : return '' slave_cur = slave_db . cursor ( MySQLdb . cursors . DictCursor ) slave_cur . execute ( 'show slave status' ) slave_status = slave_cur . fetchone ( ) master = { 'host' : slave_status [ 'Master_Host' ] } try : master_db = _connect ( ** master ) if ( master_db is None ) : return '' master_cur = master_db . cursor ( ) master_cur . execute ( 'flush logs' ) master_db . close ( ) except MySQLdb . OperationalError : pass slave_cur . execute ( 'stop slave' ) slave_cur . execute ( 'reset master' ) slave_cur . execute ( 'change master to MASTER_HOST=' ) slave_cur . execute ( 'show slave status' ) results = slave_cur . fetchone ( ) if ( results is None ) : return 'promoted' else : return 'failed'
frees a slave from its master .