Java Code Examples for org.jclouds.compute.domain.NodeMetadata#getHostname()

The following examples show how to use org.jclouds.compute.domain.NodeMetadata#getHostname() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JcloudsLocation.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
/**
 * The preferredAddress is returned if it is one of the best choices (e.g. if non-local privateAddresses 
 * contains it, or if privateAddresses.isEmpty but the publicAddresses contains it).
 * 
 * Otherwise, returns the first publicAddress (if any), or failing that the first privateAddress.
 */
private String getPrivateHostnameGeneric(NodeMetadata node, @Nullable ConfigBag setup, Optional<String> preferredAddress) {
    //prefer the private address to the hostname because hostname is sometimes wrong/abbreviated
    //(see that javadoc; also e.g. on rackspace/cloudstack, the hostname is not registered with any DNS).
    //Don't return local-only address (e.g. never 127.0.0.1)
    Iterable<String> privateAddresses = Iterables.filter(node.getPrivateAddresses(), new Predicate<String>() {
        @Override public boolean apply(String input) {
            return input != null && !Networking.isLocalOnly(input);
        }});
    if (!Iterables.isEmpty(privateAddresses)) {
        if (preferredAddress.isPresent() && Iterables.contains(privateAddresses, preferredAddress.get())) {
            return preferredAddress.get();
        }
        return Iterables.get(privateAddresses, 0);
    }
    
    if (groovyTruth(node.getPublicAddresses())) {
        if (preferredAddress.isPresent() && node.getPublicAddresses().contains(preferredAddress.get())) {
            return preferredAddress.get();
        }
        return node.getPublicAddresses().iterator().next();
    } else if (groovyTruth(node.getHostname())) {
        return node.getHostname();
    } else {
        return null;
    }
}
 
Example 2
Source File: JcloudsWinRmMachineLocation.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected void setNode(NodeMetadata node) {
    this.node = null;
    nodeId = node.getId();
    imageId = node.getImageId();
    privateAddresses = node.getPrivateAddresses();
    publicAddresses = node.getPublicAddresses();
    hostname = node.getHostname();
    _node = Optional.of(node);
}
 
Example 3
Source File: CloudDistributedTLCJob.java    From tlaplus with MIT License 4 votes vote down vote up
public WrapperNodeMetadata(final NodeMetadata m, final LoginCredentials credentials) {
	super(m.getProviderId(), m.getName(), m.getId(), m.getLocation(), m.getUri(), m.getUserMetadata(),
			m.getTags(), m.getGroup(), m.getHardware(), m.getImageId(), m.getOperatingSystem(), m.getStatus(),
			m.getBackendStatus(), m.getLoginPort(), m.getPublicAddresses(), m.getPrivateAddresses(),
			credentials, m.getHostname());
}