diff --git a/cloudcontrol/cli/commands/delforward.py b/cloudcontrol/cli/commands/delforward.py
deleted file mode 100644
index 66caee131ea4c127d9454a96d946f49eb807c219..0000000000000000000000000000000000000000
--- a/cloudcontrol/cli/commands/delforward.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#coding=utf8
-
-# This file is part of CloudControl.
-#
-# CloudControl is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# CloudControl is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with CloudControl. If not, see .
-
-'''
-CloudControl delforward command
-'''
-
-from cloudcontrol.cli.command import Command
-from cloudcontrol.cli.exception import *
-
-class Command_delforward(Command):
- '''Delete forwarded connection'''
-
- def __init__(self, cli, argv0):
- Command.__init__(self, cli, argv0)
-
- def __call__(self, argv):
- # argv check
- if len(argv) < 2:
- raise cmdBadArgument()
- for fwd_id in argv[1:]:
- if fwd_id in self.cli.forwards:
- self.printer.out("Closing %s" % fwd_id)
- self.cli.forwards[fwd_id].stop()
- del self.cli.forwards[fwd_id]
- else:
- self.printer.warn("No such forward: %s" % fwd_id)
-
- def usage(self):
- return "Usage: delforward [tunnel id]..."
diff --git a/cloudcontrol/cli/commands/addforward.py b/cloudcontrol/cli/commands/forward.py
similarity index 60%
rename from cloudcontrol/cli/commands/addforward.py
rename to cloudcontrol/cli/commands/forward.py
index 9b7c57b2ffc319d832957659f7b5aaf3f575602e..c446943f85d2e8bff49722f9d62df10bda52015d 100644
--- a/cloudcontrol/cli/commands/addforward.py
+++ b/cloudcontrol/cli/commands/forward.py
@@ -16,13 +16,42 @@
# along with CloudControl. If not, see .
'''
-CloudControl addforward command
+CloudControl forward related commands
'''
-from cloudcontrol.cli.command import TqlCommand
+from cloudcontrol.cli.command import Command, TqlCommand
from cloudcontrol.cli.tunnel import Forward
+from cloudcontrol.cli.printer import color
from cloudcontrol.cli.exception import *
+
+class Command_forwards(Command):
+ '''List open forwards'''
+
+ def __init__(self, cli, argv0):
+ Command.__init__(self, cli, argv0)
+
+ def __call__(self, argv):
+ # argv check
+ if len(argv) != 1:
+ raise cmdBadArgument()
+ out = self.printer.out
+ for fwd in self.cli.forwards.values():
+ out("Forward: %s%s%s" % (color["lpurple"], fwd.id, color["reset"]))
+ out(" HostID: %s" % fwd.host_id)
+ out(" Local socket: %s %s" % (fwd.source_ip, fwd.source_port))
+ out(" Remote socket: %s %s" % (fwd.dest_ip, fwd.dest_port))
+ out(" Tunnels:")
+ out(" count: %s" % len(fwd.tunnels))
+ for label, tun in fwd.tunnels.items():
+ remote_ip, remote_port = tun.endpoint.getpeername()
+ out(" label: %s, remote ip: %s, remote port: %s"
+ % (label, remote_ip, remote_port))
+ out("Forward count: %d, Tunnels count: %d" %
+ (len(self.cli.forwards),
+ sum(len(f.tunnels) for f in self.cli.forwards.values())))
+
+
class Command_addforward(TqlCommand):
'''Create a forward'''
@@ -74,3 +103,25 @@ class Command_addforward(TqlCommand):
def remote_functions(self):
return set(("list", "forward"))
+
+
+class Command_delforward(Command):
+ '''Delete forwarded connection'''
+
+ def __init__(self, cli, argv0):
+ Command.__init__(self, cli, argv0)
+
+ def __call__(self, argv):
+ # argv check
+ if len(argv) < 2:
+ raise cmdBadArgument()
+ for fwd_id in argv[1:]:
+ if fwd_id in self.cli.forwards:
+ self.printer.out("Closing %s" % fwd_id)
+ self.cli.forwards[fwd_id].stop()
+ del self.cli.forwards[fwd_id]
+ else:
+ self.printer.warn("No such forward: %s" % fwd_id)
+
+ def usage(self):
+ return "Usage: delforward [tunnel id]..."
diff --git a/cloudcontrol/cli/commands/forwards.py b/cloudcontrol/cli/commands/forwards.py
deleted file mode 100644
index 8b9ffc15a91d5d9e93e0f29b03bbb8dcddcdaee1..0000000000000000000000000000000000000000
--- a/cloudcontrol/cli/commands/forwards.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#coding=utf8
-
-# This file is part of CloudControl.
-#
-# CloudControl is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# CloudControl is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with CloudControl. If not, see .
-
-'''
-CloudControl forwards command
-'''
-
-from cloudcontrol.cli.command import Command
-from cloudcontrol.cli.printer import color
-from cloudcontrol.cli.exception import *
-
-class Command_forwards(Command):
- '''List open forwards'''
-
- def __init__(self, cli, argv0):
- Command.__init__(self, cli, argv0)
-
- def __call__(self, argv):
- # argv check
- if len(argv) != 1:
- raise cmdBadArgument()
- out = self.printer.out
- for fwd in self.cli.forwards.values():
- out("Forward: %s%s%s" % (color["lpurple"], fwd.id, color["reset"]))
- out(" HostID: %s" % fwd.host_id)
- out(" Local socket: %s %s" % (fwd.source_ip, fwd.source_port))
- out(" Remote socket: %s %s" % (fwd.dest_ip, fwd.dest_port))
- out(" Tunnels:")
- out(" count: %s" % len(fwd.tunnels))
- for label, tun in fwd.tunnels.items():
- remote_ip, remote_port = tun.endpoint.getpeername()
- out(" label: %s, remote ip: %s, remote port: %s"
- % (label, remote_ip, remote_port))
- out("Forward count: %d, Tunnels count: %d" %
- (len(self.cli.forwards),
- sum(len(f.tunnels) for f in self.cli.forwards.values())))