You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/09/19 08:05:12 UTC
[incubator-dlab] branch DLAB-terraform updated: DLAB-000 bugfix
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch DLAB-terraform
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-terraform by this push:
new 6fc4cb8 DLAB-000 bugfix
6fc4cb8 is described below
commit 6fc4cb82c3369d922ff154b6f985cf9905e40aeb
Author: bhliva <bo...@epam.com>
AuthorDate: Thu Sep 19 11:03:50 2019 +0300
DLAB-000 bugfix
---
services/self-service/self-service.yml | 1 +
.../conf/SelfServiceApplicationConfiguration.java | 8 ++---
.../epam/dlab/backendapi/dao/BaseBillingDAO.java | 14 ++------
.../dlab/backendapi/dao/aws/AwsBillingDAO.java | 19 ----------
.../dlab/backendapi/dao/azure/AzureBillingDAO.java | 10 ------
.../dlab/backendapi/dao/gcp/GcpBillingDao.java | 10 ------
.../dropwizard/listeners/MongoStartupListener.java | 9 ++---
.../epam/dlab/backendapi/util/RequestBuilder.java | 42 +---------------------
8 files changed, 13 insertions(+), 100 deletions(-)
diff --git a/services/self-service/self-service.yml b/services/self-service/self-service.yml
index 4f67acf..bbd60c2 100644
--- a/services/self-service/self-service.yml
+++ b/services/self-service/self-service.yml
@@ -66,6 +66,7 @@ azureUseLdap: <LOGIN_USE_LDAP>
maxSessionDurabilityMilliseconds: 288000000
</#if>
+serviceBaseName: SERVICE_BASE_NAME
server:
gzip:
enabled: true
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/conf/SelfServiceApplicationConfiguration.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/conf/SelfServiceApplicationConfiguration.java
index f2898e6..afa2871 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/conf/SelfServiceApplicationConfiguration.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/conf/SelfServiceApplicationConfiguration.java
@@ -39,8 +39,6 @@ import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
import java.util.Map;
/**
@@ -129,6 +127,8 @@ public class SelfServiceApplicationConfiguration extends ServiceConfiguration {
@NotNull
private Map<String, String> guacamole;
+ private String serviceBaseName;
+
private KeycloakConfiguration keycloakConfiguration = new KeycloakConfiguration();
public Map<String, String> getGuacamole() {
@@ -267,7 +267,7 @@ public class SelfServiceApplicationConfiguration extends ServiceConfiguration {
return keycloakConfiguration;
}
- public static void main(String[] args) throws NoSuchAlgorithmException {
- KeyFactory kf = KeyFactory.getInstance("ECDSA");
+ public String getServiceBaseName() {
+ return serviceBaseName;
}
}
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/BaseBillingDAO.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/BaseBillingDAO.java
index 2eeb966..2d681ec 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/BaseBillingDAO.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/BaseBillingDAO.java
@@ -49,7 +49,8 @@ import java.util.function.Supplier;
import static com.epam.dlab.backendapi.dao.ComputationalDAO.COMPUTATIONAL_ID;
import static com.epam.dlab.backendapi.dao.ExploratoryDAO.COMPUTATIONAL_RESOURCES;
import static com.epam.dlab.backendapi.dao.ExploratoryDAO.EXPLORATORY_ID;
-import static com.epam.dlab.backendapi.dao.MongoCollections.*;
+import static com.epam.dlab.backendapi.dao.MongoCollections.BILLING;
+import static com.epam.dlab.backendapi.dao.MongoCollections.USER_INSTANCES;
import static com.epam.dlab.model.aws.ReportLine.FIELD_RESOURCE_TYPE;
import static com.epam.dlab.model.aws.ReportLine.FIELD_USAGE_DATE;
import static com.mongodb.client.model.Accumulators.sum;
@@ -401,13 +402,6 @@ public abstract class BaseBillingDAO<T extends BillingFilter> extends BaseDAO im
if (shapeNames == null || shapeNames.isEmpty() || shapeNames.contains(ssnShape)) {
String serviceBaseName = getServiceBaseName();
shapes.put(serviceBaseName + "-ssn", new ShapeInfo(ssnShape, UserInstanceStatus.RUNNING));
- FindIterable<Document> docs = getCollection(USER_EDGE)
- .find()
- .projection(fields(include(ID, EDGE_STATUS)));
- for (Document d : docs) {
- shapes.put(edgeId(d),
- new ShapeInfo(getEdgeSize(), UserInstanceStatus.of(d.getString(EDGE_STATUS))));
- }
}
}
@@ -415,10 +409,6 @@ public abstract class BaseBillingDAO<T extends BillingFilter> extends BaseDAO im
return settings.getServiceBaseName();
}
- protected abstract String getEdgeSize();
-
- protected abstract String edgeId(Document d);
-
protected abstract String getSsnShape();
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/aws/AwsBillingDAO.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/aws/AwsBillingDAO.java
index 71bda09..a565af3 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/aws/AwsBillingDAO.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/aws/AwsBillingDAO.java
@@ -21,17 +21,7 @@ package com.epam.dlab.backendapi.dao.aws;
import com.epam.dlab.MongoKeyWords;
import com.epam.dlab.backendapi.dao.BaseBillingDAO;
-import com.epam.dlab.backendapi.domain.ProjectDTO;
import com.epam.dlab.backendapi.resources.dto.aws.AwsBillingFilter;
-import com.epam.dlab.util.UsernameUtils;
-import com.epam.dlab.backendapi.roles.RoleType;
-import com.epam.dlab.backendapi.roles.UserRoles;
-import com.epam.dlab.billing.BillingCalculationUtils;
-import com.epam.dlab.billing.DlabResourceType;
-import com.epam.dlab.dto.UserInstanceStatus;
-import com.mongodb.client.AggregateIterable;
-import com.mongodb.client.FindIterable;
-import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import org.bson.conversions.Bson;
@@ -75,15 +65,6 @@ public class AwsBillingDAO extends BaseBillingDAO<AwsBillingFilter> {
return Collections.emptyList();
}
- @Override
- protected String getEdgeSize() {
- return getSsnShape();
- }
-
- public String edgeId(Document d) {
- return String.join("-", settings.getServiceBaseName(), UsernameUtils.removeDomain(d.getString(ID)), "edge");
- }
-
@Override
protected String getSsnShape() {
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/azure/AzureBillingDAO.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/azure/AzureBillingDAO.java
index 0c5fb1e..66a9b4c 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/azure/AzureBillingDAO.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/azure/AzureBillingDAO.java
@@ -78,16 +78,6 @@ public class AzureBillingDAO extends BaseBillingDAO<AzureBillingFilter> {
}
@Override
- protected String getEdgeSize() {
- return settings.getAzureEdgeInstanceSize();
- }
-
- @Override
- protected String edgeId(Document d) {
- return d.getString(INSTANCE_ID);
- }
-
- @Override
protected String getSsnShape() {
return settings.getAzureSsnInstanceSize();
}
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/gcp/GcpBillingDao.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/gcp/GcpBillingDao.java
index 70ae6d5..e03ac01 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/gcp/GcpBillingDao.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/gcp/GcpBillingDao.java
@@ -21,7 +21,6 @@ package com.epam.dlab.backendapi.dao.gcp;
import com.epam.dlab.backendapi.dao.BaseBillingDAO;
import com.epam.dlab.backendapi.resources.dto.gcp.GcpBillingFilter;
-import com.epam.dlab.util.UsernameUtils;
import org.bson.Document;
import org.bson.conversions.Bson;
@@ -59,15 +58,6 @@ public class GcpBillingDao extends BaseBillingDAO<GcpBillingFilter> {
return Collections.emptyList();
}
- @Override
- protected String getEdgeSize() {
- return getSsnShape();
- }
-
- public String edgeId(Document d) {
- return String.join("-", settings.getServiceBaseName(), UsernameUtils.removeDomain(d.getString(ID)), "edge");
- }
-
@Override
protected String getSsnShape() {
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/dropwizard/listeners/MongoStartupListener.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/dropwizard/listeners/MongoStartupListener.java
index f3075eb..e912ed1 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/dropwizard/listeners/MongoStartupListener.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/dropwizard/listeners/MongoStartupListener.java
@@ -24,20 +24,21 @@ public class MongoStartupListener implements ServerLifecycleListener {
private static final String ROLES_FILE_FORMAT = "/mongo/%s/mongo_roles.json";
private static final ObjectMapper MAPPER = new ObjectMapper();
private final UserRoleDao userRoleDao;
- private final SettingsDAO settingsDAO;
private final SelfServiceApplicationConfiguration configuration;
+ private final SettingsDAO settingsDAO;
@Inject
- public MongoStartupListener(UserRoleDao userRoleDao, SettingsDAO settingsDAO,
- SelfServiceApplicationConfiguration configuration) {
+ public MongoStartupListener(UserRoleDao userRoleDao,
+ SelfServiceApplicationConfiguration configuration, SettingsDAO settingsDAO) {
this.userRoleDao = userRoleDao;
- this.settingsDAO = settingsDAO;
this.configuration = configuration;
+ this.settingsDAO = settingsDAO;
}
@Override
public void serverStarted(Server server) {
insertRoles();
+ settingsDAO.setServiceBaseName(configuration.getServiceBaseName());
}
private void insertRoles() {
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/util/RequestBuilder.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/util/RequestBuilder.java
index b273d74..3990331 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/util/RequestBuilder.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/util/RequestBuilder.java
@@ -90,50 +90,13 @@ public class RequestBuilder {
switch (cloudProvider()) {
case AWS:
return AwsCloudSettings.builder()
- .awsRegion(settingsDAO.getAwsRegion())
- .awsSecurityGroupIds(settingsDAO.getAwsSecurityGroups())
- .awsSubnetId(settingsDAO.getAwsSubnetId())
- .awsVpcId(settingsDAO.getAwsVpcId())
- .confTagResourceId(settingsDAO.getConfTagResourceId())
- .awsNotebookSubnetId(settingsDAO.getAwsNotebookSubnetId())
- .awsNotebookVpcId(settingsDAO.getAwsNotebookVpcId())
.awsIamUser(userInfo.getName())
- .zone(settingsDAO.getAwsZone())
- .ldapDn(settingsDAO.getLdapDn())
- .ldapHost(settingsDAO.getLdapHost())
- .ldapOu(settingsDAO.getLdapOu())
- .ldapUser(settingsDAO.getLdapUser())
- .ldapPassword(settingsDAO.getLdapPassword())
- .sbn(settingsDAO.getServiceBaseName())
- .cloud(configuration.getCloudProvider().getName())
- .os(settingsDAO.getConfOsFamily())
- .confKeyDir(settingsDAO.getConfKeyDir())
.build();
case AZURE:
return AzureCloudSettings.builder()
- .azureRegion(settingsDAO.getAzureRegion())
- .azureResourceGroupName(settingsDAO.getAzureResourceGroupName())
- .azureSecurityGroupName(settingsDAO.getAzureSecurityGroupName())
- .azureSubnetName(settingsDAO.getAzureSubnetName())
- .azureVpcName(settingsDAO.getAzureVpcName())
- .confKeyDir(settingsDAO.getConfKeyDir())
.azureIamUser(userInfo.getName()).build();
case GCP:
return GcpCloudSettings.builder()
- .projectId(settingsDAO.getGcpProjectId())
- .vpcName(settingsDAO.getGcpVpcName())
- .subnetName(settingsDAO.getGcpSubnetName())
- .zone(settingsDAO.getGcpZone())
- .region(settingsDAO.getGcpRegion())
- .ldapDn(settingsDAO.getLdapDn())
- .ldapHost(settingsDAO.getLdapHost())
- .ldapOu(settingsDAO.getLdapOu())
- .ldapUser(settingsDAO.getLdapUser())
- .ldapPassword(settingsDAO.getLdapPassword())
- .sbn(settingsDAO.getServiceBaseName())
- .cloud(configuration.getCloudProvider().getName())
- .os(settingsDAO.getConfOsFamily())
- .confKeyDir(settingsDAO.getConfKeyDir())
.gcpIamUser(userInfo.getName()).build();
default:
throw new IllegalArgumentException(UNSUPPORTED_CLOUD_PROVIDER_MESSAGE + cloudProvider());
@@ -172,10 +135,7 @@ public class RequestBuilder {
@SuppressWarnings("unchecked")
private <T extends ResourceSysBaseDTO<?>> T newResourceSysBaseDTO(UserInfo userInfo, Class<T> resourceClass) {
- T resource = newResourceBaseDTO(userInfo, resourceClass);
- return (T) resource
- .withServiceBaseName(settingsDAO.getServiceBaseName())
- .withConfOsFamily(settingsDAO.getConfOsFamily());
+ return newResourceBaseDTO(userInfo, resourceClass);
}
@SuppressWarnings("unchecked")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org