Configurable SSH-PORT

Change-Id: I2cec64822a7b18727664b97fca557b4d57d9cf67
Implements: blueprint ssh-port-argument
This commit is contained in:
eldar nugaev 2015-09-17 11:56:25 +01:00
parent d740ab8f5a
commit fd3cbba2b1
4 changed files with 11 additions and 6 deletions

View File

@ -293,6 +293,7 @@ Freezer can use:
To use ssh storage specify "--storage ssh"
And use "--container %path-to-folder-with-backups-on-remote-machine%"
Also you should specify ssh-username, ssh-key and ssh-host parameters.
ssh-port is optional parameter, default is 22
ssh-username for user ubuntu should be "--ssh-username ubuntu"
ssh-key should be path to your secret ssh key "--ssh-key %path-to-secret-key%"

View File

@ -64,7 +64,7 @@ DEFAULT_PARAMS = {
'vssadmin': True, 'shadow': '', 'shadow_path': '',
'windows_volume': '', 'command': None, 'metadata_out': False,
'storage': 'swift', 'ssh_key': '', 'ssh_username': '', 'ssh_host': '',
'compression': 'gzip'
'ssh_port': 22, 'compression': 'gzip'
}
@ -434,6 +434,10 @@ def backup_arguments(args_dict={}):
'--ssh-host', action='store',
help="Remote host for ssh storage only",
dest='ssh_host', default=DEFAULT_PARAMS['ssh_host'])
arg_parser.add_argument(
'--ssh-port', action='store',
help="Remote port for ssh storage only (default 22)", type=int,
dest='ssh_port', default=DEFAULT_PARAMS['ssh_port'])
arg_parser.set_defaults(**defaults)
backup_args = arg_parser.parse_args()

View File

@ -145,9 +145,9 @@ def freezer_main(args={}):
backup_args.work_dir)
elif backup_args.storage == "ssh":
storage = ssh.SshStorage(
backup_args.container, backup_args.work_dir,
backup_args.ssh_key, backup_args.ssh_username,
backup_args.ssh_host)
backup_args.container, backup_args.work_dir, backup_args.ssh_key,
backup_args.ssh_username, backup_args.ssh_host,
backup_args.ssh_port)
else:
raise Exception("Not storage found for name " + backup_args.storage)

View File

@ -36,7 +36,7 @@ class SshStorage(storage.Storage):
def __init__(self, storage_directory, work_dir,
ssh_key_path, remote_username, remote_ip,
chunk_size=DEFAULT_CHUNK_SIZE):
port, chunk_size=DEFAULT_CHUNK_SIZE):
"""
:param storage_directory: directory of storage
:type storage_directory: str
@ -53,7 +53,7 @@ class SshStorage(storage.Storage):
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(remote_ip, username=remote_username,
key_filename=ssh_key_path)
key_filename=ssh_key_path, port=port)
# we should keep link to ssh to prevent garbage collection
self.ssh = ssh
self.ftp = self.ssh.open_sftp()