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

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


   }

   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


      Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(zoneId);
      checkArgument(api.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
      logger.debug(">> creating securityGroup %s", zoneSecurityGroupNameAndPorts);
      try {

         SecurityGroup securityGroup = api.get().createWithDescription(
                  zoneSecurityGroupNameAndPorts.getName(), zoneSecurityGroupNameAndPorts.getName());

         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

      Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone());
      checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");

      logger.trace("looking for security group %s", securityGroupInZone.slashEncode());
      try {
         SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() {

            @Override
            public boolean apply(SecurityGroup input) {
               return input.getName().equals(securityGroupInZone.getName());
            }
View Full Code Here

      Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone());
      checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");

      logger.trace("looking for security group %s", securityGroupInZone.slashEncode());
      try {
         SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() {

            @Override
            public boolean apply(SecurityGroup input) {
               return input.getName().equals(securityGroupInZone.getName());
            }
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

      Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(zoneId);
      checkArgument(api.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
      logger.debug(">> creating securityGroup %s", zoneSecurityGroupNameAndPorts);
      try {

         SecurityGroup securityGroup = api.get().createWithDescription(
                  zoneSecurityGroupNameAndPorts.getName(), zoneSecurityGroupNameAndPorts.getName());

         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

      Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupApi(securityGroupInRegion.getRegion());
      checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");

      logger.trace("looking for security group %s", securityGroupInRegion.slashEncode());
      try {
         SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() {

            @Override
            public boolean apply(SecurityGroup input) {
               return input.getName().equals(securityGroupInRegion.getName());
            }
View Full Code Here

      Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupApi(regionId);
      checkArgument(api.isPresent(), "Security groups are required, but the extension is not available in region %s!", regionId);
      logger.debug(">> creating securityGroup %s", regionSecurityGroupNameAndPorts);
      try {

         SecurityGroup securityGroup = api.get().createWithDescription(
                  regionSecurityGroupNameAndPorts.getName(), regionSecurityGroupNameAndPorts.getName());

         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

   }

   public void createGetAndDeleteSecurityGroup() throws Exception {
      for (String regionId : api.getConfiguredRegions()) {
         SecurityGroupApi securityGroupApi = api.getSecurityGroupApi(regionId).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

TOP

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

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.