bugfix for heatbridge keystone v3 not returning any resources 44/84244/2
authorMunir Ahmad <munir.ahmad@bell.ca>
Thu, 4 Apr 2019 13:42:37 +0000 (09:42 -0400)
committerMarcus Williams <marcus.williams@intel.com>
Thu, 4 Apr 2019 20:25:18 +0000 (20:25 +0000)
Issue-ID: SO-1484

Change-Id: Ic1341e94086470c59aab324a3ea16e4e7e086d38
Signed-off-by: Munir Ahmad <munir.ahmad@bell.ca>
adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java

index 72b3795..141dd4f 100644 (file)
@@ -25,6 +25,7 @@ import org.openstack4j.api.OSClient.OSClientV2;
 import org.openstack4j.api.OSClient.OSClientV3;
 import org.openstack4j.api.exceptions.AuthenticationException;
 import org.openstack4j.openstack.OSFactory;
+import org.openstack4j.model.common.Identifier;
 
 public class OpenstackClientFactoryImpl implements OpenstackClientFactory {
 
@@ -35,12 +36,14 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory {
         Preconditions.checkNotNull(osAccess.getPassword(), "Keystone-v3 Auth: password not set.");
         Preconditions.checkNotNull(osAccess.getDomainNameIdentifier(), "Keystone-v3 Auth: domain not set.");
         Preconditions.checkNotNull(osAccess.getRegion(), "Keystone-v3 Auth: region not set.");
+        Preconditions.checkNotNull(osAccess.getTenantId(), "Keystone-v3 Auth: tenant-id not set.");
 
         OSClientV3 client;
         try {
             client = OSFactory.builderV3()
                 .endpoint(osAccess.getUrl())
                 .credentials(osAccess.getUser(), osAccess.getPassword(), osAccess.getDomainNameIdentifier())
+                .scopeToProject(Identifier.byId(osAccess.getTenantId()))
                 .authenticate()
                 .useRegion(osAccess.getRegion());
             return new OpenstackV3ClientImpl(client);
@@ -54,7 +57,7 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory {
         Preconditions.checkNotNull(osAccess.getUrl(), "Keystone-v2 Auth: endpoint not set.");
         Preconditions.checkNotNull(osAccess.getUser(), "Keystone-v2 Auth: username not set.");
         Preconditions.checkNotNull(osAccess.getPassword(), "Keystone-v2 Auth: password not set.");
-        Preconditions.checkNotNull(osAccess.getTenantId(), "Keystone-v2 Auth: domain not set.");
+        Preconditions.checkNotNull(osAccess.getTenantId(), "Keystone-v2 Auth: tenant-id not set.");
         Preconditions.checkNotNull(osAccess.getRegion(), "Keystone-v2 Auth: region not set.");
 
         OSClientV2 client;