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

Fix south gearbox #55

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/lib/goldstone/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ class ChangeHandler(object):
def __init__(self, server, change):
self.server = server
self.change = change
self.type = self.change.type

@property
def type(self):
return self.change.type

def setup_cache(self, user):
cache = user.get("cache")
if not user.get("cache"):
cache = self.server.conn.get_config_cache(user["changes"])
cache = self.server.conn.get_config_cache(user.get("changes", {}))
user["cache"] = cache
return cache

Expand Down
39 changes: 30 additions & 9 deletions src/south/gearbox/goldstone/south/gearbox/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,29 @@ async def reconcile_interface(self, ifname, obj, config):
await obj.set("auto-negotiation", "true" if anlt else "false")

async def reconcile(self):
prefix = "/goldstone-interfaces:interfaces/interface"
xpath = "/goldstone-interfaces:interfaces/interface/config"
config = self.get_running_data(xpath, default=[])

for ifname, obj, _ in await self.get_ifname_list():
xpath = f"{prefix}[name='{ifname}']"
config = self.get_running_data(
xpath, default={}, include_implicit_defaults=True
)
await self.reconcile_interface(ifname, obj, config)
remove = set()

for intf in config:
ifname = intf["name"]
pin_mode = intf.get("pin-mode")
if pin_mode:
info = self.get_interface_info(ifname, pin_mode.lower())
remove |= set(info["interface"].get("conflicts-with", []))

create = set(self._interface_info.keys()) - remove

h = PinModeHandler(self, None)
h.user = {}
# ensure TAI doesn't have interfaces that conflict with the current
# pin-mode configuration
await h.remove(remove)

# ensure TAI has all interfaces that doesn't conflict with the current
# pin-mode configuration
await h.create(create)

async def tai_cb(self, obj, attr_meta, msg):
logger.info(f"{obj}, {obj.obj}")
Expand Down Expand Up @@ -930,9 +945,15 @@ async def create_interface(self, ifname, config):

index = v[2] - 1
if v[1] == 0: # hostif
obj = await m.create_hostif(index)
try:
obj = m.get_hostif(index)
except taish.TAIException:
obj = await m.create_hostif(index)
elif v[1] == 1: # netif
obj = await m.create_netif(index)
try:
obj = m.get_netif(index)
except taish.TAIException:
obj = await m.create_netif(index)

await self.reconcile_interface(ifname, obj, config)

Expand Down
45 changes: 1 addition & 44 deletions src/south/gearbox/tests/platform.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,11 @@
[
{"interface": {"name": "Interface1/0/1", "pin-mode": "nrz"}, "component": {"name": "port1"}},
{"interface": {"name": "Interface1/0/2", "pin-mode": "nrz"}, "component": {"name": "port2"}},
{"interface": {"name": "Interface1/0/3", "pin-mode": "nrz"}, "component": {"name": "port3"}},
{"interface": {"name": "Interface1/0/4", "pin-mode": "nrz"}, "component": {"name": "port4"}},
{"interface": {"name": "Interface1/0/5", "pin-mode": "nrz"}, "component": {"name": "port5"}},
{"interface": {"name": "Interface1/0/6", "pin-mode": "nrz"}, "component": {"name": "port6"}},
{"interface": {"name": "Interface1/0/7", "pin-mode": "nrz"}, "component": {"name": "port7"}},
{"interface": {"name": "Interface1/0/8", "pin-mode": "nrz"}, "component": {"name": "port8"}},
{"interface": {"name": "Interface1/1/1", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu1", "location": "1"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface1/1/2", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu1", "location": "1"}, "hostif": {"name": "1", "index": 1}}},
{"interface": {"name": "Interface1/1/3", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu1", "location": "1"}, "hostif": {"name": "2", "index": 2}}},
{"interface": {"name": "Interface1/1/4", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu1", "location": "1"}, "hostif": {"name": "3", "index": 3}}},
{"interface": {"name": "Interface1/1/5", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu2", "location": "2"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface1/1/6", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu2", "location": "2"}, "hostif": {"name": "1", "index": 1}}},
{"interface": {"name": "Interface1/1/7", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu2", "location": "2"}, "hostif": {"name": "2", "index": 2}}},
{"interface": {"name": "Interface1/1/8", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu2", "location": "2"}, "hostif": {"name": "3", "index": 3}}},
{"interface": {"name": "Interface1/1/1", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface1/1/2"]}, "tai": {"module": {"name": "piu1", "location": "1"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface1/1/3", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface1/1/4"]}, "tai": {"module": {"name": "piu1", "location": "1"}, "hostif": {"name": "1", "index": 1}}},
{"interface": {"name": "Interface1/1/5", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface1/1/6"]}, "tai": {"module": {"name": "piu2", "location": "2"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface1/1/7", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface1/1/8"]}, "tai": {"module": {"name": "piu2", "location": "2"}, "hostif": {"name": "1", "index": 1}}},
{"interface": {"name": "Interface2/0/1", "pin-mode": "nrz"}, "component": {"name": "port9"}},
{"interface": {"name": "Interface2/0/2", "pin-mode": "nrz"}, "component": {"name": "port10"}},
{"interface": {"name": "Interface2/0/3", "pin-mode": "nrz"}, "component": {"name": "port11"}},
{"interface": {"name": "Interface2/0/4", "pin-mode": "nrz"}, "component": {"name": "port12"}},
{"interface": {"name": "Interface2/0/5", "pin-mode": "nrz"}, "component": {"name": "port13"}},
{"interface": {"name": "Interface2/0/6", "pin-mode": "nrz"}, "component": {"name": "port14"}},
{"interface": {"name": "Interface2/0/7", "pin-mode": "nrz"}, "component": {"name": "port15"}},
{"interface": {"name": "Interface2/0/8", "pin-mode": "nrz"}, "component": {"name": "port16"}},
{"interface": {"name": "Interface2/1/1", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu3", "location": "3"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface2/1/2", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu3", "location": "3"}, "hostif": {"name": "1", "index": 1}}},
{"interface": {"name": "Interface2/1/3", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu3", "location": "3"}, "hostif": {"name": "2", "index": 2}}},
{"interface": {"name": "Interface2/1/4", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu3", "location": "3"}, "hostif": {"name": "3", "index": 3}}},
{"interface": {"name": "Interface2/1/5", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu4", "location": "4"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface2/1/6", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu4", "location": "4"}, "hostif": {"name": "1", "index": 1}}},
{"interface": {"name": "Interface2/1/7", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu4", "location": "4"}, "hostif": {"name": "2", "index": 2}}},
{"interface": {"name": "Interface2/1/8", "default": true, "pin-mode": "pam4"}, "tai": {"module": {"name": "piu4", "location": "4"}, "hostif": {"name": "3", "index": 3}}},
{"interface": {"name": "Interface2/1/1", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface2/1/2"]}, "tai": {"module": {"name": "piu3", "location": "3"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface2/1/3", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface2/1/4"]}, "tai": {"module": {"name": "piu3", "location": "3"}, "hostif": {"name": "1", "index": 1}}},
{"interface": {"name": "Interface2/1/5", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface2/1/6"]}, "tai": {"module": {"name": "piu4", "location": "4"}, "hostif": {"name": "0", "index": 0}}},
{"interface": {"name": "Interface2/1/7", "default": false, "pin-mode": "nrz", "conflicts-with": ["Interface2/1/8"]}, "tai": {"module": {"name": "piu4", "location": "4"}, "hostif": {"name": "1", "index": 1}}},
{"component": {"name": "piu1"}, "tai": {"module": {"name": "piu1", "location": "1"}, "netif": {"name": "0", "index": 0}}},
{"component": {"name": "piu2"}, "tai": {"module": {"name": "piu2", "location": "2"}, "netif": {"name": "0", "index": 0}}},
{"component": {"name": "piu3"}, "tai": {"module": {"name": "piu3", "location": "3"}, "netif": {"name": "0", "index": 0}}},
{"component": {"name": "piu4"}, "tai": {"module": {"name": "piu4", "location": "4"}, "netif": {"name": "0", "index": 0}}},
{"synce-reference-clock": {"name": "0", "index": 0, "gearbox": {"name": "1"}}, "input-reference": {"name": "0", "index": 0, "dpll": {"name": "1"}}},
{"synce-reference-clock": {"name": "1", "index": 1, "gearbox": {"name": "1"}}, "input-reference": {"name": "1", "index": 1, "dpll": {"name": "1"}}},
{"synce-reference-clock": {"name": "2", "index": 2, "gearbox": {"name": "1"}}, "input-reference": {"name": "2", "index": 2, "dpll": {"name": "1"}}},
{"synce-reference-clock": {"name": "3", "index": 3, "gearbox": {"name": "1"}}, "input-reference": {"name": "3", "index": 3, "dpll": {"name": "1"}}},
{"synce-reference-clock": {"name": "0", "index": 0, "gearbox": {"name": "2"}}, "input-reference": {"name": "4", "index": 4, "dpll": {"name": "1"}}},
{"synce-reference-clock": {"name": "1", "index": 1, "gearbox": {"name": "2"}}, "input-reference": {"name": "5", "index": 5, "dpll": {"name": "1"}}},
{"synce-reference-clock": {"name": "2", "index": 2, "gearbox": {"name": "2"}}, "input-reference": {"name": "6", "index": 6, "dpll": {"name": "1"}}},
{"synce-reference-clock": {"name": "3", "index": 3, "gearbox": {"name": "2"}}, "input-reference": {"name": "7", "index": 7, "dpll": {"name": "1"}}}
{"synce-reference-clock": {"name": "3", "index": 3, "gearbox": {"name": "1"}}, "input-reference": {"name": "3", "index": 3, "dpll": {"name": "1"}}}
]
Loading