def wait_for_server(pbclient=None, dc_id=None, serverid=None,<EOL>indicator='<STR_LIT:state>', state='<STR_LIT>', timeout=<NUM_LIT>):
if pbclient is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if dc_id is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if serverid is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>total_sleep_time = <NUM_LIT:0><EOL>seconds = <NUM_LIT:5><EOL>while total_sleep_time < timeout:<EOL><INDENT>time.sleep(seconds)<EOL>total_sleep_time += seconds<EOL>if total_sleep_time == <NUM_LIT>:<EOL><INDENT>seconds = <NUM_LIT:10><EOL><DEDENT>elif total_sleep_time == <NUM_LIT>:<EOL><INDENT>seconds = <NUM_LIT:20><EOL><DEDENT>server = getServerStates(pbclient, dc_id, serverid)<EOL>if server[indicator] == state:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return server<EOL>
wait for a server/VM to reach a defined state for a specified time
indicator := {state|vmstate} specifies if server or VM stat is tested
state specifies the status the indicator should have