mirror of https://github.com/borgbase/vorta
Pass SSH key if one is selected. Fixes #15
This commit is contained in:
parent
00de9c189b
commit
49191227fb
|
@ -135,7 +135,7 @@
|
|||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>false</bool>
|
||||
|
|
|
@ -65,6 +65,14 @@
|
|||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">margin-bottom: 10</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>SSH account with Borg installed server-side. Or try <a href="https://www.borgbase.com?utm_source=vorta"><span style=" text-decoration: underline; color:#0000ff;">BorgBase</span></a>. 100GB free during Beta.</p></body></html></string>
|
||||
</property>
|
||||
|
@ -92,6 +100,14 @@
|
|||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">margin-bottom: 10</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To access repository securely. Keep default to use all your existing keys. Or create new key.</string>
|
||||
</property>
|
||||
|
|
|
@ -44,7 +44,7 @@ class BorgThread(QtCore.QThread, BackupProfileMixin):
|
|||
env['BORG_PASSPHRASE'] = params['password']
|
||||
|
||||
env['BORG_RSH'] = 'ssh -oStrictHostKeyChecking=no'
|
||||
if params.get('ssh_key') and params['ssh_key']:
|
||||
if params.get('ssh_key') and params['ssh_key'] is not None:
|
||||
env['BORG_RSH'] += f' -i ~/.ssh/{params["ssh_key"]}'
|
||||
|
||||
self.env = env
|
||||
|
@ -89,6 +89,8 @@ class BorgThread(QtCore.QThread, BackupProfileMixin):
|
|||
ret['message'] = 'Add a remote backup repository first.'
|
||||
return ret
|
||||
|
||||
ret['ssh_key'] = profile.ssh_key
|
||||
ret['repo_id'] = profile.repo.id
|
||||
ret['repo_url'] = profile.repo.url
|
||||
ret['profile_name'] = profile.name
|
||||
ret['password'] = keyring.get_password("vorta-repo", profile.repo.url) # None if no password.
|
||||
|
|
|
@ -101,7 +101,5 @@ class BorgCreateThread(BorgThread):
|
|||
ret['message'] = 'Starting backup..'
|
||||
ret['ok'] = True
|
||||
ret['cmd'] = cmd
|
||||
ret['repo_id'] = profile.repo.id
|
||||
ret['ssh_key'] = None # TODO: implement
|
||||
|
||||
return ret
|
||||
|
|
|
@ -3,8 +3,8 @@ from .borg_thread import BorgThread
|
|||
from vorta.models import SnapshotModel, RepoModel
|
||||
from vorta.utils import keyring
|
||||
|
||||
FakeRepo = namedtuple('Repo', ['url']) # TODO: implement passing SSH key.
|
||||
FakeProfile = namedtuple('FakeProfile', ['repo', 'name'])
|
||||
FakeRepo = namedtuple('Repo', ['url', 'id'])
|
||||
FakeProfile = namedtuple('FakeProfile', ['repo', 'name', 'ssh_key'])
|
||||
|
||||
|
||||
class BorgInfoThread(BorgThread):
|
||||
|
@ -20,8 +20,9 @@ class BorgInfoThread(BorgThread):
|
|||
|
||||
# Build fake profile because we don't have it in the DB yet.
|
||||
profile = FakeProfile(
|
||||
FakeRepo(params['repo_url']),
|
||||
'New Repo'
|
||||
FakeRepo(params['repo_url'], 999),
|
||||
'New Repo',
|
||||
params['ssh_key']
|
||||
)
|
||||
|
||||
ret = super().prepare(profile)
|
||||
|
|
|
@ -13,7 +13,7 @@ class BorgInitThread(BorgThread):
|
|||
|
||||
# Build fake profile because we don't have it in the DB yet.
|
||||
profile = FakeProfile(
|
||||
FakeRepo(params['repo_url']), 'Init Repo'
|
||||
FakeRepo(params['repo_url'], 999), 'Init Repo', params['ssh_key']
|
||||
)
|
||||
|
||||
ret = super().prepare(profile)
|
||||
|
|
|
@ -68,7 +68,6 @@ class AddRepoWindow(AddRepoBase, AddRepoUI):
|
|||
|
||||
def validate(self):
|
||||
"""Pre-flight check for valid input and borg binary."""
|
||||
# TODO: valid repo is xx.xx:xx. add rex
|
||||
if len(self.values['repo_url']) < 5 or ':' not in self.values['repo_url']:
|
||||
self._set_status('Please enter a valid repo URL including hostname and path.')
|
||||
return False
|
||||
|
|
|
@ -74,7 +74,7 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
self.sshComboBox.addItem('Automatically choose SSH Key (default)', None)
|
||||
self.sshComboBox.addItem('Create New Key', 'new')
|
||||
for key in keys:
|
||||
self.sshComboBox.addItem(f'{key["filename"]} ({key["format"]}:{key["fingerprint"]})', key['filename'])
|
||||
self.sshComboBox.addItem(f'{key["filename"]} ({key["format"]})', key['filename'])
|
||||
|
||||
def ssh_select_action(self, index):
|
||||
if index == 1:
|
||||
|
|
|
@ -6,7 +6,7 @@ from vorta.views.repo_add import AddRepoWindow
|
|||
from vorta.models import EventLogModel, RepoModel, SnapshotModel
|
||||
|
||||
|
||||
def test_create_error(app, qtbot):
|
||||
def test_create_fail(app, qtbot):
|
||||
main = app.main_window
|
||||
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.LeftButton)
|
||||
assert main.createProgressText.text() == 'Add a remote backup repository first.'
|
||||
|
|
Loading…
Reference in New Issue