Loading cloudcontrol/cli/commands/delforward.pydeleted 100644 → 0 +0 −44 Original line number Diff line number Diff line #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 <http://www.gnu.org/licenses/>. ''' 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> [tunnel id]..." cloudcontrol/cli/commands/addforward.py→cloudcontrol/cli/commands/forward.py +53 −2 Original line number Diff line number Diff line Loading @@ -16,13 +16,42 @@ # along with CloudControl. If not, see <http://www.gnu.org/licenses/>. ''' 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''' Loading Loading @@ -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> [tunnel id]..." cloudcontrol/cli/commands/forwards.pydeleted 100644 → 0 +0 −50 Original line number Diff line number Diff line #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 <http://www.gnu.org/licenses/>. ''' 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()))) Loading
cloudcontrol/cli/commands/delforward.pydeleted 100644 → 0 +0 −44 Original line number Diff line number Diff line #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 <http://www.gnu.org/licenses/>. ''' 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> [tunnel id]..."
cloudcontrol/cli/commands/addforward.py→cloudcontrol/cli/commands/forward.py +53 −2 Original line number Diff line number Diff line Loading @@ -16,13 +16,42 @@ # along with CloudControl. If not, see <http://www.gnu.org/licenses/>. ''' 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''' Loading Loading @@ -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> [tunnel id]..."
cloudcontrol/cli/commands/forwards.pydeleted 100644 → 0 +0 −50 Original line number Diff line number Diff line #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 <http://www.gnu.org/licenses/>. ''' 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())))