# Address/port of the SDC
ml.distribution.ASDC_ADDRESS=<SDC-Hostname>:8443
- # DMaaP consumer group.
+ # Kafka consumer group.
ml.distribution.CONSUMER_GROUP=aai-ml-group
- # DMaaP consumer ID
+ # Kafka consumer ID
ml.distribution.CONSUMER_ID=aai-ml
# SDC Environment Name. This must match the environment name configured on the SDC
# obfuscate the cleartext password: http://www.eclipse.org/jetty/documentation/9.4.x/configuring-security-secure-passwords.html
ml.distribution.PASSWORD=OBF:<password>
- # How often (in seconds) to poll the DMaaP cluster for new model events
+ # How often (in seconds) to poll the Kafka topic for new model events
ml.distribution.POLLING_INTERVAL=<integer>
- # Timeout value (in seconds) when polling DMaaP for new model events
+ # Timeout value (in seconds) when polling the Kafka topic for new model events
ml.distribution.POLLING_TIMEOUT=<integer>
# Username to use when connecting to the SDC
# Artifact type we want to download from the SDC (the values below will typically suffice)
ml.distribution.ARTIFACT_TYPES=MODEL_QUERY_SPEC,TOSCA_CSAR
-
- # List of message bus addresses on which to listen for distribution events
- ml.distribution.MSG_BUS_ADDRESSES=<host1>,<host2>
# URL of the A&AI
ml.aai.BASE_URL=https://<AAI-Hostname>:8443
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=<ASDC_HOST_NAME>:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=<CONSUMER_GROUP>
ml.distribution.CONSUMER_ID=<CONSUMER_ID>
ml.distribution.ENVIRONMENT_NAME=<ENV>
<groupId>org.onap.aai.model-loader</groupId>
<artifactId>model-loader</artifactId>
<name>aai-model-loader</name>
- <version>1.11.0-SNAPSHOT</version>
+ <version>1.12.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<hamcrest-all.version>1.3</hamcrest-all.version>
<babel.version>1.11.0</babel.version>
<aai.rest.client.version>1.2.1</aai.rest.client.version>
- <sdc-distribution-client.version>1.4.1</sdc-distribution-client.version>
+ <sdc-distribution-client.version>2.0.0</sdc-distribution-client.version>
<logback.version>1.2.3</logback.version>
<!-- docker related properties -->
<docker.fabric.version>0.39.0</docker.fabric.version>
</build>
</profile>
</profiles>
-
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.kafka</groupId>
+ <artifactId>kafka-clients</artifactId>
+ <version>3.3.1</version>
+ </dependency>
<dependency>
<groupId>org.onap.aai</groupId>
<artifactId>babel</artifactId>
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.util.security.Password;
import org.onap.sdc.api.consumer.IConfiguration;
+import org.springframework.core.env.Environment;
/**
* Properties for the Model Loader
protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT + "POLLING_TIMEOUT";
protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER";
protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT + "ARTIFACT_TYPES";
- protected static final String PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES =
- PREFIX_DISTRIBUTION_CLIENT + "MSG_BUS_ADDRESSES";
- protected static final String PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP =
- PREFIX_DISTRIBUTION_CLIENT + "USE_HTTPS_WITH_DMAAP";
-
+ protected static final String PROP_ML_DISTRIBUTION_HTTP_PROXY_HOST = PREFIX_DISTRIBUTION_CLIENT + "HTTP_PROXY_HOST";
+ protected static final String PROP_ML_DISTRIBUTION_HTTP_PROXY_PORT = PREFIX_DISTRIBUTION_CLIENT + "HTTP_PROXY_PORT";
+ protected static final String PROP_ML_DISTRIBUTION_HTTPS_PROXY_HOST = PREFIX_DISTRIBUTION_CLIENT + "HTTPS_PROXY_HOST";
+ protected static final String PROP_ML_DISTRIBUTION_HTTPS_PROXY_PORT = PREFIX_DISTRIBUTION_CLIENT + "HTTPS_PROXY_PORT";
protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL";
protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + SUFFIX_KEYSTORE_FILE;
protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + SUFFIX_KEYSTORE_PASS;
private static String configHome;
private Properties modelLoaderProperties = null;
private String certLocation = ".";
- private List<String> artifactTypes = new ArrayList<>();
- private List<String> msgBusAddrs = new ArrayList<>();
+ private final List<String> artifactTypes = new ArrayList<>();
private String modelVersion = null;
public ModelLoaderConfig(Properties configProperties) {
if (types != null) {
artifactTypes.addAll(Arrays.asList(types.split(",")));
}
-
- // Get list of message bus addresses
- String addresses = get(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES);
- if (addresses != null) {
- msgBusAddrs.addAll(Arrays.asList(addresses.split(",")));
- }
}
public static void setConfigHome(String configHome) {
}
@Override
- public String getAsdcAddress() {
+ public String getSdcAddress() {
return get(PROP_ML_DISTRIBUTION_ASDC_ADDRESS);
}
}
@Override
- public Boolean isUseHttpsWithDmaap() {
- String useHTTPS = get(PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP);
- return useHTTPS != null && Boolean.valueOf(useHTTPS);
+ public String getHttpProxyHost() {
+ return getPropertyOrNull(PROP_ML_DISTRIBUTION_HTTP_PROXY_HOST);
+ }
+
+ @Override
+ public int getHttpProxyPort() {
+ return getIntegerPropertyOrZero(PROP_ML_DISTRIBUTION_HTTP_PROXY_PORT);
}
@Override
- public List<String> getMsgBusAddress() {
- return msgBusAddrs;
+ public String getHttpsProxyHost() {
+ return getPropertyOrNull(PROP_ML_DISTRIBUTION_HTTPS_PROXY_HOST);
+ }
+
+ @Override
+ public int getHttpsProxyPort() {
+ return getIntegerPropertyOrZero(PROP_ML_DISTRIBUTION_HTTPS_PROXY_PORT);
}
public String getAaiKeyStorePath() {
}
return value;
}
+
+ public String getPropertyOrNull(String propertyName) {
+ String value = modelLoaderProperties.getProperty(propertyName);
+ if (value == null || "NULL".equals(value) || value.isEmpty()) {
+ return null;
+ } else {
+ return value;
+ }
+ }
+
+ public int getIntegerPropertyOrZero(String propertyName) {
+ String property = modelLoaderProperties.getProperty(propertyName);
+ if (property == null || "NULL".equals(property) || property.isEmpty()) {
+ return 0;
+ } else {
+ try {
+ return Integer.parseInt(property);
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+ }
+
}
@RequestMapping("/services/model-loader/v1/model-service")
public class ModelLoaderService implements ModelLoaderInterface {
- private static Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName());
+ private static final Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName());
@Value("${CONFIG_HOME}")
private String configDir;
try (InputStream configInputStream = Files.newInputStream(Paths.get(configDir, "model-loader.properties"))) {
configProperties.load(configInputStream);
config = new ModelLoaderConfig(configProperties);
-
- // Set the truststore for SDC Client to connect to Dmaap central bus if applicable (as in case of TI)
- if (Boolean.TRUE.equals(config.isUseHttpsWithDmaap())) {
- String trustStorePath = config.getKeyStorePath();
- String trustStorePassword = config.getKeyStorePassword();
- if (trustStorePath != null && Paths.get(trustStorePath).toFile().isFile() && trustStorePassword != null
- && !trustStorePassword.isEmpty()) {
- System.setProperty("javax.net.ssl.trustStore", trustStorePath);
- System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
- } else {
- throw new IllegalArgumentException("Model Loader property ml.distribution.KEYSTORE_FILE "
- + "or ml.distribution.KEYSTORE_PASSWORD not set or invalid");
- }
- }
-
if (!config.getASDCConnectionDisabled()) {
initSdcClient();
}
assertEquals(3, types.size());
}
- @Test
- public void testMsgBusAddrs() {
- Properties props = new Properties();
- props.setProperty("ml.distribution.MSG_BUS_ADDRESSES", "host1.onap.com:3904,host2.onap.com:3904");
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
- List<String> addrs = config.getMsgBusAddress();
-
- assertEquals(2, addrs.size());
- assertEquals(0, addrs.get(0).compareToIgnoreCase("host1.onap.com:3904"));
- assertEquals(0, addrs.get(1).compareToIgnoreCase("host2.onap.com:3904"));
- }
-
@Test
public void testDecryptPassword() {
String password = "youshallnotpass";
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ModelLoaderService.class, HttpsBabelServiceClientFactory.class})
-@TestPropertySource(properties = {"CONFIG_HOME=src/test/resources/sdc_test",})
+@TestPropertySource(properties = {"CONFIG_HOME=src/test/resources",})
public class TestModelLoaderServiceWithSdc {
@Autowired
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env
# because they are used in Jenkins, whose plug-in doesn't support
major=1
-minor=11
+minor=12
patch=0
base_version=${major}.${minor}.${patch}