Skip to content

Commit d29ce27

Browse files
committed
updated documentation
1 parent 277b2d9 commit d29ce27

File tree

2 files changed

+241
-155
lines changed

2 files changed

+241
-155
lines changed

docs/user_guide/connection.rst

Lines changed: 2 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,156 +1121,6 @@ the ``service_attributes`` parameter.
11211121
456
11221122
11231123
1124-
.. _unicon_credentials:
1125-
1126-
Credentials
1127-
-----------
1128-
1129-
The ``credentials`` connection parameter defines a dictionary of named
1130-
credentials. A credential is a dictionary typically containing both
1131-
``username`` and ``password`` keys.
1132-
1133-
The ``login_creds`` connection parameter defines an optional sequence of
1134-
credential names to try. Each time the device prompts for a username or
1135-
password, the current credential is set to the next credential in the sequence
1136-
if a current credential has not already been set.
1137-
When a password is sent, the current credential is unset. The one exception
1138-
is when entering an administrator's password on a routing device coming up
1139-
without configuration, in this case the current credential is reused.
1140-
If the sequence has been exhausted and no more credentials are available to
1141-
satisfy a username/password prompt, a
1142-
`CredentialsExhaustedError<unicon.core.errors.CredentialsExhaustedError>` is
1143-
raised.
1144-
1145-
Credentials are not retried, any username or password failure causes a
1146-
`UniconAuthenticationError<unicon.core.errors.UniconAuthenticationError>`
1147-
to be raised.
1148-
1149-
It is possible to specify the password to use for routing devices to enter
1150-
enable mode. This may be done via the ``enable_password`` entry under the
1151-
current credential, or via a separate credential called ``enable``.
1152-
Please see :ref:`unicon_enable_password_handling` for details.
1153-
1154-
Passwords specified as a :ref:`secret_strings` are automatically decoded prior
1155-
to being sent to the device.
1156-
1157-
In pyATS Testbed YAML
1158-
"""""""""""""""""""""
1159-
1160-
Credentials may be specified on a per-testbed, per-device or per-connection
1161-
basis, as documented in :ref:`topology_credential_password_modeling`.
1162-
1163-
1164-
.. code-block:: python
1165-
1166-
from pyats.topology import loader
1167-
tb = loader.load("""
1168-
devices:
1169-
my_device:
1170-
type: router
1171-
credentials:
1172-
default:
1173-
username: admin
1174-
password: Cisc0123
1175-
alternate:
1176-
username: alt_username
1177-
password: alt_password
1178-
termserv:
1179-
username: tsuser
1180-
password: tspw
1181-
enable:
1182-
password: enablepw
1183-
connections:
1184-
defaults: {class: 'unicon.Unicon'}
1185-
a:
1186-
protocol: ssh
1187-
ip: 10.64.70.11
1188-
port: 2042
1189-
login_creds: [termserv, default]
1190-
ssh_options: "-v -i /path/to/identityfile"
1191-
1192-
""")
1193-
dev = tb.devices.my_device
1194-
dev.connect()
1195-
1196-
# To connect using different credentials than is contained in the
1197-
# testbed YAML ``login_creds`` key:
1198-
dev.destroy()
1199-
dev.connect(login_creds=['termserv', 'alternate'])
1200-
1201-
1202-
In Python
1203-
"""""""""
1204-
1205-
.. code-block:: python
1206-
1207-
dev = Connnection(hostname=uut_hostname,
1208-
start=[uut_start_cmd],
1209-
credentials={\
1210-
{'default': {'username': 'admin', 'password': 'Cisc0123'}},\
1211-
{'enable': {'password': 'enablepw'}},\
1212-
{'termserv': {'username': 'tsuser', 'password': 'tspw'}},\
1213-
},
1214-
login_creds = ['termserv', 'default'],
1215-
)
1216-
1217-
1218-
Post credential action
1219-
""""""""""""""""""""""
1220-
1221-
In certain cases, e.g. when using a serial console server, an action is needed to get a response
1222-
from the device connected to the serial port. There are two ways to configure this action.
1223-
The first one is using a setting, the second one is using a post credential action.
1224-
The post credential action takes precedence over the setting.
1225-
1226-
Example credentials for a device.
1227-
1228-
.. code-block:: yaml
1229-
1230-
my_device:
1231-
type: router
1232-
credentials:
1233-
default:
1234-
username: admin
1235-
password: Cisc0123
1236-
terminal_server:
1237-
username: tsuser
1238-
password: tspw
1239-
1240-
1241-
Setting the credential action via `settings` in python.
1242-
1243-
.. code-block:: python
1244-
1245-
# Name of the credential after which a "sendline()" should be executed
1246-
dev.settings.SENDLINE_AFTER_CRED = 'terminal_server'
1247-
1248-
1249-
Settings can also be specified for the connection in the topology file as shown below.
1250-
1251-
.. code-block:: yaml
1252-
1253-
connections:
1254-
cli:
1255-
settings:
1256-
SENDLINE_AFTER_CRED: terminal_server
1257-
1258-
1259-
The post credential action supports ``send`` and ``sendline``, you can specify a string to be sent,
1260-
e.g. `send( )` to send a space or `send(\\x03)` to send Ctrl-C. Quotes should not be specified.
1261-
1262-
.. code-block:: yaml
1263-
1264-
connections:
1265-
cli:
1266-
login_creds: [terminal_server, default]
1267-
arguments:
1268-
cred_action:
1269-
terminal_server:
1270-
post: sendline()
1271-
1272-
1273-
12741124
Logging
12751125
-------
12761126

@@ -1694,10 +1544,10 @@ To make use of this feature, you can choose from the following actions:
16941544
arguments:
16951545
learn_tokens: True
16961546
1697-
By default, token discovery will not overwrite tokens that you have already defined in your testbed file.
1547+
By default, token discovery will not overwrite tokens that you have already defined in your testbed file.
16981548
It will only assign discovered tokens to the device object if the token does not yet exist or if the value is generic. For example: `platform: generic`.
16991549
1700-
You can override this behavior if you'd like. Using the `overwrite_testbed_tokens` flag will cause any discovered token to be assigned to the device object regardless of what has been defined in the testbed.
1550+
You can override this behavior if you'd like. Using the `overwrite_testbed_tokens` flag will cause any discovered token to be assigned to the device object regardless of what has been defined in the testbed.
17011551
This flag can be set in the same way as `learn_tokens`:
17021552
17031553
1. Set the `overwrite_testbed_tokens` argument to True when calling `device.connect`

0 commit comments

Comments
 (0)