com.dtolabs.rundeck.core.common
Class NodeEntryImpl

java.lang.Object
  extended by com.dtolabs.rundeck.core.common.NodeBaseImpl
      extended by com.dtolabs.rundeck.core.common.NodeEntryImpl
All Implemented Interfaces:
INodeBase, INodeDesc, INodeEntry

public class NodeEntryImpl
extends NodeBaseImpl
implements INodeEntry, INodeDesc

NodeEntryImpl provides a bean representation of INodesEntry


Field Summary
static java.lang.String DESCRIPTION
           
static java.lang.String HOSTNAME
           
static java.lang.String NAME
           
static java.lang.String OS_ARCH
           
static java.lang.String OS_FAMILY
           
static java.lang.String OS_NAME
           
static java.lang.String OS_VERSION
           
protected static java.lang.String PORT_REGEX
           
static java.lang.String TAGS
           
protected static java.lang.String USER_AT_HOSTNAME_REGEX
           
static java.lang.String USERNAME
           
 
Constructor Summary
NodeEntryImpl()
          Base constructor
NodeEntryImpl(java.lang.String nodename)
          Create an instance with a nodename value
NodeEntryImpl(java.lang.String hostname, java.lang.String nodename)
          Create a NodeEntryImpl with hostname and nodename
 
Method Summary
 boolean containsPort()
          Return true if the hostname string includes embedded port in the "hostname:port" pattern
static boolean containsPort(java.lang.String host)
          Return true if the hostname contains a port value in the form "hostname:port".
 boolean containsUserName()
          Return true if the hostname string includes embedded username in the "username@hostname" pattern
static boolean containsUserName(java.lang.String host)
          Checks if nodename contains a user name
static INodeEntry create(java.lang.String hostname, java.lang.String nodename)
          Factory method to create an instance with a hostname and node name.
 boolean equals(INodeDesc node)
          Checks equality with another node description
 boolean equals(java.lang.Object o)
           
 java.lang.String extractHostname()
          Return the standalone hostname value extracted from the hostname string
static java.lang.String extractHostname(java.lang.String host)
          Extract hostname from a string of the pattern "username@hostname:port"
 java.lang.String extractPort()
          Return the port string extracted from the hostname
static java.lang.String extractPort(java.lang.String host)
          Extract the port string from a string in the pattern "hostname:port"
 java.lang.String extractUserName()
          Gets the username for remote connections.
static java.lang.String extractUserName(java.lang.String hostname)
          Extract a username from a "username@hostname" pattern.
 java.lang.String getAttribute(java.lang.String name)
          Get the value for a specific attribute
 java.util.Map<java.lang.String,java.lang.String> getAttributes()
          Get the map of attributes for the node, including all predefined attribtes available via acessors.
 java.lang.String getDescription()
          Return the description
 java.util.Map<java.lang.String,java.lang.String> getExtendedAttributes()
          Return the attributes for the node without any of the predefined attributes.
 java.lang.String getFrameworkProject()
          Return the project name if it is set
 java.lang.String getHostname()
          Returns hostname
 java.lang.String getNodename()
          Return the name of the node
 java.lang.String getOsArch()
          Return the OS architecture
 java.lang.String getOsFamily()
          Return the OS family
 java.lang.String getOsName()
          Return the OS name
 java.lang.String getOsVersion()
          Return the OS version
 java.util.Set getTags()
          Return the set of tag strings
 java.lang.String getUsername()
          Return the username
 int hashCode()
           
static java.util.Map<java.lang.String,java.lang.String> nodeExtendedAttributes(INodeEntry node)
          Return the attributes for the node without any of the predefined attributes.
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> nodeNamespacedAttributes(INodeEntry node)
          Return the node attributes broken into namespaces, the result map will be contructed as: "namespace" : { "key": ["attr","value"] } where "attr" is the source full attribute name
 java.lang.String setAttribute(java.lang.String name, java.lang.String value)
          Set the value for a specific attribute
 void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
           
 void setDescription(java.lang.String description)
           
 void setFrameworkProject(java.lang.String project)
           
 void setHostname(java.lang.String hostname)
           
 void setNodename(java.lang.String nodename)
          Set the node name
 void setOsArch(java.lang.String osArch)
           
 void setOsFamily(java.lang.String osFamily)
           
 void setOsName(java.lang.String osName)
           
 void setOsVersion(java.lang.String osVersion)
           
 void setTags(java.util.Set tags)
           
 void setUsername(java.lang.String username)
           
 java.lang.String toString()
           
 
