/** {@inheritDoc} */
  public void detach(MonitoredVm vm) throws MonitorException {
    RemoteMonitoredVm rmvm = (RemoteMonitoredVm) vm;
    rmvm.detach();
    try {
      remoteHost.detachVm(rmvm.getRemoteVm());

    } catch (RemoteException e) {
      throw new MonitorException(
          "Remote Exception detaching from " + vm.getVmIdentifier().toString(), e);
    }
  }
  /** {@inheritDoc} */
  public MonitoredVm getMonitoredVm(VmIdentifier vmid, int interval) throws MonitorException {
    VmIdentifier nvmid = null;
    try {
      nvmid = hostId.resolve(vmid);
      RemoteVm rvm = remoteHost.attachVm(vmid.getLocalVmId(), vmid.getMode());
      RemoteMonitoredVm rmvm = new RemoteMonitoredVm(rvm, nvmid, timer, interval);
      rmvm.attach();
      return rmvm;

    } catch (RemoteException e) {
      throw new MonitorException("Remote Exception attaching to " + nvmid.toString(), e);
    } catch (URISyntaxException e) {
      /*
       * the VmIdentifier is expected to be a valid and should resolve
       * easonably against the host identifier. A URISyntaxException
       * here is most likely a programming error.
       */
      throw new IllegalArgumentException("Malformed URI: " + vmid.toString(), e);
    }
  }