Create OT&E entities directly, instead of calling sub-commands

This is in preparation for having a web-console endpoint to create OTE.

In addition - we streamline the code:

- we remove support for different premium lists
- we remove support for different DNS writers - we never want a "real" DnsWriter for OTE
- we remove support of --eap_only, because we don't need it anymore
- We use a single password for all the Registrars

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=225841694
This commit is contained in:
guyben
2018-12-20 07:46:33 -05:00
committed by Michael Muller
parent 1004ef5621
commit 9d6a7ef66a
6 changed files with 904 additions and 488 deletions
@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
import static com.google.common.collect.Ordering.natural;
@@ -68,6 +69,7 @@ import google.registry.model.UpdateAutoTimestamp;
import google.registry.model.annotations.ReportedOn;
import google.registry.model.common.EntityGroupRoot;
import google.registry.model.registrar.Registrar.BillingAccountEntry.CurrencyMapper;
import google.registry.model.registry.Registry;
import google.registry.util.CidrAddressBlock;
import google.registry.util.NonFinalForTesting;
import java.security.MessageDigest;
@@ -704,6 +706,28 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
return this;
}
/**
* Same as {@link #setAllowedTlds}, but doesn't use the cache to check if the TLDs exist.
*
* <p>This should be used if the TLD we want to set is persisted in the same transaction -
* meaning its existence can't be cached before we need to save the Registrar.
*
* <p>We can still only set the allowedTld AFTER we saved the Registry entity. Make sure to call
* {@code .now()} when saving the Registry entity to make sure it's actually saved before trying
* to set the allowed TLDs.
*/
public Builder setAllowedTldsUncached(Set<String> allowedTlds) {
ImmutableSet<Key<Registry>> newTldKeys =
Sets.difference(allowedTlds, getInstance().getAllowedTlds()).stream()
.map(tld -> Key.create(getCrossTldKey(), Registry.class, tld))
.collect(toImmutableSet());
Set<Key<Registry>> missingTldKeys =
Sets.difference(newTldKeys, ofy().load().keys(newTldKeys).keySet());
checkArgument(missingTldKeys.isEmpty(), "Trying to set nonexisting TLDs: %s", missingTldKeys);
getInstance().allowedTlds = ImmutableSortedSet.copyOf(allowedTlds);
return this;
}
public Builder setClientCertificate(String clientCertificate, DateTime now) {
clientCertificate = emptyToNull(clientCertificate);
String clientCertificateHash = calculateHash(clientCertificate);