Package org.jclouds.openstack.nova.v2_0.extensions

Examples of org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi


      Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
      Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
            .of(existingHardware);
      Server serverToConvert = new ParseServerTest().expected();

      ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");

      ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
               NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
                        .<Set<? extends Image>> ofInstance(images), Suppliers
                        .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);

      NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);

      assertEquals(serverInZoneToConvert.slashEncode(), convertedNodeMetadata.getId());
      assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());

      assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.HOST);
      assertEquals(convertedNodeMetadata.getLocation().getId(), "e4d909c290d0fb1ca068ffaddf22cbd0");
View Full Code Here


      Set<Image> images = ImmutableSet.<Image> of();
      Set<Hardware> hardwares = ImmutableSet.<Hardware> of();

      Server serverToConvert = expectedServer();

      ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");

      ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
               NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
                        .<Set<? extends Image>> ofInstance(images), Suppliers
                        .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);

      NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);

      assertEquals(serverInZoneToConvert.slashEncode(), convertedNodeMetadata.getId());
      assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());

      assertEquals(convertedNodeMetadata.getLocation(), zone);

      URI expectedURI = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752");
View Full Code Here

            return true;
         }
        
      };

      ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");

      Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {

         @Override
         public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
View Full Code Here

   @Test(expectedExceptions = IllegalStateException.class)
   public void testWhenFoundPredicateMustUpdateAtomicReference() throws Exception {

      Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysTrue();

      ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");

      Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {

         @Override
         public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
View Full Code Here

   @Test(expectedExceptions = IllegalStateException.class)
   public void testWhenNotFoundInputMustBeZoneSecurityGroupNameAndPorts() throws Exception {
      Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysFalse();

      ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");

      Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {

         @Override
         public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
View Full Code Here

   public void testWhenNotFoundCreatesANewSecurityGroup() throws Exception {
      Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysFalse();

      SecurityGroupInZone securityGroupInZone = createMock(SecurityGroupInZone.class);

      ZoneSecurityGroupNameAndPorts input = new ZoneSecurityGroupNameAndPorts("zone", "groupName", ImmutableSet
               .<Integer> of(22, 8080));

      Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = Functions.forMap(ImmutableMap
               .<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> of(input, securityGroupInZone));
View Full Code Here

      CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiCanCreateSecurityGroup);

      // we can find it
      assertEquals(fn.apply(
               new ZoneSecurityGroupNameAndPorts("az-1.region-a.geo-1", "jclouds_mygroup", ImmutableSet.of(22, 8080)))
               .toString(), new SecurityGroupInZone(new ParseComputeServiceTypicalSecurityGroupTest().expected(),
               "az-1.region-a.geo-1").toString());

   }
View Full Code Here

public class LoadFloatingIpsForInstanceTest {

   @Test
   public void testReturnsPublicIpOnMatch() throws Exception {
      NovaApi api = createMock(NovaApi.class);
      FloatingIPApi ipApi = createMock(FloatingIPApi.class);
      FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();

      expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
      expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(testIp)))
               .atLeastOnce();

      replay(api);
      replay(ipApi);
View Full Code Here

   }

   @Test
   public void testReturnsNullWhenNotFound() throws Exception {
      NovaApi api = createMock(NovaApi.class);
      FloatingIPApi ipApi = createMock(FloatingIPApi.class);

      expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();

      expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of()))
      .atLeastOnce();

      replay(api);
      replay(ipApi);
View Full Code Here

   }

   @Test
   public void testReturnsNullWhenNotAssigned() throws Exception {
      NovaApi api = createMock(NovaApi.class);
      FloatingIPApi ipApi = createMock(FloatingIPApi.class);

      expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();

      expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(FloatingIP.builder().id("1").ip("1.1.1.1").build())))
      .atLeastOnce();

      replay(api);
      replay(ipApi);
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi

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.