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

Examples of org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion


   public SecurityGroup createSecurityGroup(String name, String region) {
      String markerGroup = namingConvention.create().sharedNameForGroup(name);
      RegionSecurityGroupNameAndPorts regionAndName = new RegionSecurityGroupNameAndPorts(region, markerGroup, ImmutableSet.<Integer> of());

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


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

      builder.toPort(rule.getToPort());
      if (rule.getGroup() != null) {
         String region = getFirst(filter(locationIndex.get().keySet(), isSecurityGroupInRegion(rule.getGroup().getName())),
                 null);
         if (region != null) {
            SecurityGroupInRegion group = groupMap.getUnchecked(RegionAndName.fromRegionAndName(region, rule.getGroup().getName()));
            builder.groupId(region + "/" + group.getSecurityGroup().getId());
         }
      }
      if (rule.getIpRange() != null)
         builder.cidrBlock(rule.getIpRange());
View Full Code Here

            public boolean apply(SecurityGroup input) {
               return input.getName().equals(securityGroupInRegion.getName());
            }

         });
         securityGroupInRegionRef.set(new SecurityGroupInRegion(returnVal, securityGroupInRegion.getRegion()));
         return true;
      } catch (ResourceNotFoundException e) {
         return false;
      } catch (NoSuchElementException e) {
         return false;
View Full Code Here

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

   @Test
   public void testApplyWithGroup() {
      NovaSecurityGroupInRegionToSecurityGroup parser = createGroupParser();

      SecurityGroupInRegion origGroup = new SecurityGroupInRegion(securityGroupWithGroup(), region.getId());

      SecurityGroup newGroup = parser.apply(origGroup);

      assertEquals(newGroup.getId(), origGroup.getRegion() + "/" + 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.getRegion());
   }
View Full Code Here

   @Test
   public void testApplyWithCidr() {

      NovaSecurityGroupInRegionToSecurityGroup parser = createGroupParser();

      SecurityGroupInRegion origGroup = new SecurityGroupInRegion(securityGroupWithCidr(), region.getId());

      SecurityGroup newGroup = parser.apply(origGroup);

      assertEquals(newGroup.getId(), origGroup.getRegion() + "/" + 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.getRegion());
   }
View Full Code Here

   @Test
   public void testWhenNotFoundCreatesANewSecurityGroup() throws Exception {
      Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion = Predicates.alwaysFalse();

      SecurityGroupInRegion securityGroupInRegion = createMock(SecurityGroupInRegion.class);

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

      Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> groupCreator = Functions.forMap(ImmutableMap
View Full Code Here

   }

   @Test
   public void testWhenFoundReturnsSecurityGroupFromAtomicReferenceValueUpdatedDuringPredicateCheck() throws Exception {
      final SecurityGroupInRegion securityGroupInRegion = createMock(SecurityGroupInRegion.class);

      Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion = new Predicate<AtomicReference<RegionAndName>>() {

         @Override
         public boolean apply(AtomicReference<RegionAndName> input) {
View Full Code Here

      CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiCanCreateSecurityGroup);

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

   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion

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.