|
|
|
@ -29,12 +29,14 @@ import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
|
|
import static java.util.Arrays.stream;
|
|
|
|
|
import static java.util.Map.entry;
|
|
|
|
|
import static java.util.Optional.ofNullable;
|
|
|
|
|
import static java.util.stream.Collectors.toMap;
|
|
|
|
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.CLOUD_SERVER;
|
|
|
|
|
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.hs.hosting.asset.HsHostingAssetType.UNIX_USER;
|
|
|
|
|
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.assertj.core.api.Assumptions.assumeThat;
|
|
|
|
@ -91,6 +93,7 @@ public class ImportHostingAssets extends ImportOfficeData {
|
|
|
|
|
static final Integer IP_NUMBER_ID_OFFSET = 1000000;
|
|
|
|
|
static final Integer HIVE_ID_OFFSET = 2000000;
|
|
|
|
|
static final Integer PACKET_ID_OFFSET = 3000000;
|
|
|
|
|
static final Integer UNIXUSER_ID_OFFSET = 4000000;
|
|
|
|
|
|
|
|
|
|
record Hive(int hive_id, String hive_name, int inet_addr_id, AtomicReference<HsHostingAssetEntity> serverRef) {}
|
|
|
|
|
|
|
|
|
@ -261,6 +264,45 @@ public class ImportHostingAssets extends ImportOfficeData {
|
|
|
|
|
""");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@Order(14010)
|
|
|
|
|
void importUnixUsers() {
|
|
|
|
|
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "/hosting/unixuser.csv")) {
|
|
|
|
|
final var lines = readAllLines(reader);
|
|
|
|
|
importUnixUsers(justHeader(lines), withoutHeader(lines));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@Order(14019)
|
|
|
|
|
void verifyUnixUsers() {
|
|
|
|
|
assumeThatWeAreImportingControlledTestData();
|
|
|
|
|
|
|
|
|
|
// no contacts yet => mostly null values
|
|
|
|
|
assertThat(firstOfEachType(15, UNIX_USER)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
4005803=HsHostingAssetEntity(UNIX_USER, lug00, LUGs, MANAGED_WEBSPACE:lug00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/lug00", "locked": false, "shell": "/bin/bash", "userid": 102090}),
|
|
|
|
|
4005805=HsHostingAssetEntity(UNIX_USER, lug00-wla.1, Paul Klemm, MANAGED_WEBSPACE:lug00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/lug00/users/deaf", "locked": false, "shell": "/bin/bash", "userid": 102091}),
|
|
|
|
|
4005809=HsHostingAssetEntity(UNIX_USER, lug00-wla.2, Walter Müller, MANAGED_WEBSPACE:lug00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/lug00/users/marl", "locked": false, "shell": "/bin/bash", "userid": 102093}),
|
|
|
|
|
4005811=HsHostingAssetEntity(UNIX_USER, lug00-ola.a, LUG OLA - POP a, MANAGED_WEBSPACE:lug00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/lug00/users/marl.a", "locked": false, "shell": "/usr/bin/passwd", "userid": 102094}),
|
|
|
|
|
4005813=HsHostingAssetEntity(UNIX_USER, lug00-ola.b, LUG OLA - POP b, MANAGED_WEBSPACE:lug00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/lug00/users/marl.b", "locked": false, "shell": "/usr/bin/passwd", "userid": 102095}),
|
|
|
|
|
4005835=HsHostingAssetEntity(UNIX_USER, lug00-test, Test, MANAGED_WEBSPACE:lug00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/lug00/users/test", "locked": false, "shell": "/usr/bin/passwd", "userid": 102106}),
|
|
|
|
|
4005964=HsHostingAssetEntity(UNIX_USER, mim00, Michael Mellis, MANAGED_WEBSPACE:mim00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/mim00", "locked": false, "shell": "/bin/bash", "userid": 102147}),
|
|
|
|
|
4005966=HsHostingAssetEntity(UNIX_USER, mim00-1981, Jahrgangstreffen 1981, MANAGED_WEBSPACE:mim00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 256, "SDD soft quota": 128, "homedir": "/home/pacs/mim00/users/1981", "locked": false, "shell": "/bin/bash", "userid": 102148}),
|
|
|
|
|
4005990=HsHostingAssetEntity(UNIX_USER, mim00-mail, Mailbox, MANAGED_WEBSPACE:mim00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/mim00/users/mail", "locked": false, "shell": "/bin/bash", "userid": 102160}),
|
|
|
|
|
4100705=HsHostingAssetEntity(UNIX_USER, hsh00-mim, Michael Mellis, MANAGED_WEBSPACE:hsh00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/hsh00/users/mi", "locked": false, "shell": "/bin/false", "userid": 10003}),
|
|
|
|
|
4100824=HsHostingAssetEntity(UNIX_USER, hsh00, Hostsharing Paket, MANAGED_WEBSPACE:hsh00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/hsh00", "locked": false, "shell": "/bin/bash", "userid": 10000}),
|
|
|
|
|
4167846=HsHostingAssetEntity(UNIX_USER, hsh00-dph, hsh00-uph, MANAGED_WEBSPACE:hsh00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/hsh00/users/uph", "locked": false, "shell": "/bin/false", "userid": 110568}),
|
|
|
|
|
4169546=HsHostingAssetEntity(UNIX_USER, dph00, Reinhard Wiese, MANAGED_WEBSPACE:dph00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/dph00", "locked": false, "shell": "/bin/bash", "userid": 110593}),
|
|
|
|
|
4169596=HsHostingAssetEntity(UNIX_USER, dph00-uph, Domain admin, MANAGED_WEBSPACE:dph00, { "HDD hard quota": 0, "HDD soft quota": 0, "SDD hard quota": 0, "SDD soft quota": 0, "homedir": "/home/pacs/dph00/users/uph", "locked": false, "shell": "/bin/bash", "userid": 110594})
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@Order(11400)
|
|
|
|
|
void validateBookingItems() {
|
|
|
|
@ -287,6 +329,8 @@ public class ImportHostingAssets extends ImportOfficeData {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@Order(19000)
|
|
|
|
|
@Commit
|
|
|
|
@ -323,6 +367,8 @@ public class ImportHostingAssets extends ImportOfficeData {
|
|
|
|
|
persist(key, HsBookingItemEntityValidatorRegistry.validated(bi));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================================================================
|
|
|
|
|
|
|
|
|
|
private void persistHostingAssetsOfType(final HsHostingAssetType hsHostingAssetType) {
|
|
|
|
|
jpaAttempt.transacted(() -> {
|
|
|
|
|
context(rbacSuperuser);
|
|
|
|
@ -402,12 +448,17 @@ public class ImportHostingAssets extends ImportOfficeData {
|
|
|
|
|
bookingItems.put(PACKET_ID_OFFSET + packet_id, bookingItem);
|
|
|
|
|
final var haType = determineHaType(basepacket_code);
|
|
|
|
|
|
|
|
|
|
logError(() -> assertThat(!free || haType == MANAGED_WEBSPACE || bookingItem.getRelatedProject().getDebitor().getDefaultPrefix().equals("hsh"))
|
|
|
|
|
.as("packet.free only supported for Hostsharing-Assets and ManagedWebspace in customer-ManagedServer, but is set for " + packet_name)
|
|
|
|
|
logError(() -> assertThat(!free || haType == MANAGED_WEBSPACE || bookingItem.getRelatedProject()
|
|
|
|
|
.getDebitor()
|
|
|
|
|
.getDefaultPrefix()
|
|
|
|
|
.equals("hsh"))
|
|
|
|
|
.as("packet.free only supported for Hostsharing-Assets and ManagedWebspace in customer-ManagedServer, but is set for "
|
|
|
|
|
+ packet_name)
|
|
|
|
|
.isTrue());
|
|
|
|
|
|
|
|
|
|
final var asset = HsHostingAssetEntity.builder()
|
|
|
|
|
.isLoaded(haType == MANAGED_WEBSPACE) // this turns off identifier validation to accept former default prefixes
|
|
|
|
|
.isLoaded(haType
|
|
|
|
|
== MANAGED_WEBSPACE) // this turns off identifier validation to accept former default prefixes
|
|
|
|
|
.type(haType)
|
|
|
|
|
.identifier(packet_name)
|
|
|
|
|
.bookingItem(bookingItem)
|
|
|
|
@ -537,7 +588,38 @@ public class ImportHostingAssets extends ImportOfficeData {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<V> V returning(final V value, final Object... assignments) {
|
|
|
|
|
private void importUnixUsers(final String[] header, final List<String[]> records) {
|
|
|
|
|
final var columns = new Columns(header);
|
|
|
|
|
records.stream()
|
|
|
|
|
.map(this::trimAll)
|
|
|
|
|
.map(row -> new Record(columns, row))
|
|
|
|
|
.forEach(rec -> {
|
|
|
|
|
final var unixuser_id = rec.getInteger("unixuser_id");
|
|
|
|
|
final var packet_id = rec.getInteger("packet_id");
|
|
|
|
|
final var unixUserAsset = HsHostingAssetEntity.builder()
|
|
|
|
|
.type(UNIX_USER)
|
|
|
|
|
.parentAsset(hostingAssets.get(PACKET_ID_OFFSET+packet_id))
|
|
|
|
|
.identifier(rec.getString("name"))
|
|
|
|
|
.caption(rec.getString("comment"))
|
|
|
|
|
.config(Map.ofEntries(
|
|
|
|
|
entry("shell", rec.getString("shell")),
|
|
|
|
|
entry("homedir", rec.getString("homedir")),
|
|
|
|
|
entry("locked", rec.getBoolean("locked")),
|
|
|
|
|
entry("userid", rec.getInteger("userid")),
|
|
|
|
|
entry("SDD soft quota", rec.getInteger("quota_softlimit")),
|
|
|
|
|
entry("SDD hard quota", rec.getInteger("quota_hardlimit")),
|
|
|
|
|
entry("HDD soft quota", rec.getInteger("storage_softlimit")),
|
|
|
|
|
entry("HDD hard quota", rec.getInteger("storage_hardlimit"))
|
|
|
|
|
))
|
|
|
|
|
.build();
|
|
|
|
|
hostingAssets.put(UNIXUSER_ID_OFFSET + unixuser_id, unixUserAsset);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<V> V returning(
|
|
|
|
|
final V value,
|
|
|
|
|
@SuppressWarnings("unused") final Object... assignments // DSL-hack: just used for side effects on caller-side
|
|
|
|
|
) {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|