def _wait_on_instance(self, state, timeout=<NUM_LIT>, wait_period=<NUM_LIT:10>):
current_state = '<STR_LIT>'<EOL>start = time.time()<EOL>end = start + timeout<EOL>while time.time() < end:<EOL><INDENT>current_state = self._get_instance_state()<EOL>if state.lower() == current_state.lower():<EOL><INDENT>return<EOL><DEDENT>time.sleep(wait_period)<EOL><DEDENT>raise IpaCloudException(<EOL>'<STR_LIT>'.format(<EOL>state=state<EOL>)<EOL>)<EOL>
Wait until instance is in given state.