Search in sources :

Example 1 with CloudUtil

use of jetbrains.buildServer.server.rest.data.CloudUtil in project teamcity-rest by JetBrains.

the class CloudInstance method startInstance.

@Nullable
public jetbrains.buildServer.clouds.CloudInstance startInstance(@NotNull final SUser user, @NotNull final ServiceLocator serviceLocator) {
    if (submittedImage == null) {
        throw new BadRequestException("Cloud Instance should contain image");
    }
    CloudUtil util = serviceLocator.getSingletonService(CloudUtil.class);
    jetbrains.buildServer.clouds.CloudImage image = submittedImage.getFromPosted(serviceLocator);
    String profileId = util.getProfileId(image);
    if (profileId == null) {
        throw new InvalidStateException("Cannot find profile for the cloud image");
    }
    CloudManager cloudManager = serviceLocator.getSingletonService(CloudManager.class);
    cloudManager.startInstance(profileId, image.getId(), StartInstanceReason.userAction(user));
    return null;
}
Also used : CloudManager(jetbrains.buildServer.clouds.server.CloudManager) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) CloudUtil(jetbrains.buildServer.server.rest.data.CloudUtil) InvalidStateException(jetbrains.buildServer.server.rest.errors.InvalidStateException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CloudManager (jetbrains.buildServer.clouds.server.CloudManager)1 CloudUtil (jetbrains.buildServer.server.rest.data.CloudUtil)1 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)1 InvalidStateException (jetbrains.buildServer.server.rest.errors.InvalidStateException)1 Nullable (org.jetbrains.annotations.Nullable)1