]> git.proxmox.com Git - pve-manager.git/blame - PVE/CLI/pvesubscription.pm
fix #4947 spice: correct filename extension safari
[pve-manager.git] / PVE / CLI / pvesubscription.pm
CommitLineData
8002175e
DM
1package PVE::CLI::pvesubscription;
2
3use strict;
4use warnings;
5
d4df1b14
FG
6use MIME::Base64;
7use JSON qw(decode_json);
8
8002175e
DM
9use PVE::Tools;
10use PVE::SafeSyslog;
11use PVE::INotify;
12use PVE::RPCEnvironment;
13use PVE::CLIHandler;
14use PVE::API2::Subscription;
15
16use base qw(PVE::CLIHandler);
17
18my $nodename = PVE::INotify::nodename();
19
7e017024
DM
20sub setup_environment {
21 PVE::RPCEnvironment->setup_default_cli_env();
22}
23
d4df1b14
FG
24__PACKAGE__->register_method({
25 name => 'set_offline_key',
26 path => 'set_offline_key',
27 method => 'POST',
28 description => "(Internal use only!) Set a signed subscription info blob as offline key",
29 parameters => {
30 additionalProperties => 0,
31 properties => {
32 data => {
33 type => "string",
34 },
35 },
36 },
37 returns => { type => 'null' },
38 code => sub {
39 my ($param) = @_;
40
41 my $info = decode_json(decode_base64($param->{data}));
d4df1b14
FG
42
43 $info = Proxmox::RS::Subscription::check_signature($info);
44 $info = Proxmox::RS::Subscription::check_server_id($info);
45 $info = Proxmox::RS::Subscription::check_age($info, 0);
46
47 PVE::API2::Subscription::check_key($info->{key}, PVE::API2::Subscription::get_sockets());
48
49 PVE::API2::Subscription::write_etc_subscription($info);
50}});
51
8002175e
DM
52our $cmddef = {
53 update => [ 'PVE::API2::Subscription', 'update', undef, { node => $nodename } ],
75d1eb55
TL
54 get => [ 'PVE::API2::Subscription', 'get', undef, { node => $nodename }, sub {
55 my $info = shift;
56 print "$_: $info->{$_}\n" for sort keys %$info;
57 }],
8002175e 58 set => [ 'PVE::API2::Subscription', 'set', ['key'], { node => $nodename } ],
d4df1b14 59 "set-offline-key" => [ __PACKAGE__, 'set_offline_key', ['data'] ],
85222f82 60 delete => [ 'PVE::API2::Subscription', 'delete', undef, { node => $nodename } ],
8002175e
DM
61};
62
631;