/* * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.clouds.vmware.settings; import java.io.File; import jetbrains.buildServer.util.FileUtil; import org.jetbrains.annotations.NotNull; /** * @author Eugene Petrenko * Created: 07.12.2009 19:21:19 */ public class VMImageInfo { private final String myId; private final String myImagePath; private final String myImageAgentConfigLocation; private final String myUserName; private final String myPassword; public VMImageInfo(@NotNull final String id, @NotNull final String imageAgentConfigLocation, @NotNull final String imagePath, @NotNull final String userName, @NotNull final String password) { myId = id; myImageAgentConfigLocation = imageAgentConfigLocation; myImagePath = imagePath; myPassword = password; myUserName = userName; } @NotNull public String getPassword() { return myPassword; } @NotNull public String getUserName() { return myUserName; } @NotNull public String getId() { return myId; } @NotNull public String getImageAgentConfigLocation() { return myImageAgentConfigLocation; } @NotNull public String getImagePath() { return myImagePath; } /** * @return true if this image is available locally */ public boolean isLocal() { return true; } @NotNull public VMImageInfo resolvePath(@NotNull final File baseDir) { final String newPath = FileUtil.resolvePath(baseDir, myImagePath).getAbsolutePath(); return new VMImageInfo(getId(), getImageAgentConfigLocation(), newPath, getUserName(), getPassword()); } @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("VMImageInfo"); sb.append("{myId='").append(myId).append('\''); sb.append(", myImagePath='").append(myImagePath).append('\''); sb.append('}'); return sb.toString(); } }