Skip to content

Commit

Permalink
Merge pull request #5371 from Vincent-lau/private/shul2/coro-uuid
Browse files Browse the repository at this point in the history
CP-45496: Xapi writes host name/uuid to corosync.conf
  • Loading branch information
Vincent-lau authored Mar 7, 2024
2 parents c5af1a4 + a5b544e commit 50efc1a
Show file tree
Hide file tree
Showing 74 changed files with 202 additions and 43 deletions.
44 changes: 39 additions & 5 deletions ocaml/xapi-idl/cluster/cluster_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open Rpc
open Idl
open Ipaddr_rpc_type

let service_name = "cluster"

Expand All @@ -15,12 +16,45 @@ type debug_info = string [@@deriving rpcty]
(** Name of the cluster *)
type cluster_name = string [@@deriving rpcty]

(** An IPv4 address (a.b.c.d) *)
type address = IPv4 of string [@@deriving rpcty]
type ip = IPv4 of string | IPv6 of string [@@deriving rpcty]

let printaddr () = function IPv4 s -> Printf.sprintf "IPv4(%s)" s
let string_of_ip = Ipaddr.to_string

let str_of_address address = match address with IPv4 a -> a
(** this address includes the hostname and hostuuid along with an ip address
this is done to maintain backwards compatability, and should be combined with
the other variant in the future.
*)
type extended_addr = {ip: Ipaddr.t; hostuuid: string; hostname: string}
[@@deriving rpcty]

type address = IPv4 of string | Extended of extended_addr [@@deriving rpcty]

let ipstr_of_address = function
| IPv4 a ->
a
| Extended {ip; _} ->
string_of_ip ip

let ipaddr_of_address = function
| IPv4 _ as ip ->
ip
| Extended {ip; _} ->
(* FIXME: introduce IPv6 variant when IPv6 support is added *)
IPv4 (string_of_ip ip)

(** The complete address potentially including uuid and hostname *)
let fullstr_of_address = function
| IPv4 a ->
a
| Extended {ip; hostuuid; hostname} ->
Printf.sprintf "(%s, %s, %s)" (string_of_ip ip) hostuuid hostname

let printaddr () = function
| IPv4 s ->
Printf.sprintf "IPv4(%s)" s
| Extended {ip; hostuuid; hostname} ->
Printf.sprintf "IP(%s) hostuuid (%s) hostname(%s)" (string_of_ip ip)
hostuuid hostname

type addresslist = address list [@@deriving rpcty]

Expand All @@ -40,7 +74,7 @@ type all_members = node list [@@deriving rpcty]
(** This type contains all of the information required to initialise the
cluster. All optional params will have the recommended defaults if None. *)
type init_config = {
local_ip: address
member: address
; token_timeout_ms: int64 option
; token_coefficient_ms: int64 option
; name: string option
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi-idl/cluster/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
rresult
xapi-idl
threads
ipaddr
)
(wrapped false)
(preprocess (pps ppx_deriving_rpc)))
Expand Down
25 changes: 25 additions & 0 deletions ocaml/xapi-idl/cluster/ipaddr_rpc_type.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Ipaddr = struct
include Ipaddr

let typ_of =
Rpc.Types.Abstract
{
aname= "ipaddr"
; test_data=
[Ipaddr.V4 Ipaddr.V4.localhost; Ipaddr.V6 Ipaddr.V6.localhost]
; rpc_of= (fun t -> Rpc.String (Ipaddr.to_string t))
; of_rpc=
(function
| Rpc.String s ->
Ipaddr.of_string s
| r ->
Error
(`Msg
(Printf.sprintf
"typ_of_vm_uuid: expected rpc string but got %s"
(Rpc.to_string r)
)
)
)
}
end
5 changes: 5 additions & 0 deletions ocaml/xapi-idl/cluster/ipaddr_rpc_type.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Ipaddr : sig
include module type of Ipaddr

val typ_of : t Rpc.Types.typ
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>UPDATES.get</methodName><params><param><value><struct><member><name>timeout</name><value><double>0</double></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>local_ip</name><value><array><data><value>IPv4</value><value>local_ip</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>127.0.0.1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_timeout_ms</name><value>0</value></member><member><name>local_ip</name><value><array><data><value>IPv4</value><value>local_ip</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>::1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_coefficient_ms</name><value>0</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>::1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_coefficient_ms</name><value>0</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>IPv4</value><value>member</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>127.0.0.1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>::1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>member</name><value><array><data><value>IPv4</value><value>member</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>127.0.0.1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>::1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>IPv4</value><value>member</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_coefficient_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>127.0.0.1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_coefficient_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>::1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_coefficient_ms</name><value>0</value></member><member><name>local_ip</name><value><array><data><value>IPv4</value><value>local_ip</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>member</name><value><array><data><value>IPv4</value><value>member</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_coefficient_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>IPv4</value><value>member</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_coefficient_ms</name><value>0</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>127.0.0.1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_coefficient_ms</name><value>0</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>::1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_coefficient_ms</name><value>0</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>IPv4</value><value>member</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_coefficient_ms</name><value>0</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>local_ip</name><value><array><data><value>IPv4</value><value>local_ip</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>127.0.0.1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>local_ip</name><value><array><data><value>IPv4</value><value>local_ip</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>::1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_timeout_ms</name><value>0</value></member><member><name>local_ip</name><value><array><data><value>IPv4</value><value>local_ip</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_timeout_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>IPv4</value><value>member</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>name</name><value>name</value></member><member><name>token_coefficient_ms</name><value>0</value></member><member><name>local_ip</name><value><array><data><value>IPv4</value><value>local_ip</value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
<?xml version="1.0"?><methodCall><methodName>create</methodName><params><param><value><struct><member><name>init_config</name><value><struct><member><name>token_coefficient_ms</name><value>0</value></member><member><name>member</name><value><array><data><value>Extended</value><value><struct><member><name>hostname</name><value>hostname</value></member><member><name>hostuuid</name><value>hostuuid</value></member><member><name>ip</name><value>127.0.0.1</value></member></struct></value></data></array></value></member></struct></value></member><member><name>dbg</name><value>dbg</value></member></struct></value></param></params></methodCall>
Loading

0 comments on commit 50efc1a

Please sign in to comment.