]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
pvenode: use print_api_result to print acme account information
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jul 2018 08:54:04 +0000 (10:54 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jul 2018 11:09:08 +0000 (13:09 +0200)
PVE/API2/ACMEAccount.pm
PVE/CLI/pvenode.pm

index 2743cfbb1e1538c919714831570bffa4dccfea8f..90620deacbcb34257b9b1b37a09e62a54b1eaed4 100644 (file)
@@ -248,6 +248,7 @@ __PACKAGE__->register_method ({
            account => {
                type => 'object',
                optional => 1,
+               renderer => 'yaml',
            },
            directory => get_standard_option('pve-acme-directory-url', {
                optional => 1,
index 8a6a924dc434c889af8fb42e85c6525f77c73f64..5b06b674890bd7c984de61c59b3195c67acfce87 100644 (file)
@@ -128,29 +128,6 @@ my $print_cert_info = sub {
        $cert, $schema, $order, { %$options, noheader => 1, sort_key => 0 });
 };
 
-my $print_acme_account = sub {
-    my ($account) = @_;
-
-    print "Directory URL: $account->{directory}\n" if $account->{directory};
-    print "Account URL: $account->{location}\n" if $account->{location};
-    print "Terms Of Service: $account->{tos}\n" if $account->{tos};
-
-    my $data = $account->{account};
-    if ($data) {
-       print "\nAccount information:\n";
-       print "ID: $data->{id}\n" if $data->{id};
-       if ($data->{contact}) {
-           print "Contact:\n";
-           for my $contact (@{$data->{contact}}) {
-               print "\t- $contact\n";
-           }
-       }
-       print "Creation date: $data->{createdAt}\n" if $data->{createdAt};
-       print "Initial IP: $data->{initialIp}\n" if $data->{initialIp};
-       print "Status: $data->{status}\n" if $data->{status};
-    }
-};
-
 our $cmddef = {
     config => {
        get => [ 'PVE::API2::NodeConfig', 'get_config', [], { node => $nodename }, sub {
@@ -222,7 +199,11 @@ our $cmddef = {
            }],
            register => [ __PACKAGE__, 'acme_register', ['name', 'contact'], {}, $upid_exit ],
            deactivate => [ 'PVE::API2::ACMEAccount', 'deactivate_account', ['name'], {}, $upid_exit ],
-           info => [ 'PVE::API2::ACMEAccount', 'get_account', ['name'], {}, $print_acme_account],
+           info => [ 'PVE::API2::ACMEAccount', 'get_account', ['name'], {}, sub {
+               my ($data, $schema, $options) = @_;
+               PVE::CLIFormatter::query_terminal_options($options);
+               PVE::CLIFormatter::print_api_result($data, $schema, undef, $options);
+           }, $PVE::RESTHandler::standard_output_options],
            update => [ 'PVE::API2::ACMEAccount', 'update_account', ['name'], {}, $upid_exit ],
        },
        cert => {