remove duplicated functions

rewrite parts of port to use portmgmt.py function