Examples of EC2Client


Examples of com.elastisys.scale.cloudadapters.aws.commons.client.Ec2Client

   * @param region
   *            The AWS region that the request will be sent to.
   */
  public AmazonEc2Request(AWSCredentials awsCredentials, String region) {
    super(awsCredentials, region);
    this.client = new Ec2Client(awsCredentials, region);
  }
View Full Code Here

Examples of org.jclouds.aws.ec2.EC2Client

    if (clusterSpec.getProvider().equals("ec2")) {
      // This code (or something like it) may be added to jclouds (see
      // http://code.google.com/p/jclouds/issues/detail?id=336).
      // Until then we need this temporary workaround.
      String region = EC2Utils.parseHandle(Iterables.get(nodes, 0).getId())[0];
      EC2Client ec2Client = EC2Client.class.cast(
          computeServiceContext.getProviderSpecificContext().getApi());
      String groupName = "jclouds#" + clusterSpec.getClusterName();
      for (String cidr : cidrs) {
        for (int port : ports) {
          ec2Client.getSecurityGroupServices()
            .authorizeSecurityGroupIngressInRegion(region, groupName,
                IpProtocol.TCP, port, port, cidr);
        }
      }
    }
View Full Code Here

Examples of org.jclouds.aws.ec2.EC2Client

    if (clusterSpec.getProvider().equals("ec2")) {
      // This code (or something like it) may be added to jclouds (see
      // http://code.google.com/p/jclouds/issues/detail?id=336).
      // Until then we need this temporary workaround.
      String region = EC2Utils.parseHandle(Iterables.get(instances, 0).getId())[0];
      EC2Client ec2Client = EC2Client.class.cast(
          computeServiceContext.getProviderSpecificContext().getApi());
      String groupName = "jclouds#" + clusterSpec.getClusterName() + "#" + region;
      for (String cidr : cidrs) {
        for (int port : ports) {
          ec2Client.getSecurityGroupServices()
            .authorizeSecurityGroupIngressInRegion(region, groupName,
                IpProtocol.TCP, port, port, cidr);
        }
      }
    }
View Full Code Here

Examples of org.jclouds.aws.ec2.EC2Client

    if (clusterSpec.getProvider().equals("ec2")) {
      // This code (or something like it) may be added to jclouds (see
      // http://code.google.com/p/jclouds/issues/detail?id=336).
      // Until then we need this temporary workaround.
      String region = EC2Utils.parseHandle(Iterables.get(nodes, 0).getId())[0];
      EC2Client ec2Client = EC2Client.class.cast(
          computeServiceContext.getProviderSpecificContext().getApi());
      String groupName = "jclouds#" + clusterSpec.getClusterName() + "#" + region;
      for (String cidr : cidrs) {
        for (int port : ports) {
          ec2Client.getSecurityGroupServices()
            .authorizeSecurityGroupIngressInRegion(region, groupName,
                IpProtocol.TCP, port, port, cidr);
        }
      }
    }
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

   @SuppressWarnings("unchecked")
   @Test
   public void testWhenInstancesPresentSingleCall() {

      EC2Client client = createMock(EC2Client.class);
      InstanceClient instanceClient = createMock(InstanceClient.class);

      expect(client.getInstanceServices()).andReturn(instanceClient);

      // avoid imatcher fail.  if you change this, be sure to check multiple jres
      expect(instanceClient.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn(
            Set.class.cast(ImmutableSet.of(Reservation.builder().region("us-east-1")
                  .instances(ImmutableSet.of(instance1, instance2)).build())));
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

public class EC2DestroyNodeStrategyTest {

   @SuppressWarnings("unchecked")
   @Test
   public void testDestroyNodeTerminatesInstanceAndReturnsRefreshedNode() throws Exception {
      EC2Client client = createMock(EC2Client.class);
      InstanceClient instanceClient = createMock(InstanceClient.class);
      GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class);
      LoadingCache<RegionAndName, String> elasticIpCache = createMock(LoadingCache.class);

      NodeMetadata node = createMock(NodeMetadata.class);

      expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce();
      expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null);
      expect(getNode.getNode("region/i-blah")).andReturn(node);

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

Examples of org.jclouds.ec2.EC2Client

   @SuppressWarnings("unchecked")
   @Test
   public void testApply() throws ExecutionException {

      EC2ImageParser parser = createMock(EC2ImageParser.class);
      EC2Client caller = createMock(EC2Client.class);
      AMIClient client = createMock(AMIClient.class);

      org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
      Image image = createNiceMock(Image.class);
      Set<? extends org.jclouds.ec2.domain.Image> images = ImmutableSet.<org.jclouds.ec2.domain.Image> of(ec2Image);

      expect(caller.getAMIServices()).andReturn(client).atLeastOnce();
      expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images));
      expect(parser.apply(ec2Image)).andReturn(image);

      replay(caller);
      replay(image);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

   @SuppressWarnings("unchecked")
   @Test
   public void testDestroyNodeDisassociatesAndReleasesIpThenTerminatesInstanceAndReturnsRefreshedNode()
            throws Exception {
      EC2Client client = createMock(EC2Client.class);
      GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class);
      LoadingCache<RegionAndName, String> elasticIpCache = createMock(LoadingCache.class);
      ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class);
      InstanceClient instanceClient = createMock(InstanceClient.class);

      NodeMetadata node = createMock(NodeMetadata.class);

      expect(elasticIpCache.get(new RegionAndName("region", "i-blah"))).andReturn("1.1.1.1");

      expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce();
      ipClient.disassociateAddressInRegion("region", "1.1.1.1");
      ipClient.releaseAddressInRegion("region", "1.1.1.1");
      elasticIpCache.invalidate(new RegionAndName("region", "i-blah"));


      expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce();
      expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null);
      expect(getNode.getNode("region/i-blah")).andReturn(node);

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

Examples of org.jclouds.ec2.EC2Client

   @SuppressWarnings("unchecked")
   @Test(expectedExceptions = ExecutionException.class)
   public void testApplyNotFoundMakesExecutionException() throws ExecutionException {

      EC2ImageParser parser = createMock(EC2ImageParser.class);
      EC2Client caller = createMock(EC2Client.class);
      AMIClient client = createMock(AMIClient.class);

      org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
      Image image = createNiceMock(Image.class);
      Set<? extends org.jclouds.ec2.domain.Image> images = ImmutableSet.<org.jclouds.ec2.domain.Image> of(ec2Image);

      expect(caller.getAMIServices()).andReturn(client).atLeastOnce();
      expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images));
      expect(parser.apply(ec2Image)).andThrow(new ResourceNotFoundException());

      replay(caller);
      replay(image);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

   @SuppressWarnings("unchecked")
   @Test
   public void testDestroyNodeSafeOnCacheMissThenTerminatesInstanceAndReturnsRefreshedNode()
            throws Exception {
      EC2Client client = createMock(EC2Client.class);
      GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class);
      LoadingCache<RegionAndName, String> elasticIpCache = createMock(LoadingCache.class);
      ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class);
      InstanceClient instanceClient = createMock(InstanceClient.class);

      NodeMetadata node = createMock(NodeMetadata.class);

      expect(elasticIpCache.get(new RegionAndName("region", "i-blah"))).andThrow(new CacheLoader.InvalidCacheLoadException(null));

      expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce();
      expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null);
      expect(getNode.getNode("region/i-blah")).andReturn(node);

      replay(client);
      replay(getNode);
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.