Methods inherited from class com.dtolabs.rundeck.core.common.NodeBaseImpl
create
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

USER_AT_HOSTNAME_REGEX

protected static final java.lang.String USER_AT_HOSTNAME_REGEX
See Also:
Constant Field Values

PORT_REGEX

protected static final java.lang.String PORT_REGEX
See Also:
Constant Field Values

OS_NAME

public static final java.lang.String OS_NAME
See Also:
Constant Field Values

OS_FAMILY

public static final java.lang.String OS_FAMILY
See Also:
Constant Field Values

OS_VERSION

public static final java.lang.String OS_VERSION
See Also:
Constant Field Values

HOSTNAME

public static final java.lang.String HOSTNAME
See Also:
Constant Field Values

OS_ARCH

public static final java.lang.String OS_ARCH
See Also:
Constant Field Values

USERNAME

public static final java.lang.String USERNAME
See Also:
Constant Field Values

DESCRIPTION

public static final java.lang.String DESCRIPTION
See Also:
Constant Field Values

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

TAGS

public static final java.lang.String TAGS
See Also:
Constant Field Values
Constructor Detail

NodeEntryImpl

public NodeEntryImpl()
Base constructor


NodeEntryImpl

public NodeEntryImpl(java.lang.String nodename)
Create an instance with a nodename value

Parameters:
nodename - the node name

NodeEntryImpl

public NodeEntryImpl(java.lang.String hostname,
                     java.lang.String nodename)
Create a NodeEntryImpl with hostname and nodename

Parameters:
hostname - hostname
nodename - node name
Method Detail

create

public static INodeEntry create(java.lang.String hostname,
                                java.lang.String nodename)
Factory method to create an instance with a hostname and node name.

Parameters:
hostname - hostname value
nodename - node name

setNodename

public void setNodename(java.lang.String nodename)
Description copied from class: NodeBaseImpl
Set the node name

Overrides:
setNodename in class NodeBaseImpl
Parameters:
nodename - name of the node

getNodename

public java.lang.String getNodename()
Description copied from interface: INodeBase
Return the name of the node

Specified by:
getNodename in interface INodeBase
Specified by:
getNodename in interface INodeDesc
Specified by:
getNodename in interface INodeEntry
Overrides:
getNodename in class NodeBaseImpl
Returns:

getTags

public java.util.Set getTags()
Description copied from interface: INodeEntry
Return the set of tag strings

Specified by:
getTags in interface INodeEntry

setTags

public void setTags(java.util.Set tags)

getOsName

public java.lang.String getOsName()
Description copied from interface: INodeEntry
Return the OS name

Specified by:
getOsName in interface INodeEntry

setOsName

public void setOsName(java.lang.String osName)

getOsFamily

public java.lang.String getOsFamily()
Description copied from interface: INodeEntry
Return the OS family

Specified by:
getOsFamily in interface INodeEntry

setOsFamily

public void setOsFamily(java.lang.String osFamily)

getOsVersion

public java.lang.String getOsVersion()
Description copied from interface: INodeEntry
Return the OS version

Specified by:
getOsVersion in interface INodeEntry

setOsVersion

public void setOsVersion(java.lang.String osVersion)

getHostname

public java.lang.String getHostname()
Description copied from interface: INodeDesc
Returns hostname

Specified by:
getHostname in interface INodeDesc
Returns:
Name of node

setHostname

public void setHostname(java.lang.String hostname)

getOsArch

public java.lang.String getOsArch()
Description copied from interface: INodeEntry
Return the OS architecture

Specified by:
getOsArch in interface INodeEntry

setOsArch

public void setOsArch(java.lang.String osArch)

getUsername

public java.lang.String getUsername()
Description copied from interface: INodeEntry
Return the username

