@@ -53,47 +53,16 @@ def connect(self):
53
53
raise exceptions .InvalidEquipmentAccessException ()
54
54
### End block ###
55
55
56
- #Bypassing connection
56
+ # Bypassing connection due python version incompatibility
57
57
try :
58
58
pass
59
59
60
- # ### Getting device access data ###
61
- # device = self.equipment_access.fqdn
62
- # username = self.equipment_access.user
63
- # password = self.equipment_access.password
64
- # ### End block ###
65
-
66
- # ### Runs connection ###
67
- # try:
68
- # log.info("Starting connection to '%s' using NCClient..." % device)
69
- # # transport = paramiko.Transport((device, 22))
70
- # # transport.get_security_options().kex = (
71
- # # 'curve25519-sha256',
72
- # # 'diffie-hellman-group14-sha1',
73
- # # 'diffie-hellman-group-exchange-sha256',
74
- # # )
75
- # # transport.get_security_options().ciphers = (
76
- # # 'aes128-ctr', 'aes256-ctr'
77
- # # )
78
-
79
- # self.session_manager = manager.connect(
80
- # host = device,
81
- # port = self.connect_port,
82
- # username = username,
83
- # password = password,
84
- # # hostkey_verify = False,
85
- # # allow_agent=False,
86
- # # look_for_keys=False,
87
-
88
- # )
89
- # log.info('Connection succesfully...')
90
-
91
60
### Exception handler
92
61
except IOError , e :
93
- log .error ('Could not connect to host %s: %s' % (device , e ))
94
- raise exceptions .ConnectionException (device )
62
+ log .error ('Could not connect to host %s: %s' % (self . equipment_access . fqdn , e ))
63
+ raise exceptions .ConnectionException (self . equipment_access . fqdn )
95
64
except Exception , e :
96
- log .error ('Error connecting to host %s:%s' % (device , e ))
65
+ log .error ('Error connecting to host %s:%s' % (self . equipment_access . fqdn , e ))
97
66
98
67
def apply_config_to_equipment (self , config , use_vrf = None , tarqet = 'running' ):
99
68
@@ -202,11 +171,6 @@ def copyScriptFileToConfig(self, filename, use_vrf='', destination=''):
202
171
command_file = open (file_path , "r" )
203
172
command = command_file .read ()
204
173
205
- # Check if Configuration is not empty and raises exception if not contain
206
- # self.check_configuration_has_content(command=command, file_path=file_path)
207
-
208
- # log.info("Load configuration from file {} successfully".format(file_path))
209
-
210
174
return self .exec_command (command = command )
211
175
212
176
except IOError as e :
@@ -224,8 +188,7 @@ def exec_command(self, command, success_regex='', invalid_regex=None, error_rege
224
188
225
189
try :
226
190
self .__try_lock () # Do nothing, will be executed by the locked method of ncclient
227
- # with self.session_manager.locked(target='running'):
228
- # self.session_manager.edit_config(target='running', config=command)
191
+ # Here we make a request to a microservice that runs in docker with python 3
229
192
230
193
response = requests .post (
231
194
url = "http://localhost:5000/deploy" ,
@@ -258,21 +221,6 @@ def close(self):
258
221
259
222
:returns: True if success or raise an exception on any error
260
223
"""
261
- # log.info("Close connection started...")
224
+ # Not necessary
262
225
pass
263
- # try:
264
- # if self.session_manager:
265
- # self.session_manager.close_session()
266
- # log.info('Connection closed successfully.')
267
- # return True
268
-
269
- # else:
270
- # raise Exception("session_manager is None.")
271
-
272
- # except Exception as e:
273
- # message = "Error while calling close session method on equipment %s" % self.equipment_access.fqdn
274
- # log.error(message)
275
- # log.error(e)
276
-
277
- # raise exceptions.APIException(message)
278
226
0 commit comments