From b65cd89989ead7082089bf6f333e56b03f619606 Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Thu, 13 Jul 2017 20:21:01 +0200 Subject: HONEYCOMB-360 - Restconf Northbound Intefaces provider separation - Restconf configuration included under restconf.json Change-Id: I45f503d3ef383bd6e3d356308d3212c7314b7a28 Signed-off-by: Jan Srnicek --- infra/minimal-distribution-core/pom.xml | 45 +--------- .../distro/activation/ActiveModuleProvider.java | 26 ++---- .../distro/cfgattrs/HoneycombConfiguration.java | 78 +----------------- .../distro/restconf/HttpConnectorProvider.java | 41 ---------- .../distro/restconf/HttpsConnectorProvider.java | 75 ----------------- .../infra/distro/restconf/JettyServerProvider.java | 95 ---------------------- .../infra/distro/restconf/RestconfModule.java | 39 --------- .../infra/distro/restconf/RestconfProvider.java | 41 ---------- .../infra/distro/schema/ResourceLoader.java | 8 +- .../config/honeycomb.json | 20 ----- 10 files changed, 18 insertions(+), 450 deletions(-) delete mode 100644 infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java delete mode 100644 infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java delete mode 100644 infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java delete mode 100644 infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java delete mode 100644 infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java (limited to 'infra/minimal-distribution-core') diff --git a/infra/minimal-distribution-core/pom.xml b/infra/minimal-distribution-core/pom.xml index 4c395eda6..646d93ff3 100644 --- a/infra/minimal-distribution-core/pom.xml +++ b/infra/minimal-distribution-core/pom.xml @@ -33,9 +33,6 @@ 2.5 - 1.19.1 - 3.1.0 - 5.0.0 @@ -67,11 +64,6 @@ org.opendaylight.controller sal-core-api - - - org.opendaylight.netconf - sal-rest-connector - org.opendaylight.netconf @@ -101,41 +93,8 @@ org.opendaylight.netconf ietf-netconf-monitoring-extension - - - org.eclipse.jetty - jetty-server - - - javax.servlet - javax.servlet-api - ${servlet.version} - - - org.eclipse.jetty - jetty-webapp - ${jetty.version} - - - org.eclipse.jetty - jetty-servlets - ${jetty.version} - - - com.sun.jersey - jersey-server - ${jersey.version} - - - com.sun.jersey - jersey-core - ${jersey.version} - - - com.sun.jersey - jersey-servlet - ${jersey.version} - + + org.osgi diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModuleProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModuleProvider.java index d31024ce9..a373bf636 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModuleProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModuleProvider.java @@ -20,6 +20,8 @@ import com.google.common.collect.ImmutableList; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.Provider; +import io.fd.honeycomb.infra.distro.schema.ResourceLoader; + import java.io.File; import java.io.IOException; import java.net.URI; @@ -27,7 +29,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -40,7 +42,7 @@ import org.slf4j.LoggerFactory; /** * Provides list of active modules for distribution */ -class ActiveModuleProvider implements Provider { +public class ActiveModuleProvider implements Provider, ResourceLoader { private static final Logger LOG = LoggerFactory.getLogger(ActiveModuleProvider.class); @@ -50,7 +52,7 @@ class ActiveModuleProvider implements Provider { @Override public ActiveModules get() { return new ActiveModules(loadActiveModules( - aggregateResources(config.getModulesResourcePath(), Thread.currentThread().getContextClassLoader()))); + aggregateResources(config.getModulesResourcePath()))); } /** @@ -77,20 +79,10 @@ class ActiveModuleProvider implements Provider { /** * Aggregate all resources from provided relative path into a {@code List} */ - public static List aggregateResources(final String relativePath, final ClassLoader classLoader) { - try { - return Collections.list(classLoader.getResources(relativePath)).stream() - .map(ActiveModuleProvider::toURI) - .flatMap(ActiveModuleProvider::folderToFile) - .map(File::toURI) - .map(Paths::get) - // readAll lines and add them to iteration - .flatMap(ActiveModuleProvider::readLines) - .collect(Collectors.toList()); - } catch (IOException e) { - LOG.error("Unable to load resources from relative path {}", relativePath, e); - throw new IllegalStateException("Unable to load resources from relative path " + relativePath, e); - } + public List aggregateResources(final String relativePath) { + // must use universal approach of loading from folder/jar + // because of memory footprint benchmark + return new ArrayList<>(loadResourceContentsOnPath(relativePath)); } private static Stream folderToFile(final URI uri) { diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java index f7d5ca52a..392248771 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java @@ -31,18 +31,6 @@ import net.jmob.guice.conf.core.Syntax; @BindConfig(value = "honeycomb", syntax = Syntax.JSON) public class HoneycombConfiguration { - public boolean isRestconfHttpEnabled() { - return Boolean.valueOf(restconfHttp); - } - - public boolean isRestconfHttpsEnabled() { - return Boolean.valueOf(restconfHttps); - } - - public boolean isRestconfEnabled() { - return isRestconfHttpEnabled() || isRestconfHttpsEnabled(); - } - public boolean isNetconfTcpEnabled() { return Boolean.valueOf(netconfTcp); } @@ -76,52 +64,7 @@ public class HoneycombConfiguration { public String persistedConfigRestorationType; @InjectConfig("notification-service-queue-depth") public int notificationServiceQueueDepth; - @InjectConfig("restconf-http-enabled") - public String restconfHttp; - @InjectConfig("restconf-binding-address") - public Optional restconfBindingAddress; - @InjectConfig("restconf-port") - public Optional restconfPort; - @InjectConfig("restconf-https-enabled") - public String restconfHttps; - @InjectConfig("restconf-https-binding-address") - public Optional restconfHttpsBindingAddress; - @InjectConfig("restconf-https-port") - public Optional restconfHttpsPort; - /** - * Restconf keystore file name. It will be loaded from the classpath so must be present in one of the folders - * packaged with the distribution e.g. cert/ - */ - @InjectConfig("restconf-keystore") - public Optional restconfKeystore = Optional.of("/honeycomb-keystore"); - @InjectConfig("restconf-keystore-password") - public Optional keystorePassword; - @InjectConfig("restconf-keystore-manager-password") - public Optional keystoreManagerPassword; - /** - * Restconf truststore file name. It will be loaded from the classpath so must be present in one of the folders - * packaged with the distribution e.g. cert/ - */ - @InjectConfig("restconf-truststore") - public Optional restconfTruststore; - @InjectConfig("restconf-truststore-password") - public Optional truststorePassword; - @InjectConfig("restconf-websocket-port") - public Optional restconfWebsocketPort = Optional.of(7779); - @InjectConfig("restconf-root-path") - public Optional restconfRootPath = Optional.of("/restconf"); - @InjectConfig("restconf-pool-max-size") - public Optional restPoolMaxSize = Optional.of(10); - @InjectConfig("restconf-pool-min-size") - public Optional restPoolMinSize = Optional.of(1); - @InjectConfig("restconf-acceptors-size") - public Optional acceptorsSize = Optional.of(1); - @InjectConfig("restconf-selectors-size") - public Optional selectorsSize = Optional.of(1); - @InjectConfig("restconf-https-acceptors-size") - public Optional httpsAcceptorsSize = Optional.of(1); - @InjectConfig("restconf-https-selectors-size") - public Optional httpsSelectorsSize = Optional.of(1); + @InjectConfig("netconf-netty-threads") public Integer netconfNettyThreads; @InjectConfig("netconf-tcp-enabled") @@ -147,25 +90,6 @@ public class HoneycombConfiguration { .add("peristConfigPath", peristConfigPath) .add("persistedConfigRestorationType", persistedConfigRestorationType) .add("notificationServiceQueueDepth", notificationServiceQueueDepth) - .add("restconfHttp", restconfHttp) - .add("restconfBindingAddress", restconfBindingAddress) - .add("restconfPort", restconfPort) - .add("restconfHttps", restconfHttps) - .add("restconfHttpsBindingAddress", restconfHttpsBindingAddress) - .add("restconfHttpsPort", restconfHttpsPort) - .add("restconfKeystore", restconfKeystore) - .add("keystorePassword", keystorePassword) - .add("keystoreManagerPassword", keystoreManagerPassword) - .add("restconfTruststore", restconfTruststore) - .add("truststorePassword", truststorePassword) - .add("restconfWebsocketPort", restconfWebsocketPort) - .add("restconfRootPath", restconfRootPath) - .add("restPoolMaxSize", restPoolMaxSize) - .add("restPoolMinSize", restPoolMinSize) - .add("acceptorsSize", acceptorsSize) - .add("selectorsSize", selectorsSize) - .add("httpsAcceptorsSize", httpsAcceptorsSize) - .add("httpsSelectorsSize", httpsSelectorsSize) .add("netconfNettyThreads", netconfNettyThreads) .add("netconfTcp", netconfTcp) .add("netconfTcpBindingAddress", netconfTcpBindingAddress) diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java deleted file mode 100644 index 678791c63..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.infra.distro.restconf; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; - -final class HttpConnectorProvider extends ProviderTrait { - - @Inject - private HoneycombConfiguration cfg; - @Inject - private Server server; - - @Override - protected ServerConnector create() { - ServerConnector httpConnector = - new ServerConnector(server, cfg.acceptorsSize.get(), cfg.selectorsSize.get()); - httpConnector.setHost(cfg.restconfBindingAddress.get()); - httpConnector.setPort(cfg.restconfPort.get()); - server.addConnector(httpConnector); - return httpConnector; - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java deleted file mode 100644 index 3387c0f3b..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.infra.distro.restconf; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import java.net.URL; -import org.eclipse.jetty.http.HttpVersion; -import org.eclipse.jetty.server.HttpConnectionFactory; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.SslConnectionFactory; -import org.eclipse.jetty.util.ssl.SslContextFactory; - -final class HttpsConnectorProvider extends ProviderTrait { - - @Inject - private HoneycombConfiguration cfg; - @Inject - private Server server; - - @Override - protected ServerConnector create() { - // SSL Context Factory - // Based on: - // https://github.com/eclipse/jetty.project/blob/jetty-9.3.x/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java - // https://wiki.eclipse.org/Jetty/Howto/Configure_SSL#Loading_Keys_and_Certificates_via_PKCS12 - // Keystore created with: - // openssl genrsa -des3 -out honeycomb.key - // openssl req -new -x509 -key honeycomb.key -out honeycomb.crt - // openssl pkcs12 -inkey honeycomb.key -in honeycomb.crt -export -out honeycomb.pkcs12 - // keytool -importkeystore -srckeystore honeycomb.pkcs12 -srcstoretype PKCS12 -destkeystore honeycomb-keystore - SslContextFactory sslContextFactory = new SslContextFactory(); - URL keystoreURL = getClass().getResource(cfg.restconfKeystore.get()); - sslContextFactory.setKeyStorePath(keystoreURL.getPath()); - sslContextFactory.setKeyStorePassword(cfg.keystorePassword.get()); - sslContextFactory.setKeyManagerPassword((cfg.keystoreManagerPassword.get())); - URL truststoreURL = getClass().getResource(cfg.restconfTruststore.get()); - sslContextFactory.setTrustStorePath(truststoreURL.getPath()); - sslContextFactory.setTrustStorePassword((cfg.truststorePassword.get())); - // TODO HONEYCOMB-167 make this more configurable - sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", - "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", - "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"); - - // SSL Connector - ServerConnector sslConnector = - new ServerConnector(server, cfg.httpsAcceptorsSize.get(), cfg.httpsSelectorsSize.get(), - // The ssl connection factory delegates the real processing to http connection factory - new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), - // That's why http connection factory is also required here - // Order is IMPORTANT here - new HttpConnectionFactory() - ); - sslConnector.setHost(cfg.restconfHttpsBindingAddress.get()); - sslConnector.setPort(cfg.restconfHttpsPort.get()); - server.addConnector(sslConnector); - return sslConnector; - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java deleted file mode 100644 index e596b276d..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.infra.distro.restconf; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import io.fd.honeycomb.northbound.CredentialsConfiguration; -import java.net.URL; -import java.util.Collections; -import org.eclipse.jetty.security.ConstraintMapping; -import org.eclipse.jetty.security.ConstraintSecurityHandler; -import org.eclipse.jetty.security.HashLoginService; -import org.eclipse.jetty.security.authentication.BasicAuthenticator; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.gzip.GzipHandler; -import org.eclipse.jetty.util.security.Constraint; -import org.eclipse.jetty.util.security.Password; -import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.eclipse.jetty.webapp.WebAppContext; - -final class JettyServerProvider extends ProviderTrait { - - private static final String REALM = "HCRealm"; - // Mime types to be compressed when requested - private static final String[] GZIP_MIME_TYPES = {"application/xml", - "xml", - "application/yang.data+xml", - "application/json", - "application/yang.data+json"}; - - @Inject - private HoneycombConfiguration cfg; - - @Inject - private CredentialsConfiguration credentialsCfg; - - @Override - protected Server create() { - Server server = new Server(new QueuedThreadPool(cfg.restPoolMaxSize.get(), cfg.restPoolMinSize.get())); - - // Load Realm for basic auth - HashLoginService service = new HashLoginService(REALM); - // Reusing the name as role - service.putUser(credentialsCfg.username, new Password(credentialsCfg.password), - new String[]{credentialsCfg.username}); - server.addBean(service); - - final URL resource = getClass().getResource("/"); - WebAppContext webapp = new WebAppContext(resource.getPath(), cfg.restconfRootPath.get()); - - server.setHandler(getGzip(service, webapp)); - return server; - } - - private GzipHandler getGzip(final HashLoginService service, final WebAppContext webapp) { - final GzipHandler gzipHandler = new GzipHandler(); - gzipHandler.setIncludedMimeTypes(GZIP_MIME_TYPES); - gzipHandler.setHandler(getBaseAuth(service, webapp)); - return gzipHandler; - } - - private ConstraintSecurityHandler getBaseAuth(HashLoginService service, WebAppContext webapp) { - Constraint constraint = new Constraint(); - constraint.setName("auth"); - constraint.setAuthenticate(true); - constraint.setRoles(new String[]{credentialsCfg.username}); - - ConstraintMapping mapping = new ConstraintMapping(); - mapping.setPathSpec("/*"); - mapping.setConstraint(constraint); - - ConstraintSecurityHandler security = new ConstraintSecurityHandler(); - security.setConstraintMappings(Collections.singletonList(mapping)); - security.setAuthenticator(new BasicAuthenticator()); - security.setLoginService(service); - - security.setHandler(webapp); - return security; - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java deleted file mode 100644 index 7799d7fde..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.infra.distro.restconf; - -import com.google.inject.AbstractModule; -import com.google.inject.Singleton; -import com.google.inject.name.Names; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.opendaylight.netconf.sal.rest.api.RestConnector; - -public class RestconfModule extends AbstractModule { - - public static final String RESTCONF_HTTP = "restconf-http"; - public static final String RESTCONF_HTTPS = "restconf-https"; - - protected void configure() { - bind(Server.class).toProvider(JettyServerProvider.class).in(Singleton.class); - bind(ServerConnector.class).annotatedWith(Names.named(RESTCONF_HTTP)).toProvider(HttpConnectorProvider.class) - .in(Singleton.class); - bind(ServerConnector.class).annotatedWith(Names.named(RESTCONF_HTTPS)).toProvider(HttpsConnectorProvider.class) - .in(Singleton.class); - bind(RestConnector.class).toProvider(RestconfProvider.class).in(Singleton.class); - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java deleted file mode 100644 index 01f177e27..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.infra.distro.restconf; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import org.opendaylight.controller.sal.core.api.Broker; -import org.opendaylight.netconf.sal.rest.api.RestConnector; -import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; - -final class RestconfProvider extends ProviderTrait { - - @Inject - private HoneycombConfiguration cfg; - @Inject - private Broker domBroker; - - @Override - protected RestconfProviderImpl create() { - RestconfProviderImpl instance = new RestconfProviderImpl(); - instance.setWebsocketPort(new PortNumber(cfg.restconfWebsocketPort.get())); - domBroker.registerProvider(instance); - return instance; - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ResourceLoader.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ResourceLoader.java index c851dab1b..60aaaae6b 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ResourceLoader.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ResourceLoader.java @@ -17,6 +17,7 @@ package io.fd.honeycomb.infra.distro.schema; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import static java.lang.String.format; import com.google.common.base.Charsets; @@ -38,11 +39,14 @@ import java.util.jar.JarFile; import java.util.stream.Collectors; import org.apache.commons.io.IOUtils; -interface ResourceLoader { +/** + * Allows loading content of X amount of files from filesystem or archive + */ +public interface ResourceLoader { default Set loadResourceContentsOnPath(final String path) { final URL folderUrl = getClass().getClassLoader().getResource(path); - checkNotNull(folderUrl, "Resources %s not found", path); + checkState(folderUrl != null, "Resources %s not found", path); if (ResourceLoaderIml.urlToUri(folderUrl).getScheme().equals("jar")) { return ResourceLoaderIml.readFromJar(path, folderUrl); diff --git a/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json b/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json index a5a18bd6d..ab934db5a 100644 --- a/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json +++ b/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json @@ -8,26 +8,6 @@ "notification-service-queue-depth": 1, - "restconf-http-enabled": "true", - "restconf-root-path": "/restconf", - "restconf-binding-address": "127.0.0.1", - "restconf-port": 8183, - "restconf-https-enabled": "true", - "restconf-https-binding-address": "0.0.0.0", - "restconf-https-port": 8445, - "restconf-keystore": "/honeycomb-keystore", - "restconf-keystore-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", - "restconf-keystore-manager-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", - "restconf-truststore": "/honeycomb-keystore", - "restconf-truststore-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", - "restconf-websocket-port": 7779, - "restconf-pool-max-size": 10, - "restconf-pool-min-size": 1, - "restconf-acceptors-size": 1, - "restconf-selectors-size": 1, - "restconf-https-acceptors-size": 1, - "restconf-https-selectors-size": 1, - "netconf-netty-threads": 2, "netconf-tcp-enabled" : "true", "netconf-tcp-binding-address": "127.0.0.1", -- cgit 1.2.3-korg