-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from lindig/CP-18289
CP-18289 add booleans to VM state: nomigrate, nested_virt
- Loading branch information
Showing
5 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(* | ||
* Copyright (C) Citrix Systems Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; version 2.1 only. with the special | ||
* exception on linking described in file LICENSE. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
*) | ||
|
||
|
||
type platformdata = (string * string) list | ||
|
||
let is_valid ~key ~platformdata = | ||
(not (List.mem_assoc key platformdata)) || | ||
(match List.assoc key platformdata |> String.lowercase with | ||
| "true" | "1" | "false" | "0" -> true | ||
| v -> false | ||
) | ||
|
||
let is_true ~key ~platformdata ~default = | ||
try | ||
match List.assoc key platformdata |> String.lowercase with | ||
| "true" | "1" -> true | ||
| "false" | "0" -> false | ||
| _ -> default (* Check for validity using is_valid if required *) | ||
with Not_found -> | ||
default | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(* | ||
* Copyright (C) Citrix Systems Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; version 2.1 only. with the special | ||
* exception on linking described in file LICENSE. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
*) | ||
|
||
(* This module defines interpretation of boolean platform values. It | ||
* matches the interpretation implemented in XenAPI for these values. | ||
*) | ||
|
||
type platformdata = (string * string) list | ||
|
||
(** [is_valid key platformdata] returns true if: | ||
* 1. The key is _not_ in platformdata (absence of key is valid) or | ||
* 2. The key is in platformdata, associated with a booleanish value *) | ||
val is_valid: key:string -> platformdata:platformdata -> bool | ||
|
||
(** [is_true key platformdata default] returns true, if the platformdata | ||
* contains a value for key that is "true" or "1". It returns false, if | ||
* a value "0" or "false" exists. If the key doesn't exist or contains | ||
* none of the values above, [default] is returned. | ||
*) | ||
val is_true: | ||
key:string -> | ||
platformdata:platformdata -> | ||
default:bool -> | ||
bool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters