Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list_facility_ports cannot serialize to json #210

Closed
disprosium8 opened this issue Jul 26, 2023 · 3 comments · Fixed by #212
Closed

list_facility_ports cannot serialize to json #210

disprosium8 opened this issue Jul 26, 2023 · 3 comments · Fixed by #212
Assignees

Comments

@disprosium8
Copy link

I fixed this locally with "link_layer": str(link.layer) at:

https://github.com/fabric-testbed/fabrictestbed-extensions/blob/main/fabrictestbed_extensions/fablib/resources.py#L1014

from fabrictestbed_extensions.fablib.fablib import FablibManager as fablib_manager                                                                                                  
fablib = fablib_manager()                                                                                                                                                           
fablib.show_config()                                                                                                                                                                
fablib.list_facility_ports(output='json') 

Traceback (most recent call last):
  File "/home/ezra/test_fp.py", line 7, in <module>
    fablib.list_facility_ports(output='json')
  File "/home/ezra/repos/fabrictestbed-extensions/fabrictestbed_extensions/fablib/fablib.py", line 1160, in list_facility_ports
    return self.get_facility_ports(update=update).list_facility_ports(
  File "/home/ezra/repos/fabrictestbed-extensions/fabrictestbed_extensions/fablib/resources.py", line 1043, in list_facility_ports
    return self.get_fablib_manager().list_table(
  File "/home/ezra/repos/fabrictestbed-extensions/fabrictestbed_extensions/fablib/fablib.py", line 2277, in list_table
    return self.list_table_json(data, quiet=quiet)
  File "/home/ezra/repos/fabrictestbed-extensions/fabrictestbed_extensions/fablib/fablib.py", line 2224, in list_table_json
    json_str = json.dumps(data, indent=4)
  File "/usr/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/usr/lib/python3.9/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.9/json/encoder.py", line 429, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)
  File "/usr/lib/python3.9/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.9/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type NSLayer is not JSON serializable
@disprosium8
Copy link
Author

@kthare10 as a follow-up to this, how is the facility port information added to FIM? For the fabfed work, we are looking to get the raw values as maintained here: https://github.com/fabric-testbed/NetworkController/blob/main/device-config/ansible/inventory/fabric-cisco-dev.py#L281

It looks like most of that is there, although we would need some parsing info for node_id and name fields and a way to get the associated site (e.g. STAR, UTAH, etc.)

@kthare10
Copy link
Collaborator

@disprosium8 - Looking at this will keep you posted.

@kthare10 kthare10 self-assigned this Jul 26, 2023
@kthare10 kthare10 linked a pull request Jul 27, 2023 that will close this issue
@kthare10
Copy link
Collaborator

@disprosium8 - I updated list_facility_ports to return info as below. Would this help? Please let me know if anything else is needed.

Screen Shot 2023-07-27 at 11 25 26 AM

[
    {
        "name": "Clemson-CloudLab",
        "site_name": "CLEM",
        "node_id": "port+clem-data-sw:FourHundredGigE0/0/0/24:facility+Clemson-CloudLab-int",
        "vlan_range": [
            "3000-3999"
        ],
        "local_name": "N/A",
        "device_name": "N/A",
        "region": "N/A"
    },
    {
        "name": "Chameleon-StarLight",
        "site_name": "STAR",
        "node_id": "port+star-data-sw:HundredGigE0/0/0/30:facility+Chameleon-StarLight-int",
        "vlan_range": [
            "3300-3309"
        ],
        "local_name": "N/A",
        "device_name": "N/A",
        "region": "N/A"
    },
    {
        "name": "ESnet-StarLight",
        "site_name": "STAR",
        "node_id": "port+star-data-sw:HundredGigE0/0/0/30:facility+ESnet-StarLight-int",
        "vlan_range": [
            "3737-3739"
        ],
        "local_name": "2/1/c5/1",
        "device_name": "star-cr6.es.net",
        "region": "N/A"
    },
    {
        "name": "Internet2-StarLight",
        "site_name": "STAR",
        "node_id": "port+star-data-sw:HundredGigE0/0/0/30:facility+Internet2-StarLight-int",
        "vlan_range": [
            "3727-3729"
        ],
        "local_name": "HundredGigE0/0/0/20",
        "device_name": "core1.star.net.internet2.edu",
        "region": "N/A"
    },
    {
        "name": "Chameleon-TACC",
        "site_name": "TACC",
        "node_id": "port+tacc-data-sw:HundredGigE0/0/0/20:facility+Chameleon-TACC-int",
        "vlan_range": [
            "3210-3499"
        ],
        "local_name": "N/A",
        "device_name": "N/A",
        "region": "N/A"
    },
    {
        "name": "Utah-Cloudlab-Powder",
        "site_name": "UTAH",
        "node_id": "port+utah-data-sw:HundredGigE0/0/0/22:facility+Utah-Cloudlab-Powder-int",
        "vlan_range": [
            "2100-3499"
        ],
        "local_name": "N/A",
        "device_name": "N/A",
        "region": "N/A"
    },
    {
        "name": "OCT-MGHPCC",
        "site_name": "MASS",
        "node_id": "port+mass-data-sw:HundredGigE0/0/0/23:facility+OCT-MGHPCC-int",
        "vlan_range": [
            "3110-3119"
        ],
        "local_name": "N/A",
        "device_name": "N/A",
        "region": "N/A"
    },
    {
        "name": "RCNF",
        "site_name": "WASH",
        "node_id": "port+wash-data-sw:HundredGigE0/0/0/15:facility+RCNF-int",
        "vlan_range": [
            "3741-3751"
        ],
        "local_name": "N/A",
        "device_name": "via Internet2 AL2S",
        "region": "N/A"
    },
    {
        "name": "Cloud-Facility-Azure",
        "site_name": "Azure",
        "node_id": "port+al2s:agg3.ashb.net.internet2.edu:TenGigE0/0/0/12/1:Cloud-Facility-Azure:facility_port",
        "vlan_range": [
            "3-4095"
        ],
        "local_name": "TenGigE0/0/0/12/1",
        "device_name": "agg3.ashb.net.internet2.edu",
        "region": "eastus"
    },
    {
        "name": "Cloud-Facility-Azure-Gov",
        "site_name": "Azure-Gov",
        "node_id": "port+al2s:agg3.dall3.net.internet2.edu:TenGigE0/0/0/13/0:Cloud-Facility-Azure-Gov:facility_port",
        "vlan_range": [
            "3-4095"
        ],
        "local_name": "TenGigE0/0/0/13/0",
        "device_name": "agg3.dall3.net.internet2.edu",
        "region": "eastus2"
    },
    {
        "name": "Cloud-Facility-GCP",
        "site_name": "GCP",
        "node_id": "port+al2s:agg3.dall3.net.internet2.edu:Bundle-Ether110:Cloud-Facility-GCP:facility_port",
        "vlan_range": [
            "3-4095"
        ],
        "local_name": "Bundle-Ether110",
        "device_name": "agg3.dall3.net.internet2.edu",
        "region": "us-west-2"
    },
    {
        "name": "Cloud-Facility-AWS",
        "site_name": "AWS",
        "node_id": "port+al2s:agg3.eqch.net.internet2.edu:TenGigE0/0/0/11/1:Cloud-Facility-AWS:facility_port",
        "vlan_range": [
            "3-4095"
        ],
        "local_name": "TenGigE0/0/0/11/1",
        "device_name": "agg3.eqch.net.internet2.edu",
        "region": "us-east-2"
    }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants