Name the created templates with the correct prefix, instead of inventing a random name

This commit is contained in:
Richard Downer 2011-12-05 10:05:19 +02:00
parent 1d60c0d819
commit 72d70162ab
1 changed files with 2 additions and 5 deletions

View File

@ -30,7 +30,6 @@ import org.testng.annotations.Test;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.net.URI; import java.net.URI;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Random;
import java.util.Set; import java.util.Set;
import static org.jclouds.cloudstack.options.ListTemplatesOptions.Builder.zoneId; import static org.jclouds.cloudstack.options.ListTemplatesOptions.Builder.zoneId;
@ -108,9 +107,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
Volume volume = Iterables.getOnlyElement(volumes); Volume volume = Iterables.getOnlyElement(volumes);
// Create a template // Create a template
String tmplName = "jclouds-" + Integer.toHexString(new Random().nextInt());
CreateTemplateOptions options = CreateTemplateOptions.Builder.volumeId(volume.getId()); CreateTemplateOptions options = CreateTemplateOptions.Builder.volumeId(volume.getId());
AsyncCreateResponse response = client.getTemplateClient().createTemplate(TemplateMetadata.builder().name(tmplName).osTypeId(vmForCreation.getGuestOSId()).displayText("jclouds live testCreateTemplate").build(), options); AsyncCreateResponse response = client.getTemplateClient().createTemplate(TemplateMetadata.builder().name(prefix+"-createTemplate").osTypeId(vmForCreation.getGuestOSId()).displayText("jclouds live testCreateTemplate").build(), options);
assert jobComplete.apply(response.getJobId()) : vmForCreation; assert jobComplete.apply(response.getJobId()) : vmForCreation;
createdTemplate = client.getTemplateClient().getTemplateInZone(response.getId(), vmForCreation.getZoneId()); createdTemplate = client.getTemplateClient().getTemplateInZone(response.getId(), vmForCreation.getZoneId());
@ -154,9 +152,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
OSType osType = Iterables.getFirst(osTypes, null); OSType osType = Iterables.getFirst(osTypes, null);
// Register a template // Register a template
String tmplName = "jclouds-" + Integer.toHexString(new Random().nextInt());
RegisterTemplateOptions options = RegisterTemplateOptions.Builder.bits(32).isExtractable(true); RegisterTemplateOptions options = RegisterTemplateOptions.Builder.bits(32).isExtractable(true);
TemplateMetadata templateMetadata = TemplateMetadata.builder().name(tmplName).osTypeId(osType.getId()).displayText("jclouds live testRegisterTemplate").build(); TemplateMetadata templateMetadata = TemplateMetadata.builder().name(prefix+"-registerTemplate").osTypeId(osType.getId()).displayText("jclouds live testRegisterTemplate").build();
Set<Template> templates = client.getTemplateClient().registerTemplate(templateMetadata, "VHD", "XenServer", IMPORT_VHD_URL, zone.getId(), options); Set<Template> templates = client.getTemplateClient().registerTemplate(templateMetadata, "VHD", "XenServer", IMPORT_VHD_URL, zone.getId(), options);
registeredTemplate = Iterables.getOnlyElement(templates, null); registeredTemplate = Iterables.getOnlyElement(templates, null);
assertNotNull(registeredTemplate); assertNotNull(registeredTemplate);