def open(self): try: self.device = bigsuds.BIGIP(hostname=self.hostname, username=self.username, password=self.password) self.devices = self.device.Management.Device.get_list() except bigsuds.OperationFailed as err: raise ConnectionException('ConfigSync API Error ({})'.format(err))
def open(self): try: self.device.open() except ConnectTimeoutError as cte: raise ConnectionException(cte.message) self.device.timeout = self.timeout self.device.bind(cu=Config) if self.config_lock: self.lock()
def open(self): try: self.api = connect(host=self.hostname, username=self.username, password=self.password, timeout=self.timeout) except (TrapError, FatalError, ConnectionError, MultiTrapError) as exc: raise ConnectionException( 'Could not connect to {}:{} - [{!r}]'.format( self.hostname, self.port, exc))
def open(self): self.device = ConnectHandler(device_type='vyos', host=self.hostname, username=self.username, password=self.password, **self.netmiko_optional_args) try: self._scp_client = SCPConn(self.device) except: raise ConnectionException("Failed to open connection ")
def open(self): try: if self.api_key: self.device = pan.xapi.PanXapi(hostname=self.hostname, api_key=self.api_key) else: self.device = pan.xapi.PanXapi(hostname=self.hostname, api_username=self.username, api_password=self.password) except ConnectionException as e: raise ConnectionException(str(e))
def _open_ssh(self): try: self.ssh_device = ConnectHandler(device_type='paloalto_panos', ip=self.hostname, username=self.username, password=self.password, **self.netmiko_optional_args) except ConnectionException as e: raise ConnectionException(str(e)) self.ssh_connection = True
def open(self): """Implementation of NAPALM method open.""" try: self.device = EXOS(hostname=self.hostname, username=self.username, password=self.password, port=self.port, timeout=self.timeout) self.device.open() except Exception: raise ConnectionException("Unable to connect to {0}".format( self.hostname))
def open(self): try: # FIXME: Needs to be changed to extreme_netiron (?) self.device = ConnectHandler(device_type='brocade_netiron', ip=self.hostname, port=self.port, username=self.username, password=self.password, timeout=self.timeout, verbose=True) except Exception: raise ConnectionException("Cannot connect to switch: %s:%s" \ % (self.hostname, self.port))
def open(self): try: self.device.open(normalize=False, gather_facts=False) except ConnectTimeoutError as cte: raise ConnectionException(cte.message) self.device.timeout = self.timeout if hasattr(self.device, "cu"): # make sure to remove the cu attr from previous session # ValueError: requested attribute name cu already exists del self.device.cu self.device.bind(cu=Config) if self.config_lock: self._lock()
def open(self): try: self.device = NXOSDevice(self.hostname, self.username, self.password, timeout=self.timeout, port=self.port, transport=self.transport) self.device.show('show hostname') self.up = True except (CLIError, ValueError): # unable to open connection raise ConnectionException('Cannot connect to {}'.format( self.hostname))
def open(self): try: self.device = NXOSDevice(username=self.username, password=self.password, ip=self.hostname, timeout=self.timeout, protocol=self.protocol) self.device.show('show version', fmat='json') # execute something easy # something easier with XML format? self.up = True except URLError: # unable to open connection raise ConnectionException('Cannot connect to {}'.format(self.hostname))
def open(self): """Implemantation of NAPALM method open.""" try: connection = pyeapi.client.connect(transport='https', host=self.hostname, username=self.username, password=self.password, port=self.port, timeout=self.timeout) self.device = pyeapi.client.Node(connection) # does not raise an Exception if unusable # let's try to run a very simple command self.device.run_commands(['show clock'], encoding='text') except ConnectionError as ce: # and this is raised either if device not avaiable # either if HTTP(S) agent is not enabled # show management api http-commands raise ConnectionException(ce.message)
def open(self): try: self.device.open() except ConnectionError as ce: raise ConnectionException(ce.message)
def scp_file(self, source_file, dest_file): try: scp_transfer = SCPConn(self.device) scp_transfer.scp_put_file(source_file, dest_file) except: raise ConnectionException("SCP transfer to remote device failed")