Package org.jclouds.googlecomputeengine.domain

Examples of org.jclouds.googlecomputeengine.domain.Instance$SerialPortOutput


   }

   @Test(groups = "live", dependsOnMethods = "testInsertInstance")
   public void testGetInstance() {

      Instance instance = api().get(INSTANCE_NAME);
      assertNotNull(instance);
      assertInstanceEquals(instance, this.instance);
   }
View Full Code Here


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

   @Override
   public NodeMetadata apply(InstanceInZone instanceInZone) {
      Instance input = instanceInZone.getInstance();

      String group = groupFromMapOrName(input.getMetadata().getItems(),
                                               input.getName(), nodeNamingConvention);
      FluentIterable<String> tags = FluentIterable.from(input.getTags().getItems())
                                            .filter(Predicates.not(firewallTagNamingConvention.get(group).isFirewallTag()));

      NodeMetadataBuilder builder = new NodeMetadataBuilder();

      builder.id(SlashEncodedIds.fromTwoIds(checkNotNull(locations.get().get(input.getZone()),
                                                                "location for %s", input.getZone())
                                                    .getId(), input.getName()).slashEncode())
              .name(input.getName())
              .providerId(input.getId())
              .hostname(input.getName())
              .location(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()))
              .hardware(checkNotNull(hardwares.get().get(input.getMachineType()), "hardware type for %s",
                                            input.getMachineType().toString()))
              .status(toPortableNodeStatus.get(input.getStatus()))
              .tags(tags)
              .uri(input.getSelfLink())
              .userMetadata(input.getMetadata().getItems())
              .group(group)
              .privateAddresses(collectPrivateAddresses(input))
              .publicAddresses(collectPublicAddresses(input));

      if (input.getMetadata().getItems().containsKey(GCE_IMAGE_METADATA_KEY)) {
         try {
            URI imageUri = URI.create(input.getMetadata().getItems()
                                              .get(GCE_IMAGE_METADATA_KEY));

            Map<URI, ? extends Image> imagesMap = images.get();

            Image image = checkNotNull(imagesMap.get(imageUri),
View Full Code Here

   @Override
   public InstanceInZone getNode(String name) {
      SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);

      Instance instance= api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
              slashEncodedIds.getSecondId());

      return instance == null null : new InstanceInZone(instance, slashEncodedIds.getFirstId());
   }
View Full Code Here

   @Override
   public void destroyNode(final String name) {
      SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
      String diskName = null;
      try {
         Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
                                                                              slashEncodedIds.getSecondId());
         if (instance.getMetadata().getItems().get(GCE_DELETE_BOOT_DISK_METADATA_KEY).equals("true")) {
            Optional<AttachedDisk> disk = tryFind(instance.getDisks(), new Predicate<AttachedDisk>() {
               @Override
               public boolean apply(AttachedDisk input) {
                  return PersistentAttachedDisk.class.isInstance(input) &&
                         PersistentAttachedDisk.class.cast(input).isBoot();
               }
View Full Code Here

   @Override
   public Set<SecurityGroup> listSecurityGroupsForNode(String id) {
      SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(id);

      Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
              slashEncodedIds.getSecondId());

      if (instance == null) {
         return ImmutableSet.of();
      }

      ImmutableSet.Builder builder = ImmutableSet.builder();


      for (NetworkInterface nwInterface : instance.getNetworkInterfaces()) {
         String networkUrl = nwInterface.getNetwork().getPath();
         Network nw = api.getNetworkApiForProject(userProject.get()).get(networkUrl.substring(networkUrl.lastIndexOf('/') + 1));

         SecurityGroup grp = groupForTagsInNetwork(nw, instance.getTags().getItems());
         if (grp != null) {
            builder.add(grp);
         }
      }
View Full Code Here

   }

   @Test(groups = "live", dependsOnMethods = "testInsertInstance")
   public void testGetInstance() {

      Instance instance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
      assertNotNull(instance);
      assertInstanceEquals(instance, this.instance);
   }
View Full Code Here

      assertInstanceEquals(instance, this.instance);
   }

   @Test(groups = "live", dependsOnMethods = "testListInstance")
   public void testSetMetadataForInstance() {
      Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
      assertZoneOperationDoneSucessfully(api().setMetadataInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
              ImmutableMap.of(METADATA_ITEM_KEY, METADATA_ITEM_VALUE),
              originalInstance.getMetadata().getFingerprint()),
              TIME_WAIT);

      Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);

      assertTrue(modifiedInstance.getMetadata().getItems().containsKey(METADATA_ITEM_KEY));
      assertEquals(modifiedInstance.getMetadata().getItems().get(METADATA_ITEM_KEY),
              METADATA_ITEM_VALUE);
      assertNotNull(modifiedInstance.getMetadata().getFingerprint());

   }
View Full Code Here

   @Test(groups = "live", dependsOnMethods = "testSetMetadataForInstance")
   public void testAttachDiskToInstance() {
      assertZoneOperationDoneSucessfully(diskApi().createInZone(ATTACH_DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);

      Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
      assertZoneOperationDoneSucessfully(api().attachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
              new AttachDiskOptions().type(DiskType.PERSISTENT)
                      .source(getDiskUrl(userProject.get(), ATTACH_DISK_NAME))
                      .mode(DiskMode.READ_ONLY)
                      .deviceName(ATTACH_DISK_DEVICE_NAME)),
              TIME_WAIT);

      Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);

      assertTrue(modifiedInstance.getDisks().size() > originalInstance.getDisks().size());
      assertTrue(Iterables.any(modifiedInstance.getDisks(), new Predicate<AttachedDisk>() {

         @Override
         public boolean apply(AttachedDisk disk) {
            return disk instanceof PersistentAttachedDisk &&
                   ((PersistentAttachedDisk) disk).getDeviceName().isPresent() &&
View Full Code Here

      }));
   }

   @Test(groups = "live", dependsOnMethods = "testAttachDiskToInstance")
   public void testDetachDiskFromInstance() {
      Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
      assertZoneOperationDoneSucessfully(api().detachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
              ATTACH_DISK_DEVICE_NAME), TIME_WAIT);

      Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);

      assertTrue(modifiedInstance.getDisks().size() < originalInstance.getDisks().size());

      assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, ATTACH_DISK_NAME), TIME_WAIT);
   }
View Full Code Here

   @Override
   public InstanceInZone getNode(String name) {
      SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);

      Instance instance= api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
              slashEncodedIds.getSecondId());

      return instance == null null : new InstanceInZone(instance, slashEncodedIds.getFirstId());
   }
View Full Code Here

TOP

Related Classes of org.jclouds.googlecomputeengine.domain.Instance$SerialPortOutput

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.