Specified by:
getUsername in interface INodeEntry

setUsername

public void setUsername(java.lang.String username)

equals

public boolean equals(INodeDesc node)
Description copied from interface: INodeDesc
Checks equality with another node description

Specified by:
equals in interface INodeDesc
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

containsUserName

public static boolean containsUserName(java.lang.String host)
Checks if nodename contains a user name

Parameters:
host - hostname value
Returns:
true if matches a "user@host" pattern

containsUserName

public boolean containsUserName()
Description copied from interface: INodeEntry
Return true if the hostname string includes embedded username in the "username@hostname" pattern

Specified by:
containsUserName in interface INodeEntry

extractUserName

public static java.lang.String extractUserName(java.lang.String hostname)
Extract a username from a "username@hostname" pattern.

Parameters:
hostname - value
Returns:
username extracted, or null

extractUserName

public java.lang.String extractUserName()
Gets the username for remote connections. The following logic is used: If the username property is set then the username value is returned. If the username is not set and the hostname contains a "user@" prefix then the "user" substring is returned If the hostname contains a substring that looks like a port (eg, :22) the port is stripped off

Specified by:
extractUserName in interface INodeEntry
Returns:
Gets the username for remote connections

extractHostname

public static java.lang.String extractHostname(java.lang.String host)
Extract hostname from a string of the pattern "username@hostname:port"

Parameters:
host - the hostname
Returns:
the extracted hostname, or the original string if the pattern is not matched

extractHostname

public java.lang.String extractHostname()
Description copied from interface: INodeEntry
Return the standalone hostname value extracted from the hostname string

Specified by:
extractHostname in interface INodeEntry

extractPort

public java.lang.String extractPort()
Description copied from interface: INodeEntry
Return the port string extracted from the hostname

Specified by:
extractPort in interface INodeEntry

extractPort

public static java.lang.String extractPort(java.lang.String host)
Extract the port string from a string in the pattern "hostname:port"

Parameters:
host - the hostname
Returns:
the extracted port string, or null if the pattern is not matched.

containsPort

public boolean containsPort()
Description copied from interface: INodeEntry
Return true if the hostname string includes embedded port in the "hostname:port" pattern

Specified by:
containsPort in interface INodeEntry

containsPort

public static boolean containsPort(java.lang.String host)
Return true if the hostname contains a port value in the form "hostname:port".

Parameters:
host - hostname
Returns:
true if it matches the "host:port" pattern

setFrameworkProject

public void setFrameworkProject(java.lang.String project)

getFrameworkProject

public java.lang.String getFrameworkProject()
Description copied from interface: INodeEntry
Return the project name if it is set

Specified by:
getFrameworkProject in interface INodeEntry

getAttributes

public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Get the map of attributes for the node, including all predefined attribtes available via acessors.

Specified by:
getAttributes in interface INodeEntry
Returns:
attributes

setAttributes

public void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)

setDescription

public void setDescription(java.lang.String description)

getDescription

public java.lang.String getDescription()
Description copied from interface: INodeEntry
Return the description

Specified by:
getDescription in interface INodeEntry

getExtendedAttributes

public java.util.Map<java.lang.String,java.lang.String> getExtendedAttributes()
Return the attributes for the node without any of the predefined attributes.


nodeExtendedAttributes

public static java.util.Map<java.lang.String,java.lang.String> nodeExtendedAttributes(INodeEntry node)
Return the attributes for the node without any of the predefined attributes.


nodeNamespacedAttributes

public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> nodeNamespacedAttributes(INodeEntry node)
Return the node attributes broken into namespaces, the result map will be contructed as: "namespace" : { "key": ["attr","value"] } where "attr" is the source full attribute name


getAttribute

public java.lang.String getAttribute(java.lang.String name)
Get the value for a specific attribute

Parameters:
name - attribute name
Returns:
attribute value, or null if it is not set

setAttribute

public java.lang.String setAttribute(java.lang.String name,
                                     java.lang.String value)
Set the value for a specific attribute

Parameters:
name - attribute name
value - attribute value

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class NodeBaseImpl

hashCode

public int hashCode()
Overrides:
hashCode in class NodeBaseImpl