Python jsonrpclib.Server() Examples

The following are code examples for showing how to use jsonrpclib.Server(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: Mastering-Python-Networking-Second-Edition   Author: PacktPublishing   File: eapi_2_acl.py    MIT License 6 votes vote down vote up
def getEndpoints(switchHostnames, protocol, username, password):
   """ Check that each server is up, and return a mapping from
   hostname to jsonrpclib.Server """
   apiEndpoints = {} # mapping from hostname to the API endpoint
   for switch in switchHostnames:
      url = "{protocol}://{user}:{pw}@{hostname}/command-api".format(
         protocol=protocol, user=username, pw=password, hostname=switch)
      server = jsonrpclib.Server(url)
      try:
         # We should at least be able to 'enable'
         server.runCmds(1, ["enable"])
      except Exception as e:
         print "Unable to run 'enable' on switch", e
         sys.exit(1)
      apiEndpoints[switch] = server
   return apiEndpoints 
Example 2
Project: Mastering-Python-Networking-Second-Edition   Author: PacktPublishing   File: eapi_2_acl.py    MIT License 6 votes vote down vote up
def prepopulateAclFile(filename, aclName, apiEndpoints):
   """ Given a jsonrpclib.Server called 'switch', prepopulate
   'filename' with the ACL contents. If the ACL does not yet exist,
   just print a message """

   # Currently assume all switches have the same config, so just use a
   # random one as the sample.
   apiEndpoint = apiEndpoints.itervalues().next()
   responseList = apiEndpoint.runCmds(1, ["enable",
                                          "show ip access-lists %s" % aclName])
   response = responseList[1] # Only care about the ACL output.
   if not response["aclList"]:
      print "No existing access list named", aclName, "- creating new ACL"
   else:
      # Prepopulate the file with the existing config
      print "Editing existing access list:"
      with open(filename, "w") as f:
         for rule in response["aclList"][0]["sequence"]:
            line = str(rule["sequenceNumber"]) + " " + rule["text"] + "\n"
            print "  ", line,
            f.write(line)
   print 
Example 3
Project: bounty_tools   Author: gradiuscypher   File: reconng.py    MIT License 6 votes vote down vote up
def run():

    # Setup the jsonrpclib for the recon-ng RPC server, stop the API if it cannot connect to the RPC server.
    try:
        client = jsonrpclib.Server('http://localhost:4141')
        sid = client.init()

        # Get the configuration from JSON POST
        content = request.get_json()
        target_module = content['module']
        target_domain = content['domain']
        print(target_domain, target_module)

        # Set the target domain
        client.add('domains', target_domain, sid)
        print(client.show('domains', sid))
        client.use(target_module, sid)

        # Execute the requested module and return the results
        results = client.run(sid)

        return jsonify(results)

    except:
        return traceback.format_exc(), 500 
Example 4
Project: encompass   Author: mazaclub   File: merchant.py    GNU General Public License v3.0 6 votes vote down vote up
def send_command(cmd, params):
    import jsonrpclib
    server = jsonrpclib.Server('http://%s:%d'%(my_host, my_port))
    try:
        f = getattr(server, cmd)
    except socket.error:
        print "Server not running"
        return 1
        
    try:
        out = f(*params)
    except socket.error:
        print "Server not running"
        return 1

    print json.dumps(out, indent=4)
    return 0 
Example 5
Project: dkodi   Author: dknlght   File: jsonrpc.py    GNU General Public License v2.0 6 votes vote down vote up
def _run_request(self, request, notify=None):
        history.add_request(request)

        response = self.__transport.request(
            self.__host,
            self.__handler,
            request,
            verbose=self.__verbose
        )
        
        # Here, the XMLRPC library translates a single list
        # response to the single value -- should we do the
        # same, and require a tuple / list to be passed to
        # the response object, or expect the Server to be 
        # outputting the response appropriately?
        
        history.add_response(response)
        if not response:
            return None
        return_obj = loads(response)
        return return_obj 
Example 6
Project: btcnano-wallet-client-desktop   Author: bitcoinnano   File: daemon.py    MIT License 6 votes vote down vote up
def get_server(config):
    lockfile = get_lockfile(config)
    while True:
        create_time = None
        try:
            with open(lockfile) as f:
                (host, port), create_time = ast.literal_eval(f.read())
                server = jsonrpclib.Server('http://%s:%d' % (host, port))
            # Test daemon is running
            server.ping()
            return server
        except Exception as e:
            print_error("[get_server]", e)
        if not create_time or create_time < time.time() - 1.0:
            return None
        # Sleep a bit and try again; it might have just been started
        time.sleep(1.0) 
Example 7
Project: hws   Author: nash-x   File: arista_l3_driver.py    Apache License 2.0 6 votes vote down vote up
def __init__(self):
        self._servers = []
        self._hosts = []
        self.interfaceDict = None
        self._validate_config()
        host = cfg.CONF.l3_arista.primary_l3_host
        self._hosts.append(host)
        self._servers.append(jsonrpclib.Server(self._eapi_host_url(host)))
        self.mlag_configured = cfg.CONF.l3_arista.mlag_config
        self.use_vrf = cfg.CONF.l3_arista.use_vrf
        if self.mlag_configured:
            host = cfg.CONF.l3_arista.secondary_l3_host
            self._hosts.append(host)
            self._servers.append(jsonrpclib.Server(self._eapi_host_url(host)))
            self._additionalRouterCmdsDict = additional_cmds_for_mlag['router']
            self._additionalInterfaceCmdsDict = (
                additional_cmds_for_mlag['interface'])
        if self.use_vrf:
            self.routerDict = router_in_vrf['router']
            self.interfaceDict = router_in_vrf['interface']
        else:
            self.routerDict = router_in_default_vrf['router']
            self.interfaceDict = router_in_default_vrf['interface'] 
Example 8
Project: hws   Author: nash-x   File: arista_l3_driver.py    Apache License 2.0 6 votes vote down vote up
def create_router_on_eos(self, router_name, rdm, server):
        """Creates a router on Arista HW Device.

        :param router_name: globally unique identifier for router/VRF
        :param rdm: A value generated by hashing router name
        :param server: Server endpoint on the Arista switch to be configured
        """
        cmds = []
        rd = "%s:%s" % (rdm, rdm)

        for c in self.routerDict['create']:
            cmds.append(c.format(router_name, rd))

        if self.mlag_configured:
            mac = VIRTUAL_ROUTER_MAC
            for c in self._additionalRouterCmdsDict['create']:
                cmds.append(c.format(mac))

        self._run_openstack_l3_cmds(cmds, server) 
Example 9
Project: eAPI-Scripts   Author: GADify   File: ShowVer.py    GNU General Public License v3.0 6 votes vote down vote up
def GetVersion(x):
   verLoc = 19
   IP = "10.0.0." + str(x)
   switch = Server( "https://" + ScriptUser + ":" + ScriptPass + "@" + IP + "/command-api" )
   # Results in Host Unreach never happening, but [ . ] means same thing 
   #         without waiting
   socket.setdefaulttimeout(3)
   try:
      response = switch.runCmds( 1, [ "show version" ] )
   except socket.error,ERR :
       ErrorCode = ERR[0]
       if ErrorCode == errno.ECONNREFUSED:
          win.addstr(x, verLoc -6, "        [ Err " + str(ErrorCode) + ": No eAPI ]          ")
          refresh() 
       elif ErrorCode == errno.EHOSTUNREACH:
          # Never hit with lower socket timeout
          win.addstr(x, verLoc, "Err " + str(ErrorCode) + ": Pwr off or Aboot ]          ")
          refresh() 
       elif ErrorCode == errno.ECONNRESET:
          win.addstr(x, verLoc, "Err " + str(ErrorCode) + ": Con RST ]          ")
          refresh() 
Example 10
Project: Mastering-Python-Networking-Third-Edition   Author: PacktPublishing   File: eapi_2_acl.py    MIT License 6 votes vote down vote up
def getEndpoints(switchHostnames, protocol, username, password):
   """ Check that each server is up, and return a mapping from
   hostname to jsonrpclib.Server """
   apiEndpoints = {} # mapping from hostname to the API endpoint
   for switch in switchHostnames:
      url = "{protocol}://{user}:{pw}@{hostname}/command-api".format(
         protocol=protocol, user=username, pw=password, hostname=switch)
      server = jsonrpclib.Server(url)
      try:
         # We should at least be able to 'enable'
         server.runCmds(1, ["enable"])
      except Exception as e:
         print "Unable to run 'enable' on switch", e
         sys.exit(1)
      apiEndpoints[switch] = server
   return apiEndpoints 
Example 11
Project: Mastering-Python-Networking-Third-Edition   Author: PacktPublishing   File: eapi_2_acl.py    MIT License 6 votes vote down vote up
def prepopulateAclFile(filename, aclName, apiEndpoints):
   """ Given a jsonrpclib.Server called 'switch', prepopulate
   'filename' with the ACL contents. If the ACL does not yet exist,
   just print a message """

   # Currently assume all switches have the same config, so just use a
   # random one as the sample.
   apiEndpoint = apiEndpoints.itervalues().next()
   responseList = apiEndpoint.runCmds(1, ["enable",
                                          "show ip access-lists %s" % aclName])
   response = responseList[1] # Only care about the ACL output.
   if not response["aclList"]:
      print "No existing access list named", aclName, "- creating new ACL"
   else:
      # Prepopulate the file with the existing config
      print "Editing existing access list:"
      with open(filename, "w") as f:
         for rule in response["aclList"][0]["sequence"]:
            line = str(rule["sequenceNumber"]) + " " + rule["text"] + "\n"
            print "  ", line,
            f.write(line)
   print 
Example 12
Project: encompass   Author: martexcoin   File: merchant.py    GNU General Public License v3.0 6 votes vote down vote up
def send_command(cmd, params):
    import jsonrpclib
    server = jsonrpclib.Server('http://%s:%d'%(my_host, my_port))
    try:
        f = getattr(server, cmd)
    except socket.error:
        print "Server not running"
        return 1
        
    try:
        out = f(*params)
    except socket.error:
        print "Server not running"
        return 1

    print json.dumps(out, indent=4)
    return 0 
Example 13
Project: pyeos   Author: spotify   File: eos.py    Apache License 2.0 5 votes vote down vote up
def open(self):
        """
        Opens the connection with the device.
        """
        if self.use_ssl:
            url = 'https://%s:%[email protected]%s/command-api' % (self.username, self.password, self.hostname)
        else:
            url = 'http://%s:%[email protected]%s/command-api' % (self.username, self.password, self.hostname)

        self.device = Server(url) 
Example 14
Project: dkodi   Author: dknlght   File: jsonrpc.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, code=-32000, message='Server error', rpcid=None):
        self.faultCode = code
        self.faultString = message
        self.rpcid = rpcid 
