public class HostHelper
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HostHelper.OSType
Enumerates the legal values for
HostPrms.osTypes. |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ONLY_ON_PLATFORMS_PROP
The
onlyOnPlatforms system property |
| Constructor and Description |
|---|
HostHelper() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
applyRFC2732(java.lang.String hostname)
Process the String form of a hostname to make it comply with Jmx URL
restrictions.
|
protected static boolean |
compareHosts(java.lang.String host1,
java.lang.String host2)
Returns true if the noncanonical hostname of each host is the same or
if one contains the other.
|
static java.lang.String |
getCanonicalHostName()
Returns the canonical name of the local host, based on the IPv4 address.
|
static java.lang.String |
getCanonicalHostName(java.lang.String host)
Returns the canonical name of the given host, based on the IPv4 address.
|
static java.lang.String |
getHostAddress()
Returns the address for the local host.
|
static java.lang.String |
getHostAddress(java.net.InetAddress addr)
A wrapper for
InetAddress.getHostAddress() that removes the
scope_id from all IPv4 address and all global IPv6 addresses. |
static HostHelper.OSType |
getHostOS(java.lang.String host)
Returns the O/S type for the specified host.
|
static java.net.InetAddress |
getIPAddress()
Returns the IP address for the local host.
|
protected static java.net.InetAddress |
getIPv4Address()
Returns the IPv4 address for the local host.
|
static java.net.InetAddress |
getIPv6Address()
Returns the IPv6 address for the local host.
|
static java.lang.String |
getLocalHost()
Returns the non-canonical name of the local host, based on the IPv4
address.
|
static HostHelper.OSType |
getLocalHostOS()
Returns the OSType of the local host O/S.
|
protected static java.lang.String |
getNoncanonicalHostName(java.lang.String host)
Returns the non-canonical host name of the given host.
|
static boolean |
isLocalHost(java.lang.String host)
Answers whether the specified host is the local host.
|
static boolean |
isWindows()
Returns true if the OSType for this JVM is "windows".
|
static boolean |
shouldRun(java.lang.String onlyOnPlatforms)
Returns whether or the given value of the
onlyOnPlatforms system property applies to this
host. |
public static final java.lang.String ONLY_ON_PLATFORMS_PROP
onlyOnPlatforms system propertyshouldRun(java.lang.String),
Constant Field Valuespublic static java.lang.String getLocalHost()
HydraRuntimeException - if the IPv4 address is not found.public static java.lang.String getCanonicalHostName()
HydraRuntimeException - if the IPv4 address is not found.protected static boolean compareHosts(java.lang.String host1,
java.lang.String host2)
protected static java.lang.String getNoncanonicalHostName(java.lang.String host)
HydraRuntimeException - if no host is specified.public static java.lang.String getCanonicalHostName(java.lang.String host)
HydraRuntimeException - if the host is not found.public static boolean isLocalHost(java.lang.String host)
public static java.lang.String getHostAddress()
HydraRuntimeException - if an address of the appropriate type
cannot be found.public static java.lang.String getHostAddress(java.net.InetAddress addr)
InetAddress.getHostAddress() that removes the
scope_id from all IPv4 address and all global IPv6 addresses.
We don't need to use isIPv6LinkLocalAddress(java.net.Inet6Address) because that
is for the case where the scope_id is missing.addr - public static java.net.InetAddress getIPAddress()
HydraRuntimeException - if an address of the appropriate type
cannot be found.protected static java.net.InetAddress getIPv4Address()
HydraRuntimeException - if the IPv4 address cannot be found.public static java.net.InetAddress getIPv6Address()
HydraRuntimeException - if the IPv6 address cannot be found.public static boolean isWindows()
public static HostHelper.OSType getLocalHostOS()
public static HostHelper.OSType getHostOS(java.lang.String host)
public static boolean shouldRun(java.lang.String onlyOnPlatforms)
onlyOnPlatforms system property applies to this
host. Note that this only applies to the host on which MasterController runs. Another mechanism must be used if you
want to restrict the platforms on which client VMs can run.onlyOnPlatforms - A comma-separated string of platforms (as determined by
the os.name Java system property) on which a test
should be run. Examples of platforms are
SunOS, Linux, and
WindowsIf null or an empty
string (""), then the test should be run on
all platforms.public static java.lang.String applyRFC2732(java.lang.String hostname)
hostname - the name to safeguard.Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.