Simon Tasker

Games, apps, and the occasional detour.

App Dev · · 3 min read

NetLay: Checking the wiring rules

A model is only as good as the things it refuses, so I spent an evening attacking my own API with every bad idea I could think of, and two of them worked.

What does it refuse?#

A data model is defined as much by what it will not accept as by what it stores. The port rule from post two, one port is a device or an uplink or free and never two of them, is the reason half the later features work at all.

So this time I went looking for the rules I had never actually written down, by attacking my own API like a careless user.

Every bad idea I could think of.#

There is a test file now that tries all of them. Putting a device on a port that already carries an uplink. Putting an uplink on a port that already has a device. Making the same uplink twice. Linking a switch to itself. Asking for port zero. Hosting a server on one of its own virtual machines. Linking to a switch that lives on somebody else's layout. Then the cascades, which matter just as much: deleting a switch should take its links with it, deleting an access point should take its wireless clients.

Most of it was already refused, which was a pleasant surprise and slightly beside the point, because an unwritten rule that happens to hold is not a rule. It is luck with good manners. Now they are all tested, so they stay true.

Two of them were not refused, and both were worth finding.

A device or a virtual machine could be moved onto a switch port or a host that belonged to a completely different layout. The data structure allows it, nothing checked it, and the result is a device that appears on one map and is plugged into another. That is now refused with a message telling you to export and import if you genuinely want to move something between layouts.

And wireless clients could hang off anything at all. You could attach a laptop to a printer by radio. The rule now is that only access points, routers and firewalls can carry wireless clients, and a device with clients attached cannot be changed into something that could not have them.

The one that was pointed out to me.#

That second fix has a sibling, from a note that is hard to argue with.

"+VM is on any device it should only be visible on Virtual servers possible a PC but it likely never be needed on a router or switch"

Entirely right. The add VM button was on every device in the application, including switches and routers, which is nonsense dressed up as flexibility.

It now appears on servers, PCs and NAS boxes only, and the same restriction applies to the host picker and to discovery's option to place a host as a virtual machine. The server refuses it elsewhere rather than relying on the button being hidden, and a host that already has VMs cannot be changed into a type that could not host them.

Anything created under the old rules stays visible with a warning suggesting you move it, because silently deleting somebody's data to enforce a rule you invented afterwards is not acceptable, even when the data is wrong.

Groups that move as one.#

The other half of this release is a usability thing that had been quietly annoying me since post fourteen.

Dragging a collapsed group card moved the card and left all its members where they were, so expanding it afterwards scattered them back across the map like a dropped tray. Now the members come along, and expanding shows them where you put the card.

An expanded group can be dragged by its name tab or its dashed frame to move everything inside it, while dragging an individual device still moves just that device. Hosted devices move with their host, and a selection containing both a group and some of its members no longer moves those members twice, which produced a lovely effect where the things you selected most carefully flew off the furthest.

One small interaction between features worth recording. A device folded inside a collapsed group card has its line ending at the card rather than at the device, so its pinned cable bends from post twenty are ignored while it is folded and no handles appear. The bends are stored for the device's real position, and the real position is not currently on the map. They come back when you expand it.

Next time, the question the portable version should have been asking from the start.