Examples of CloudStackApi


Examples of com.cloud.stack.CloudStackApi

     *
     * @return
     */
    private CloudStackApi getApi() {
        if (_eng == null) {
            _eng = new CloudStackApi(managementServer, cloudAPIPort, false);
        }
        // regardless of whether _eng is initialized, we must make sure
        // access/secret keys are current with what's in the UserCredentials
        _eng.setApiKey(UserContext.current().getAccessKey());
        _eng.setSecretKey(UserContext.current().getSecretKey());
View Full Code Here

Examples of com.cloud.stack.CloudStackApi

            return false;
        }

        // okay, instead of using the getApi() nonsense for validate, we are going to manage _eng
        if (_eng == null) {
            _eng = new CloudStackApi(managementServer, cloudAPIPort, false);
        }

        try {
            oldApiKey = _eng.getApiKey();
            oldSecretKey = _eng.getSecretKey();
View Full Code Here

Examples of com.cloud.stack.CloudStackApi

     *
     * @return
     */
    private CloudStackApi getApi() {
        if (_eng == null) {
            _eng = new CloudStackApi(managementServer, cloudAPIPort, false);
        }
        // regardless of whether _eng is initialized, we must make sure
        // access/secret keys are current with what's in the UserCredentials
        _eng.setApiKey(UserContext.current().getAccessKey());
        _eng.setSecretKey(UserContext.current().getSecretKey());
View Full Code Here

Examples of com.cloud.stack.CloudStackApi

            return false;
        }

        // okay, instead of using the getApi() nonsense for validate, we are going to manage _eng
        if (_eng == null) {
            _eng = new CloudStackApi(managementServer, cloudAPIPort, false);
        }

        try {
            oldApiKey = _eng.getApiKey();
            oldSecretKey = _eng.getSecretKey();
View Full Code Here

Examples of org.jclouds.cloudstack.CloudStackApi

         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

Examples of org.jclouds.cloudstack.CloudStackApi

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

   @Test
   public void testLoad() 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(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupApi()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneApi()).andReturn(zoneClient);
      expect(client.getAsyncJobApi()).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.CloudStackApi

   }

  
   @Test
   public void testLoadAlreadyExists() 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(group.getId()).andReturn("sec-1234").anyTimes();
     
      expect(client.getSecurityGroupApi()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneApi()).andReturn(zoneClient);
      expect(client.getAsyncJobApi()).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.CloudStackApi

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

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testLoadZoneNoSecurityGroups() 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.getSecurityGroupApi()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneApi()).andReturn(zoneClient);
      expect(client.getAsyncJobApi()).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

Examples of org.jclouds.cloudstack.CloudStackApi

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

   @Test
   public void testApply() 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(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupApi()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneApi()).andReturn(zoneClient);
      expect(client.getAsyncJobApi()).andReturn(jobClient).anyTimes();

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

Examples of org.jclouds.cloudstack.CloudStackApi

   }

  
   @Test
   public void testApplyGroupAlreadyExists() 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(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupApi()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneApi()).andReturn(zoneClient);
      expect(client.getAsyncJobApi()).andReturn(jobClient).anyTimes();

      expect(zoneClient.getZone("zone-abc2")).andReturn(zone);
      expect(secClient.createSecurityGroup("group-1")).andThrow(new IllegalStateException());
      expect(secClient.getSecurityGroupByName("group-1")).andReturn(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.