Example 15
Project: dkodi   Author: dknlght   File: jsonrpc.py    GNU General Public License v2.0 5 votes vote down vote up
def error(self, code=-32000, message='Server error.'):
        error = self.response()
        if self.version >= 2:
            del error['result']
        else:
            error['result'] = None
        error['error'] = {'code':code, 'message':message}
        return error 
Example 16
Project: uwallet-client   Author: UlordChain   File: daemon.py    MIT License 5 votes vote down vote up
def get_daemon(config):
    try:
        with open(lockfile(config)) as f:
            host, port = ast.literal_eval(f.read())
    except:
        return
    server = jsonrpclib.Server('http://%s:%d' % (host, port))
    # check if daemon is running
    try:
        server.ping()
        return server
    except:
        pass 
Example 17
Project: dom   Author: aristanetworks   File: dom.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def main(args):
    '''Do Stuff.
    '''

    log("Entering {0}.".format(sys._getframe().f_code.co_name), level='DEBUG')

    log("Started up successfully. Entering main loop...")

    switch = Server("{0}://{1}:{2}@{3}:{4}/command-api"\
        .format(PROTOCOL, USERNAME, PASSWORD, HOSTNAME, PORT))
    interfaces = {}
    while True:
        interfaces = get_interfaces(switch)
        response = switch.runCmds(1, ["show interfaces {0} transceiver"
                                      .format(', '.join(interfaces.keys())),
                                      "show version"])
        dominfo = response[0][u'interfaces']
        uptime = int(response[1][u'bootupTimestamp'])

        for interface in interfaces.keys():
            check_interfaces(uptime, str(interface), interfaces[interface],
                             dominfo[interface])

        log("---sleeping for {0} seconds.".format(args.poll_interval),
            level='DEBUG')
        time.sleep(args.poll_interval) 
