 
     if vmItem = @getVmNode vmName
       return warn "VM #{vmName} is already mounted!"
+
+    @saveMountState vmName, yes
 
     @vms.push FSHelper.createFile
       name   : "#{path}"

  unmountVm:(vmName)->
    return unless KD.isLoggedIn()
    return warn 'No such VM!'  unless vmItem = @getVmNode vmName

    if vmItem
      @stopWatching vmItem.data.path

      callback?()

    if vmNames then mountVms vmNames
    else
      groupSlug  = KD.singletons.groupsController.getGroupSlug()
      groupSlug ?= 'koding'
      appStorage = new AppStorage "vm-list", "1.0"
      appStorage.fetchValue groupSlug, (vms)->
        vms or= []
        if vms.length > 0
          mountVms vms
        else
          KD.remote.api.JVM.fetchVmsByContext {}, (err, vms)->
            return callback? err  if err
            if not vms or vms.length is 0
              vms = [(KD.getSingleton 'vmController').getDefaultVmName()]
            mountVms vms

  getVmNode:(vmName)->
    return null  unless vmName
    for path, vmItem of @treeController.nodes  when vmItem.data?.type is 'vm'
      return vmItem  if vmItem.data.vmName is vmName

  saveMountState:(vmName, state)->
    groupSlug  = KD.singletons.groupsController.getGroupSlug()
    groupSlug ?= 'koding'
    appStorage = new AppStorage "vm-list", "1.0"
    appStorage.fetchValue groupSlug, (vms)->
      vms or= []
      if state and vmName not in vms
        vms.push vmName
      else if not state and vmName in vms
        vms.splice vms.indexOf(vmName), 1
      appStorage.setValue groupSlug, vms

  mountVm:(vm, fetchContent = yes)->
    return unless KD.isLoggedIn()
