@Override public OperatingSystem apply(String from) { checkNotNull(from, "vapp template name"); Builder builder = new OperatingSystem.Builder(); builder.description(from); if (from.equals("-Windows 2003 Std. R2 SQL 2005 Std. (x64)")) System.out.print(';'); builder.is64Bit(from.indexOf("64") != -1); from = from.replace("Red Hat Enterprise Linux", "RHEL").replace("Sun Solaris", "SOLARIS").replace( " Server", "").replace("Std. ", ""); Matcher matcher = OS_PATTERN.matcher(from); if (matcher.find()) { OsFamily osFamily = parseOsFamilyOrUnrecognized(matcher.group(1)); builder.family(osFamily); String version = (matcher.group(3) != null) ? matcher.group(2) + matcher.group(3) : matcher.group(2); builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, version, osVersionMap)); } else { OsFamily osFamily = parseOsFamilyOrUnrecognized(from); builder.family(osFamily); } return builder.build(); } }
@Override public Image apply(DriveInfo drive) { WellKnownImage input = preinstalledImages.get().get(drive.getUuid()); // set credentials in the store here, as opposed to directly modifying the image. we need to // set credentials on the image outside of this function so that they can be for example // overridden by properties credentialStore.put("image#" + drive.getUuid(), LoginCredentials.builder().user(input.getLoginUser()).build()); return new ImageBuilder() .ids(drive.getUuid()) .userMetadata( ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata()) .put("size", input.getSize() + "").build()) .location(locationSupplier.get()) .name(input.getDescription()) .description(drive.getName()) .status(Status.AVAILABLE) .operatingSystem( new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()) .name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()) .version("").build(); } }
@Override public Image apply(DriveInfo drive) { WellKnownImage input = preinstalledImages.get().get(drive.getUuid()); // set credentials in the store here, as opposed to directly modifying the image. we need to // set credentials on the image outside of this function so that they can be for example // overridden by properties credentialStore.put("image#" + drive.getUuid(), LoginCredentials.builder().user(input.getLoginUser()).build()); return new ImageBuilder() .ids(drive.getUuid()) .userMetadata( ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata()) .put("size", input.getSize() + "").build()) .location(locationSupplier.get()) .name(input.getDescription()) .description(drive.getName()) .status(Status.AVAILABLE) .operatingSystem( new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()) .name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()) .version("").build(); } }
@Override public Image apply(DriveInfo drive) { WellKnownImage input = preinstalledImages.get().get(drive.getUuid()); // set credentials in the store here, as opposed to directly modifying the image. we need to // set credentials on the image outside of this function so that they can be for example // overridden by properties credentialStore.put("image#" + drive.getUuid(), LoginCredentials.builder().user(input.getLoginUser()).build()); return new ImageBuilder() .ids(drive.getUuid()) .userMetadata( ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata()) .put("size", input.getSize() + "").build()) .location(locationSupplier.get()) .name(input.getDescription()) .description(drive.getName()) .status(Status.AVAILABLE) .operatingSystem( new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()) .name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()) .version("").build(); } }
@Override public Image apply(DriveInfo drive) { WellKnownImage input = preinstalledImages.get(drive.getUuid()); // set credentials in the store here, as opposed to directly modifying the image. we need to // set credentials on the image outside of this function so that they can be for example // overridden by properties credentialStore.put("image#" + drive.getUuid(), LoginCredentials.builder().user(input.getLoginUser()).build()); return new ImageBuilder() .ids(drive.getUuid()) .userMetadata( ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata()) .put("size", input.getSize() + "").build()) .location(locationSupplier.get()) .name(input.getDescription()) .description(drive.getName()) .status(Status.AVAILABLE) .operatingSystem( new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()) .name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()) .version("").build(); } }
@Test public void testApplyWhereTagDoesntMatchAndImageHardwareAndLocationFound() throws UnknownHostException { RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet .of(provider), EC2ImageParserTest.convertImages("/amzn_images.xml"), ImmutableMap .<String, Credentials> of()); RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals( parser.apply(server).toString(), new NodeMetadataBuilder() .hostname("ip-10-243-42-70") .status(Status.RUNNING).backendStatus("running") .privateAddresses(ImmutableSet.of("10.243.42.70")) .publicAddresses(ImmutableSet.of("174.129.81.68")) .imageId("us-east-1/ami-82e4b5c7") .hardware(m1_small().build()) .operatingSystem( new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual") .description("137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()) .id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build().toString()); }
public void testParseCCImage() { Set<org.jclouds.compute.domain.Image> result = convertImages("/describe_images_cc.xml"); assertEquals( Iterables.get(result, 0), new ImageBuilder() .name("EC2 CentOS 5.4 HVM AMI") .operatingSystem( new OperatingSystem.Builder().family(OsFamily.CENTOS).arch("hvm").version("5.4") .description("amazon/EC2 CentOS 5.4 HVM AMI").is64Bit(true).build()) .description("EC2 CentOS 5.4 HVM AMI") .defaultCredentials(LoginCredentials.builder().user("root").build()).id("us-east-1/ami-7ea24a17") .providerId("ami-7ea24a17").location(defaultLocation) .userMetadata(ImmutableMap.of( "owner", "206029621532", "rootDeviceType", "ebs", "virtualizationType", "hvm", "hypervisor", "xen")) .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build()); assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); }
@Override public Image apply(DriveInfo drive) { WellKnownImage input = preinstalledImages.get(drive.getUuid()); // set credentials in the store here, as opposed to directly modifying the image. we need to // set credentials on the image outside of this function so that they can be for example // overridden by properties credentialStore.put("image#" + drive.getUuid(), LoginCredentials.builder().user(input.getLoginUser()).build()); return new ImageBuilder() .ids(drive.getUuid()) .userMetadata( ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata()) .put("size", input.getSize() + "").build()) .location(locationSupplier.get()) .name(input.getDescription()) .description(drive.getName()) .status(Status.AVAILABLE) .operatingSystem( new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()) .name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()) .version("").build(); } }
public void testParseCentOsOnMarketplaceImage() { Set<org.jclouds.compute.domain.Image> result = convertImages("/centos_marketplace_images.xml"); assertEquals( Iterables.get(result, 0), new ImageBuilder() .name("CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4") .operatingSystem( new OperatingSystem.Builder().family(OsFamily.CENTOS).arch("x86_64") .version("7").description("aws-marketplace/CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4") .is64Bit(true).build()).description("CentOS Linux 7 x86_64 HVM EBS 1704_01") .defaultCredentials(LoginCredentials.builder().user("centos").build()).id("us-east-1/ami-061b1560") .providerId("ami-061b1560").location(defaultLocation).version("7") .userMetadata(ImmutableMap.of( "owner", "679593333241", "rootDeviceType", "ebs", "virtualizationType", "hvm", "hypervisor", "xen")) .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build()); assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); }
@Override public Image apply(DriveInfo drive) { WellKnownImage input = preinstalledImages.get(drive.getUuid()); // set credentials in the store here, as opposed to directly modifying the image. we need to // set credentials on the image outside of this function so that they can be for example // overridden by properties credentialStore.put("image#" + drive.getUuid(), LoginCredentials.builder().user(input.getLoginUser()).build()); return new ImageBuilder() .ids(drive.getUuid()) .userMetadata( ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata()) .put("size", input.getSize() + "").build()) .location(locationSupplier.get()) .name(input.getDescription()) .description(drive.getName()) .status(Status.AVAILABLE) .operatingSystem( new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()) .name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()) .version("").build(); } }
@Test public void testApplyWhereTagDoesntMatchAndImageAndLocationFoundAndHardwareNotFound() throws UnknownHostException { RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet.of(provider), EC2ImageParserTest.convertImages("/amzn_images.xml"), ImmutableMap.<String, Credentials> of()); RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals( parser.apply(server).toString(), new NodeMetadataBuilder() .status(Status.RUNNING).backendStatus("running") .hostname("ip-10-243-42-70") .privateAddresses(ImmutableSet.of("10.243.42.70")) .publicAddresses(ImmutableSet.of("174.129.81.68")) .imageId("us-east-1/ami-82e4b5c7") .operatingSystem( new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual") .description("137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()) .id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build().toString()); }
@Test public void testApplyWhereTagDoesntMatchAndImageHardwareAndLocationFound() throws UnknownHostException { RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet .of(provider), EC2ImageParserTest.convertImages("/amzn_images.xml"), ImmutableMap .<String, Credentials> of()); RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals( parser.apply(server).toString(), new NodeMetadataBuilder() .hostname("ip-10-243-42-70") .status(Status.RUNNING).backendStatus("running") .privateAddresses(ImmutableSet.of("10.243.42.70")) .publicAddresses(ImmutableSet.of("174.129.81.68")) .imageId("us-east-1/ami-82e4b5c7") .hardware(m1_small().build()) .operatingSystem( new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual") .description("137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()) .id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build().toString()); }
@Override public Image apply(org.jclouds.servermanager.Image from) { ImageBuilder builder = new ImageBuilder(); builder.ids(from.id + ""); builder.name(from.name); builder.description(from.name); OsFamily family = null; try { family = OsFamily.fromValue(from.name); builder.operatingSystem(new OperatingSystem.Builder().name(from.name).family(family).build()); } catch (IllegalArgumentException e) { logger.debug("<< didn't match os(%s)", from); } builder.status(Status.AVAILABLE); return builder.build(); }
@Test public void testApplyWhereTagDoesntMatchAndImageAndLocationFoundAndHardwareNotFound() throws UnknownHostException { RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet.of(provider), EC2ImageParserTest.convertImages("/amzn_images.xml"), ImmutableMap.<String, Credentials> of()); RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals( parser.apply(server).toString(), new NodeMetadataBuilder() .status(Status.RUNNING).backendStatus("running") .hostname("ip-10-243-42-70") .privateAddresses(ImmutableSet.of("10.243.42.70")) .publicAddresses(ImmutableSet.of("174.129.81.68")) .imageId("us-east-1/ami-82e4b5c7") .operatingSystem( new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual") .description("137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()) .id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build().toString()); }
public void testParseVostokImage() { Set<org.jclouds.compute.domain.Image> result = convertImages("/vostok.xml"); assertEquals( Iterables.get(result, 0), new ImageBuilder() .operatingSystem( new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("") .description("vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml") .is64Bit(false).build()) .description("vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml") .defaultCredentials(LoginCredentials.builder().user("root").build()).id("us-east-1/ami-870de2ee") .providerId("ami-870de2ee").location(defaultLocation).version("5622") .userMetadata(ImmutableMap.of("owner", "133804938231", "rootDeviceType", "instance-store")) .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).build()); }
@Override public Image apply(org.jclouds.servermanager.Image from) { ImageBuilder builder = new ImageBuilder(); builder.ids(from.id + ""); builder.name(from.name); builder.description(from.name); OsFamily family = null; try { family = OsFamily.fromValue(from.name); builder.operatingSystem(new OperatingSystem.Builder().name(from.name).family(family).build()); } catch (IllegalArgumentException e) { logger.debug("<< didn't match os(%s)", from); } builder.status(Status.AVAILABLE); return builder.build(); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }