Package com.dtolabs.rundeck.core.common
Class NodeEntryImpl
- java.lang.Object
-
- com.dtolabs.rundeck.core.common.NodeBaseImpl
-
- 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
Fields Modifier and Type Field Description 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
Constructors Constructor Description NodeEntryImpl()
Base constructorNodeEntryImpl(java.lang.String nodename)
Create an instance with a nodename valueNodeEntryImpl(java.lang.String hostname, java.lang.String nodename)
Create a NodeEntryImpl with hostname and nodename
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsPort()
static boolean
containsPort(java.lang.String host)
Return true if the hostname contains a port value in the form "hostname:port".boolean
containsUserName()
static boolean
containsUserName(java.lang.String host)
Checks if nodename contains a user namestatic INodeEntry
create(java.lang.String hostname, java.lang.String nodename)
Factory methodboolean
equals(INodeDesc node)
Checks equality with another node descriptionboolean
equals(java.lang.Object o)
java.lang.String
extractHostname()
static java.lang.String
extractHostname(java.lang.String host)
Extract hostname from a string of the pattern "username@hostname:port"java.lang.String
extractPort()
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 attributejava.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()
java.util.Map<java.lang.String,java.lang.String>
getExtendedAttributes()
java.lang.String
getFrameworkProject()
java.lang.String
getHostname()
Returns hostnamejava.lang.String
getNodename()
java.lang.String
getOsArch()
java.lang.String
getOsFamily()
java.lang.String
getOsName()
java.lang.String
getOsVersion()
java.util.Set
getTags()
java.lang.String
getUsername()
int
hashCode()
static java.util.Map<java.lang.String,java.lang.String>
nodeExtendedAttributes(INodeEntry node)
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>>
nodeNamespacedAttributes(INodeEntry node)
java.lang.String
setAttribute(java.lang.String name, java.lang.String value)
Set the value for a specific attributevoid
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 namevoid
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
-
-
-
-
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
- hostnamenodename
- node name
-
-
Method Detail
-
create
public static INodeEntry create(java.lang.String hostname, java.lang.String nodename)
Factory method- Parameters:
hostname
- hostname valuenodename
- node name- Returns:
- create an instance with a hostname and node name.
-
setNodename
public void setNodename(java.lang.String nodename)
Description copied from class:NodeBaseImpl
Set the node name- Overrides:
setNodename
in classNodeBaseImpl
- Parameters:
nodename
- name of the node
-
getNodename
public java.lang.String getNodename()
- Specified by:
getNodename
in interfaceINodeBase
- Specified by:
getNodename
in interfaceINodeDesc
- Specified by:
getNodename
in interfaceINodeEntry
- Overrides:
getNodename
in classNodeBaseImpl
- Returns:
- the name of the node
-
getTags
public java.util.Set getTags()
- Specified by:
getTags
in interfaceINodeEntry
- Returns:
- the set of tag strings
-
setTags
public void setTags(java.util.Set tags)
-
getOsName
public java.lang.String getOsName()
- Specified by:
getOsName
in interfaceINodeEntry
- Returns:
- the OS name
-
setOsName
public void setOsName(java.lang.String osName)
-
getOsFamily
public java.lang.String getOsFamily()
- Specified by:
getOsFamily
in interfaceINodeEntry
- Returns:
- the OS family
-
setOsFamily
public void setOsFamily(java.lang.String osFamily)
-
getOsVersion
public java.lang.String getOsVersion()
- Specified by:
getOsVersion
in interfaceINodeEntry
- Returns:
- the OS version
-
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 interfaceINodeDesc
- Returns:
- Name of node
-
setHostname
public void setHostname(java.lang.String hostname)
-
getOsArch
public java.lang.String getOsArch()
- Specified by:
getOsArch
in interfaceINodeEntry
- Returns:
- the OS architecture
-
setOsArch
public void setOsArch(java.lang.String osArch)
-
getUsername
public java.lang.String getUsername()
- Specified by:
getUsername
in interfaceINodeEntry
- Returns:
- the username
-
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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()
- Specified by:
containsUserName
in interfaceINodeEntry
- Returns:
- true if the hostname string includes embedded username in the "username@hostname" pattern
-
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 interfaceINodeEntry
- 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()
- Specified by:
extractHostname
in interfaceINodeEntry
- Returns:
- the standalone hostname value extracted from the hostname string
-
extractPort
public java.lang.String extractPort()
- Specified by:
extractPort
in interfaceINodeEntry
- Returns:
- the port string extracted from the hostname
-
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()
- Specified by:
containsPort
in interfaceINodeEntry
- Returns:
- true if the hostname string includes embedded port in the "hostname:port" pattern
-
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()
- Specified by:
getFrameworkProject
in interfaceINodeEntry
- Returns:
- the project name if it is set
-
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 interfaceINodeEntry
- 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()
- Specified by:
getDescription
in interfaceINodeEntry
- Returns:
- the description
-
getExtendedAttributes
public java.util.Map<java.lang.String,java.lang.String> getExtendedAttributes()
- Returns:
- 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)
- Parameters:
node
- node- Returns:
- 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)
- Parameters:
node
- node- Returns:
- 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 namevalue
- attribute value- Returns:
- value
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classNodeBaseImpl
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classNodeBaseImpl
-
-