本文整理汇总了Java中jetbrains.buildServer.clouds.CloudImageParameters类的典型用法代码示例。如果您正苦于以下问题:Java CloudImageParameters类的具体用法?Java CloudImageParameters怎么用?Java CloudImageParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CloudImageParameters类属于jetbrains.buildServer.clouds包,在下文中一共展示了CloudImageParameters类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseImageData
import jetbrains.buildServer.clouds.CloudImageParameters; //导入依赖的package包/类
public static <T extends CloudImageDetails> Collection<T> parseImageData(Class<T> clazz, final CloudClientParameters params) {
Gson gson = new Gson();
final String imageData = StringUtil.emptyIfNull(params.getParameter(CloudImageParameters.SOURCE_IMAGES_JSON));
if (StringUtil.isEmpty(imageData)) {
return Collections.emptyList();
}
final ListParametrizedType listType = new ListParametrizedType(clazz);
final List<T> images = gson.fromJson(imageData, listType);
if (CloudImagePasswordDetails.class.isAssignableFrom(clazz)) {
final String passwordData = params.getParameter("secure:passwords_data");
final Map<String, String> data = gson.fromJson(passwordData, stringStringMapType);
if (data != null) {
for (T image : images) {
final CloudImagePasswordDetails userImage = (CloudImagePasswordDetails) image;
if (data.get(image.getSourceId()) != null) {
userImage.setPassword(data.get(image.getSourceId()));
}
}
}
}
return new ArrayList<>(images);
}
示例2: VmwareCloudImageDetails
import jetbrains.buildServer.clouds.CloudImageParameters; //导入依赖的package包/类
public VmwareCloudImageDetails(@NotNull final CloudImageParameters imageParameters){
myCustomizationSpec = imageParameters.getParameter(VmwareConstants.CUSTOMIZATION_SPEC);
myMaxInstances = StringUtil.parseInt(StringUtil.emptyIfNull(imageParameters.getParameter(VmwareConstants.MAX_INSTANCES)), 0);
mySourceVmName = imageParameters.getParameter(VmwareConstants.SOURCE_VM_NAME);
myFolderId = imageParameters.getParameter(VmwareConstants.FOLDER);
myResourcePoolId = imageParameters.getParameter(VmwareConstants.RESOURCE_POOL);
myCloneBehaviour = CloneBehaviour.valueOf(imageParameters.getParameter(VmwareConstants.BEHAVIOUR));
mySnapshotName = StringUtil.emptyIfNull(imageParameters.getParameter(VmwareConstants.SNAPSHOT));
myNickname = StringUtil.nullIfEmpty(imageParameters.getParameter(VmwareConstants.NICKNAME));
myAgentPoolId = imageParameters.getAgentPoolId();
if (myCloneBehaviour.isUseOriginal()){
mySourceId = mySourceVmName;
} else {
mySourceId = myNickname == null ? mySourceVmName : myNickname;
}
}
示例3: setUp
import jetbrains.buildServer.clouds.CloudImageParameters; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
super.setUp();
myStatusTask = new CloudAsyncTaskExecutor("Test-vmware");
myApiConnector = new FakeApiConnector(TEST_SERVER_UUID, PROFILE_ID);
myIdxStorage = createTempDir();
final Map<String, String> imgParams = new HashMap<>();
imgParams.put("nickname", "imageNickname");
imgParams.put("sourceVmName", "mySource");
imgParams.put("snapshot", "mySourceSnapshot");
imgParams.put("folder", "myFolder");
imgParams.put("pool", "myPool");
imgParams.put("behaviour", CloneBehaviour.FRESH_CLONE.toString());
imgParams.put("maxInstances", "5");
CloudImageParameters imageParameters = new CloudImageParametersImpl(imgParams, VmwareCloudIntegrationTest.PROJECT_ID);
myImageDetails = new VmwareCloudImageDetails(imageParameters);
final CloudClientParameters clientParameters = new CloudClientParametersImpl(createMap(), createSet(imageParameters));
final FakeDatacenter dc2 = FakeModel.instance().addDatacenter("dc2");
FakeModel.instance().addFolder("myFolder").setParent(dc2);
FakeModel.instance().addVM("mySource").setParentFolder("myFolder");
FakeModel.instance().addVMSnapshot("mySource", "mySourceSnapshot");
FakeModel.instance().addResourcePool("myPool");
myImage = new VmwareCloudImage(myApiConnector,
myImageDetails,
myStatusTask,
myIdxStorage,
VmwareTestUtils.createProfileFromProps(clientParameters));
}
示例4: setUp
import jetbrains.buildServer.clouds.CloudImageParameters; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
super.setUp();
FakeModel.instance().clear();
myTaskExecutor = new CloudAsyncTaskExecutor("Test-vmware");
myApiConnector = new FakeApiConnector(VmwareCloudIntegrationTest.TEST_SERVER_UUID, VmwareCloudIntegrationTest.PROFILE_ID);
myIdxStorage = createTempDir();
Map<String, String> params = new HashMap<>();
params.put("nickname", "imageNickname");
params.put("sourceVmName", "srcVM");
params.put("snapshot", "srcVMSnap");
params.put("folder", "folderId");
params.put("pool", "rpId");
params.put("behaviour", CloneBehaviour.FRESH_CLONE.toString());
params.put("maxInstances", "5");
CloudImageParameters imageParameters = new CloudImageParametersImpl(params, VmwareCloudIntegrationTest.PROJECT_ID);
myImageDetails = new VmwareCloudImageDetails(imageParameters);
FakeModel.instance().addDatacenter("dc2");
FakeModel.instance().addFolder("folderId").setParent("dc2", Datacenter.class);
FakeModel.instance().addVM("srcVM").setParentFolder("folderId");
FakeModel.instance().addResourcePool("rpId").setParentFolder("folderId");
FakeModel.instance().addVMSnapshot("srcVM", "srcVMSnap");
myProfile = VmwareTestUtils.createProfileFromProps(new CloudClientParametersImpl(Collections.emptyMap(), Collections.emptyList()));
myImage = new VmwareCloudImage(myApiConnector, myImageDetails, myTaskExecutor, myIdxStorage, myProfile);
myCloudClient = new VMWareCloudClient(myProfile, myApiConnector, new VmwareUpdateTaskManager(), createTempDir());
myCloudClient.populateImagesData(Collections.singletonList(myImageDetails));
myUpdateTask = new UpdateInstancesTask<VmwareCloudInstance, VmwareCloudImage, VMWareCloudClient>(myApiConnector, myCloudClient, 10*1000, false);
}
示例5: getAgentPoolIdField
import jetbrains.buildServer.clouds.CloudImageParameters; //导入依赖的package包/类
public String getAgentPoolIdField() {
return CloudImageParameters.AGENT_POOL_ID_FIELD;
}
示例6: KubeCloudImageData
import jetbrains.buildServer.clouds.CloudImageParameters; //导入依赖的package包/类
public KubeCloudImageData(@NotNull final CloudImageParameters rawImageData) {
myRawImageData = rawImageData;
}
示例7: process
import jetbrains.buildServer.clouds.CloudImageParameters; //导入依赖的package包/类
@NotNull
public Collection<InvalidProperty> process(final Map<String, String> properties) {
List<InvalidProperty> list = new ArrayList<InvalidProperty>();
notEmpty(properties, VMWareWebConstants.SECURE_PASSWORD, list);
notEmpty(properties, VMWareWebConstants.USERNAME, list);
notEmpty(properties, VMWareWebConstants.SERVER_URL, list);
final String instancesLimit = properties.get(VMWareWebConstants.PROFILE_INSTANCE_LIMIT);
if (!StringUtil.isEmpty(instancesLimit)){
if (!StringUtil.isAPositiveNumber(instancesLimit)){
list.add(new InvalidProperty(VMWareWebConstants.PROFILE_INSTANCE_LIMIT, "Must be a positive integer or empty"));
}
}
if (list.size() > 0)
return list;
final String serverURL = properties.get(VMWareWebConstants.SERVER_URL);
final String currentProfileId = properties.get(CloudConstants.PROFILE_ID);
final Map<String, String> existingImages = new HashMap<>();
myCloudManager.listAllProfiles().stream()
.filter(p->(VmwareConstants.TYPE.equals(p.getCloudCode())
&& (currentProfileId == null || !currentProfileId.equals(p.getProfileId()))
&& (serverURL.equals(p.getProfileProperties().get(VMWareWebConstants.SERVER_URL))))
)
.forEach(p->
myCloudManager
.getClient(p.getProjectId(), p.getProfileId())
.getImages()
.stream()
.forEach(i->existingImages.put(i.getId().toUpperCase(), p.getProfileName()))
);
final String imagesData = properties.get(CloudImageParameters.SOURCE_IMAGES_JSON);
if (StringUtil.isEmpty(imagesData))
return list; // allowing empty profiles
JsonParser parser = new JsonParser();
final JsonElement element = parser.parse(imagesData);
if (element.isJsonArray()){
StreamSupport.stream(element.getAsJsonArray().spliterator(), false)
.map(JsonElement::getAsJsonObject)
.map(obj->obj.getAsJsonPrimitive(CloudImageParameters.SOURCE_ID_FIELD))
.filter(Objects::nonNull)
.map(json->json.getAsString().toUpperCase())
.filter(existingImages::containsKey)
.map(id->new InvalidProperty(CloudImageParameters.SOURCE_IMAGES_JSON,
String.format("The cloud profile '%s' already contains an image named '%s'. Select a different VM or change the custom name.", existingImages.get(id), id)
)).forEachOrdered(list::add);
} else {
list.add(new InvalidProperty(CloudImageParameters.SOURCE_IMAGES_JSON, "Unable to parse images data - bad format"));
}
return list;
}