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

Examples of org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule


   }

   @Test(expectedExceptions = IllegalStateException.class)
   public void testConversionWhereLocationNotFound() {
      UUID id = UUID.randomUUID();
      Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build();
      OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
               "My Test OS", true);
      ImageInZoneToImage converter = new ImageInZoneToImage(NovaComputeServiceContextModule.toPortableImageStatus,
               constant(operatingSystem), locationIndex);
View Full Code Here


   }

   public void createGetAndDeleteSecurityGroup() throws Exception {
      for (String zoneId : api.getConfiguredZones()) {
         SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
         SecurityGroup securityGroup = null;
         String id;
         try {
            securityGroup = securityGroupApi
                     .createWithDescription(SECURITY_GROUP_NAME, "test security group");
            assertNotNull(securityGroup);
            id = securityGroup.getId();
            SecurityGroup theGroup = securityGroupApi.get(id);
            assertNotNull(theGroup);
         } finally {
            if (securityGroup != null) {
               securityGroupApi.delete(securityGroup.getId());
            }
View Full Code Here

   }

   public void createAndDeleteSecurityGroupRule() throws Exception {
      for (String zoneId : api.getConfiguredZones()) {
         SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
         SecurityGroup securityGroup = null;

         try {
            securityGroup = securityGroupApi.createWithDescription(SECURITY_GROUP_NAME, "test security group");
            assertNotNull(securityGroup);

            for (int port : ImmutableSet.of(22, 8080)) {
               SecurityGroupRule rule = securityGroupApi.createRuleAllowingCidrBlock(securityGroup.getId(), Ingress
                        .builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), "0.0.0.0/0");
               assertNotNull(rule);

               SecurityGroupRule rule2 = securityGroupApi.createRuleAllowingSecurityGroupId(securityGroup.getId(),
                        Ingress.builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), securityGroup
                                 .getId());

               assertNotNull(rule2);
            }
            securityGroup = securityGroupApi.get(securityGroup.getId());

         } finally {
            if (securityGroup != null) {
               securityGroupApi.delete(securityGroup.getId());
            }
         }
      }

   }
View Full Code Here

         try {
            securityGroup = securityGroupApi.createWithDescription(SECURITY_GROUP_NAME, "test security group");
            assertNotNull(securityGroup);

            for (int port : ImmutableSet.of(22, 8080)) {
               SecurityGroupRule rule = securityGroupApi.createRuleAllowingCidrBlock(securityGroup.getId(), Ingress
                        .builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), "0.0.0.0/0");
               assertNotNull(rule);

               SecurityGroupRule rule2 = securityGroupApi.createRuleAllowingSecurityGroupId(securityGroup.getId(),
                        Ingress.builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), securityGroup
                                 .getId());

               assertNotNull(rule2);
            }
View Full Code Here

           groupCache.get());

   public static org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroupWithGroup() {
      TenantIdAndName group = TenantIdAndName.builder().tenantId("tenant").name("some-other-group").build();

      SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
              .id("some-id")
              .ipProtocol(IpProtocol.TCP)
              .fromPort(10)
              .toPort(20)
              .group(group)
View Full Code Here

      return origGroup;
   }

   public static org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroupWithCidr() {
      SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
              .id("some-id")
              .ipProtocol(IpProtocol.TCP)
              .fromPort(10)
              .toPort(20)
              .ipRange("0.0.0.0/0")
View Full Code Here

   @Test
   public void testApplyWithGroup() {

      TenantIdAndName group = TenantIdAndName.builder().tenantId("tenant").name("some-group").build();
     
      SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
         .id("some-id")
         .ipProtocol(IpProtocol.TCP)
         .fromPort(10)
         .toPort(20)
         .group(group)
         .parentGroupId("some-other-id")
         .build();

      IpPermission convertedPerm = NovaSecurityGroupToSecurityGroupTest.ruleConverter.apply(ruleToConvert);

      assertEquals(convertedPerm.getIpProtocol(), ruleToConvert.getIpProtocol());
      assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort());
      assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort());
      assertTrue(convertedPerm.getGroupIds().contains("az-1.region-a.geo-1/some-id"));
      assertTrue(convertedPerm.getCidrBlocks().size() == 0);
   }
View Full Code Here

      assertTrue(convertedPerm.getCidrBlocks().size() == 0);
   }

   @Test
   public void testApplyWithCidr() {
      SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
         .id("some-id")
         .ipProtocol(IpProtocol.TCP)
         .fromPort(10)
         .toPort(20)
         .ipRange("0.0.0.0/0")
         .parentGroupId("some-other-id")
         .build();

      IpPermission convertedPerm = NovaSecurityGroupToSecurityGroupTest.ruleConverter.apply(ruleToConvert);

      assertEquals(convertedPerm.getIpProtocol(), ruleToConvert.getIpProtocol());
      assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort());
      assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort());
      assertEquals(convertedPerm.getCidrBlocks(), ImmutableSet.of("0.0.0.0/0"));
      assertTrue(convertedPerm.getTenantIdGroupNamePairs().size() == 0);
   }
View Full Code Here

         try {
            securityGroup = securityGroupApi.createWithDescription(SECURITY_GROUP_NAME, "test security group");
            assertNotNull(securityGroup);

            for (int port : ImmutableSet.of(22, 8080)) {
               SecurityGroupRule rule = securityGroupApi.createRuleAllowingCidrBlock(securityGroup.getId(), Ingress
                        .builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), "0.0.0.0/0");
               assertNotNull(rule);

               SecurityGroupRule rule2 = securityGroupApi.createRuleAllowingSecurityGroupId(securityGroup.getId(),
                        Ingress.builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), securityGroup
                                 .getId());

               assertNotNull(rule2);
            }
View Full Code Here

           groupCache.get());

   public static org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroupWithGroup() {
      TenantIdAndName group = TenantIdAndName.builder().tenantId("tenant").name("some-other-group").build();

      SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
              .id("some-id")
              .ipProtocol(IpProtocol.TCP)
              .fromPort(10)
              .toPort(20)
              .group(group)
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule

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.