Fixes in ServiceCatalogV2 11/29511/3
authorburdziak <olaf.burdziakowski@nokia.com>
Mon, 29 Jan 2018 12:30:19 +0000 (13:30 +0100)
committerPatrick Brady <pb071s@att.com>
Tue, 30 Jan 2018 18:27:39 +0000 (18:27 +0000)
Change-Id: I8cd58acc8db233f08a10bcb88123c802fa952e87
Issue-ID: APPC-548
Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ServiceCatalogV2.java

index 846eca2..72b0332 100644 (file)
@@ -30,6 +30,8 @@ import com.att.cdp.openstack.util.ExceptionMapper;
 import com.att.cdp.pal.util.Time;\r
 import com.att.cdp.zones.ContextFactory;\r
 import com.att.cdp.zones.spi.RequestState;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import com.woorea.openstack.base.client.OpenStackBaseException;\r
 import com.woorea.openstack.base.client.OpenStackClientConnector;\r
 import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;\r
@@ -41,8 +43,6 @@ import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
 import com.woorea.openstack.keystone.model.Authentication;\r
 import com.woorea.openstack.keystone.model.Tenant;\r
 import com.woorea.openstack.keystone.model.authentication.UsernamePassword;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
 \r
 import java.util.ArrayList;\r
 import java.util.Calendar;\r
@@ -84,7 +84,7 @@ import java.util.regex.Pattern;
  */\r
 public class ServiceCatalogV2 extends ServiceCatalog {\r
 \r
-    private final static Logger logger = LoggerFactory.getLogger(ServiceCatalogV2.class);\r
+    protected static final EELFLogger loggerV2 = EELFManager.getInstance().getLogger(ServiceCatalogV2.class);\r
 \r
     /**\r
      * The Openstack Access object that manages the authenticated token and access control\r
@@ -126,7 +126,7 @@ public class ServiceCatalogV2 extends ServiceCatalog {
             connectorClass = Class.forName(CLIENT_CONNECTOR_CLASS);\r
             connector = (OpenStackClientConnector) connectorClass.newInstance();\r
         } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {\r
-            logger.error(e.getMessage());\r
+            loggerV2.error(e.getMessage());\r
             return;\r
         }\r
         Keystone keystone = new Keystone(identityURL, connector);\r
@@ -252,26 +252,25 @@ public class ServiceCatalogV2 extends ServiceCatalog {
     @Override\r
     public String getVMRegion(VMURL url) {\r
         String region = null;\r
+        if (url == null) {\r
+            return region;\r
+        }\r
+\r
         Pattern urlPattern = Pattern.compile("[^:]+://([^:/]+)(?::([0-9]+)).*");\r
 \r
-        if (url != null) {\r
-            for (Endpoint endpoint : getEndpoints(ServiceCatalog.COMPUTE_SERVICE)) {\r
-                String endpointUrl = endpoint.getPublicURL();\r
-                Matcher matcher = urlPattern.matcher(endpointUrl);\r
-                if (matcher.matches()) {\r
-                    if (url.getHost().equals(matcher.group(1))) {\r
-                        if (url.getPort() != null) {\r
-                            if (!url.getPort().equals(matcher.group(2))) {\r
-                                continue;\r
-                            }\r
-                        }\r
-\r
-                        region = endpoint.getRegion();\r
-                        break;\r
-                    }\r
-                }\r
+        for (Endpoint endpoint : getEndpoints(ServiceCatalog.COMPUTE_SERVICE)) {\r
+            String endpointUrl = endpoint.getPublicURL();\r
+            Matcher matcher = urlPattern.matcher(endpointUrl);\r
+            if (!matcher.matches() ||\r
+                !url.getHost().equals(matcher.group(1)) ||\r
+                (url.getPort() != null && url.getPort().equals(matcher.group(2))) ) {\r
+                continue;\r
             }\r
+\r
+            region = endpoint.getRegion();\r
+            break;\r
         }\r
+\r
         return region;\r
     }\r
 \r