- sock.connect(socket_name)
- encoded = base64.b64encode(STOP_MSG)
- sock.send("%s\n" % encoded)
- reply = sock.recv(1024)
- reply = base64.b64decode(reply)
- print reply
+ try:
+ sock.connect(socket_name)
+ encoded = base64.b64encode(STOP_MSG)
+ sock.send("%s\n" % encoded)
+ reply = sock.recv(1024)
+ reply = base64.b64decode(reply)
+ print(reply)
+ except:
+ print("Did not properly shutdown device")
+ # If a slicename is provided, use it to remove a GRE device
+ elif slicename:
+ import pwd
+ import getpass
+
+ sliceid = pwd.getpwnam(slicename).pw_uid
+
+ if vif_type == vsys.IFF_TAP:
+ vif_prefix = "tap"
+ else:
+ vif_prefix = "tun"
+
+ # if_name should be a unique numeric vif id
+ vif_name = "%s%s-%s" % (vif_prefix, sliceid, vif_name)
+
+ vsys.vif_down(vif_name, delete = True)