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.StringDESCRIPTIONstatic java.lang.StringHOSTNAMEstatic java.lang.StringNAMEstatic java.lang.StringOS_ARCHstatic java.lang.StringOS_FAMILYstatic java.lang.StringOS_NAMEstatic java.lang.StringOS_VERSIONprotected static java.lang.StringPORT_REGEXstatic java.lang.StringTAGSprotected static java.lang.StringUSER_AT_HOSTNAME_REGEXstatic java.lang.StringUSERNAME
-
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 booleancontainsPort()static booleancontainsPort(java.lang.String host)Return true if the hostname contains a port value in the form "hostname:port".booleancontainsUserName()static booleancontainsUserName(java.lang.String host)Checks if nodename contains a user namestatic INodeEntrycreate(java.lang.String hostname, java.lang.String nodename)Factory methodbooleanequals(INodeDesc node)Checks equality with another node descriptionbooleanequals(java.lang.Object o)java.lang.StringextractHostname()static java.lang.StringextractHostname(java.lang.String host)Extract hostname from a string of the pattern "username@hostname:port"java.lang.StringextractPort()static java.lang.StringextractPort(java.lang.String host)Extract the port string from a string in the pattern "hostname:port"java.lang.StringextractUserName()Gets the username for remote connections.static java.lang.StringextractUserName(java.lang.String hostname)Extract a username from a "username@hostname" pattern.java.lang.StringgetAttribute(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.StringgetDescription()java.util.Map<java.lang.String,java.lang.String>getExtendedAttributes()java.lang.StringgetFrameworkProject()java.lang.StringgetHostname()Returns hostnamejava.lang.StringgetNodename()java.lang.StringgetOsArch()java.lang.StringgetOsFamily()java.lang.StringgetOsName()java.lang.StringgetOsVersion()java.util.SetgetTags()java.lang.StringgetUsername()inthashCode()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.StringsetAttribute(java.lang.String name, java.lang.String value)Set the value for a specific attributevoidsetAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)voidsetDescription(java.lang.String description)voidsetFrameworkProject(java.lang.String project)voidsetHostname(java.lang.String hostname)voidsetNodename(java.lang.String nodename)Set the node namevoidsetOsArch(java.lang.String osArch)voidsetOsFamily(java.lang.String osFamily)voidsetOsName(java.lang.String osName)voidsetOsVersion(java.lang.String osVersion)voidsetTags(java.util.Set tags)voidsetUsername(java.lang.String username)java.lang.StringtoString()-
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:NodeBaseImplSet the node name- Overrides:
setNodenamein classNodeBaseImpl- Parameters:
nodename- name of the node
-
getNodename
public java.lang.String getNodename()
- Specified by:
getNodenamein interfaceINodeBase- Specified by:
getNodenamein interfaceINodeDesc- Specified by:
getNodenamein interfaceINodeEntry- Overrides:
getNodenamein classNodeBaseImpl- Returns:
- the name of the node
-
getTags
public java.util.Set getTags()
- Specified by:
getTagsin interfaceINodeEntry- Returns:
- the set of tag strings
-
setTags
public void setTags(java.util.Set tags)
-
getOsName
public java.lang.String getOsName()
- Specified by:
getOsNamein interfaceINodeEntry- Returns:
- the OS name
-
setOsName
public void setOsName(java.lang.String osName)
-
getOsFamily
public java.lang.String getOsFamily()
- Specified by:
getOsFamilyin interfaceINodeEntry- Returns:
- the OS family
-
setOsFamily
public void setOsFamily(java.lang.String osFamily)
-
getOsVersion
public java.lang.String getOsVersion()
- Specified by:
getOsVersionin interfaceINodeEntry- Returns:
- the OS version
-
setOsVersion
public void setOsVersion(java.lang.String osVersion)
-
getHostname
public java.lang.String getHostname()
Description copied from interface:INodeDescReturns hostname- Specified by:
getHostnamein interfaceINodeDesc- Returns:
- Name of node
-
setHostname
public void setHostname(java.lang.String hostname)
-
getOsArch
public java.lang.String getOsArch()
- Specified by:
getOsArchin interfaceINodeEntry- Returns:
- the OS architecture
-
setOsArch
public void setOsArch(java.lang.String osArch)
-
getUsername
public java.lang.String getUsername()
- Specified by:
getUsernamein interfaceINodeEntry- Returns:
- the username
-
setUsername
public void setUsername(java.lang.String username)
-
equals
public boolean equals(INodeDesc node)
Description copied from interface:INodeDescChecks equality with another node description
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
containsUserNamein 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:
extractUserNamein 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:
extractHostnamein interfaceINodeEntry- Returns:
- the standalone hostname value extracted from the hostname string
-
extractPort
public java.lang.String extractPort()
- Specified by:
extractPortin 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:
containsPortin 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:
getFrameworkProjectin 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:
getAttributesin 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:
getDescriptionin 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:
equalsin classNodeBaseImpl
-
hashCode
public int hashCode()
- Overrides:
hashCodein classNodeBaseImpl
-
-