Example 18
Project: hws   Author: nash-x   File: mechanism_arista.py    Apache License 2.0 5 votes vote down vote up
def __init__(self):
        self._server = jsonrpclib.Server(self._eapi_host_url())
        self.keystone_conf = cfg.CONF.keystone_authtoken
        self.region = cfg.CONF.ml2_arista.region_name
        self.sync_interval = cfg.CONF.ml2_arista.sync_interval
        self._region_updated_time = None
        # The cli_commands dict stores the mapping between the CLI command key
        # and the actual CLI command.
        self.cli_commands = {}
        self.initialize_cli_commands() 
Example 19
Project: hws   Author: nash-x   File: arista_l3_driver.py    Apache License 2.0 5 votes vote down vote up
def delete_router_from_eos(self, router_name, server):
        """Deletes a router from Arista HW Device.

        :param router_name: globally unique identifier for router/VRF
        :param server: Server endpoint on the Arista switch to be configured
        """
        cmds = []
        for c in self.routerDict['delete']:
            cmds.append(c.format(router_name))
        if self.mlag_configured:
            for c in self._additionalRouterCmdsDict['delete']:
                cmds.append(c)

        self._run_openstack_l3_cmds(cmds, server) 
Example 20
Project: hws   Author: nash-x   File: arista_l3_driver.py    Apache License 2.0 5 votes vote down vote up
def add_interface_to_router(self, segment_id,
                                router_name, gip, router_ip, mask, server):
        """Adds an interface to existing HW router on Arista HW device.

        :param segment_id: VLAN Id associated with interface that is added
        :param router_name: globally unique identifier for router/VRF
        :param gip: Gateway IP associated with the subnet
        :param router_ip: IP address of the router
        :param mask: subnet mask to be used
        :param server: Server endpoint on the Arista switch to be configured
        """

        if not segment_id:
            segment_id = DEFAULT_VLAN
        cmds = []
        for c in self.interfaceDict['add']:
            if self.mlag_configured:
                ip = router_ip
            else:
                ip = gip + '/' + mask
            cmds.append(c.format(segment_id, router_name, ip))
        if self.mlag_configured:
            for c in self._additionalInterfaceCmdsDict['add']:
                cmds.append(c.format(gip))

        self._run_openstack_l3_cmds(cmds, server) 
Example 21
Project: hws   Author: nash-x   File: arista_l3_driver.py    Apache License 2.0 5 votes vote down vote up
def _run_openstack_l3_cmds(self, commands, server):
        """Execute/sends a CAPI (Command API) command to EOS.

        In this method, list of commands is appended with prefix and
        postfix commands - to make is understandble by EOS.

        :param commands : List of command to be executed on EOS.
        :param server: Server endpoint on the Arista switch to be configured
        """
        command_start = ['enable', 'configure']
        command_end = ['exit']
        full_command = command_start + commands + command_end

        LOG.info(_('Executing command on Arista EOS: %s'), full_command)

        try:
            # this returns array of return values for every command in
            # full_command list
            ret = server.runCmds(version=1, cmds=full_command)
            LOG.info(_('Results of execution on Arista EOS: %s'), ret)

        except Exception:
            msg = (_('Error occured while trying to execute '
                     'commands %(cmd)s on EOS %(host)s') %
                   {'cmd': full_command, 'host': server})
            LOG.exception(msg)
            raise arista_exc.AristaServicePluginRpcError(msg=msg) 
Example 22
Project: steth   Author: unitedstack   File: iperf_api.py    Apache License 2.0 5 votes vote down vote up
def setup_server(agent):
    log = logging.getLogger(__name__)
    if agent in AGENT_INFOS:
        log.debug('get agent:%s ip_address:%s' % (
            agent, AGENT_INFOS[agent]))
    else:
        log.error('Agent %s not configured. Please check it.' % (
                         agent))
        sys.exit()
    log.debug('Begin create connection with http://%s:9698.' % (
                    agent))
    server = jsonrpclib.Server('http://%s:%s' % (
             AGENT_INFOS[agent], LISTEN_PORT))
    log.debug('Create connection with %s success.' % (agent))
    return server 
Example 23
Project: steth   Author: unitedstack   File: agent_api.py    Apache License 2.0 5 votes vote down vote up
def setup_server(agent):
    log = logging.getLogger(__name__)
    if agent in AGENT_INFOS:
        log.debug('get agent:%s ip_address:%s' % (
            agent, AGENT_INFOS[agent]))
    else:
        log.error('Agent %s not configured. Please check it.' % (
                         agent))
        sys.exit()
    log.debug('Begin create connection with http://%s:9698.' % (
                    agent))
    server = jsonrpclib.Server('http://%s:%s' % (
             AGENT_INFOS[agent], LISTEN_PORT))
    log.debug('Create connection with %s success.' % (agent))
    return server 
