// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/base/connector/AbstractInstance.java
// public abstract class AbstractInstance {
//   @NotNull
//   public abstract String getName();
// 
//   public abstract boolean isInitialized();
// 
//   public abstract Date getStartDate();
// 
//   public abstract String getIpAddress();
// 
//   public abstract InstanceStatus getInstanceStatus();
// 
//   @Nullable
//   public abstract String getProperty(String name);
// }
// 
// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/VmwareSourceState.java
// public class VmwareSourceState {
// 
//   @Nullable
//   private final String mySnapshotName;
// 
//   @Nullable
//   private final String mySourceVmId;
// 
//   private VmwareSourceState(@Nullable final String snapshotName, @Nullable final String sourceVmId){
//     mySnapshotName = snapshotName;
//     mySourceVmId = sourceVmId;
//   }
// 
//   public static VmwareSourceState from(@Nullable final String snapshot, @Nullable final String sourceVmId){
//     return new VmwareSourceState(snapshot, sourceVmId);
//   }
// 
//   @Nullable
//   public String getDiffMessage(final VmwareSourceState vmState) {
//     if (!Objects.equals(vmState.mySnapshotName, this.mySnapshotName)) {
//       return String.format("Snapshot is outdated. VM: '%s' vs Actual: '%s'", mySnapshotName, vmState.mySnapshotName);
//     } else if (!Objects.equals(vmState.mySourceVmId, this.mySourceVmId) && mySourceVmId != null && vmState.mySourceVmId != null) {
//       return String.format("Source VM id is outdated. VM: '%s' vs Actual: '%s'", mySourceVmId, vmState.mySourceVmId);
//     }
//     return null;
//   }
// 
//   @Nullable
//   public String getSnapshotName() {
//     return mySnapshotName;
//   }
// 
//   @Nullable
//   public String getSourceVmId() {
//     return mySourceVmId;
//   }
// 
//   @Override
//   public boolean equals(final Object obj) {
//     if (!(obj instanceof VmwareSourceState))
//       return false;
//     final VmwareSourceState state = (VmwareSourceState)obj;
// 
//     if (!Objects.equals(state.mySnapshotName, this.mySnapshotName))
//       return false;
// 
//     if (!Objects.equals(state.mySourceVmId, this.mySourceVmId) && mySourceVmId != null && state.mySourceVmId != null)
//       return false;
// 
//     return true;
//   }
// 
//   @Override
//   public String toString() {
//     return "VmwareSourceState{" +
//            "mySnapshotName='" + mySnapshotName + '\'' +
//            ", mySourceVmId='" + mySourceVmId + '\'' +
//            '}';
//   }
// }


import com.intellij.openapi.diagnostic.Logger;
import com.vmware.vim25.ManagedObjectReference;
import com.vmware.vim25.OptionValue;
import com.vmware.vim25.VirtualMachinePowerState;
import com.vmware.vim25.mo.VirtualMachine;
import java.util.*;
import jetbrains.buildServer.Used;
import jetbrains.buildServer.clouds.InstanceStatus;
import jetbrains.buildServer.clouds.base.connector.AbstractInstance;
import jetbrains.buildServer.clouds.vmware.VmwareSourceState;
import jetbrains.buildServer.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
  public String getChangeVersion() {
    return myChangeVersion;
  }

  @Nullable
  public VmwareSourceState getVmSourceState(){
    return VmwareSourceState.from(
      StringUtil.nullIfEmpty(getProperty(VMWareApiConnector.TEAMCITY_VMWARE_IMAGE_SNAPSHOT)),
      StringUtil.nullIfEmpty(getProperty(VMWareApiConnector.TEAMCITY_VMWARE_IMAGE_SOURCE_VM_ID))
    );
  }

  @NotNull
  public String getId() {
    return myId;
  }

  @NotNull
  public String getDatacenterId() {
    return myDatacenterId;
  }

  @NotNull
  @Override
  public ManagedObjectReference getMOR() {
    throw new UnsupportedOperationException("VmwareInstance.getMOR");

    //return null;
  }

// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/base/connector/AbstractInstance.java
// public abstract class AbstractInstance {
//   @NotNull
//   public abstract String getName();
// 
//   public abstract boolean isInitialized();
// 
//   public abstract Date getStartDate();
// 
//   public abstract String getIpAddress();
// 
//   public abstract InstanceStatus getInstanceStatus();
// 
//   @Nullable
//   public abstract String getProperty(String name);
// }
// 
// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/VmwareSourceState.java
// public class VmwareSourceState {
// 
//   @Nullable
//   private final String mySnapshotName;
// 
//   @Nullable
//   private final String mySourceVmId;
// 
//   private VmwareSourceState(@Nullable final String snapshotName, @Nullable final String sourceVmId){
//     mySnapshotName = snapshotName;
//     mySourceVmId = sourceVmId;
//   }
// 
//   public static VmwareSourceState from(@Nullable final String snapshot, @Nullable final String sourceVmId){
//     return new VmwareSourceState(snapshot, sourceVmId);
//   }
// 
//   @Nullable
//   public String getDiffMessage(final VmwareSourceState vmState) {
//     if (!Objects.equals(vmState.mySnapshotName, this.mySnapshotName)) {
//       return String.format("Snapshot is outdated. VM: '%s' vs Actual: '%s'", mySnapshotName, vmState.mySnapshotName);
//     } else if (!Objects.equals(vmState.mySourceVmId, this.mySourceVmId) && mySourceVmId != null && vmState.mySourceVmId != null) {
//       return String.format("Source VM id is outdated. VM: '%s' vs Actual: '%s'", mySourceVmId, vmState.mySourceVmId);
//     }
//     return null;
//   }
// 
//   @Nullable
//   public String getSnapshotName() {
//     return mySnapshotName;
//   }
// 
//   @Nullable
//   public String getSourceVmId() {
//     return mySourceVmId;
//   }
// 
//   @Override
//   public boolean equals(final Object obj) {
//     if (!(obj instanceof VmwareSourceState))
//       return false;
//     final VmwareSourceState state = (VmwareSourceState)obj;
// 
//     if (!Objects.equals(state.mySnapshotName, this.mySnapshotName))
//       return false;
// 
//     if (!Objects.equals(state.mySourceVmId, this.mySourceVmId) && mySourceVmId != null && state.mySourceVmId != null)
//       return false;
// 
//     return true;
//   }
// 
//   @Override
//   public String toString() {
//     return "VmwareSourceState{" +
//            "mySnapshotName='" + mySnapshotName + '\'' +
//            ", mySourceVmId='" + mySourceVmId + '\'' +
//            '}';
//   }
// }


// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/connector/VmwareInstance.java
import com.intellij.openapi.diagnostic.Logger;
import com.vmware.vim25.ManagedObjectReference;
import com.vmware.vim25.OptionValue;
import com.vmware.vim25.VirtualMachinePowerState;
import com.vmware.vim25.mo.VirtualMachine;
import java.util.*;
import jetbrains.buildServer.Used;
import jetbrains.buildServer.clouds.InstanceStatus;
import jetbrains.buildServer.clouds.base.connector.AbstractInstance;
import jetbrains.buildServer.clouds.vmware.VmwareSourceState;
import jetbrains.buildServer.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

  public String getChangeVersion() {
    return myChangeVersion;
  }

  @Nullable
  public VmwareSourceState getVmSourceState(){
    return VmwareSourceState.from(
      StringUtil.nullIfEmpty(getProperty(VMWareApiConnector.TEAMCITY_VMWARE_IMAGE_SNAPSHOT)),
      StringUtil.nullIfEmpty(getProperty(VMWareApiConnector.TEAMCITY_VMWARE_IMAGE_SOURCE_VM_ID))
    );
  }

  @NotNull
  public String getId() {
    return myId;
  }

  @NotNull
  public String getDatacenterId() {
    return myDatacenterId;
  }

  @NotNull
  @Override
  public ManagedObjectReference getMOR() {
    throw new UnsupportedOperationException("VmwareInstance.getMOR");

    //return null;
  }

  @Nullable