Skip to content

Commit 01be785

Browse files
Merge pull request #455 from renan-lopes-rodrigues/FLSTD-2566
code cleanning
2 parents e626dca + 5ebd43d commit 01be785

File tree

1 file changed

+6
-58
lines changed

1 file changed

+6
-58
lines changed

networkapi/plugins/Netconf/plugin.py

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -53,47 +53,16 @@ def connect(self):
5353
raise exceptions.InvalidEquipmentAccessException()
5454
### End block ###
5555

56-
#Bypassing connection
56+
# Bypassing connection due python version incompatibility
5757
try:
5858
pass
5959

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-
9160
### Exception handler
9261
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)
9564
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))
9766

9867
def apply_config_to_equipment(self, config, use_vrf=None, tarqet='running'):
9968

@@ -202,11 +171,6 @@ def copyScriptFileToConfig(self, filename, use_vrf='', destination=''):
202171
command_file = open(file_path, "r")
203172
command = command_file.read()
204173

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-
210174
return self.exec_command(command=command)
211175

212176
except IOError as e:
@@ -224,8 +188,7 @@ def exec_command(self, command, success_regex='', invalid_regex=None, error_rege
224188

225189
try:
226190
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
229192

230193
response = requests.post(
231194
url="http://localhost:5000/deploy",
@@ -258,21 +221,6 @@ def close(self):
258221
259222
:returns: True if success or raise an exception on any error
260223
"""
261-
# log.info("Close connection started...")
224+
# Not necessary
262225
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)
278226

0 commit comments

Comments
 (0)