-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nodectl, libnodectld: update SSH host keys/os-release on demand
- Loading branch information
Showing
6 changed files
with
146 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module NodeCtld::RemoteCommands | ||
class Update < Base | ||
handle :update | ||
|
||
def exec | ||
case @command | ||
when 'ssh-host-keys' | ||
if @vps_ids&.any? | ||
NodeCtld::VpsSshHostKeys.update_vps_ids(@vps_ids) | ||
else | ||
NodeCtld::VpsSshHostKeys.update_all_vps | ||
end | ||
|
||
when 'os-release' | ||
if @vps_ids&.any? | ||
NodeCtld::VpsOsRelease.update_vps_ids(@vps_ids) | ||
else | ||
NodeCtld::VpsOsRelease.update_all_vps | ||
end | ||
|
||
else | ||
raise NodeCtld::SystemCommandFailed.new(nil, nil, "Unknown command #{@command}") | ||
end | ||
|
||
ok | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module NodeCtl | ||
class Commands::Update < Command::Remote | ||
cmd :update | ||
args '<command>' | ||
description 'Update information about VPS' | ||
|
||
def options(parser, _args) | ||
parser.separator <<~END | ||
Subcommands: | ||
ssh-host-keys [vps...] Update SSH host keys | ||
os-release [vps...] Update OS template info by reading /etc/os-release | ||
END | ||
end | ||
|
||
def validate | ||
if args.empty? | ||
raise ValidationError, 'missing subcommand' | ||
elsif !%w[ssh-host-keys os-release].include?(args[0]) | ||
raise ValidationError, "invalid subcommand '#{args[0]}'" | ||
end | ||
|
||
params.update( | ||
command: args[0], | ||
vps_ids: args[1..].map(&:to_i).select { |v| v > 0 } | ||
) | ||
end | ||
|
||
def process | ||
puts 'Update in progress' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters