Package org.jclouds.openstack.nova.v2_0.domain.zonescoped

Examples of org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone


   @Test
   public void testApplyWithCidr() {

      NovaSecurityGroupInZoneToSecurityGroup parser = createGroupParser();

      SecurityGroupInZone origGroup = new SecurityGroupInZone(securityGroupWithCidr(), zone.getId());

      SecurityGroup newGroup = parser.apply(origGroup);

      assertEquals(newGroup.getId(), origGroup.getZone() + "/" + origGroup.getSecurityGroup().getId());
      assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId());
      assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName());
      assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId());
      assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getSecurityGroup().getRules(),
              NovaSecurityGroupToSecurityGroupTest.ruleConverter)));
      assertEquals(newGroup.getLocation().getId(), origGroup.getZone());
   }
View Full Code Here


   @Test
   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
View Full Code Here

   }
  
   @Test
   public void testWhenFoundReturnsSecurityGroupFromAtomicReferenceValueUpdatedDuringPredicateCheck() throws Exception {
      final SecurityGroupInZone securityGroupInZone = createMock(SecurityGroupInZone.class);

      Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = new Predicate<AtomicReference<ZoneAndName>>() {

         @Override
         public boolean apply(AtomicReference<ZoneAndName> input) {
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

      CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiWhenSecurityGroupsExist);

      // 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

      // we can find it
      assertTrue(predicate.apply(securityGroupInZoneRef));

      // the reference is now up to date, and includes the actual group found.
      assertEquals(securityGroupInZoneRef.get().toString(), new SecurityGroupInZone(Iterables
               .getOnlyElement(new ParseSecurityGroupListTest().expected()), "az-1.region-a.geo-1").toString());

   }
View Full Code Here

      if (!sgApi.isPresent()) {
         return null;
      }

      SecurityGroupInZone rawGroup = new SecurityGroupInZone(sgApi.get().get(groupId), zone);

      return groupConverter.apply(rawGroup);
   }
View Full Code Here

   public SecurityGroup createSecurityGroup(String name, String zone) {
      String markerGroup = namingConvention.create().sharedNameForGroup(name);
      ZoneSecurityGroupNameAndPorts zoneAndName = new ZoneSecurityGroupNameAndPorts(zone, markerGroup, ImmutableSet.<Integer> of());

      SecurityGroupInZone rawGroup = groupCreator.getUnchecked(zoneAndName);
      return groupConverter.apply(rawGroup);
   }
View Full Code Here

   protected Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInZone> groupToGroupInZone(final String zone) {
      return new Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInZone>() {
         @Override
         public SecurityGroupInZone apply(org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group) {
            return new SecurityGroupInZone(group, zone);
         }
      };
   }
View Full Code Here

         logger.debug("<< created securityGroup(%s)", securityGroup);
         for (int port : zoneSecurityGroupNameAndPorts.getPorts()) {
            authorizeGroupToItselfAndAllIPsToTCPPort(api.get(), securityGroup, port);
         }
         return new SecurityGroupInZone(api.get().get(securityGroup.getId()), zoneId);
      } catch (IllegalStateException e) {
         logger.trace("<< trying to find securityGroup(%s): %s", zoneSecurityGroupNameAndPorts, e.getMessage());
         SecurityGroup group = find(api.get().list(), nameEquals(zoneSecurityGroupNameAndPorts
                  .getName()));
         logger.debug("<< reused securityGroup(%s)", group.getId());
         return new SecurityGroupInZone(group, zoneId);
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone

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.