#789: account must use existing key
This commit is contained in:
parent
adb20343f6
commit
8d145c10b4
@ -22,20 +22,7 @@ module Devops
|
||||
|
||||
def add_account provider
|
||||
account = ::Provider::ProviderFactory.get(provider).create_account(parser.account)
|
||||
certificate_content = account.certificate
|
||||
cert_name = "#{account.account_name}.pem"
|
||||
certificate_path = File.join(Devops::Api2.settings.keys_dir, cert_name)
|
||||
if File.exists?(certificate_path)
|
||||
raise ConflictException.new("File '#{cert_name}' already exists")
|
||||
end
|
||||
File.open(certificate_path, "w") do |f|
|
||||
f << certificate_content
|
||||
end
|
||||
File.chmod(0600, certificate_path)
|
||||
DevopsLogger.logger.info("File '#{certificate_path}' for provider account '#{account.account_name}' has been created")
|
||||
key = Devops::Model::Key.new({"id" => account.ssh_key, "path" => certificate_path, "scope" => Devops::Model::Key::SYSTEM})
|
||||
Devops::Db.connector.key_insert key
|
||||
account.certificate = certificate_path
|
||||
key = Devops::Db.connector.key account.ssh_key
|
||||
Devops::Db.connector.provider_accounts_insert(account)
|
||||
account
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user