Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.NodeMetadataBuilder


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

      return new NodeMetadataBuilder()
              .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())
View Full Code Here


         logger.debug("<< deleted an existing snapshot of vm(%s)", master.getMachine().getName());
      }
   }

   private NodeMetadata buildPartialNodeMetadata(IMachine clone, String guestOsUser, String guestOsPassword) {
      NodeMetadataBuilder nodeMetadataBuilder = new NodeMetadataBuilder();
      nodeMetadataBuilder.id(clone.getName());
      nodeMetadataBuilder.status(VirtualBoxComputeServiceContextModule.toPortableNodeStatus.get(clone.getState()));
      nodeMetadataBuilder.publicAddresses(ImmutableSet.of(networkUtils.getValidHostOnlyIpFromVm(clone.getName())));
      nodeMetadataBuilder.credentials(LoginCredentials.builder()
                                                      .user(guestOsUser)
                                                      .password(guestOsPassword)
                                                      .authenticateSudo(true).build());
      return nodeMetadataBuilder.build();
   }
View Full Code Here

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

   @Override
   public NodeMetadata apply(final VirtualMachine vm) {
      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.ids(vm.getId().toString());
      builder.uri(vm.getURI());
      builder.name(vm.getNameLabel());
      builder.group(vm.getVirtualAppliance().getName());

      // TODO: Node credentials still not present in Abiquo template metadata
      // Will be added in Abiquo 2.4:
      // http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647

      // Location details
      VirtualDatacenter vdc = vm.getVirtualDatacenter();
      builder.location(virtualDatacenterToLocation.apply(vdc));

      // Image details
      VirtualMachineTemplate template = vm.getTemplate();
      Image image = virtualMachineTemplateToImage.apply(template);
      builder.imageId(image.getId().toString());
      builder.operatingSystem(image.getOperatingSystem());

      // Hardware details
      Hardware defaultHardware = virtualMachineTemplateToHardware.apply(new VirtualMachineTemplateInVirtualDatacenter(
            template, vdc));

      Hardware hardware = HardwareBuilder
            .fromHardware(defaultHardware)
            .ram(vm.getRam())
            .processors(
                  Lists.newArrayList(new Processor(vm.getCpu(),
                        VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED))) //
            .build();

      builder.hardware(hardware);

      // Networking configuration
      List<Ip<?, ?>> nics = vm.listAttachedNics();
      builder.privateAddresses(ips(filter(nics, Predicates.instanceOf(PrivateIp.class))));
      builder.publicAddresses(ips(filter(nics, Predicates.not(Predicates.instanceOf(PrivateIp.class)))));

      // Node state
      VirtualMachineState state = vm.getState();
      builder.status(virtualMachineStateToNodeState.apply(state));
      builder.backendStatus(state.name());

      return builder.build();
   }
View Full Code Here

      this.credentialStore = checkNotNull(credentialStore, "credentialStore");
      this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus");
   }

   public NodeMetadata apply(VApp from) {
      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.ids(from.getHref().toASCIIString());
      builder.uri(from.getHref());
      builder.name(from.getName());
      String groupName = "";
      Map<String, String> metadataMap;

      if (!isNullOrEmpty(from.getDescription())
         && from.getDescription().indexOf('=') != -1
         && from.getDescription().indexOf('\n') != -1) {
         try {
            metadataMap = Splitter.on('\n').withKeyValueSeparator("=").split(from.getDescription());

            addMetadataAndParseTagsFromCommaDelimitedValue(builder, metadataMap);
         } catch (IllegalArgumentException iae) {
            // no op
            metadataMap = ImmutableMap.of();
         }
      } else {
         metadataMap = ImmutableMap.of();
      }
      builder.hostname(from.getName());
      builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
      builder.group(groupFromMapOrName(metadataMap, from.getName(), nodeNamingConvention));
      builder.operatingSystem(toComputeOs(from, null));
      builder.hardware(hardwareForVApp.apply(from));
      builder.status(vAppStatusToNodeStatus.get(from.getStatus()));
      Set<String> addresses = getIpsFromVApp(from);
      builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
      builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));

      // normally, we don't affect the credential store when reading vApps.
      // However, login user, etc, is actually in the metadata, so lets see
      Credentials fromApi = getCredentialsFrom(from);
      if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString()))
         credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi);
      return builder.build();
   }
View Full Code Here

         });
   }
   @Override
   public NodeWithInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, Template template) {
      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      String id = idProvider.get() + "";
      builder.ids(id);
      builder.name(name);
      // using a predictable name so tests will pass
      builder.hostname(group);
      builder.tags(template.getOptions().getTags());
      builder.userMetadata(template.getOptions().getUserMetadata());
      builder.group(group);
      builder.location(location.get());
      builder.imageId(template.getImage().getId());
      builder.operatingSystem(template.getImage().getOperatingSystem());
      builder.status(Status.PENDING);
      builder.publicAddresses(ImmutableSet.<String> of(publicIpPrefix + id));
      builder.privateAddresses(ImmutableSet.<String> of(privateIpPrefix + id));
      builder.credentials(LoginCredentials.builder().user("root").password(passwordPrefix + id).build());
      NodeMetadata node = builder.build();
      nodes.put(node.getId(), node);

      if (template.getOptions().getGroups().size() > 0) {
         final String groupId = Iterables.getFirst(template.getOptions().getGroups(), "0");
         Optional<SecurityGroup> secGroup = Iterables.tryFind(securityGroupExtension.get().listSecurityGroups(),
View Full Code Here

   private NodeMetadata node;
   private GetNodeMetadataStrategy computeService;

   @Test
   public void testNoUpdatesAtomicReferenceOnPass() {
      NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
View Full Code Here

   }

   @Test
   public void testRefreshUpdatesAtomicReferenceOnRecheckPending() {
      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(pending);

      replay(computeService);
View Full Code Here

   }

   @Test
   public void testRefreshUpdatesAtomicReferenceOnRecheckPendingAcceptsNewCredentials() {
      LoginCredentials creds = LoginCredentials.builder().user("user").password("password").build();
      NodeMetadata newNode = new NodeMetadataBuilder().id("myid").status(Status.UNRECOGNIZED).credentials(creds).build();

      LoginCredentials creds2 = LoginCredentials.builder().user("user").password("password2").build();

      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).credentials(creds2).build();
     
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(pending);
View Full Code Here

      verify(computeService);
   }
  
   @Test
   public void testRefreshUpdatesAtomicReferenceOnRecheckRunning() {
      NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(running);

      replay(computeService);
View Full Code Here

@Test
public class PollNodeRunningTest {

   @Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "node\\(id\\) didn't achieve the status running; aborting after 0 seconds with final status: PENDING")
   public void testIllegalStateExceptionWhenNodeStillPending() {
      final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build();

      // node always stays pending
      Predicate<AtomicReference<NodeMetadata>> nodeRunning = new Predicate<AtomicReference<NodeMetadata>>() {

         @Override
View Full Code Here

TOP

Related Classes of org.jclouds.compute.domain.NodeMetadataBuilder

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.