]> git.proxmox.com Git - pmg-api.git/commitdiff
pmgcm: add 'sync' command
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 11 Apr 2017 05:33:50 +0000 (07:33 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 11 Apr 2017 05:33:50 +0000 (07:33 +0200)
PMG/CLI/pmgcm.pm

index 7c17b10090b733685529cc5c320f7ff3d41c8e16..9764ca57bc866358a2c31a40bf7f7e2daecd24ce 100644 (file)
@@ -133,11 +133,44 @@ __PACKAGE__->register_method({
        return undef;
     }});
 
+__PACKAGE__->register_method({
+    name => 'sync',
+    path => 'sync',
+    method => 'GET',
+    description => "Synchronize cluster configuration.",
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           master_ip => {
+               description => 'Optional IP address for master node.',
+               type => 'string', format => 'ip',
+               optional => 1,
+           }
+       },
+    },
+    returns => { type => 'null' },
+    code => sub {
+       my ($param) = @_;
+
+       my $cfg = PVE::INotify::read_file('cluster.conf');
+
+       my $syncip = $param->{master_ip};
+
+       $syncip = $cfg->{master}->{ip} if !$syncip && $cfg->{master};
+
+       die "no master IP specified (use option --master_ip)\n" if !$syncip;
+
+       print STDERR "syncing master configuration from '$syncip'\n";
+
+       PMG::Cluster::sync_config_from_master($cfg, $syncip);
+    }});
+
 our $cmddef = {
     nodes => [ 'PMG::API2::Cluster', 'nodes', [], {}, $format_nodelist],
     create => [ 'PMG::API2::Cluster', 'create', [], {}, $upid_exit],
     join => [ __PACKAGE__, 'join', ['master_ip']],
     join_cmd => [ __PACKAGE__, 'join_cmd', []],
+    sync => [ __PACKAGE__, 'sync', []],
 };
 
 1;