Examples of CloudStackClient


Examples of com.cloud.stack.CloudStackClient

    // remember to replace with a valid key-pair in test
    private final static String API_KEY = "kVMfr1iE0KlKKOUPD-H4GburZHo4KLxIczbl5CM_ilcKFXkmsIfZjWIkCY5QpuKpDvu-DyFud44VfVvXmPKMkw";
    private final static String SECRET_KEY = "a5Y0ysvVHZ0cuffaV26wRm_vvsV5VQldRq9udC21AE8Kwsk0JG8-pz6YSp3bbc3rC0kK5q3_B9QBBzjHafVicw";

    public void testCall() {
      CloudStackClient client = new CloudStackClient("192.168.130.22", 8080, false);

    CloudStackCommand command = new CloudStackCommand("startVirtualMachine");
    command.setParam("id", "246446");
    try {
      CloudStackUserVm vm = client.call(command, API_KEY, SECRET_KEY, true, "startvirtualmachineresponse", "virtualmachine", CloudStackUserVm.class);
      Assert.assertTrue(vm.getId() == "246446");
    } catch(Exception e) {
      logger.error("Unexpected exception ", e);
    }
    }
View Full Code Here

Examples of com.cloud.stack.CloudStackClient

      logger.error("Unexpected exception ", e);
    }
    }

    public void testListCall() {
      CloudStackClient client = new CloudStackClient("192.168.130.22", 8080, false);
     
    CloudStackCommand command = new CloudStackCommand("listVirtualMachines");
    command.setParam("domainid", "1");
    command.setParam("account", "admin");
    command.setParam("page", "1");
    command.setParam("pagesize", "20");
    try {
      List<CloudStackUserVm> vms = client.listCall(command, API_KEY, SECRET_KEY,
        "listvirtualmachinesresponse", "virtualmachine", new TypeToken<List<CloudStackUserVm>>() {}.getType());

      for(CloudStackUserVm vm : vms) {
        logger.info("id: " + vm.getId() + ", name: " + vm.getName());
      }
View Full Code Here

Examples of com.cloud.stack.CloudStackClient

    // remember to replace with a valid key-pair in test
    private final static String API_KEY = "kVMfr1iE0KlKKOUPD-H4GburZHo4KLxIczbl5CM_ilcKFXkmsIfZjWIkCY5QpuKpDvu-DyFud44VfVvXmPKMkw";
    private final static String SECRET_KEY = "a5Y0ysvVHZ0cuffaV26wRm_vvsV5VQldRq9udC21AE8Kwsk0JG8-pz6YSp3bbc3rC0kK5q3_B9QBBzjHafVicw";

    public void testCall() {
        CloudStackClient client = new CloudStackClient("192.168.130.22", 8080, false);

        CloudStackCommand command = new CloudStackCommand("startVirtualMachine");
        command.setParam("id", "246446");
        try {
            CloudStackUserVm vm = client.call(command, API_KEY, SECRET_KEY, true, "startvirtualmachineresponse", "virtualmachine", CloudStackUserVm.class);
            Assert.assertTrue(vm.getId() == "246446");
        } catch (Exception e) {
            logger.error("Unexpected exception ", e);
        }
    }
View Full Code Here

Examples of com.cloud.stack.CloudStackClient

            logger.error("Unexpected exception ", e);
        }
    }

    public void testListCall() {
        CloudStackClient client = new CloudStackClient("192.168.130.22", 8080, false);

        CloudStackCommand command = new CloudStackCommand("listVirtualMachines");
        command.setParam("domainid", "1");
        command.setParam("account", "admin");
        command.setParam("page", "1");
        command.setParam("pagesize", "20");
        try {
            List<CloudStackUserVm> vms =
                client.listCall(command, API_KEY, SECRET_KEY, "listvirtualmachinesresponse", "virtualmachine", new TypeToken<List<CloudStackUserVm>>() {
                }.getType());

            for (CloudStackUserVm vm : vms) {
                logger.info("id: " + vm.getId() + ", name: " + vm.getName());
            }
View Full Code Here

Examples of com.cloud.stack.CloudStackClient

    // remember to replace with a valid key-pair in test
    private final static String API_KEY = "kVMfr1iE0KlKKOUPD-H4GburZHo4KLxIczbl5CM_ilcKFXkmsIfZjWIkCY5QpuKpDvu-DyFud44VfVvXmPKMkw";
    private final static String SECRET_KEY = "a5Y0ysvVHZ0cuffaV26wRm_vvsV5VQldRq9udC21AE8Kwsk0JG8-pz6YSp3bbc3rC0kK5q3_B9QBBzjHafVicw";

    public void testCall() {
      CloudStackClient client = new CloudStackClient("192.168.130.22", 8080, false);

    CloudStackCommand command = new CloudStackCommand("startVirtualMachine");
    command.setParam("id", "246446");
    try {
      CloudStackUserVm vm = client.call(command, API_KEY, SECRET_KEY, true, "startvirtualmachineresponse", "virtualmachine", CloudStackUserVm.class);
//      Assert.assertTrue(vm.getId() == 246446);
    } catch(Exception e) {
      logger.error("Unexpected exception ", e);
    }
    }
View Full Code Here

Examples of com.cloud.stack.CloudStackClient

      logger.error("Unexpected exception ", e);
    }
    }

    public void testListCall() {
      CloudStackClient client = new CloudStackClient("192.168.130.22", 8080, false);
     
    CloudStackCommand command = new CloudStackCommand("listVirtualMachines");
    command.setParam("domainid", "1");
    command.setParam("account", "admin");
    command.setParam("page", "1");
    command.setParam("pagesize", "20");
    try {
      List<CloudStackUserVm> vms = client.listCall(command, API_KEY, SECRET_KEY,
        "listvirtualmachinesresponse", "virtualmachine", new TypeToken<List<CloudStackUserVm>>() {}.getType());

      for(CloudStackUserVm vm : vms) {
        logger.info("id: " + vm.getId() + ", name: " + vm.getName());
      }
View Full Code Here

Examples of org.jclouds.cloudstack.CloudStackClient

   }

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

      CloudStackClient client = context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi();
      Set<Account> accounts = client.getAccountClient().listAccounts();

      assert accounts.size() > 0;

      context.close();
   }
View Full Code Here

Examples of org.jclouds.cloudstack.CloudStackClient

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

   @Test
   public void testLoad() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();

      expect(zoneClient.getZone("zone-1")).andReturn(zone);
      expect(secClient.getSecurityGroupByName("group-1")).andReturn(null);
      expect(secClient.createSecurityGroup("group-1")).andReturn(group);
      expect(secClient.authorizeIngressPortsToCIDRs("sec-1234",
View Full Code Here

Examples of org.jclouds.cloudstack.CloudStackClient

   }

  
   @Test
   public void testLoadAlreadyExists() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getId()).andReturn("sec-1234").anyTimes();
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();

      expect(secClient.getSecurityGroupByName("group-1")).andReturn(group);

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

Examples of org.jclouds.cloudstack.CloudStackClient

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

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testLoadZoneNoSecurityGroups() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(zone.isSecurityGroupsEnabled()).andReturn(false);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();

      expect(zoneClient.getZone("zone-1")).andReturn(zone);
      expect(secClient.getSecurityGroupByName("group-1")).andReturn(null);

      replay(client, secClient, zoneClient, zone, group);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.