Example 24
Project: lbryum   Author: lbryio   File: daemon.py    MIT License 5 votes vote down vote up
def get_daemon(config):
    try:
        with open(lockfile(config)) as f:
            host, port = ast.literal_eval(f.read())
    except:
        return
    server = jsonrpclib.Server('http://%s:%d' % (host, port))
    # check if daemon is running
    try:
        server.ping()
        return server
    except:
        pass 
Example 25
Project: eAPI-Scripts   Author: GADify   File: BaslineEOS.py    GNU General Public License v3.0 5 votes vote down vote up
def BaselineEOS(switchNumber):
      location = 28 
      IP = "10.0.0." + str(switchNumber)
   
      #print "Switch " + str(switchNumber).zfill(2) + ": ", 
   
      #Connect to Switch via eAPI
      target = "https://" + ScriptUser + ":" + ScriptPass + "@" + IP + "/command-api"
      switch = jsonrpclib.Server( target )
   
      # capture Connection problem messages
      # Map of erronos is here: http://www.python.org/doc//current/library/errno.html
      try:
         response = switch.runCmds( 1, 
            [ "enable" , 
              "configure",
              "delete EOS*.swi",
              "copy " + FileServer + EOSVer + " flash:",
              "boot system flash:" + EOSVer, 
              "write erase now", 
              "reload now"
            ], "text")

      except KeyboardInterrupt:
         print "Caught Keyboard Interrupt - Exiting"
         sys.exit()

      except socket.error,ERR :
          # Socket Errors
          ErrorCode = ERR[0]
          if ErrorCode == errno.ECONNREFUSED:
             win.addstr(switchNumber, location -15, "        [ Err " + str(ErrorCode) + ": No eAPI ]          ")
             refresh()
          elif ErrorCode == errno.EHOSTUNREACH:
             # Never hit with lower socket timeout
             win.addstr(switchNumber, location -15, "        [ Err " + str(ErrorCode) + ": Pwr off | Aboot ]  ")
             refresh()
          elif ErrorCode == errno.ECONNRESET:
             win.addstr(switchNumber, location -15, "        [ Err " + str(ErrorCode) + ": Con RST ]          ")
             refresh() 
Example 26
Project: Uwallet   Author: UlordChain   File: daemon.py    MIT License 5 votes vote down vote up
def get_daemon(config):
    try:
        with open(lockfile(config)) as f:
            host, port = ast.literal_eval(f.read())
    except:
        return
    server = jsonrpclib.Server('http://%s:%d' % (host, port))
    # check if daemon is running
    try:
        server.ping()
        return server
    except:
        pass 
Example 27
Project: trex-http-proxy   Author: alwye   File: trex_client.py    MIT License 5 votes vote down vote up
def connect_master(self):
        '''
        Connects to Master daemon via JsonRPC.
        This daemon controls TRex daemon server.
        Return true if success, false if fail
        '''
        try:
            print('Connecting to Master daemon @ %s ...' % self.master_daemon_path)
            self.master_daemon      = jsonrpclib.Server(self.master_daemon_path, history = self.history)
            self.check_master_connectivity()
            print('Connected to Master daemon.')
            return True
        except Exception as e:
            print(e)
            return False 
Example 28
Project: trex-http-proxy   Author: alwye   File: trex_client.py    MIT License 5 votes vote down vote up
def connect_server(self):
        '''
        Connects to TRex daemon server via JsonRPC.
        This daemon controls TRex. (start/stop)
        Return true if success, false if fail
        '''
        try:
            print('Connecting to TRex daemon server @ %s ...' % self.trex_server_path)
            self.server             = jsonrpclib.Server(self.trex_server_path, history = self.history)
            self.check_server_connectivity()
            print('Connected TRex server daemon.')
            return True
        except Exception as e:
            print(e)
            return False 
Example 29
Project: pyLCI   Author: CRImier   File: rpc_client.py    Apache License 2.0 5 votes vote down vote up
def __init__(self, host, port):
        self.host = host
        self.port = port
        self._server = Server("http://{}:{}".format(self.host, self.port))
        #self.retrieve_function_list() 
