Files
ubicloud/rhizome/host/bin/storage-key-tool
Daniel Farina 46e2647d69 Add rhizome multi-device storage abstractions
Managing multiple storage devices per VM indicates makes the old
one-to-one assumptions of the code in `vm_path.rb` obsolete.  This
patch introduces a similar `storage_path.rb` that is capable of
computing paths for multiple storage devices.

With the exception of the storage-key-tool interface change -- largely
harmless as the key tool is not run automatically -- these rhizome
changes are thought to be backwards compatible, and can be deployed
first.

Hadi wrote the code, but I am taking responsibility for breaking it up
and deploying it.

Co-authored-by: Hadi Moshayedi <hadi@ubicloud.com>
2024-01-24 09:19:33 -08:00

63 lines
1.1 KiB
Ruby
Executable File

#!/bin/env ruby
# frozen_string_literal: true
require "json"
require_relative "../lib/storage_key_tool"
params = JSON.parse($stdin.read)
unless (vm_name = ARGV.shift)
puts "expected vm_name as argument"
exit 1
end
unless (device = ARGV.shift)
puts "expect storage device as argument"
exit 1
end
unless (disk_index = ARGV.shift)
puts "expected disk_index as argument"
exit 1
end
unless (action = ARGV.shift)
puts "expected action as argument"
exit 1
end
storage_key_tool = StorageKeyTool.new(vm_name, device, disk_index)
case action
when "reencrypt"
unless (old_key = params["old_key"])
puts "need old_key"
exit 1
end
unless (new_key = params["new_key"])
puts "need new_key"
exit 1
end
storage_key_tool.reencrypt_key_file(old_key, new_key)
when "test-keys"
unless (old_key = params["old_key"])
puts "need old_key"
exit 1
end
unless (new_key = params["new_key"])
puts "need new_key"
exit 1
end
storage_key_tool.test_keys(old_key, new_key)
when "retire-old-key"
storage_key_tool.retire_old_key
else
puts "invalid action : #{action}"
exit 1
end