def _ensure_instance_running(self, instance_name):
try:<EOL><INDENT>instance_info = self._compute.instances().get(<EOL>project=self.project, zone=self.zone, instance=instance_name<EOL>).execute()<EOL>if instance_info['<STR_LIT:status>'] == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>elif instance_info['<STR_LIT:status>'] == '<STR_LIT>':<EOL><INDENT>self._start_terminated_server(instance_name)<EOL><DEDENT>else:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>").format(<EOL>instance_name, instance_info['<STR_LIT:status>'])<EOL>raise Exception(msg)<EOL><DEDENT><DEDENT>except HttpError as e:<EOL><INDENT>if e.resp.status == <NUM_LIT>:<EOL><INDENT>log_red("<STR_LIT>".format(instance_name))<EOL>log_yellow("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>log_red("<STR_LIT>".format(<EOL>instance_name))<EOL><DEDENT>raise e<EOL><DEDENT>
If an instance is terminated but still exists (hasn't been deleted
calling this will start the instance up again. Raises an error
if the instance no longer exists.