code: def ensure_vm_running(self, vm_location):
          
          import vagrant
  
          if self.vagrant is None:
              vagrant_file = vm_location / "Vagrantfile"
              if not vagrant_file.exists():
                  self.init_vagrant(vagrant_file)
  
              self.vagrant = vagrant.Vagrant(vm_location,
                                             quiet_stdout=self.quiet,
                                             quiet_stderr=self.quiet,
                                             out_cm=self.log_cm,
                                             err_cm=self.log_cm)
  
          status = [x for x in self.vagrant.status() if x.name == "default"][0]
  
          if status.state != "running":
              try:
                  self.vagrant.up()
              except subprocess.CalledProcessError:
                  raise BuildError("Vagrant VM couldn't up launched. See output for details.")
docs: Gets or creates a Vagrantfile in ``vm_location`` and calls ``vagrant up`` if the VM is not running.