[pve-devel] [PATCH cluster 06/16] move corosync_link schema to Corosync.pm

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Nov 6 13:36:11 CET 2019


since it can be/is already used by all relevant files, and it is not
related at all to pmxcfs.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 data/PVE/API2/ClusterConfig.pm |  4 ++--
 data/PVE/CLI/pvecm.pm          |  4 ++--
 data/PVE/Cluster.pm            | 31 -------------------------------
 data/PVE/Cluster/Setup.pm      |  5 +++--
 data/PVE/Corosync.pm           | 32 ++++++++++++++++++++++++++++++++
 5 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
index e6f47a6..c426a30 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -253,8 +253,8 @@ __PACKAGE__->register_method ({
 		}
 	    };
 
-	    my $link0 = PVE::Cluster::parse_corosync_link($param->{link0});
-	    my $link1 = PVE::Cluster::parse_corosync_link($param->{link1});
+	    my $link0 = PVE::Corosync::parse_corosync_link($param->{link0});
+	    my $link1 = PVE::Corosync::parse_corosync_link($param->{link1});
 
 	    $check_duplicate_addr->($link0);
 	    $check_duplicate_addr->($link1);
diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index 48c110b..0fed6cb 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -357,8 +357,8 @@ __PACKAGE__->register_method ({
 	my $host = $param->{hostname};
 	my $local_ip_address = PVE::Cluster::remote_node_ip($nodename);
 
-	my $link0 = PVE::Cluster::parse_corosync_link($param->{link0});
-	my $link1 = PVE::Cluster::parse_corosync_link($param->{link1});
+	my $link0 = PVE::Corosync::parse_corosync_link($param->{link0});
+	my $link1 = PVE::Corosync::parse_corosync_link($param->{link1});
 
 	PVE::Cluster::Setup::assert_joinable($local_ip_address, $link0, $link1, $param->{force});
 
diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index 28f59eb..b5157ba 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -1184,37 +1184,6 @@ sub ssh_info_to_command {
     return $cmd;
 }
 
-my $corosync_link_format = {
-    address => {
-	default_key => 1,
-	type => 'string', format => 'address',
-	format_description => 'IP',
-	description => "Hostname (or IP) of this corosync link address.",
-    },
-    priority => {
-	optional => 1,
-	type => 'integer',
-	minimum => 0,
-	maximum => 255,
-	default => 0,
-	description => "The priority for the link when knet is used in 'passive' mode. Lower value means higher priority.",
-    },
-};
-my $corosync_link_desc = {
-    type => 'string', format => $corosync_link_format,
-    description => "Address and priority information of a single corosync link.",
-    optional => 1,
-};
-PVE::JSONSchema::register_standard_option("corosync-link", $corosync_link_desc);
-
-sub parse_corosync_link {
-    my ($value) = @_;
-
-    return undef if !defined($value);
-
-    return PVE::JSONSchema::parse_property_string($corosync_link_format, $value);
-}
-
 # NOTE: filesystem must be offline here, no DB changes allowed
 sub cfs_backup_database {
     mkdir $dbbackupdir;
diff --git a/data/PVE/Cluster/Setup.pm b/data/PVE/Cluster/Setup.pm
index e81a110..81e3ef8 100644
--- a/data/PVE/Cluster/Setup.pm
+++ b/data/PVE/Cluster/Setup.pm
@@ -13,6 +13,7 @@ use POSIX qw(EEXIST);
 
 use PVE::APIClient::LWP;
 use PVE::Cluster;
+use PVE::Corosync;
 use PVE::INotify;
 use PVE::JSONSchema;
 use PVE::Network;
@@ -618,8 +619,8 @@ sub join {
     my $nodename = PVE::INotify::nodename();
     my $local_ip_address = PVE::Cluster::remote_node_ip($nodename);
 
-    my $link0 = PVE::Cluster::parse_corosync_link($param->{link0});
-    my $link1 = PVE::Cluster::parse_corosync_link($param->{link1});
+    my $link0 = PVE::Corosync::parse_corosync_link($param->{link0});
+    my $link1 = PVE::Corosync::parse_corosync_link($param->{link1});
 
     # check if we can join with the given parameters and current node state
     assert_joinable($local_ip_address, $link0, $link1, $param->{force});
diff --git a/data/PVE/Corosync.pm b/data/PVE/Corosync.pm
index c0b9075..d1b85dc 100644
--- a/data/PVE/Corosync.pm
+++ b/data/PVE/Corosync.pm
@@ -9,6 +9,7 @@ use Socket qw(AF_INET AF_INET6 inet_ntop);
 use Net::IP qw(ip_is_ipv6);
 
 use PVE::Cluster;
+use PVE::JSONSchema;
 use PVE::Tools;
 use PVE::Tools qw($IPV4RE $IPV6RE);
 
@@ -19,6 +20,37 @@ my $conf_array_sections = {
     interface => 1,
 };
 
+my $corosync_link_format = {
+    address => {
+	default_key => 1,
+	type => 'string', format => 'address',
+	format_description => 'IP',
+	description => "Hostname (or IP) of this corosync link address.",
+    },
+    priority => {
+	optional => 1,
+	type => 'integer',
+	minimum => 0,
+	maximum => 255,
+	default => 0,
+	description => "The priority for the link when knet is used in 'passive' mode. Lower value means higher priority.",
+    },
+};
+my $corosync_link_desc = {
+    type => 'string', format => $corosync_link_format,
+    description => "Address and priority information of a single corosync link.",
+    optional => 1,
+};
+PVE::JSONSchema::register_standard_option("corosync-link", $corosync_link_desc);
+
+sub parse_corosync_link {
+    my ($value) = @_;
+
+    return undef if !defined($value);
+
+    return PVE::JSONSchema::parse_property_string($corosync_link_format, $value);
+}
+
 # a very simply parser ...
 sub parse_conf {
     my ($filename, $raw) = @_;
-- 
2.20.1





More information about the pve-devel mailing list