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

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


      return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter));
   }

   @Override
   public SecurityGroup getSecurityGroupById(String id) {
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(checkNotNull(id, "id"));
      String region = regionAndId.getRegion();
      String groupId = regionAndId.getId();

      Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);

      if (!sgApi.isPresent()) {
         return null;
View Full Code Here


   }

   @Override
   public boolean removeSecurityGroup(String id) {
      checkNotNull(id, "id");
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
      String region = regionAndId.getRegion();
      String groupId = regionAndId.getId();

      Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);

      if (!sgApi.isPresent()) {
         return false;
View Full Code Here

   }

   @Override
   public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
      String region = group.getLocation().getId();
      RegionAndId groupRegionAndId = RegionAndId.fromSlashEncoded(group.getId());
      String id = groupRegionAndId.getId();
      Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);

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

      if (!ipPermission.getCidrBlocks().isEmpty()) {
         for (String cidr : ipPermission.getCidrBlocks()) {
            sgApi.get().createRuleAllowingCidrBlock(id,
                    Ingress.builder()
                            .ipProtocol(ipPermission.getIpProtocol())
                            .fromPort(ipPermission.getFromPort())
                            .toPort(ipPermission.getToPort())
                            .build(),
                    cidr);
         }
      }

      if (!ipPermission.getGroupIds().isEmpty()) {
         for (String regionAndGroupRaw : ipPermission.getGroupIds()) {
            RegionAndId regionAndId = RegionAndId.fromSlashEncoded(regionAndGroupRaw);
            String groupId = regionAndId.getId();
            sgApi.get().createRuleAllowingSecurityGroupId(id,
                    Ingress.builder()
                            .ipProtocol(ipPermission.getIpProtocol())
                            .fromPort(ipPermission.getFromPort())
                            .toPort(ipPermission.getToPort())
View Full Code Here

   }

   @Override
   public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
      String region = group.getLocation().getId();
      RegionAndId groupRegionAndId = RegionAndId.fromSlashEncoded(group.getId());
      String id = groupRegionAndId.getId();

      Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);

      if (!sgApi.isPresent()) {
         return null;
View Full Code Here

      return ImmutableSet.of();
   }

   @Override
   public ServerInRegion getNode(String id) {
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
      Server server = novaApi.getServerApi(regionAndId.getRegion()).get(regionAndId.getId());
      return server == null ? null : new ServerInRegion(server, regionAndId.getRegion());
   }
View Full Code Here

      return server == null ? null : new ServerInRegion(server, regionAndId.getRegion());
   }

   @Override
   public ImageInRegion getImage(String id) {
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
      Image image = novaApi.getImageApi(regionAndId.getRegion()).get(regionAndId.getId());
      return image == null ? null : new ImageInRegion(image, regionAndId.getRegion());
   }
View Full Code Here

      return image == null ? null : new ImageInRegion(image, regionAndId.getRegion());
   }

   @Override
   public void destroyNode(String id) {
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
      if (novaApi.getFloatingIPApi(regionAndId.getRegion()).isPresent()) {
         try {
            removeFloatingIpFromNodeAndDeallocate.apply(regionAndId);
         } catch (RuntimeException e) {
            logger.warn(e, "<< error removing and deallocating ip from node(%s): %s", id, e.getMessage());
         }
      }
      novaApi.getServerApi(regionAndId.getRegion()).delete(regionAndId.getId());
   }
View Full Code Here

      novaApi.getServerApi(regionAndId.getRegion()).delete(regionAndId.getId());
   }

   @Override
   public void rebootNode(String id) {
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
      novaApi.getServerApi(regionAndId.getRegion()).reboot(regionAndId.getId(), RebootType.HARD);
   }
View Full Code Here

      this.imageAvailablePredicate = checkNotNull(imageAvailablePredicate, "imageAvailablePredicate");
   }

   @Override
   public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
      Server server = novaApi.getServerApi(regionAndId.getRegion()).get(regionAndId.getId());
      if (server == null)
         throw new NoSuchElementException("Cannot find server with id: " + regionAndId);
      CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
      return template;
   }
View Full Code Here

      novaApi.getServerApi(regionAndId.getRegion()).reboot(regionAndId.getId(), RebootType.HARD);
   }

   @Override
   public void resumeNode(String id) {
      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
      if (novaApi.getServerAdminApi(regionAndId.getRegion()).isPresent()) {
         novaApi.getServerAdminApi(regionAndId.getRegion()).get().resume(regionAndId.getId());
      } else {
         throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension");
      }
   }
View Full Code Here

TOP

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

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.