예제 #1
0
파일: f5.py 프로젝트: ssumsam/napalm-f5
 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))
예제 #2
0
 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()
예제 #3
0
파일: ros.py 프로젝트: pierky/napalm-ros
 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))
예제 #4
0
    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 ")
예제 #5
0
 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))
예제 #6
0
    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
예제 #7
0
파일: exos.py 프로젝트: inex/napalm-exos
 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))
예제 #8
0
 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))
예제 #9
0
 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()
예제 #10
0
 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))
예제 #11
0
파일: nxos.py 프로젝트: ktbyers/napalm-nxos
 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))
예제 #12
0
    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)
예제 #13
0
 def open(self):
     try:
         self.device.open()
     except ConnectionError as ce:
         raise ConnectionException(ce.message)
예제 #14
0
 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")