Example 30
Project: Example_Scripts   Author: Hugh-Adams   File: My_First_API_Scriptv2.py    BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def runCommand(user, password, address, port, commands, output="json", protocol="https"):
    """ Function to connect to EAPI interface on a switch and send commands to it, the routine will return
        the output of each command in JSON format by default.
        user - username to access switch with, requires correct privledge level to run the required commands
        password - password for above user
        address - ip or url for target switch
        port - tcp port to access the EAPI interface, normally 443
        commands - list of commands to pass to the switch
        option - protocol to use for EAPI session http, https, or local (unix sockets)
        output - output format to be return by the EAPI options are txt or json """

    # Work arround for ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
    # import ssl

    ssl._create_default_https_context = ssl._create_unverified_context
    
    if protocol == "http":
        #Connect to Switch via HTTP eAPI
        switch = Server("http://"+user+":"+password+"@"+address+":"+str(port)+"/command-api")
    elif protocol == "https":
        #Connect to Switch via HTTPS eAPI
        switch = Server("https://"+user+":"+password+"@"+address+":"+str(port)+"/command-api")
    elif protocol == "local":
        # Connect to Switch via Unix Socket
        EAPI_SOCKET = 'unix:/var/run/command-api.sock'
        switch = Server(EAPI_SOCKET)
    # capture Connection problem messages:
    try:
        response = switch.runCmds(1,commands,output)
        jsonrpclib.history.clear()
    except socket.error, error:
        error_code = error[0]
        if error_code == errno.ECONNREFUSED: # Raise exception if connection is refused by switch
            con_error = str("[Error:"+str(error_code)+"] Connection Refused!(eAPI not configured?)")
        elif error_code == errno.EHOSTUNREACH: # Raise exception if switch is unreachable from host
            con_error = str("[Error:"+str(error_code)+"] No Route to Host(Switch powered off?)")
        elif error_code == errno.ECONNRESET: # Raise exception if connection is refset by the switch
            con_error = str("[Error:"+str(error_code)+"] Connection RST by peer (Restart eAPI)")
        elif error_code == 8: # Raise exception if switch hostname cannot be resolved in DNS
            con_error = str("[Error:"+str(error_code)+"] Host/Server name not resolved (Check DNS or Host File)")
        else:
            # Unknown error - report error number and error string (should capture all)
            con_error = str("[Error:"+str(error_code) + "] "+error[1])
        return con_error
    # Protcol errors - report error number and error string (catches command execution errors) 
Example 31
Project: dom   Author: aristanetworks   File: dom.py    BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def get_interfaces(switch):
    """Get all of the interfaces on a switch.
    Get summary info on all of the interfaces in a switch and return a
        dictionary keyed on interface name.  NOTE: the interfaceIDs are
        missing the space between the interface type and the number.
    args:
        switch (object): A :class:`jsonrpclib` Server object
    returns:
        dict: Dictionary, keyed on interface name (without space), of interface
            summary information."
    Example:
        {u'Ethernet1': {u'autoNegotigateActive': False,
                        u'bandwidth': 10000000000,
                        u'description': u'',
                        u'duplex': u'duplexFull',
                        u'interfaceType': u'EbraTestPhyPort',
                        u'linkStatus': u'connected',
                        u'vlanInformation': {u'interfaceForwardingModel': u'bridged',
                                             u'interfaceMode': u'bridged',
                                             u'vlanId': 1}},
        u'Ethernet2': {u'autoNegotigateActive': False,
                       u'bandwidth': 10000000000,
                       u'description': u'',
                       u'duplex': u'duplexFull',
                       u'interfaceType': u'EbraTestPhyPort',
                       u'linkStatus': u'connected',
                       u'vlanInformation': {u'interfaceForwardingModel': u'bridged',
                                            u'interfaceMode': u'bridged',
                                            u'vlanId': 1}}
    """

    log("Entering {0}.".format(sys._getframe().f_code.co_name), level='DEBUG')
    conn_error = False
    commands = ["show interfaces status"]

    try:
        response = switch.runCmds(1, commands)
    except ProtocolError, err:
        (errno, msg) = err[0]
        # 1002: invalid command
        if errno == 1002:
            log("Invalid EOS interface name ({0})".format(commands), error=True)
        else:
            conn_error = True
            log("ProtocolError while retrieving {0} ([{1}] {2})".
                format(commands, errno, msg),
                error=True)