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

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


      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


         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

         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"));
      assertEquals(convertedPerm.getCidrBlocks().size(), 0);
   }
View Full Code Here

      assertEquals(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"));
      assertEquals(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

   /**
    * Will block until the requested server is in the correct state, if Extended Server Status extension is loaded
    * this will continue to block while any task is in progress.
    */
   protected void blockUntilServerInState(String serverId, ServerApi api, Status status) {
      Server currentDetails = null;
      for (currentDetails = api.get(serverId); currentDetails.getStatus() != status
               || ((currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get()
                        .getTaskState() != null)); currentDetails = api.get(serverId)) {
         System.out.printf("blocking on status %s%n%s%n", status, currentDetails);
         try {
            Thread.sleep(5 * 1000);
         } catch (InterruptedException e) {
View Full Code Here

         String expectedImageId, OperatingSystem expectedOs, Image existingImage) {

      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");

      assertEquals(convertedNodeMetadata.getLocation().getParent(), locationIndex.get().get("az-1.region-a.geo-1"));

      assertEquals(serverToConvert.getName(), convertedNodeMetadata.getName());
      assertEquals(convertedNodeMetadata.getGroup(), "sample");

      assertEquals(convertedNodeMetadata.getImageId(), expectedImageId);
      assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs);

      assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);

      assertEquals(NovaComputeServiceContextModule.toPortableNodeStatus.get(serverToConvert.getStatus()),
               convertedNodeMetadata.getStatus());

      assertNotNull(convertedNodeMetadata.getPrivateAddresses());
      assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
View Full Code Here

TOP

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

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.