public T fromOSType(OSType in) { return this .id(in.getId()) .OSCategoryId(in.getOSCategoryId()) .description(in.getDescription()); } }
public OSType build() { return new OSType(id, OSCategoryId, description); }
@Override public String toString() { return string().toString(); }
@Override public String apply(OSType input) { return input.getId(); }
public OperatingSystem apply(Template from) { Builder builder = OperatingSystem.builder().description(from.getOSType()); OSType type = osTypes.get().get(from.getOSTypeId()); if (type == null) { logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get()); return builder.build(); } builder.description(type.getDescription()); builder.is64Bit(type.getDescription().indexOf("64-bit") != -1); String osCategory = osCategories.get().get(type.getOSCategoryId()); if (osCategory == null) { logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get()); return builder.build(); } builder.name(osCategory); OsFamily family = OsFamily.fromValue(osCategory.toLowerCase()); builder.family(family); Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription()); if (matcher.find()) { builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap)); } return builder.build(); } }
@Override public String apply(OSType input) { return categories.get(input.getOSCategoryId()); }
@BeforeMethod public void setUp() { client = createMock(CloudStackClient.class); guestOSClient = createMock(GuestOSClient.class); expect(client.getGuestOSClient()).andReturn(guestOSClient).times(2); Map<String, String> osCategories = Maps.newHashMap(); osCategories.put("1", "Ubuntu"); osCategories.put("2", "CentOS"); osCategories.put("3", "RHEL"); expect(guestOSClient.listOSCategories()).andReturn(osCategories); Set<OSType> osTypes = ImmutableSet.of( OSType.builder().id("10").OSCategoryId("1").description("Ubuntu 10.04 LTS").build(), OSType.builder().id("20").OSCategoryId("2").description("CentOS 5.4").build(), OSType.builder().id("30").OSCategoryId("3").description("RHEL 6").build() ); expect(guestOSClient.listOSTypes()).andReturn(osTypes); replay(client, guestOSClient); }
@Override public String apply(OSType input) { return input.getId(); }
public OperatingSystem apply(Template from) { Builder builder = OperatingSystem.builder().description(from.getOSType()); OSType type = osTypes.get().get(from.getOSTypeId()); if (type == null) { logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get()); return builder.build(); } builder.description(type.getDescription()); builder.is64Bit(type.getDescription().indexOf("64-bit") != -1); String osCategory = osCategories.get().get(type.getOSCategoryId()); if (osCategory == null) { logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get()); return builder.build(); } builder.name(osCategory); OsFamily family = OsFamily.fromValue(osCategory.toLowerCase()); builder.family(family); Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription()); if (matcher.find()) { builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap)); } return builder.build(); } }
@Override public String apply(OSType input) { return categories.get(input.getOSCategoryId()); }
@BeforeMethod public void setUp() { client = createMock(CloudStackApi.class); guestOSClient = createMock(GuestOSApi.class); expect(client.getGuestOSApi()).andReturn(guestOSClient).times(2); Map<String, String> osCategories = Maps.newHashMap(); osCategories.put("1", "Ubuntu"); osCategories.put("2", "CentOS"); osCategories.put("3", "RHEL"); expect(guestOSClient.listOSCategories()).andReturn(osCategories); Set<OSType> osTypes = ImmutableSet.of( OSType.builder().id("10").OSCategoryId("1").description("Ubuntu 10.04 LTS").build(), OSType.builder().id("20").OSCategoryId("2").description("CentOS 5.4").build(), OSType.builder().id("30").OSCategoryId("3").description("RHEL 6").build() ); expect(guestOSClient.listOSTypes()).andReturn(osTypes); replay(client, guestOSClient); }
public T fromOSType(OSType in) { return this .id(in.getId()) .OSCategoryId(in.getOSCategoryId()) .description(in.getDescription()); } }
@Override public String apply(OSType input) { return input.getId(); }
public OperatingSystem apply(Template from) { Builder builder = OperatingSystem.builder().description(from.getOSType()); OSType type = osTypes.get().get(from.getOSTypeId()); if (type == null) { logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get()); return builder.build(); } builder.description(type.getDescription()); builder.is64Bit(type.getDescription().indexOf("64-bit") != -1); String osCategory = osCategories.get().get(type.getOSCategoryId()); if (osCategory == null) { logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get()); return builder.build(); } builder.name(osCategory); OsFamily family = OsFamily.fromValue(osCategory.toLowerCase()); builder.family(family); Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription()); if (matcher.find()) { builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap)); } return builder.build(); } }
@Override public String apply(OSType input) { return categories.get(input.getOSCategoryId()); }
return ImmutableSet .<OSType> builder() .add(OSType.builder().id("69").OSCategoryId("7").description("Asianux 3(32-bit)").build()) .add(OSType.builder().id("70").OSCategoryId("7").description("Asianux 3(64-bit)").build()) .add(OSType.builder().id("1").OSCategoryId("1").description("CentOS 4.5 (32-bit)").build()) .add(OSType.builder().id("2").OSCategoryId("1").description("CentOS 4.6 (32-bit)").build()) .add(OSType.builder().id("3").OSCategoryId("1").description("CentOS 4.7 (32-bit)").build()) .add(OSType.builder().id("4").OSCategoryId("1").description("CentOS 4.8 (32-bit)").build()) .add(OSType.builder().id("5").OSCategoryId("1").description("CentOS 5.0 (32-bit)").build()) .add(OSType.builder().id("6").OSCategoryId("1").description("CentOS 5.0 (64-bit)").build()) .add(OSType.builder().id("7").OSCategoryId("1").description("CentOS 5.1 (32-bit)").build()) .add(OSType.builder().id("8").OSCategoryId("1").description("CentOS 5.1 (64-bit)").build()) .add(OSType.builder().id("9").OSCategoryId("1").description("CentOS 5.2 (32-bit)").build()) .add(OSType.builder().id("10").OSCategoryId("1").description("CentOS 5.2 (64-bit)").build()) .add(OSType.builder().id("11").OSCategoryId("1").description("CentOS 5.3 (32-bit)").build()) .add(OSType.builder().id("12").OSCategoryId("1").description("CentOS 5.3 (64-bit)").build()) .add(OSType.builder().id("13").OSCategoryId("1").description("CentOS 5.4 (32-bit)").build()) .add(OSType.builder().id("14").OSCategoryId("1").description("CentOS 5.4 (64-bit)").build()) .add(OSType.builder().id("111").OSCategoryId("1").description("CentOS 5.5 (32-bit)").build()) .add(OSType.builder().id("112").OSCategoryId("1").description("CentOS 5.5 (64-bit)").build()) .add(OSType.builder().id("73").OSCategoryId("2").description("Debian GNU/Linux 4(32-bit)").build()) .add(OSType.builder().id("74").OSCategoryId("2").description("Debian GNU/Linux 4(64-bit)").build()) .add(OSType.builder().id("72").OSCategoryId("2").description("Debian GNU/Linux 5(64-bit)").build()) .add(OSType.builder().id("15").OSCategoryId("2").description("Debian GNU/Linux 5.0 (32-bit)").build()) .add(OSType.builder().id("132").OSCategoryId("2").description("Debian GNU/Linux 6(32-bit)").build()) .add(OSType.builder().id("133").OSCategoryId("2").description("Debian GNU/Linux 6(64-bit)").build()) .add(OSType.builder().id("102").OSCategoryId("6").description("DOS").build()) .add(OSType.builder().id("118").OSCategoryId("4").description("Fedora 10").build()) .add(OSType.builder().id("117").OSCategoryId("4").description("Fedora 11").build())
public OSType build() { return new OSType(id, OSCategoryId, description); }
@Override public String toString() { return string().toString(); }
public T fromOSType(OSType in) { return this .id(in.getId()) .OSCategoryId(in.getOSCategoryId()) .description(in.getDescription()); } }
@Override public int compareTo(OSType o) { return id.compareTo(o.getId()); } }