Package org.jclouds.cloudstack

Examples of org.jclouds.cloudstack.CloudStackApi


      verify(client, secClient, zoneClient, zone, group);
   }

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testApplyZoneNoSecurityGroups() throws UnknownHostException {
      final CloudStackApi client = createMock(CloudStackApi.class);
      SecurityGroupApi secClient = createMock(SecurityGroupApi.class);
      ZoneApi zoneClient = createMock(ZoneApi.class);
      AsyncJobApi jobClient = createMock(AsyncJobApi.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(zone.isSecurityGroupsEnabled()).andReturn(false);
     
      expect(client.getZoneApi()).andReturn(zoneClient);

      expect(zoneClient.getZone("zone-abc3")).andReturn(zone);

      replay(client, zoneClient, zone);
View Full Code Here


         context =  ContextBuilder.newBuilder(new CloudStackApiMetadata())
               .endpoint(checkNotNull(endpoint, "endpoint").toASCIIString())
               .credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password)
               .overrides(overrides).build(CloudStackContext.class);

         CloudStackApi client = context.getApi();
         Set<Account> listOfAccounts = client.getAccountApi().listAccounts();

         domain = (domain.equals("") || domain.equals("/")) ? "ROOT" : domain;
         for (Account account : listOfAccounts) {
            for (User user : account.getUsers()) {
               if (user.getName().equals(username) && user.getDomain().equals(domain)) {
View Full Code Here

   @BeforeClass(groups = { "integration", "live" })
   public void setupContext() {
      super.setupContext();

      CloudStackApi api = view.unwrapApi(CloudStackApi.class);
      for (Zone z : api.getZoneApi().listZones()) {
         if (z.isSecurityGroupsEnabled()) {
            zone = z;
            break;
         }
      }
View Full Code Here

@Test(groups = "unit", testName = "CreateUniqueKeyPairTest")
public class CreateUniqueKeyPairTest {

   @Test
   public void testLoad() throws UnknownHostException {
      final CloudStackApi client = createMock(CloudStackApi.class);
      SSHKeyPairApi keyClient = createMock(SSHKeyPairApi.class);

      SshKeyPair pair = createMock(SshKeyPair.class);

      expect(client.getSSHKeyPairApi()).andReturn(keyClient);
      expect(keyClient.createSSHKeyPair("group-1")).andReturn(pair);

      replay(client, keyClient);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here

   public void testApply() {
      String id = "1";
      String jobId = "2";

      CloudStackApi client = createMock(CloudStackApi.class);
      Predicate<String> jobComplete = Predicates.alwaysTrue();
      AsyncJobApi jobClient = createMock(AsyncJobApi.class);

      expect(client.getAsyncJobApi()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(AsyncJob.builder().id(jobId).result("foo").build()).atLeastOnce();

      replay(client);
      replay(jobClient);
View Full Code Here

   @Test(expectedExceptions = IllegalStateException.class)
   public void testJobDoesntCompleteThrowsIllegalStateException() {
      String id = "1";
      String jobId = "2";

      CloudStackApi client = createMock(CloudStackApi.class);
      // the alwaysfalse predicate should blow up with IllegalStateException
      Predicate<String> jobComplete = Predicates.alwaysFalse();
      AsyncJobApi jobClient = createMock(AsyncJobApi.class);

      expect(client.getAsyncJobApi()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(AsyncJob.builder().id(jobId).result("foo").build()).atLeastOnce();

      replay(client);
      replay(jobClient);
View Full Code Here

   @Test(expectedExceptions = UncheckedExecutionException.class)
   public void testJobWithErrorThrowsUncheckedExecutionException() {
      String id = "1";
      String jobId = "2";

      CloudStackApi client = createMock(CloudStackApi.class);
      Predicate<String> jobComplete = Predicates.alwaysTrue();
      AsyncJobApi jobClient = createMock(AsyncJobApi.class);

      expect(client.getAsyncJobApi()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(
            AsyncJob.builder().id(jobId)
                  .error(AsyncJobError.builder().errorCode(ErrorCode.INTERNAL_ERROR).errorText("ERRROR").build())
                  .result("foo").build())
            .atLeastOnce();
View Full Code Here

         .associatedNetworkId(networkId).zoneId(zoneId).build();

   public void testReuseWorks() throws SecurityException, NoSuchMethodException {

      // create mocks
      CloudStackApi client = createMock(CloudStackApi.class);
      BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult = createMock(BlockUntilJobCompletesAndReturnResult.class);
      AddressApi addressClient = createMock(AddressApi.class);
      expect(client.getAddressApi()).andReturn(addressClient).atLeastOnce();

      // an address is available
      expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
            ImmutableSet.<PublicIPAddress> of(address));
View Full Code Here

   }

   public void testAssociateWorks() throws SecurityException, NoSuchMethodException {

      // create mocks
      CloudStackApi client = createMock(CloudStackApi.class);
      BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult = createMock(BlockUntilJobCompletesAndReturnResult.class);
      AddressApi addressClient = createMock(AddressApi.class);
      expect(client.getAddressApi()).andReturn(addressClient).atLeastOnce();

      // no ip addresses available
      expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
            ImmutableSet.<PublicIPAddress> of());
View Full Code Here

   }

   private void checkAuthAsUser(ApiKeyPair keyPair) {
      CloudStackContext context = createView(credentialsAsProperties(keyPair), setupModules());

      CloudStackApi client = context.getApi();
      Set<Account> accounts = client.getAccountApi().listAccounts();

      assert !accounts.isEmpty();

      context.close();
   }
View Full Code Here

TOP

Related Classes of org.jclouds.cloudstack.CloudStackApi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.