Skip to content

Commit

Permalink
Merge pull request #90 from arista-eosplus/hotfix-0.6.1
Browse files Browse the repository at this point in the history
Hotfix 0.6.1
  • Loading branch information
phil-dileo committed Mar 4, 2016
2 parents 825915d + 6cafe2e commit 3ee6d88
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
20 changes: 20 additions & 0 deletions docs/release-notes-0.6.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
######
v0.6.1
######

2016-03-04

(This is a hotfix release)

New Modules
^^^^^^^^^^^
* None

Enhancements
^^^^^^^^^^^^
* None

Fixed
^^^^^
* SR56181 - pyeapi 0.5.0 and 0.6.0 aren't able to execute commands with enable password (`88 <https://github.com/arista-eosplus/pyeapi/issues/88>`_)
A regression was introduced in 0.5.0 which broke passing the enable password to the Node() object.
1 change: 1 addition & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Release Notes
release-notes-0.4.0.rst
release-notes-0.5.0.rst
release-notes-0.6.0.rst
release-notes-0.6.1.rst
2 changes: 1 addition & 1 deletion pyeapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
__version__ = '0.6.0'
__version__ = '0.6.1'
__author__ = 'Arista EOS+'


Expand Down
11 changes: 3 additions & 8 deletions pyeapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def make_connection(transport, **kwargs):
return klass(**kwargs)

def connect(transport=None, host='localhost', username='admin',
password='', port=None, timeout=60, return_node=False):
password='', port=None, timeout=60, return_node=False, **kwargs):
""" Creates a connection using the supplied settings
This function will create a connection to an Arista EOS node using
Expand Down Expand Up @@ -415,7 +415,7 @@ def connect(transport=None, host='localhost', username='admin',
password=password, port=port, timeout=timeout)
if return_node:
return Node(connection, transport=transport, host=host,
username=username, password=password, port=port)
username=username, password=password, port=port, **kwargs)
return connection


Expand Down Expand Up @@ -772,10 +772,5 @@ def connect_to(name):
if not kwargs:
raise AttributeError('connection profile not found in config')

node = connect(transport=kwargs.get('transport'),
host=kwargs.get('host'),
username=kwargs.get('username'),
password=kwargs.get('password'),
port=kwargs.get('port'),
return_node=True)
node = connect(return_node=True, **kwargs)
return node
2 changes: 1 addition & 1 deletion test/fixtures/eapi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
host: 192.168.1.16
username: eapi
password: password
enablepwd: enablepwd
tags: tag1, tag2

[connection:test2]
Expand All @@ -12,4 +13,3 @@ tags: tag1
[connection:localhost]
username: eapi
password: password

11 changes: 10 additions & 1 deletion test/system/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ def setUp(self):
for name in config.sections():
if name.startswith('connection:') and 'localhost' not in name:
name = name.split(':')[1]
self.duts.append(pyeapi.client.connect_to(name))
dut = pyeapi.client.connect_to(name)
self.duts.append(dut)
if dut._enablepwd is not None:
# If enable password defined for dut, set the
# enable password on the dut and clear it on tearDown
dut.config("enable secret %s" % dut._enablepwd)

def test_enable_single_command(self):
for dut in self.duts:
Expand Down Expand Up @@ -126,6 +131,10 @@ def test_get_block_none(self):
txtstr = api.get_block('interface Ethernet1', config='config')
self.assertEqual(txtstr, None)

def tearDown(self):
for dut in self.duts:
dut.config("no enable secret")


class TestNode(unittest.TestCase):

Expand Down
26 changes: 22 additions & 4 deletions test/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_load_config_for_connection_with_filename(self):
self.assertEqual(cfg['host'], '192.168.1.16')
self.assertEqual(cfg['username'], 'eapi')
self.assertEqual(cfg['password'], 'password')
self.assertEqual(cfg['enablepwd'], 'enablepwd')

def test_load_config_for_connection_with_env(self):
os.environ['EAPI_CONF'] = get_fixture('eapi.conf')
Expand All @@ -164,6 +165,7 @@ def test_load_config_for_connection_with_env(self):
self.assertEqual(cfg['host'], '192.168.1.16')
self.assertEqual(cfg['username'], 'eapi')
self.assertEqual(cfg['password'], 'password')
self.assertEqual(cfg['enablepwd'], 'enablepwd')

def test_load_config(self):
conf = get_fixture('eapi.conf')
Expand Down Expand Up @@ -291,22 +293,38 @@ def test_connect_return_node(self):
with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(filename=conf)
pyeapi.client.connect(host='192.168.1.16', username='eapi',
password='password', port=None, timeout=60,
return_node=True)
node = pyeapi.client.connect(host='192.168.1.16', username='eapi',
password='password', port=None,
timeout=60, return_node=True)
kwargs = dict(host='192.168.1.16', username='eapi',
password='password', port=None, timeout=60)
transport.assert_called_once_with(**kwargs)
self.assertIsNone(node._enablepwd)

def test_connect_return_node_enablepwd(self):
transport = Mock()
with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(filename=conf)
node = pyeapi.client.connect(host='192.168.1.16', username='eapi',
password='password', port=None,
timeout=60, enablepwd='enablepwd',
return_node=True)
kwargs = dict(host='192.168.1.16', username='eapi',
password='password', port=None, timeout=60)
transport.assert_called_once_with(**kwargs)
self.assertEqual(node._enablepwd, 'enablepwd')

def test_connect_to_with_config(self):
transport = Mock()
with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(filename=conf)
pyeapi.client.connect_to('test1')
node = pyeapi.client.connect_to('test1')
kwargs = dict(host='192.168.1.16', username='eapi',
password='password', port=None, timeout=60)
transport.assert_called_once_with(**kwargs)
self.assertEqual(node._enablepwd, 'enablepwd')


if __name__ == '__main__':
Expand Down

0 comments on commit 3ee6d88

Please sign in to comment.