Hook networking code back up

This PR hooks the code for attach/detach networks back up, where I removed it in my last PR.

It also removes the agent API endpoint to get a list of ports for the agent, since we don't need it.