Skip to content

Conversation

@da-ar
Copy link
Contributor

@da-ar da-ar commented Nov 20, 2018

As each class inherits directly from node_util, each class has its own cache of node. This removes the per class cache.
Additionally a reset has been added that can be called prior to Environment allowing the new environment settings to be used.

As each class inherits directly from `node_util`, each class has its own cache of `node`. This removes the per class cache.
Additionally a reset has been added that can be called prior to `Environment` allowing the new environment settings to be used.
@da-ar
Copy link
Contributor Author

da-ar commented Nov 20, 2018

@mikewiebe
Copy link
Contributor

@da-ar Not sure I fully understand the reason for this change. Can you provide more context? Thanks!

@da-ar
Copy link
Contributor Author

da-ar commented Nov 20, 2018

@mikewiebe So the reason for this change is that the module will only be instantiated once and used to access many different devices. The current code allows multiple environments to be created but you cannot specify the specific connection you want to use and class based caches mean that old connections are retained when an environment is changed. This PR will allow a previously set environment to be manually cleared and a new environment to take its place.

For example, this would break like this:

Cisco::Environment.add_new('default', host1)
Cisco::DomainNames.domainnames['something'] = value1
#connect to second device
Cisco::Environment.add_new('default', host2)
Cisco::DomainNames.domainnames['something'] = value2 # changes are made to host1

Take the following code path:
domain_name.domainnames > config_get > NodeUtil.config_get > node.config_get

node is Cisco::Node.instance

Which is Cisco::Node.new

node.config_get calls out to get which accesses @client.get. @client is set when Cisco::Node is initalized and does not pass an environment, so it defaults to nil

@mikewiebe
Copy link
Contributor

@da-ar Thanks for the explanation. Looks pretty straight forward but I kicked of a test against our internal testbed just to be safe. I will have results in the morning and will post back here.

@mikewiebe
Copy link
Contributor

@da-ar Test results looked good. 👍

@mikewiebe mikewiebe merged commit 20adf44 into cisco:develop Nov 21, 2018
Thomas-Franklin pushed a commit to Thomas-Franklin/cisco-network-puppet-module that referenced this pull request Feb 8, 2019
Refer to cisco/cisco-network-node-utils#601 (comment) for the explanation. This basically allows for multiple devices to be managed in the same catalog compilation without environmental bleeding.
chrisvanheuveln pushed a commit to cisco/cisco-network-puppet-module that referenced this pull request Feb 8, 2019
)

Refer to cisco/cisco-network-node-utils#601 (comment) for the explanation. This basically allows for multiple devices to be managed in the same catalog compilation without environmental bleeding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants