|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.foxsmart.csu.config.CiscoRouterConfigParser
com.foxsmart.csu.config.CiscoRouterConfigComponent
public abstract class CiscoRouterConfigComponent
The CiscoRouterConfigComponent class represents a part of an overall Cisco Router IOS configuration. All parts of the router configuration should be made up of classes that extend this class.
| Field Summary | |
|---|---|
protected CommentComponent |
commentComponent
|
protected java.util.Map |
componentMap
|
protected org.apache.commons.logging.Log |
log
|
protected CiscoRouterConfigComponent |
parentComponent
|
| Fields inherited from class com.foxsmart.csu.config.CiscoRouterConfigParser |
|---|
NO, tokenIndex |
| Constructor Summary | |
|---|---|
CiscoRouterConfigComponent()
Constructs the component. |
|
| Method Summary | |
|---|---|
void |
addComponent(CiscoRouterConfigComponent component)
Adds a component to the list of configuration components based on a configuration key. |
protected void |
addComponent(java.lang.String key,
CiscoRouterConfigComponent component)
Adds a component to the list of configuration components based on a configuration key. |
abstract java.util.List |
buildFromIos(java.util.List configLines)
Parse and populate the specific CiscoRouterComponent object based on the passed in individual lines of the IOS configuration. |
CiscoRouterConfigComponent |
checkComponentType(CiscoRouterConfigComponent component,
java.lang.Class compareClass)
Checks that the passed in component is the same type as our component. |
protected boolean |
deleteOldConfigWhenUpdating()
A flag that determines if delete commands should be issued to first delete the old component before issuing the update commands for the new component. |
protected void |
dumpComponents()
Dumps the configuration components. |
protected Commands |
generateChildrenUpdateConfiglet(CiscoRouterConfigComponent origCompositeComponent)
Generates the list of commands that will handle the updating of all children of this component. |
protected Commands |
generateCompositeIos(CiscoRouterConfigComponent component)
Generates the IOS commands for a composite component. |
protected Commands |
generateCompositeIos(CiscoRouterConfigComponent configComponent,
boolean update)
Generates the IOS commands for a composite component. |
Commands |
generateDeleteIos(CiscoRouterConfig updatedCiscoRouterConfig)
Generates the IOS configuration commands to delete this component. |
abstract Commands |
generateIos()
Returns the IOS configuration commands for this component. |
protected Commands |
generateIos(java.lang.Class key)
Generates the IOS commands for all components based on the specified key. |
protected Commands |
generateIos(java.lang.String key)
Generates the IOS commands for all components based on the specified key. |
protected Commands |
generateIos(java.lang.String key,
boolean update)
Generates the IOS commands for all components based on the specified key. |
protected Commands |
generateMultiLineUpdateConfiglet(CiscoRouterConfigComponent origComponent)
Generates the IOS commands that will handle the updating of a multi-line component. |
protected Commands |
generateUpdateCompositeIos(CiscoRouterConfigComponent component)
Generates the update IOS commands for a composite component. |
protected Commands |
generateUpdateIos()
Generates the IOS commands that will handle the updating of this component. |
protected Commands |
generateUpdateIos(java.lang.String key)
Generates the IOS commands for all components based on the specified key. |
java.util.List |
getAllComponents()
Gets all the components for all keys. |
static CiscoRouterConfig |
getCiscoRouterConfig(CiscoRouterConfigComponent component)
Searches the parent component hierarchy of the passed in component and returns the first CiscoRouterConfig component found (should be the highest level parent). |
CommentComponent |
getComment()
Gets the comment associated with this component. |
protected java.lang.String |
getComponentClassName(java.util.List tokens,
int numTokens)
Gets the component class name for the passed in list of tokens and number of tokens to use. |
protected java.lang.String |
getComponentClassName(java.lang.String componentKeyword)
Gets the component class name for the passed in router component keyword. |
protected java.util.List |
getComponentKeys()
Gets the component key set for this component. |
java.util.List |
getComponents(java.lang.Class key)
Gets all the components for a specified key. |
protected java.util.List |
getComponents(java.lang.String key)
Gets all the components for a specified key. |
boolean |
getDeferredDelete()
This default implementation returns false which ensures all Commands are processed in their standard order. |
CiscoRouterConfigComponent |
getFirstComponent(java.lang.Class key)
Gets a single component for a specified key. |
protected CiscoRouterConfigComponent |
getFirstComponent(java.lang.String key)
Gets a single component for a specified key. |
CiscoRouterConfigComponent |
getParentComponent()
Gets the parent component of this component. |
int |
getTotalComponents(java.lang.Class key)
Gets the number of components for a specified key. |
protected int |
getTotalComponents(java.lang.String key)
Gets the number of components for a specified key. |
Commands |
getUpdateConfiglet(CiscoRouterConfigComponent origComponent)
Returns the list of IOS commands that can be used to provision the router to update the original configuration (passed in as a parameter) to look like this component. |
protected CiscoRouterConfigComponent |
instantiateComponent(java.util.List tokens,
java.util.List packages)
Instantiates the passed in List of tokens as a class name trying the passed in packages for its location. |
protected CiscoRouterConfigComponent |
instantiateComponent(java.lang.String className,
java.util.List packages)
Instantiates the passed in class name trying the passed in packages for its location. |
boolean |
isValid()
Determines if this component is valid or not. |
void |
removeAllComponents()
Removes all components from the list of configuration components for all configuration keys. |
void |
removeAllComponents(java.lang.Class key)
Removes all components from the list of configuration components based on a configuration key. |
protected void |
removeAllComponents(java.lang.String key)
Removes all components from the list of configuration components based on a configuration key. |
void |
removeComponent(CiscoRouterConfigComponent component)
Removes a component from the list of configuration components based on a configuration key. |
protected void |
removeComponent(java.util.List componentList,
CiscoRouterConfigComponent component)
Removes the component from the component list while also removing the component's parent reference. |
protected void |
removeComponent(java.lang.String key,
CiscoRouterConfigComponent component)
Removes a component from the list of configuration components based on a configuration key. |
boolean |
requiresCommentSeparator()
Determines if a comment separator should be generated between the various instances of this component when generateIos is called and more than one component of this type exists. |
void |
setComment(CommentComponent comment)
Sets a comment associated with a CiscoRouterConfigComponent. |
protected void |
setParentComponent(CiscoRouterConfigComponent parentComponent)
Sets the parent component for this component. |
abstract void |
validate()
Validates this object to ensure it contains a valid IOS configuration. |
protected void |
validateChildren()
Validates all the children of this component. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.apache.commons.logging.Log log
protected CommentComponent commentComponent
protected java.util.Map componentMap
protected CiscoRouterConfigComponent parentComponent
| Constructor Detail |
|---|
public CiscoRouterConfigComponent()
| Method Detail |
|---|
public abstract java.util.List buildFromIos(java.util.List configLines)
throws InvalidConfigurationException
configLines - The list of IOS configuration lines.
InvalidConfigurationException - if the IOS configuration can not be parsed for any reason.
public abstract Commands generateIos()
throws InvalidConfigurationException
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated.
The validate() method is used to determine if the configuration is valid.
public abstract void validate()
throws InvalidConfigurationException
InvalidConfigurationException - if the configuration is invalid.protected java.util.List getComponentKeys()
protected void validateChildren()
throws InvalidConfigurationException
InvalidConfigurationException - if any of the children are invalid.
protected Commands generateIos(java.lang.Class key)
throws InvalidConfigurationException
key - The key for the components to generate.
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated.
The validate() method is used to determine if the configuration is valid.
protected Commands generateIos(java.lang.String key)
throws InvalidConfigurationException
key - The key for the components to generate.
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated.
The validate() method is used to determine if the configuration is valid.
protected Commands generateUpdateIos(java.lang.String key)
throws InvalidConfigurationException
key - The key for the components to generate.
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated.
The validate() method is used to determine if the configuration is valid.
protected Commands generateIos(java.lang.String key,
boolean update)
throws InvalidConfigurationException
key - The key for the components to generate.update - If true, update IOS statements will be issued (e.g. generateUpdateIos). Otherwise, view IOS
statements will be generated (e.g. generateIos).
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated.
The validate() method is used to determine if the configuration is valid.
protected Commands generateCompositeIos(CiscoRouterConfigComponent component)
throws InvalidConfigurationException
component - The component to generate the IOS from
InvalidConfigurationException - if the configuration is invalid.
protected Commands generateUpdateCompositeIos(CiscoRouterConfigComponent component)
throws InvalidConfigurationException
component - The component to generate the IOS from
InvalidConfigurationException - if the configuration is invalid.
protected Commands generateCompositeIos(CiscoRouterConfigComponent configComponent,
boolean update)
throws InvalidConfigurationException
configComponent - The component to generate the IOS fromupdate - If true, update IOS statements will be issued (e.g. generateUpdateIos). If false, view IOS
statements will be issued (e.g. generateIos).
InvalidConfigurationException - if the configuration is invalid.public boolean getDeferredDelete()
public Commands generateDeleteIos(CiscoRouterConfig updatedCiscoRouterConfig)
throws InvalidConfigurationException
updatedCiscoRouterConfig - the updated Cisco router configuration.
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated.
The validate() method is used to determine if the configuration is valid.public boolean requiresCommentSeparator()
public void setComment(CommentComponent comment)
comment - The comment to associate with this component.public CommentComponent getComment()
public boolean isValid()
public void addComponent(CiscoRouterConfigComponent component)
throws InvalidConfigurationException
component - The component to add
InvalidConfigurationException - if a non-MultiInterfaceComponent has already been added.
protected void addComponent(java.lang.String key,
CiscoRouterConfigComponent component)
throws InvalidConfigurationException
key - The key for which component list to add tocomponent - The component to add
InvalidConfigurationException - if a non-MultiInterfaceComponent has already been added.public void removeAllComponents(java.lang.Class key)
key - The key for which component list to delete fromprotected void removeAllComponents(java.lang.String key)
key - The key for which component list to delete frompublic void removeAllComponents()
public void removeComponent(CiscoRouterConfigComponent component)
component - The component to remove
protected void removeComponent(java.lang.String key,
CiscoRouterConfigComponent component)
key - The key for which component list to delete fromcomponent - The component to remove
protected void removeComponent(java.util.List componentList,
CiscoRouterConfigComponent component)
componentList - the component list to remove the component from.component - the component to remove.public java.util.List getComponents(java.lang.Class key)
key - The key for the components.
protected java.util.List getComponents(java.lang.String key)
key - The key for the components.
public java.util.List getAllComponents()
public int getTotalComponents(java.lang.Class key)
key - The key for the components.
protected int getTotalComponents(java.lang.String key)
key - The key for the components.
public CiscoRouterConfigComponent getFirstComponent(java.lang.Class key)
key - The key for the components.
protected CiscoRouterConfigComponent getFirstComponent(java.lang.String key)
key - The key for the components.
protected CiscoRouterConfigComponent instantiateComponent(java.lang.String className,
java.util.List packages)
throws InvalidConfigurationException
className - The class name to try to instantiatepackages - The list of packages to try, in the order specified.
InvalidConfigurationException - if we were unable to find the root CiscoRouterConfig object.
protected CiscoRouterConfigComponent instantiateComponent(java.util.List tokens,
java.util.List packages)
throws InvalidConfigurationException
tokens - The list of tokens for this IOS line (e.g. exec-timeout, ...)packages - The list of packages to try, in the order specified.
InvalidConfigurationException - if we were unable to find the root CiscoRouterConfig object.
protected java.lang.String getComponentClassName(java.util.List tokens,
int numTokens)
tokens - The list of tokensnumTokens - The number of tokens to use
protected java.lang.String getComponentClassName(java.lang.String componentKeyword)
componentKeyword - The keyword for the component (e.g. exec-timeout).
public CiscoRouterConfigComponent getParentComponent()
protected void setParentComponent(CiscoRouterConfigComponent parentComponent)
parentComponent - the parent component.
public Commands getUpdateConfiglet(CiscoRouterConfigComponent origComponent)
throws InvalidConfigurationException
origComponent - The original component.
InvalidConfigurationException - if either this or the passed in configuration are invalid.
protected Commands generateUpdateIos()
throws InvalidConfigurationException
InvalidConfigurationException - if this component can't be updated.
protected Commands generateMultiLineUpdateConfiglet(CiscoRouterConfigComponent origComponent)
throws InvalidConfigurationException
origComponent - The original component.
InvalidConfigurationException - if either this or the passed in configuration are invalid.
protected Commands generateChildrenUpdateConfiglet(CiscoRouterConfigComponent origCompositeComponent)
throws InvalidConfigurationException
origCompositeComponent - The original composite component. This parameter can not be null.
InvalidConfigurationException - if either this or the passed in configuration are invalid.
public static CiscoRouterConfig getCiscoRouterConfig(CiscoRouterConfigComponent component)
throws InvalidConfigurationException
component - The component whose parents will be searched.
InvalidConfigurationException - if no CiscoRouterConfig parent could be found.protected boolean deleteOldConfigWhenUpdating()
public CiscoRouterConfigComponent checkComponentType(CiscoRouterConfigComponent component,
java.lang.Class compareClass)
throws InvalidConfigurationException
component - the component to compare with.compareClass - the class the component needs to match.
InvalidConfigurationException - if the components are not the same.protected void dumpComponents()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||