Home › Forums › FABRIC General Questions and Discussion › Error on get_management_os_interface
- This topic has 7 replies, 2 voices, and was last updated 2 years, 2 months ago by Fraida Fund.
-
AuthorPosts
-
September 29, 2022 at 11:47 am #3221
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?
September 29, 2022 at 2:47 pm #3223The 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?
September 29, 2022 at 3:10 pm #3224Hi! I did a bunch of other
execute
calls for that node in the same notebook, no problem with those.September 29, 2022 at 3:19 pm #3225In case this helps:
September 29, 2022 at 3:44 pm #3227The 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.
September 29, 2022 at 3:53 pm #3228Ubuntu 18
September 30, 2022 at 7:39 am #3231Yeah, 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.
September 30, 2022 at 7:51 am #3232Thanks 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 expect
get_management_os_interface()
to fail. (Even besides for old software versions.) -
AuthorPosts
- You must be logged in to reply to this topic.