|
10 | 10 | __email__ = "marcin.usielski@nokia.com" |
11 | 11 |
|
12 | 12 |
|
13 | | -import logging |
14 | 13 | from moler.device.proxy_pc import ProxyPc |
| 14 | +from moler.exceptions import DeviceFailure |
15 | 15 | from moler.helpers import ( |
16 | 16 | call_base_class_method_with_same_name, |
17 | 17 | mark_to_call_base_class_method_with_same_name, |
@@ -61,10 +61,10 @@ class UnixRemote(ProxyPc): |
61 | 61 | UNIX_REMOTE: |
62 | 62 | execute_command: ssh # default value |
63 | 63 | command_params: |
64 | | - expected_prompt: unix_remote_prompt |
65 | | - host: host_ip |
66 | | - login: login |
67 | | - password: password |
| 64 | + expected_prompt: unix_remote_prompt |
| 65 | + host: host_ip |
| 66 | + login: login |
| 67 | + password: password |
68 | 68 |
|
69 | 69 |
|
70 | 70 | """ |
@@ -116,21 +116,27 @@ def _overwrite_prompts(self): |
116 | 116 | Overwrite prompts for some states to easily configure the SM. |
117 | 117 | """ |
118 | 118 | super(UnixRemote, self)._overwrite_prompts() |
119 | | - if self._use_proxy_pc: |
120 | | - self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote][UnixRemote.proxy_pc][ |
121 | | - "command_params"]["expected_prompt"] = \ |
122 | | - self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.proxy_pc][ |
123 | | - "command_params"]["expected_prompt"] |
| 119 | + try: |
| 120 | + if self._use_proxy_pc: |
| 121 | + self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote][UnixRemote.proxy_pc][ |
| 122 | + "command_params"]["expected_prompt"] = \ |
| 123 | + self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.proxy_pc][ |
| 124 | + "command_params"]["expected_prompt"] |
124 | 125 |
|
125 | | - self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][ |
126 | | - "command_params"]["expected_prompt"] = \ |
127 | | - self._configurations[UnixRemote.connection_hops][UnixRemote.proxy_pc][UnixRemote.unix_remote][ |
128 | | - "command_params"]["expected_prompt"] |
129 | | - else: |
130 | | - self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][ |
131 | | - "command_params"]["expected_prompt"] = \ |
132 | | - self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.unix_remote][ |
133 | | - "command_params"]["expected_prompt"] |
| 126 | + self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][ |
| 127 | + "command_params"]["expected_prompt"] = \ |
| 128 | + self._configurations[UnixRemote.connection_hops][UnixRemote.proxy_pc][UnixRemote.unix_remote][ |
| 129 | + "command_params"]["expected_prompt"] |
| 130 | + else: |
| 131 | + self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][ |
| 132 | + "command_params"]["expected_prompt"] = \ |
| 133 | + self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.unix_remote][ |
| 134 | + "command_params"]["expected_prompt"] |
| 135 | + except KeyError as ke: |
| 136 | + raise DeviceFailure( |
| 137 | + device=self.__class__.__name__, |
| 138 | + message=f"Wrong configuration. Cannot get prompts. {ke} {repr(ke)}" |
| 139 | + ) |
134 | 140 |
|
135 | 141 | @mark_to_call_base_class_method_with_same_name |
136 | 142 | def _get_default_sm_configuration_with_proxy_pc(self): |
|
0 commit comments