How to use the ncclient.NCClientError function in ncclient

To help you get started, we’ve selected a few ncclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github osrg / ryu / tests / integrated / test_of_config.py View on Github external
def _do_of_config(self):
        self._do_get()
        self._do_get_config('running')
        self._do_get_config('startup')

        # LINC doesn't support 'candidate' datastore
        try:
            self._do_get_config('candidate')
        except ncclient.NCClientError:
            traceback.print_exc()

        # use raw XML format
        self._do_edit_config(SWITCH_PORT_DOWN)
        self._do_edit_config(SWITCH_ADVERTISED)
        self._do_edit_config(SWITCH_CONTROLLER)

        self._set_ports_down()

        self.switch.close_session()
github osrg / ryu / ryu / lib / of_config / capable_switch.py View on Github external
# limitations under the License.

import ncclient
import ncclient.manager
import ncclient.xml_

from ryu import exception as ryu_exc
from ryu.lib import of_config
from ryu.lib.of_config import constants as ofc_consts
from ryu.lib.of_config import classes as ofc


# TODO: When we re-organize ncclient, its NCClientError will be
#       subclass of RyuException.
class OFConfigCapableSwitchNotFound(ryu_exc.RyuException,
                                    ncclient.NCClientError):
    message = 'OpenFlow Capable Switch not found'


def get_ns_tag(tag):
    if tag[0] == '{':
        return tuple(tag[1:].split('}', 1))
    return (None, tag)


class OFCapableSwitch(object):
    def __init__(self, connect_method='connect_ssh', *args, **kwargs):
        super(OFCapableSwitch, self).__init__()
        self._connect_method = connect_method
        self._connect_args = args
        self._connect_kwargs = kwargs
        self.version = None
github ncclient / ncclient / ncclient / transport / errors.py View on Github external
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"TODO: docstrings"

from ncclient import NCClientError

class TransportError(NCClientError):
    pass

class AuthenticationError(TransportError):
    pass

class SessionCloseError(TransportError):
    
    def __init__(self, in_buf, out_buf=None):
        msg = 'Unexpected session close.'
        if in_buf:
            msg += ' IN_BUFFER: {%s}' % in_buf
        if out_buf:
            msg += ' OUT_BUFFER: {%s}' % out_buf
        SSHError.__init__(self, msg)

class SSHError(TransportError):
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ncclient / operations / errors.py View on Github external
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ncclient import NCClientError

class OperationError(NCClientError):
    pass

class TimeoutExpiredError(NCClientError):
    pass

class MissingCapabilityError(NCClientError):
    pass
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ncclient / operations / errors.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ncclient import NCClientError

class OperationError(NCClientError):
    pass

class TimeoutExpiredError(NCClientError):
    pass

class MissingCapabilityError(NCClientError):
    pass
github ncclient / ncclient / ncclient / transport / errors.py View on Github external
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ncclient import NCClientError

class TransportError(NCClientError):
    pass

class SessionError(NCClientError):
    pass

class AuthenticationError(TransportError):
    pass

class PermissionError(TransportError):
    pass

class SessionCloseError(TransportError):

    def __init__(self, in_buf, out_buf=None):
        msg = 'Unexpected session close'
        if in_buf:
github hsnlab / escape / escape / escape / util / netconf.py View on Github external
rpc in order to set the switches where the vnf should be connected.

    :param request_data: data for RPC request body
    :type request_data: dict
    :return: raw RPC response
    :rtype: :class:`lxml.etree.ElementTree`
    """
    # SENDING THE CREATED RPC XML to the server
    # rpc_reply = without .xml the reply has GetReply type
    # rpc_reply = with .xml we convert it to xml-string
    try:
      # we set our global variable's value to this xml-string therefore,
      # last RPC will always be accessible
      self._rpc_reply_as_xml = self.__connection.dispatch(request_data).xml
      return self._rpc_reply_as_xml
    except NCClientError:
      # need to handle???
      raise
github ncclient / ncclient / ncclient / transport / errors.py View on Github external
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ncclient import NCClientError

class TransportError(NCClientError):
    pass

class SessionError(NCClientError):
    pass

class AuthenticationError(TransportError):
    pass

class PermissionError(TransportError):
    pass

class SessionCloseError(TransportError):

    def __init__(self, in_buf, out_buf=None):
        msg = 'Unexpected session close'
        if in_buf:
            msg += '\nIN_BUFFER: `%s`' % in_buf
        if out_buf:
            msg += ' OUT_BUFFER: `%s`' % out_buf
github hsnlab / escape / escape / escape / infr / topo_manager.py View on Github external
reply = self.remoteAdapter.removeNF(vnf_id=vnf_id)
          self.log.log(VERBOSE,
                       "Removed NF status:\n%s" % pprint.pformat(reply))
          # Remove NF from deployed cache
          del self.deployed_vnfs[(infra_id, nf_id)]
          # Delete infra ports connected to the deletable NF
          for u, v, link in topo.network.out_edges([nf_id], data=True):
            topo[v].del_port(id=link.dst.id)
          # Delete NF
          topo.del_node(nf_id)
        except KeyError:
          self.log.error("Deployed VNF data for NF: %s is not found! "
                         "Skip deletion..." % nf_id)
          result = False
          continue
        except NCClientError as e:
          self.log.error("Got NETCONF RPC communication error during NF: %s "
                         "deletion! Skip deletion..." % nf_id)
          self.log.error(VERBOSE, "Exception: %s" % e)
          result = False
          continue
    self.log.debug("NF deletion result: %s" %
                   ("SUCCESS" if result else "FAILURE"))
    return result
github ncclient / ncclient / ncclient / operations / errors.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ncclient import NCClientError

class OperationError(NCClientError):
    pass

class TimeoutExpiredError(NCClientError):
    pass

class MissingCapabilityError(NCClientError):
    pass