set HA+BI caption and cleanup

This commit is contained in:
Michael Hoennig 2024-07-17 08:31:57 +02:00
parent 731fa369ad
commit ce26f4665f

View File

@ -26,6 +26,7 @@ import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.CLOU
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV4_NUMBER;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_SERVER;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
import static org.assertj.core.api.Assertions.assertThat;
/*
@ -163,15 +164,15 @@ public class ImportHostingAssets extends CsvDataImport {
assertThat(firstOfEachType(3, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
{
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, D-???????-?:agu00),
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, D-???????-?:ahr00),
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, D-???????-?:ahr01),
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, D-???????-?:vm1064),
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, D-???????-?:vm1063),
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, D-???????-?:vm1062),
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, D-???????-?:vm2097),
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, D-???????-?:vm2062),
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, D-???????-?:vm2058)
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, HA agu00, D-???????-?:BI agu00),
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, HA ahr00, D-???????-?:BI ahr00),
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, HA ahr01, D-???????-?:BI ahr01),
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, HA vm1064, D-???????-?:BI vm1064),
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, HA vm1063, D-???????-?:BI vm1063),
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, HA vm1062, D-???????-?:BI vm1062),
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, HA vm2097, D-???????-?:BI vm2097),
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, HA vm2062, D-???????-?:BI vm2062),
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, HA vm2058, D-???????-?:BI vm2058)
}
""");
assertThat(firstOfEachType(
@ -180,15 +181,15 @@ public class ImportHostingAssets extends CsvDataImport {
HsBookingItemType.MANAGED_SERVER,
HsBookingItemType.MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
{
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), agu00),
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr00),
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr01),
3000964=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1064),
3000966=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1063),
3000967=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1062),
3023611=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2097),
3023612=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2062),
3023613=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2058)
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-07-07,), BI agu00),
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2001-12-17,), BI ahr00),
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-03-12,), BI ahr01),
3000964=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1064),
3000966=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1063),
3000967=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1062),
3023611=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2097),
3023612=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2062),
3023613=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2058)
}
""");
}
@ -213,21 +214,21 @@ public class ImportHostingAssets extends CsvDataImport {
assertThat(firstOfEachType(5, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE))
.isEqualToIgnoringWhitespace("""
{
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, D-???????-?:agu00),
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, D-???????-?:ahr00),
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, D-???????-?:ahr01),
3000009=HsHostingAssetEntity(MANAGED_WEBSPACE, aih00, D-???????-?:aih00),
3000012=HsHostingAssetEntity(MANAGED_WEBSPACE, al000, D-???????-?:al000),
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, D-???????-?:vm1064),
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, D-???????-?:vm1063),
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, D-???????-?:vm1062),
3000968=HsHostingAssetEntity(MANAGED_SERVER, vm1061, D-???????-?:vm1061),
3000969=HsHostingAssetEntity(MANAGED_SERVER, vm1060, D-???????-?:vm1060),
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, D-???????-?:vm2097),
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, D-???????-?:vm2062),
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, D-???????-?:vm2058),
3023614=HsHostingAssetEntity(CLOUD_SERVER, vm2055, D-???????-?:vm2055),
3023615=HsHostingAssetEntity(CLOUD_SERVER, vm2010, D-???????-?:vm2010)
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, HA agu00, D-???????-?:BI agu00),
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, HA ahr00, D-???????-?:BI ahr00),
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, HA ahr01, D-???????-?:BI ahr01),
3000009=HsHostingAssetEntity(MANAGED_WEBSPACE, aih00, HA aih00, D-???????-?:BI aih00),
3000012=HsHostingAssetEntity(MANAGED_WEBSPACE, al000, HA al000, D-???????-?:BI al000),
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, HA vm1064, D-???????-?:BI vm1064),
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, HA vm1063, D-???????-?:BI vm1063),
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, HA vm1062, D-???????-?:BI vm1062),
3000968=HsHostingAssetEntity(MANAGED_SERVER, vm1061, HA vm1061, D-???????-?:BI vm1061),
3000969=HsHostingAssetEntity(MANAGED_SERVER, vm1060, HA vm1060, D-???????-?:BI vm1060),
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, HA vm2097, D-???????-?:BI vm2097),
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, HA vm2062, D-???????-?:BI vm2062),
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, HA vm2058, D-???????-?:BI vm2058),
3023614=HsHostingAssetEntity(CLOUD_SERVER, vm2055, HA vm2055, D-???????-?:BI vm2055),
3023615=HsHostingAssetEntity(CLOUD_SERVER, vm2010, HA vm2010, D-???????-?:BI vm2010)
}
""");
assertThat(firstOfEachType(
@ -237,21 +238,21 @@ public class ImportHostingAssets extends CsvDataImport {
HsBookingItemType.MANAGED_WEBSPACE))
.isEqualToIgnoringWhitespace("""
{
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), agu00, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 8192, "Traffic": 20}),
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr00, { "Multi": 6, "SLA-Platform": "EXT24H", "SSD": 25600, "Traffic": 10}),
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr01, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 5120, "Traffic": 10}),
3000009=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), aih00, { "HDD": 20480, "Multi": 2, "SLA-Platform": "BASIC", "SSD": 3072, "Traffic": 10}),
3000012=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), al000, { "HDD": 10240, "Multi": 3, "SLA-Platform": "BASIC", "SSD": 6144, "Traffic": 40}),
3000964=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1064, { "CPU": 2, "RAM": 4096, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 76800, "Traffic": 500}),
3000966=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1063, { "CPU": 2, "HDD": 256000, "RAM": 8192, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 51200, "Traffic": 250}),
3000967=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1062, { "CPU": 2, "HDD": 256000, "RAM": 12288, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT2H", "SLA-Web": true, "SSD": 102400, "Traffic": 250}),
3000968=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1061, { "CPU": 6, "HDD": 256000, "RAM": 14336, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "BASIC", "SLA-Web": true, "SSD": 384000, "Traffic": 250}),
3000969=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1060, { "CPU": 2, "RAM": 4096, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT2H", "SLA-Web": true, "SSD": 76800, "Traffic": 250}),
3023611=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2097, { "CPU": 8, "RAM": 12288, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023612=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2062, { "CPU": 10, "RAM": 65536, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023613=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2058, { "CPU": 1, "RAM": 8192, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023614=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2055, { "CPU": 8, "HDD": 256000, "RAM": 16384, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023615=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2010, { "CPU": 2, "RAM": 2048, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 51200, "Traffic": 250})
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-07-07,), BI agu00, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 8192, "Traffic": 20}),
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2001-12-17,), BI ahr00, { "Multi": 6, "SLA-Platform": "EXT24H", "SSD": 25600, "Traffic": 10}),
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-03-12,), BI ahr01, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 5120, "Traffic": 10}),
3000009=HsBookingItemEntity(MANAGED_WEBSPACE, [2002-07-03,), BI aih00, { "HDD": 20480, "Multi": 2, "SLA-Platform": "BASIC", "SSD": 3072, "Traffic": 10}),
3000012=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-10-17,), BI al000, { "HDD": 10240, "Multi": 3, "SLA-Platform": "BASIC", "SSD": 6144, "Traffic": 40}),
3000964=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1064, { "CPU": 2, "RAM": 4096, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 76800, "Traffic": 500}),
3000966=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1063, { "CPU": 2, "HDD": 256000, "RAM": 8192, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 51200, "Traffic": 250}),
3000967=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1062, { "CPU": 2, "HDD": 256000, "RAM": 12288, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT2H", "SLA-Web": true, "SSD": 102400, "Traffic": 250}),
3000968=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1061, { "CPU": 6, "HDD": 256000, "RAM": 14336, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "BASIC", "SLA-Web": true, "SSD": 384000, "Traffic": 250}),
3000969=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1060, { "CPU": 2, "RAM": 4096, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT2H", "SLA-Web": true, "SSD": 76800, "Traffic": 250}),
3023611=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2097, { "CPU": 8, "RAM": 12288, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023612=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2062, { "CPU": 10, "RAM": 65536, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023613=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2058, { "CPU": 1, "RAM": 8192, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023614=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2055, { "CPU": 8, "HDD": 256000, "RAM": 16384, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023615=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2010, { "CPU": 2, "RAM": 2048, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 51200, "Traffic": 250})
}
""");
}
@ -304,29 +305,32 @@ public class ImportHostingAssets extends CsvDataImport {
final var old_inet_addr_id = rec.getInteger("old_inet_addr_id");
final var free = rec.getBoolean("free");
final var bookingItem = HsBookingItemEntity.builder()
.type(switch (rec.getString("basepacket_code")) {
final var biType = switch (basepacket_code) {
case "SRV/CLD" -> HsBookingItemType.CLOUD_SERVER;
case "SRV/MGD" -> HsBookingItemType.MANAGED_SERVER;
case "PAC/WEB" -> HsBookingItemType.MANAGED_WEBSPACE;
default -> throw new IllegalArgumentException(
"unknown basepacket_code: " + rec.getString("basepacket_code"));
})
.caption(packet_name)
"unknown basepacket_code: " + basepacket_code);
};
final var bookingItem = HsBookingItemEntity.builder()
.type(biType)
.caption("BI " + packet_name)
.validity(toPostgresDateRange(created, cancelled))
.build();
bookingItems.put(PACKET_ID_OFFSET + packet_id, bookingItem);
final var asset = HsHostingAssetEntity.builder()
.type(switch (rec.getString("basepacket_code")) {
final var haType = switch (basepacket_code) {
case "SRV/CLD" -> CLOUD_SERVER;
case "SRV/MGD" -> MANAGED_SERVER;
case "PAC/WEB" -> MANAGED_WEBSPACE;
default -> throw new IllegalArgumentException(
"unknown basepacket_code: " + rec.getString("basepacket_code"));
})
.identifier(rec.getString("packet_name"))
"unknown basepacket_code: " + basepacket_code);
};
final var asset = HsHostingAssetEntity.builder()
.type(haType)
.identifier(packet_name)
.bookingItem(bookingItem)
// .caption(rec.getString("description"))
.caption("HA " + packet_name)
.build();
hostingAssets.put(PACKET_ID_OFFSET + packet_id, asset);
});
@ -410,6 +414,14 @@ public class ImportHostingAssets extends CsvDataImport {
});
}
private static HsHostingAssetEntity ipNumber(final Integer inet_addr_id) {
return inet_addr_id != null ? hostingAssets.get(IP_NUMBER_ID_OFFSET + inet_addr_id) : null;
}
private static Hive hive(final Integer hive_id) {
return hive_id != null ? hives.get(HIVE_ID_OFFSET + hive_id) : null;
}
private String firstOfEachType(
final int maxCount,
final HsHostingAssetType... types) {
@ -449,5 +461,4 @@ public class ImportHostingAssets extends CsvDataImport {
protected static void assumeThatWeAreImportingControlledTestData() {
// assumeThat(isImportingControlledTestData()).isTrue(); FIXME
}
}