answers support

This commit is contained in:
Michael Hudson-Doyle 2018-05-09 15:51:44 +12:00
parent 9b4b86baac
commit 1033f2041f
2 changed files with 12 additions and 3 deletions

View File

@ -17,6 +17,8 @@ Identity:
hostname: ubuntu-server
# ubuntu
password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
ssh_import_id: lp:mwhudson
accept-ssh-key: true
InstallProgress:
reboot: yes

View File

@ -45,9 +45,12 @@ class IdentityController(BaseController):
'username': self.answers['username'],
'hostname': self.answers['hostname'],
'password': self.answers['password'],
#'ssh_import_id': self.answers.get('ssh-import-id', ''),
}
self.done(d)
if 'ssh_import_id' in self.answers:
ssh_import_id = self.answers['ssh_import_id']
self.fetch_ssh_keys(d, ssh_import_id)
else:
self.done(d)
def cancel(self):
self.signal.emit_signal('prev-screen')
@ -87,7 +90,11 @@ class IdentityController(BaseController):
if result is not None:
ok, result, ssh_key, fingerprint = result
if ok:
self.ui.frame.body.confirm_ssh_keys(result, ssh_key, fingerprint)
if self.answers.get('accept-ssh-key'):
result['ssh_key'] = ssh_key
self.loop.set_alarm_in(0.0, lambda loop, ud: self.done(result))
else:
self.ui.frame.body.confirm_ssh_keys(result, ssh_key, fingerprint)
def fetch_ssh_keys(self, result, ssh_import_id):
self._fetching_proc = run_command_start(['ssh-import-id', '-o-', ssh_import_id])