Search in sources :

Example 1 with CloudManager

use of jetbrains.buildServer.clouds.server.CloudManager in project teamcity-rest by JetBrains.

the class AbstractAgentPoolResolverTest method setUp.

@Override
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
    super.setUp();
    myActionChecker = new AgentPoolAccessCheckerForTests();
    SecuredProjectManager projectManager = new SecuredProjectManager(myFixture.getSecurityContext());
    projectManager.setDelegate(myProjectManager);
    Mock cloudManagerMock = mock(CloudManager.class);
    myResolver = new AbstractAgentPoolResolver(projectManager, myActionChecker, // not actually used in tests
    (CloudManager) cloudManagerMock.proxy(), myFixture.getAgentTypeFinder(), myServer.getSecurityContext());
}
Also used : SecuredProjectManager(jetbrains.buildServer.serverSide.impl.auth.SecuredProjectManager) CloudManager(jetbrains.buildServer.clouds.server.CloudManager) AbstractAgentPoolResolver(jetbrains.buildServer.server.graphql.resolver.agentPool.AbstractAgentPoolResolver) Mock(org.jmock.Mock) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with CloudManager

use of jetbrains.buildServer.clouds.server.CloudManager 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)2 AbstractAgentPoolResolver (jetbrains.buildServer.server.graphql.resolver.agentPool.AbstractAgentPoolResolver)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 SecuredProjectManager (jetbrains.buildServer.serverSide.impl.auth.SecuredProjectManager)1 Nullable (org.jetbrains.annotations.Nullable)1 Mock (org.jmock.Mock)1 BeforeMethod (org.testng.annotations.BeforeMethod)1