diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java index 7c80ff861f..4a6e40205c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java @@ -29,11 +29,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.cloudstack.CloudStackContext; -import org.jclouds.cloudstack.CloudStackDomainAsyncClient; -import org.jclouds.cloudstack.CloudStackDomainClient; +import org.jclouds.cloudstack.*; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Template; import org.jclouds.cloudstack.domain.User; @@ -78,6 +74,8 @@ import com.google.inject.Module; public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { protected String domainAdminIdentity; protected String domainAdminCredential; + protected String globalAdminIdentity; + protected String globalAdminCredential; public BaseCloudStackClientLiveTest() { provider = "cloudstack"; @@ -88,9 +86,11 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { super.setupCredentials(); domainAdminIdentity = emptyToNull(System.getProperty("test." + provider + ".domainAdminIdentity")); domainAdminCredential = emptyToNull(System.getProperty("test." + provider + ".domainAdminCredential")); + globalAdminIdentity = emptyToNull(System.getProperty("test." + provider + ".globalAdminIdentity")); + globalAdminCredential = emptyToNull(System.getProperty("test." + provider + ".globalAdminCredential")); } - protected Properties setupAdminProperties() { + protected Properties setupDomainAdminProperties() { if (domainAdminIdentity != null && domainAdminCredential != null) { Properties overrides = setupProperties(); overrides.setProperty(provider + ".identity", domainAdminIdentity); @@ -101,6 +101,17 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { } } + protected Properties setupGlobalAdminProperties() { + if (globalAdminIdentity != null && globalAdminCredential != null) { + Properties overrides = setupProperties(); + overrides.setProperty(provider + ".identity", globalAdminIdentity); + overrides.setProperty(provider + ".credential", globalAdminCredential); + return overrides; + } else { + return null; + } + } + public static long defaultTemplateOrPreferredInZone(Long defaultTemplate, CloudStackClient client, long zoneId) { long templateId = defaultTemplate != null ? defaultTemplate : getTemplateForZone(client, zoneId); return templateId; @@ -157,6 +168,12 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { protected CloudStackClient domainAdminClient; protected User domainAdminUser; + protected boolean globalAdminEnabled; + protected CloudStackContext globalAdminComputeContext; + protected RestContext globalAdminContext; + protected CloudStackGlobalClient globalAdminClient; + protected User globalAdminUser; + protected void checkSSH(IPSocket socket) { socketTester.apply(socket); SshClient client = sshFactory.create(socket, new Credentials("root", password)); @@ -183,18 +200,28 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { client = context.getApi(); user = verifyCurrentUserIsOfType(context, Account.Type.USER); - domainAdminEnabled = setupAdminProperties() != null; - + domainAdminEnabled = setupDomainAdminProperties() != null; if (domainAdminEnabled) { domainAdminComputeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()). createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), setupAdminProperties())); + new Log4JLoggingModule(), new SshjSshClientModule()), setupDomainAdminProperties())); domainAdminContext = domainAdminComputeContext.getDomainContext(); domainAdminClient = domainAdminContext.getApi(); domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN); adminClient = domainAdminContext.getApi(); } + globalAdminEnabled = setupDomainAdminProperties() != null; + if (globalAdminEnabled) { + globalAdminComputeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()). + createContext(provider, ImmutableSet. of( + new Log4JLoggingModule(), new SshjSshClientModule()), setupGlobalAdminProperties())); + globalAdminContext = globalAdminComputeContext.getGlobalContext(); + globalAdminClient = globalAdminContext.getApi(); + globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN); + adminClient = globalAdminContext.getApi(); + } + injector = Guice.createInjector(new SshjSshClientModule(), new Log4JLoggingModule()); sshFactory = injector.getInstance(SshClient.Factory.class); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 180, 1, 1, TimeUnit.SECONDS);