Class SecuredCloudManager
- java.lang.Object
-
- jetbrains.buildServer.clouds.server.impl.SecuredCloudManager
-
- All Implemented Interfaces:
CloudInstanceManager,CloudManager
public class SecuredCloudManager extends Object implements CloudManager
- Author:
- Eugene Petrenko Created: 11.11.2009 22:13:23
-
-
Constructor Summary
Constructors Constructor Description SecuredCloudManager(CloudSecurity cloudSecurity, CloudManager insecureCloudManager, CloudInstancesProvider cloudInstancesProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CanStartNewInstanceResultcanStartNewInstance(CloudProfile profile, CloudImage image)Indicates whether it's possible to start a new instance of a certain image in particular cloud profileCloudProfilecheckProfileReadAccess(String profileId)CloudImageParameterscreateImage(String projectId, CloudImageData imageData)CloudProfilecreateProfile(String projectId, CloudProfileData profileData)voiddeleteImage(String projectId, String profileId, String imageId)Deletes a cloud image with the specified imageId from a cloud profilevoiddeleteImageAndInstances(String projectId, String profileId, String imageId, TerminateInstanceReason reason)Deletes a cloud image with the specified imageId from a cloud profile.voiddisposeClient(String projectId, String profileId)Disposes of the client associated to the cloud profile with the given project and profile IDs.voiddisposeClientAndRemoveInstances(String projectId, String profileId, TerminateInstanceReason reason)Disposes of the client associated to the cloud profile with the given project and profile IDs.Collection<SBuildAgent>findAgentByInstance(String profileId, String instanceId)CloudTypefindCloudType(String cloudName)Returns cloud type for name or nullCloudImageParametersfindImageByInternalId(String projectId, String imageInternalId)Pair<CloudProfile,CloudInstance>findInstanceByAgent(AgentDescription agent)Checks if the agent is an instnce of one of the running instances.CloudInstancefindInstanceById(String projectId, String profileId, String instanceId)Returns instance by the specified identifier.Map<AgentDescription,Pair<CloudProfile,CloudInstance>>findInstancesByAgents(Collection<? extends AgentDescription> agents)Finds cloud instances (if any) for the collection of agentsCloudProfilefindProfileById(String projectId, String profileId)Returns profile by the specified identifier in a certain project.CloudProfilefindProfileByImageId(String imageId)CloudProfilefindProfileGloballyById(String profileId)Returns profile by the specified identifier.StringgenerateAgentName(AgentDescription agent)Generated name for build agent that is thought to be running as instance of this cloud client.CloudClientExgetClient(String projectId, String profileId)Provides a client for the specified profile.CloudClientExgetClientIfExists(String projectId, String profileId)Provides a client for the specified profile.Collection<? extends CloudType>getCloudTypes()Returns all available "Real" cloud types, excluding ReadOnlyClient (which is not a "real" cloud type, but rather used to show instances on the secondary nodes).SAgentTypegetDescriptionFor(CloudProfile profile, String imageId)Fetches recorded agent descriptionProjectCloudIntegrationStatusgetProjectIntegrationStatus(String projectId)StringgetServerUrlForAgent(CloudProfile profile, CloudImage image)Server url that will be sent to new created build agentbooleanisConfigurable(String projectId)Returns true if user can enable/disable configuration in the current project's treebooleanisImageWithAgent(CloudProfile profile, CloudImage image)Checks if the image is configured to start agent.booleanisInstanceExpired(String profileId, String instanceId)Returns true, if instance will be terminated after current build finishesbooleanisIntegrationEnabled(String projectId)voiditerateInstances(CloudInstancesProviderCallback callback)Iterates through all running instances of all profiles.voiditerateInstances(CloudInstancesProviderExtendedCallback callback)Iterates through all running instances of all profiles.voiditerateProfileInstances(CloudProfile profile, CloudInstancesProviderExtendedCallback callback)Iterates through all running instances of all profiles.Collection<CloudProfile>listAllProfiles()Returns all cloud profiles available to current user.Collection<CloudImageParameters>listImagesByProject(String projectId)Collection<CloudProfile>listProfilesByProject(String projectId, boolean includeFromSubprojects)Returns cloud profiles defined in the current project.voidmarkInstanceExpired(String profileId, String instanceId)Marks the instance as expired, so it should be terminated after current build finishesbooleanremoveProfile(String projectId, String profileId)voidremoveProfileAndInstances(String projectId, String profileId, TerminateInstanceReason reason)Terminate all running instance for the profile and then removes the profile itselfvoidsetProfileEnabled(String projectId, String profileId, boolean enabled)CloudInstancestartInstance(String projectId, String profileId, String imageId, StartInstanceReason reason)Starts new agent instance for given profile and imageCloudInstancestartInstance(String profileId, String imageId, StartInstanceReason reason)voidterminateInstance(String projectId, String profileId, String imageId, String instanceId, TerminateInstanceReason reason)Schedules termination a running instancevoidterminateInstance(String profileId, String imageId, String instanceId, TerminateInstanceReason reason)voidterminateProfileInstances(String projectId, String profileId, TerminateInstanceReason reason)Terminate all running instance for the profilevoidterminateProfileInstances(String profileId, TerminateInstanceReason reason)voidterminateProjectInstances(String projectId, TerminateInstanceReason reason, boolean subProjectsOnly)Terminate all running instanceCloudProfileupdateProfile(String projectId, String profileId, CloudProfileData profileData)voidupdateStatus(String projectId, ProjectCloudIntegrationStatus newStatus)Updates enabled/disabled status of integration-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.clouds.server.CloudManager
findAgentByInstance, isInstanceExpired, markInstanceExpired
-
-
-
-
Constructor Detail
-
SecuredCloudManager
public SecuredCloudManager(@NotNull CloudSecurity cloudSecurity, @NotNull CloudManager insecureCloudManager, @NotNull CloudInstancesProvider cloudInstancesProvider)
-
-
Method Detail
-
findAgentByInstance
@NotNull public Collection<SBuildAgent> findAgentByInstance(@NotNull String profileId, @NotNull String instanceId)
- Specified by:
findAgentByInstancein interfaceCloudManager- Returns:
- agent, if any, that associated with the instance, profile pair
-
findCloudType
@Nullable public CloudType findCloudType(@Nullable String cloudName)
Description copied from interface:CloudManagerReturns cloud type for name or null- Specified by:
findCloudTypein interfaceCloudManager- Parameters:
cloudName- cloud type ID- Returns:
- registered cloud type or null
-
findInstanceByAgent
@Nullable public Pair<CloudProfile,CloudInstance> findInstanceByAgent(@NotNull AgentDescription agent)
Description copied from interface:CloudManagerChecks if the agent is an instnce of one of the running instances.- Specified by:
findInstanceByAgentin interfaceCloudManager- Parameters:
agent- agent description of an agent that is going to connect- Returns:
- corresponding
CloudInstanceif found or null
-
findInstancesByAgents
@NotNull public Map<AgentDescription,Pair<CloudProfile,CloudInstance>> findInstancesByAgents(@NotNull Collection<? extends AgentDescription> agents)
Description copied from interface:CloudManagerFinds cloud instances (if any) for the collection of agents- Specified by:
findInstancesByAgentsin interfaceCloudManager- Parameters:
agents- agent descriptions of agents- Returns:
- found pairs of agents and cloud instances. For agents that we don't find cloud instance for there's no entry in this collection
-
findProfileById
@Nullable public CloudProfile findProfileById(@NotNull String projectId, @NotNull String profileId)
Description copied from interface:CloudManagerReturns profile by the specified identifier in a certain project.- Specified by:
findProfileByIdin interfaceCloudManager- Parameters:
projectId- internal project idprofileId- , seeCloudProfile.getProfileId().- Returns:
- found profile or null if no such ones.
-
findProfileGloballyById
@Nullable public CloudProfile findProfileGloballyById(@NotNull String profileId)
Returns profile by the specified identifier.- Specified by:
findProfileGloballyByIdin interfaceCloudManager- Parameters:
profileId-- Returns:
- found profile or null if no such ones.
-
checkProfileReadAccess
@Nullable public CloudProfile checkProfileReadAccess(@NotNull String profileId)
-
findInstanceById
@Nullable public CloudInstance findInstanceById(@NotNull String projectId, @NotNull String profileId, @NotNull String instanceId)
Returns instance by the specified identifier.- Specified by:
findInstanceByIdin interfaceCloudManager- Parameters:
projectId-profileId-instanceId-- Returns:
- found instance or null if no such ones.
-
getClient
@NotNull public CloudClientEx getClient(String projectId, @NotNull String profileId) throws CloudException, IllegalArgumentException
Description copied from interface:CloudManagerProvides a client for the specified profile. Creates a new client or gets a cached one if exists.- Specified by:
getClientin interfaceCloudManagerprofileId- id of profile, seeCloudProfile.getProfileId().- Returns:
- correct ready for use cloud client.
- Throws:
CloudException- eIllegalArgumentException- e
-
getClientIfExists
@Nullable public CloudClientEx getClientIfExists(String projectId, @NotNull String profileId) throws CloudException, IllegalArgumentException
Description copied from interface:CloudManagerProvides a client for the specified profile. Creates gets a cached one if exists, returns null otherwise- Specified by:
getClientIfExistsin interfaceCloudManagerprofileId- id of profile, seeCloudProfile.getProfileId().- Returns:
- correct ready for use cloud client.
- Throws:
CloudException- eIllegalArgumentException- e
-
getCloudTypes
@NotNull public Collection<? extends CloudType> getCloudTypes()
Description copied from interface:CloudManagerReturns all available "Real" cloud types, excluding ReadOnlyClient (which is not a "real" cloud type, but rather used to show instances on the secondary nodes).- Specified by:
getCloudTypesin interfaceCloudManager- Returns:
- list of types. No order specified
-
getDescriptionFor
@Nullable public SAgentType getDescriptionFor(@NotNull CloudProfile profile, @NotNull String imageId)
Description copied from interface:CloudManagerFetches recorded agent description- Specified by:
getDescriptionForin interfaceCloudManager- Parameters:
profile- profileimageId- image id- Returns:
- description if found
-
isImageWithAgent
public boolean isImageWithAgent(@NotNull CloudProfile profile, @NotNull CloudImage image)Description copied from interface:CloudManagerChecks if the image is configured to start agent. If unknown - true is returned- Specified by:
isImageWithAgentin interfaceCloudManager- Parameters:
profile- profileimage- image- Returns:
- true is this image may contain agent, false if it is definitly broken
-
getServerUrlForAgent
@NotNull public String getServerUrlForAgent(@NotNull CloudProfile profile, @NotNull CloudImage image)
Description copied from interface:CloudManagerServer url that will be sent to new created build agent- Specified by:
getServerUrlForAgentin interfaceCloudManager- Parameters:
profile- profileimage- image- Returns:
- server url
-
isIntegrationEnabled
public boolean isIntegrationEnabled(String projectId)
- Specified by:
isIntegrationEnabledin interfaceCloudManager- Returns:
- false if user decided to disabled cloud integration at all
-
isConfigurable
public boolean isConfigurable(@NotNull String projectId)Returns true if user can enable/disable configuration in the current project's tree- Specified by:
isConfigurablein interfaceCloudManager- Parameters:
projectId- project internal id- Returns:
- see above
-
listProfilesByProject
@NotNull public Collection<CloudProfile> listProfilesByProject(String projectId, boolean includeFromSubprojects)
Description copied from interface:CloudManagerReturns cloud profiles defined in the current project.- Specified by:
listProfilesByProjectin interfaceCloudManager- Returns:
- list of profiles; order of items is not specified (or depend on this interface implementation); empty list when no ones.
-
listAllProfiles
@NotNull public Collection<CloudProfile> listAllProfiles()
Returns all cloud profiles available to current user. Cloud profile is available if user has VIEW_AGENT_CLOUDS permission in the project where this profile belongs.- Specified by:
listAllProfilesin interfaceCloudManager- Returns:
- list of profiles; order of items is not specified (or depend on this interface implementation); empty list when no ones.
-
updateStatus
public void updateStatus(String projectId, @NotNull ProjectCloudIntegrationStatus newStatus)
Description copied from interface:CloudManagerUpdates enabled/disabled status of integration- Specified by:
updateStatusin interfaceCloudManager
-
getProjectIntegrationStatus
@Nullable public ProjectCloudIntegrationStatus getProjectIntegrationStatus(String projectId)
- Specified by:
getProjectIntegrationStatusin interfaceCloudManager- Parameters:
projectId- - project internal id- Returns:
- returns cloud integration status information in this project; null, if project doesn't have any information (inherits from parent project)
-
iterateInstances
public void iterateInstances(@NotNull CloudInstancesProviderCallback callback)Description copied from interface:CloudInstanceManagerIterates through all running instances of all profiles.- Specified by:
iterateInstancesin interfaceCloudInstanceManager- Parameters:
callback- uses this interface to notify next instance
-
iterateInstances
public void iterateInstances(@NotNull CloudInstancesProviderExtendedCallback callback)Description copied from interface:CloudInstanceManagerIterates through all running instances of all profiles.- Specified by:
iterateInstancesin interfaceCloudInstanceManager- Parameters:
callback- uses this interface to notify next instance
-
iterateProfileInstances
public void iterateProfileInstances(@NotNull CloudProfile profile, @NotNull CloudInstancesProviderExtendedCallback callback)Description copied from interface:CloudInstanceManagerIterates through all running instances of all profiles.- Specified by:
iterateProfileInstancesin interfaceCloudInstanceManagercallback- uses this interface to notify next instance
-
canStartNewInstance
@NotNull public CanStartNewInstanceResult canStartNewInstance(@NotNull CloudProfile profile, @NotNull CloudImage image)
Description copied from interface:CloudInstanceManagerIndicates whether it's possible to start a new instance of a certain image in particular cloud profile- Specified by:
canStartNewInstancein interfaceCloudInstanceManager- Returns:
- see above
-
startInstance
@NotNull public CloudInstance startInstance(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId, @NotNull StartInstanceReason reason) throws StartAgentQuotaExceededException, FailedToStartInstanceException
Description copied from interface:CloudInstanceManagerStarts new agent instance for given profile and image- Specified by:
startInstancein interfaceCloudInstanceManager- Parameters:
projectId- projectIdprofileId- profileIdimageId- imageIdreason- reason why instance is stared. Used for logging- Throws:
StartAgentQuotaExceededException- if there is not enough quotaFailedToStartInstanceException- if image or profile was not found
-
startInstance
@NotNull public CloudInstance startInstance(@NotNull String profileId, @NotNull String imageId, @NotNull StartInstanceReason reason) throws StartAgentQuotaExceededException, FailedToStartInstanceException
- Specified by:
startInstancein interfaceCloudInstanceManager- Throws:
StartAgentQuotaExceededExceptionFailedToStartInstanceException
-
terminateProjectInstances
public void terminateProjectInstances(String projectId, @NotNull TerminateInstanceReason reason, boolean subProjectsOnly)
Description copied from interface:CloudInstanceManagerTerminate all running instance- Specified by:
terminateProjectInstancesin interfaceCloudInstanceManagerreason- reason of termination
-
terminateInstance
public void terminateInstance(@NotNull String profileId, @NotNull String imageId, @NotNull String instanceId, @NotNull TerminateInstanceReason reason) throws FailedToStopInstanceException- Specified by:
terminateInstancein interfaceCloudInstanceManager- Throws:
FailedToStopInstanceException
-
terminateInstance
public void terminateInstance(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId, @NotNull String instanceId, @NotNull TerminateInstanceReason reason)Description copied from interface:CloudInstanceManagerSchedules termination a running instance- Specified by:
terminateInstancein interfaceCloudInstanceManager- Parameters:
projectId- projectIdprofileId- profileIdimageId- imageIdinstanceId- instanceIdreason- reason why instance is terminated. Used for logging
-
terminateProfileInstances
public void terminateProfileInstances(@NotNull String profileId, @NotNull TerminateInstanceReason reason)- Specified by:
terminateProfileInstancesin interfaceCloudInstanceManager
-
terminateProfileInstances
public void terminateProfileInstances(@NotNull String projectId, @NotNull String profileId, @NotNull TerminateInstanceReason reason)Description copied from interface:CloudInstanceManagerTerminate all running instance for the profile- Specified by:
terminateProfileInstancesin interfaceCloudInstanceManager- Parameters:
projectId- projectIdprofileId- profileIdreason- reason of temination
-
generateAgentName
public String generateAgentName(@NotNull AgentDescription agent)
Description copied from interface:CloudManagerGenerated name for build agent that is thought to be running as instance of this cloud client.- Specified by:
generateAgentNamein interfaceCloudManager- Parameters:
agent- agent instance- Returns:
- proposed build agent name or null
-
isInstanceExpired
public boolean isInstanceExpired(@NotNull String profileId, @NotNull String instanceId)Description copied from interface:CloudManagerReturns true, if instance will be terminated after current build finishes- Specified by:
isInstanceExpiredin interfaceCloudManager- Returns:
- true, if no other buids will be run on this instance. False otherwise
-
markInstanceExpired
public void markInstanceExpired(@NotNull String profileId, @NotNull String instanceId)Description copied from interface:CloudManagerMarks the instance as expired, so it should be terminated after current build finishes- Specified by:
markInstanceExpiredin interfaceCloudManager
-
createProfile
@NotNull public CloudProfile createProfile(@NotNull String projectId, @NotNull CloudProfileData profileData)
- Specified by:
createProfilein interfaceCloudManager
-
updateProfile
@NotNull public CloudProfile updateProfile(@NotNull String projectId, @NotNull String profileId, @NotNull CloudProfileData profileData)
- Specified by:
updateProfilein interfaceCloudManager
-
removeProfile
public boolean removeProfile(@NotNull String projectId, @NotNull String profileId)- Specified by:
removeProfilein interfaceCloudManager
-
setProfileEnabled
public void setProfileEnabled(@NotNull String projectId, @NotNull String profileId, boolean enabled)- Specified by:
setProfileEnabledin interfaceCloudManager
-
listImagesByProject
@NotNull public Collection<CloudImageParameters> listImagesByProject(@NotNull String projectId)
- Specified by:
listImagesByProjectin interfaceCloudManager
-
createImage
@NotNull public CloudImageParameters createImage(@NotNull String projectId, @NotNull CloudImageData imageData)
- Specified by:
createImagein interfaceCloudManager
-
deleteImageAndInstances
public void deleteImageAndInstances(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId, @NotNull TerminateInstanceReason reason)Description copied from interface:CloudManagerDeletes a cloud image with the specified imageId from a cloud profile. Will also remove any instances running of this image- Specified by:
deleteImageAndInstancesin interfaceCloudManager- Parameters:
projectId- The ID of the project that the image belongs to. Cannot be null.profileId- The ID of the profile that the image belongs to. Cannot be null.imageId- The ID of the image to be deleted. Cannot be null.reason- reason of termination
-
deleteImage
public void deleteImage(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId)Description copied from interface:CloudManagerDeletes a cloud image with the specified imageId from a cloud profile- Specified by:
deleteImagein interfaceCloudManager- Parameters:
projectId- The ID of the project that the image belongs to. Cannot be null.profileId- The ID of the profile that the image belongs to. Cannot be null.imageId- The ID of the image to be deleted. Cannot be null.
-
disposeClientAndRemoveInstances
public void disposeClientAndRemoveInstances(@NotNull String projectId, @NotNull String profileId, @NotNull TerminateInstanceReason reason)Description copied from interface:CloudManagerDisposes of the client associated to the cloud profile with the given project and profile IDs. Will terminate all running instances- Specified by:
disposeClientAndRemoveInstancesin interfaceCloudManager- Parameters:
projectId- the unique identifier of the projectprofileId- the unique identifier of the profilereason- reason of termination
-
disposeClient
public void disposeClient(@NotNull String projectId, @NotNull String profileId)Description copied from interface:CloudManagerDisposes of the client associated to the cloud profile with the given project and profile IDs.- Specified by:
disposeClientin interfaceCloudManager- Parameters:
projectId- the unique identifier of the projectprofileId- the unique identifier of the profile
-
findImageByInternalId
@Nullable public CloudImageParameters findImageByInternalId(@NotNull String projectId, @NotNull String imageInternalId)
- Specified by:
findImageByInternalIdin interfaceCloudManager
-
findProfileByImageId
@Nullable public CloudProfile findProfileByImageId(@NotNull String imageId)
- Specified by:
findProfileByImageIdin interfaceCloudManager
-
removeProfileAndInstances
public void removeProfileAndInstances(@NotNull String projectId, @NotNull String profileId, TerminateInstanceReason reason)Description copied from interface:CloudManagerTerminate all running instance for the profile and then removes the profile itself- Specified by:
removeProfileAndInstancesin interfaceCloudManager- Parameters:
projectId- projectIdprofileId- profileIdreason- reason of temination
-
-