1. Error on get_management_os_interface

Error on get_management_os_interface

Home Forums FABRIC General Questions and Discussion Error on get_management_os_interface

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #3221
    Fraida Fund
    Participant

      Hi! I’m trying to use get_management_os_interface but it’s raising this error:

      slice.get_node(name="client").get_management_os_interface()
      ---------------------------------------------------------------------------
      JSONDecodeError Traceback (most recent call last)
      /tmp/ipykernel_1287/4246491042.py in
      ----> 1 slice.get_node(name="client").get_management_os_interface()
      
      /opt/conda/lib/python3.9/site-packages/fabrictestbed_extensions/fablib/node.py in get_management_os_interface(self)
      1092 logging.debug(f"{self.get_name()}->get_management_os_interface")
      1093 stdout, stderr = self.execute("sudo ip -j route list")
      -> 1094 stdout_json = json.loads(stdout)
      1095
      1096 #print(pythonObj)
      
      /opt/conda/lib/python3.9/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
      344 parse_int is None and parse_float is None and
      345 parse_constant is None and object_pairs_hook is None and not kw):
      --> 346 return _default_decoder.decode(s)
      347 if cls is None:
      348 cls = JSONDecoder
      
      /opt/conda/lib/python3.9/json/decoder.py in decode(self, s, _w)
      335
      336 """
      --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      338 end = _w(s, end).end()
      339 if end != len(s):
      
      /opt/conda/lib/python3.9/json/decoder.py in raw_decode(self, s, idx)
      353 obj, end = self.scan_once(s, idx)
      354 except StopIteration as err:
      --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
      356 return obj, end
      
      JSONDecodeError: Expecting value: line 1 column 1 (char 0)
      

      any thoughts?

      #3223
      Paul Ruth
      Keymaster

        The way this works is that it ssh’s to your node and gets the result of ‘ip addr route’ as json.  It then digs through that json to find the name of the device.

        Your error seems to be that the json that is returned is ‘None’.  This likely means the ssh failed.

        Can you do a “mynode.execute(‘hello, fabric’)” ?  Does that fail too?

        #3224
        Fraida Fund
        Participant

          Hi! I did a bunch of other execute calls for that node in the same notebook, no problem with those.

          #3225
          Fraida Fund
          Participant

            In case this helps:

             

            #3227
            Paul Ruth
            Keymaster

              The json it is returning seems like its one big string.  Which image are you using?

              I’d like to try that image and see if it is behaving in a way I didn’t expect.

              #3228
              Fraida Fund
              Participant

                Ubuntu 18

                #3231
                Paul Ruth
                Keymaster

                  Yeah, it looks like the version of ‘ip’ in Ubuntu 18 is not capable of json as output.

                  A workaround would be to use this execute command:

                  stdout, stderr = node.execute("ip route list default | cut -d ' ' -f 5")
                  print(stdout)

                  In general, the fablib functions that get/set internal attributes of the VMs are just convenience wrappers around ssh commands. Most of these settings are determined by the OS or user configuration and are not controlled by FABRIC. Getting them can be tricky so we are trying to add some helper functions, but there will always be some corner cases.  In this case, we can add a check for successful return of a json object and fall back to parsing the string but parsing stdout is always going to be fragile.

                  Thanks for letting us know about this.

                  #3232
                  Fraida Fund
                  Participant

                    Thanks for the update!

                    It would be useful if the sphinx docs for this function (and similar ones) would briefly mention what they do “under the hood” in cases where it’s not obvious.

                    For example, I have some teaching experiments that remove the default route (first replacing it with a more specific routes to maintain SSH access) in order to show what happens when there is no route to a particular destination. I also have some research experiments that change the default route in order to route most Internet traffic through another host in the testbed topology. So it would be useful to know when I should expectget_management_os_interface() to fail. (Even besides for old software versions.)

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • You must be logged in to reply to this topic.