def login(self): try: NXAPITransport.init(target_url=self.target_url, username=self.username, password=self.password) NXAPITransport.cli('! Testing if device is online') except Exception as e: self._is_online = False e = str(e).lower() if 'timed out' in e: self.error_online = ('Connection timed out!! Make sure that ' 'URL provided ({0}) is accurate' '').format(self.target_url) elif 'unauthorized' in e: self.error_online = ( 'Unauthorized!! Make sure that username ' '({0}) and/or password provided are accurate' '').format(self.username) elif 'target machine actively refused it' in e: self.error_online = ('NXAPI TCP Port not open!! Make sure ' '"feature nxapi" is configured on ' 'target Nexus switch') else: self.error_online = e else: self._is_online = True return self._is_online
def login(self): try: NXAPITransport.init(target_url=self.target_url, username=self.username, password=self.password) NXAPITransport.cli('! Testing if device is online') except Exception as e: self._is_online = False e = str(e).lower() if 'timed out' in e: self.error_online = ('Connection timed out!! Make sure that ' 'URL provided ({0}) is accurate' '').format(self.target_url) elif 'unauthorized' in e: self.error_online = ('Unauthorized!! Make sure that username ' '({0}) and/or password provided are accurate' '').format(self.username) elif 'target machine actively refused it' in e: self.error_online = ('NXAPI TCP Port not open!! Make sure ' '"feature nxapi" is configured on ' 'target Nexus switch') else: self.error_online = e else: self._is_online = True return self._is_online