Skip to content

Commit

Permalink
Add proxy host management (#432)
Browse files Browse the repository at this point in the history
* Update alien4cloud dependency

* Change transaction isolation level

* Add proxy host management

* Restore RemoteRepositoryServiceImpl

* Add proxy credential

* Update dependencies

* Fix typo in jdbc isolation level
  • Loading branch information
maricaantonacci authored Jan 3, 2022
1 parent 89c9fec commit 3040e3f
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@
<editorconfig-maven-plugin.version>0.0.10</editorconfig-maven-plugin.version>

<!-- Dependencies -->
<guava.version>24.1.1-jre</guava.version>
<guava.version>30.0-jre</guava.version>
<elasticsearch.version>1.7.5</elasticsearch.version>
<assertj.version>3.8.0</assertj.version>
<openid-connect.version>1.3.3</openid-connect.version>
<im-java-api.version>0.4.14</im-java-api.version>
<monitoring-pillar-domain.version>1.8.1-FINAL</monitoring-pillar-domain.version>
<flowable.version>6.5.0</flowable.version>
<alien4cloud.version>2.1.0-DEEP-1.3.0</alien4cloud.version>
<alien4cloud.version>2.1.0-DEEP-1.3.1</alien4cloud.version>
<chronos-client.version>0.0.1</chronos-client.version>
<marathon-client.version>0.6.3</marathon-client.version>
<deep-qcg-client.version>1.0.5</deep-qcg-client.version>
Expand Down Expand Up @@ -345,7 +345,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.42.Final</version>
<version>4.1.43.Final</version>
</dependency>

<dependency>
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/it/reply/orchestrator/dto/cmdb/ComputeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ public class ComputeService extends CloudService {
@Nullable
private String privateNetworkName;

@JsonProperty("private_network_proxy_host")
@Nullable
private String privateNetworkProxyHost;

@JsonProperty("private_network_proxy_user")
@Nullable
private String privateNetworkProxyUser;

/**
* Generate a new ComputeService.
*
Expand Down Expand Up @@ -100,6 +108,10 @@ public class ComputeService extends CloudService {
* the private network CIDR
* @param privateNetworkName
* the private network name
* @param privateNetworkProxyHost
* the private network proxy host ip/dns name
* @param privateNetworkProxyUser
* the private network proxy host user
*/
@Builder(builderMethodName = "computeBuilder")
public ComputeService(
Expand All @@ -121,14 +133,18 @@ public ComputeService(
@NonNull List<SupportedIdp> supportedIdps,
@Nullable String publicNetworkName,
@Nullable String privateNetworkCidr,
@Nullable String privateNetworkName) {
@Nullable String privateNetworkName,
@Nullable String privateNetworkProxyHost,
@Nullable String privateNetworkProxyUser) {
super(id, serviceType, endpoint, providerId, type, publicService, tenant, region, hostname,
parentServiceId, iamEnabled, idpProtocol, publicIpAssignable, supportedIdps);
this.images = CommonUtils.notNullOrDefaultValue(images, ArrayList::new);
this.flavors = CommonUtils.notNullOrDefaultValue(flavors, ArrayList::new);
this.publicNetworkName = publicNetworkName;
this.privateNetworkName = privateNetworkName;
this.privateNetworkCidr = privateNetworkCidr;
this.privateNetworkProxyHost = privateNetworkProxyHost;
this.privateNetworkProxyUser = privateNetworkProxyHost;
}

@Deprecated
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/it/reply/orchestrator/dto/cmdb/Tenant.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ public class Tenant implements CmdbIdentifiable {
@JsonProperty("private_network_name")
@Nullable
private String privateNetworkName;

@JsonProperty("private_network_proxy_host")
@Nullable
private String privateNetworkProxyHost;

@JsonProperty("private_network_proxy_user")
@Nullable
private String privateNetworkProxyUser;
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public CloudProvider fillCloudProviderInfo(String providerId,
computeService.setPublicNetworkName(tenant.getPublicNetworkName());
computeService.setPrivateNetworkName(tenant.getPrivateNetworkName());
computeService.setPrivateNetworkCidr(tenant.getPrivateNetworkCidr());
computeService.setPrivateNetworkProxyHost(tenant.getPrivateNetworkProxyHost());
computeService.setPrivateNetworkProxyUser(tenant.getPrivateNetworkProxyUser());
computeService.setTenant(tenant.getTenantName());
}
LOG.debug("Image list for service <{}> of provider <{}>: <{}>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ public ArchiveRoot setHybridUpdateDeployment(ArchiveRoot ar,

public ArchiveRoot setNetworkNames(ArchiveRoot ar,
String publicNetworkName,
String privateNetworkName);
String privateNetworkName,
String privateNetworkProxyHost,
String privateNetworkProxyUser);

public Map<NodeTemplate, Flavor> extractFlavorRequirements(ArchiveRoot parsingResult);

Expand Down
33 changes: 30 additions & 3 deletions src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,28 @@ private boolean setNetworkName(Optional<NodeTemplate> pn, String networkName) {
return false;
}

private boolean setNetworkProxy(Optional<NodeTemplate> pn, String privateNetworkProxyHost,
String privateNetworkProxyUser) {
if (pn.isPresent()) {
if (StringUtils.isNotEmpty(privateNetworkProxyHost)) {
Optional<String> nn = ToscaUtils.extractScalar(pn.get().getProperties(),
ToscaConstants.Nodes.Properties.NETWORKPROXYHOST);
if (!nn.isPresent()) {
pn.get().getProperties().put(ToscaConstants.Nodes.Properties.NETWORKPROXYHOST,
new ScalarPropertyValue(privateNetworkProxyHost));
Map<String, Object> credentials = new HashMap<>();
ComplexPropertyValue credentialsProperty = new ComplexPropertyValue(credentials);
credentials.put(ToscaConstants.Nodes.Properties.NETWORKPROXYHOSTUSER,
privateNetworkProxyUser);
pn.get().getProperties().put(ToscaConstants.Nodes.Properties.NETWORKPROXYHOSTCRED,
credentialsProperty);
}
}
return true;
}
return false;
}

private boolean setHdPublicNetworkProperties(ArchiveRoot ar, String publicNetworkName) {
Optional<NodeTemplate> pn = getNodesOfType(ar, ToscaConstants.Nodes.Types.NETWORK)
.stream()
Expand Down Expand Up @@ -1312,9 +1334,11 @@ private String extractGatewayFromCidr(String cidr) {
public ArchiveRoot setNetworkNames(
ArchiveRoot ar,
String publicNetworkName,
String privateNetworkName) {
String privateNetworkName,
String privateNetworkProxyHost,
String privateNetworkProxyUser) {

Optional<NodeTemplate> pn = getNodesOfType(ar, ToscaConstants.Nodes.Types.NETWORK)
Optional<NodeTemplate> pn = getNodesLikeType(ar, ToscaConstants.Nodes.RE.NETWORK_NODE_RE)
.stream()
.filter(node -> {
Optional<String> nt = ToscaUtils.extractScalar(node.getProperties(),
Expand All @@ -1326,7 +1350,7 @@ public ArchiveRoot setNetworkNames(
setNetworkName(pn, publicNetworkName);
}

pn = getNodesOfType(ar, ToscaConstants.Nodes.Types.NETWORK)
pn = getNodesLikeType(ar, ToscaConstants.Nodes.RE.NETWORK_NODE_RE)
.stream()
.filter(node -> {
Optional<String> nt = ToscaUtils.extractScalar(node.getProperties(),
Expand All @@ -1336,6 +1360,9 @@ public ArchiveRoot setNetworkNames(
if (pn.isPresent()) {
// set private network name
setNetworkName(pn, privateNetworkName);
if (isOfToscaType(pn.get(), ToscaConstants.Nodes.Types.CUSTOM_NETWORK)) {
setNetworkProxy(pn, privateNetworkProxyHost, privateNetworkProxyUser);
}
}
return ar;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ public boolean doDeploy(DeploymentMessage deploymentMessage) {
} else {
toscaService.setNetworkNames(ar,
computeService.getPublicNetworkName(),
computeService.getPrivateNetworkName());
computeService.getPrivateNetworkName(),
computeService.getPrivateNetworkProxyHost(),
computeService.getPrivateNetworkProxyUser());
}

//add tags
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/it/reply/orchestrator/utils/ToscaConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public static class Types {
public static final String BASE_NETWORK_NAME = "tosca.nodes.network.";
public static final String NETWORK = BASE_NETWORK_NAME + "Network";
public static final String PORT = BASE_NETWORK_NAME + "Port";

public static final String CUSTOM_BASE_NETWORK = "tosca.nodes.indigo.network.";
public static final String CUSTOM_NETWORK = "tosca.nodes.indigo.network.Network";

}

@UtilityClass
Expand All @@ -72,6 +76,8 @@ public static class RE {
"^tosca\\.nodes\\.indigo\\.LRMS\\.FrontEnd\\.\\w+$";
public static final String WORKER_NODE_RE =
"^tosca\\.nodes\\.indigo\\.LRMS\\.WorkerNode\\.\\w+$";
public static final String NETWORK_NODE_RE =
"^tosca\\.nodes\\.(indigo\\.)?network\\.Network$";
}

@UtilityClass
Expand All @@ -85,6 +91,9 @@ public static class Attributes {
public static class Properties {
public static final String NETWORKTYPE = "network_type";
public static final String NETWORKNAME = "network_name";
public static final String NETWORKPROXYHOST = "proxy_host";
public static final String NETWORKPROXYHOSTCRED = "proxy_credential";
public static final String NETWORKPROXYHOSTUSER = "user";
public static final String HYBRID = "hybrid";
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spring.jta.bitronix.datasource.enable-jdbc4-connection-test=false
spring.jta.bitronix.datasource.test-query=ROLLBACK
spring.jta.bitronix.datasource.max-pool-size=30
spring.jta.bitronix.properties.default-transaction-timeout=300
spring.jta.bitronix.datasource.isolation-level=READ_COMMITTED

########## Jackson Configuration ##########
spring.jackson.default-property-inclusion=NON_NULL
Expand Down

0 comments on commit 3040e3f

Please sign in to comment.