Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: johnelse/xen-api
base: df98fbe832
...
head fork: johnelse/xen-api
compare: 6a403fbfd7
  • 6 commits
  • 11 files changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 27, 2013
@robhoes robhoes CP-4431: Remove VMPR functions
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
f47eb99
@robhoes robhoes CP-4431: Remove VMPP metadata on upgrade
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
1186a0d
Commits on Apr 02, 2013
@robhoes robhoes CP-4431: Tweak description of message_removed error
I think the new version make a little more then when using the CLI.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
c364fdc
@robhoes robhoes CP-4431: Remove VMPP CLI commands
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
a850759
@robhoes robhoes CP-4431: Mark VMPR stuff as "removed" in API docs
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
86bc64b
@johnelse Merge pull request #1121 from robhoes/remove-vmpr
CP-4431: Remove vmpr
6a403fb
View
8 ocaml/client_records/record_util.ml
@@ -434,14 +434,6 @@ let on_boot_to_string onboot =
let wrap f err x = try f x with _ -> err x
let generic_error x = raise (Record_failure ("Unknown value: "^x))
let rpc_to_string = function | Rpc.String s -> s | _ -> failwith "Bad RPC type in record_util"
-let backup_type_to_string t = rpc_to_string (API.rpc_of_vmpp_backup_type t)
-let string_to_backup_type = wrap (fun s -> API.vmpp_backup_type_of_rpc (Rpc.String s)) generic_error
-let backup_frequency_to_string t = rpc_to_string (API.rpc_of_vmpp_backup_frequency t)
-let string_to_backup_frequency = wrap (fun s -> API.vmpp_backup_frequency_of_rpc (Rpc.String s)) generic_error
-let archive_frequency_to_string t = rpc_to_string (API.rpc_of_vmpp_archive_frequency t)
-let string_to_archive_frequency = wrap (fun s -> API.vmpp_archive_frequency_of_rpc (Rpc.String s)) generic_error
-let archive_target_type_to_string t = rpc_to_string (API.rpc_of_vmpp_archive_target_type t)
-let string_to_archive_target_type = wrap (fun s -> API.vmpp_archive_target_type_of_rpc (Rpc.String s)) generic_error
(** Parse a string which might have a units suffix on the end *)
let bytes_of_string field x =
View
107 ocaml/client_records/records.ml
@@ -546,108 +546,6 @@ let role_record rpc session_id role =
(*make_field ~name:"is_basic" ~get:(fun () -> string_of_bool (x ()).API.role_is_basic) ();*)
]}
-let vmpp_record rpc session_id vmpp =
- let _ref = ref vmpp in
- let empty_record = ToGet (fun () -> Client.VMPP.get_record rpc session_id !_ref) in
- let record = ref empty_record in
- let x () = lzy_get record in
- { setref=(fun r -> _ref := r; record := empty_record );
- setrefrec=(fun (a,b) -> _ref := a; record := Got b);
- record=x;
- getref=(fun () -> !_ref);
- fields =
-[
- make_field ~name:"uuid"
- ~get:(fun () -> (x ()).API.vMPP_uuid)
- ();
- make_field ~name:"name-label"
- ~get:(fun () -> (x ()).API.vMPP_name_label)
- ~set:(fun x -> Client.VMPP.set_name_label rpc session_id vmpp x)
- ();
- make_field ~name:"name-description"
- ~get:(fun () -> (x ()).API.vMPP_name_description)
- ~set:(fun x -> Client.VMPP.set_name_description rpc session_id vmpp x)
- ();
- make_field ~name:"is-policy-enabled"
- ~get:(fun () -> string_of_bool (x ()).API.vMPP_is_policy_enabled)
- ~set:(fun x -> Client.VMPP.set_is_policy_enabled rpc session_id vmpp (safe_bool_of_string "is-policy-enabled" x))
- ();
- make_field ~name:"backup-type"
- ~get:(fun () -> Record_util.backup_type_to_string (x ()).API.vMPP_backup_type)
- ~set:(fun x -> Client.VMPP.set_backup_type rpc session_id vmpp (Record_util.string_to_backup_type x))
- ();
- make_field ~name:"backup-retention-value"
- ~get:(fun () -> string_of_int (Int64.to_int (x ()).API.vMPP_backup_retention_value))
- ~set:(fun x -> Client.VMPP.set_backup_retention_value rpc session_id vmpp (safe_i64_of_string "backup-retention-value" x))
- ();
- make_field ~name:"backup-frequency"
- ~get:(fun () -> Record_util.backup_frequency_to_string (x ()).API.vMPP_backup_frequency)
- ~set:(fun x -> Client.VMPP.set_backup_frequency rpc session_id vmpp (Record_util.string_to_backup_frequency x))
- ();
- make_field ~name:"backup-schedule"
- ~get:(fun () -> Record_util.s2sm_to_string "; " (x ()).API.vMPP_backup_schedule)
- ~get_map:(fun () -> (x ()).API.vMPP_backup_schedule)
- ~add_to_map:(fun k v -> Client.VMPP.add_to_backup_schedule rpc session_id vmpp k v)
- ~remove_from_map:(fun k -> Client.VMPP.remove_from_backup_schedule rpc session_id vmpp k)
- ();
- make_field ~name:"is-backup-running"
- ~get:(fun () -> string_of_bool (x ()).API.vMPP_is_backup_running)
- ();
- make_field ~name:"backup-last-run-time"
- ~get:(fun () -> Date.to_string (x ()).API.vMPP_backup_last_run_time)
- ();
- make_field ~name:"archive-target-type"
- ~get:(fun () -> Record_util.archive_target_type_to_string (x ()).API.vMPP_archive_target_type)
- ~set:(fun x -> Client.VMPP.set_archive_target_type rpc session_id vmpp (Record_util.string_to_archive_target_type x))
- ();
- make_field ~name:"archive-target-config"
- ~get:(fun () -> Record_util.s2sm_to_string "; " (x ()).API.vMPP_archive_target_config)
- ~get_map:(fun () -> (x ()).API.vMPP_archive_target_config)
- ~add_to_map:(fun k v -> Client.VMPP.add_to_archive_target_config rpc session_id vmpp k v)
- ~remove_from_map:(fun k ->
- Client.VMPP.remove_from_archive_target_config rpc session_id vmpp k)
- ();
- make_field ~name:"archive-frequency"
- ~get:(fun () -> Record_util.archive_frequency_to_string (x ()).API.vMPP_archive_frequency)
- ~set:(fun x -> Client.VMPP.set_archive_frequency rpc session_id vmpp (Record_util.string_to_archive_frequency x))
- ();
- make_field ~name:"archive-schedule" ~get:(fun () -> Record_util.s2sm_to_string "; " (x ()).API.vMPP_archive_schedule)
- ~get_map:(fun () -> (x ()).API.vMPP_archive_schedule)
- ~add_to_map:(fun k v -> Client.VMPP.add_to_archive_schedule rpc session_id vmpp k v)
- ~remove_from_map:(fun k ->
- Client.VMPP.remove_from_archive_schedule rpc session_id vmpp k)
- ();
- make_field ~name:"is-archive-running"
- ~get:(fun () -> string_of_bool (x ()).API.vMPP_is_archive_running)
- ();
- make_field ~name:"archive-last-run-time" ~get:(fun () -> Date.to_string (x ()).API.vMPP_archive_last_run_time)
- ();
- make_field ~name:"is-alarm-enabled"
- ~get:(fun () -> string_of_bool (x ()).API.vMPP_is_alarm_enabled)
- ~set:(fun x -> Client.VMPP.set_is_alarm_enabled rpc session_id vmpp (safe_bool_of_string "is-alarm-enabled" x))
- ();
- make_field ~name:"alarm-config" ~get:(fun () -> Record_util.s2sm_to_string "; " (x ()).API.vMPP_alarm_config)
- ~get_map:(fun () -> (x ()).API.vMPP_alarm_config)
- ~add_to_map:(fun k v -> Client.VMPP.add_to_alarm_config rpc session_id vmpp k v)
- ~remove_from_map:(fun k ->
- Client.VMPP.remove_from_alarm_config rpc session_id vmpp k)
- ();
- make_field ~name:"VMs"
- ~get:(fun () -> String.concat "; "
- (try
- List.map
- (fun self -> try Client.VM.get_uuid rpc session_id self with _ -> nid)
- (Client.VMPP.get_VMs rpc session_id vmpp)
- with _ -> []
- )
- )
- ~expensive:false
- ~get_set:(fun () -> try List.map
- (fun self -> try Client.VM.get_uuid rpc session_id self with _ -> nid)
- (Client.VMPP.get_VMs rpc session_id vmpp) with _ -> [])
- ();
-]}
-
(*
let alert_record rpc session_id pool =
let _ref = ref pool in
@@ -943,11 +841,6 @@ let vm_record rpc session_id vm =
(* NB this can receive VM_IS_SNAPSHOT *)
~get:(fun () -> string_of_bool (try Client.VM.get_cooperative rpc session_id vm with _ -> true))
~expensive:true ~deprecated:true ();
- make_field ~name:"protection-policy"
- ~get:(fun () -> get_uuid_from_ref (x ()).API.vM_protection_policy)
- ~set:(fun x -> if x="" then Client.VM.set_protection_policy rpc session_id vm Ref.null else Client.VM.set_protection_policy rpc session_id vm (Client.VMPP.get_by_uuid rpc session_id x)) ();
- make_field ~name:"is-snapshot-from-vmpp"
- ~get:(fun () -> string_of_bool (x ()).API.vM_is_snapshot_from_vmpp) ();
make_field ~name:"tags"
~get:(fun () -> String.concat ", " (x ()).API.vM_tags)
~get_set:(fun () -> (x ()).API.vM_tags)
View
124 ocaml/idl/datamodel.ml
@@ -346,7 +346,7 @@ let _ =
error Api_errors.message_deprecated []
~doc:"This message has been deprecated." ();
error Api_errors.message_removed []
- ~doc:"This message has been removed." ();
+ ~doc:"This function is no longer available." ();
error Api_errors.permission_denied ["message"]
~doc:"Caller not allowed to perform this operation." ();
@@ -6721,8 +6721,8 @@ let vm =
field ~writer_roles:_R_VM_POWER_ADMIN ~qualifier:DynamicRO ~in_product_since:rel_midnight_ride ~ty:(Set (Ref _vm)) "children" "List pointing to all the children of this VM";
field ~qualifier:DynamicRO ~in_product_since:rel_midnight_ride ~default_value:(Some (VMap [])) ~ty:(Map (String,String)) "bios_strings" "BIOS strings";
- field ~writer_roles:_R_VM_POWER_ADMIN ~qualifier:StaticRO ~in_product_since:rel_cowley ~default_value:(Some (VRef (Ref.string_of Ref.null))) ~ty:(Ref _vmpp) "protection_policy" "Ref pointing to a protection policy for this VM";
- field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO ~in_product_since:rel_cowley ~default_value:(Some (VBool false)) ~ty:Bool "is_snapshot_from_vmpp" "true if this snapshot was created by the protection policy";
+ field ~writer_roles:_R_VM_POWER_ADMIN ~qualifier:StaticRO ~lifecycle:[Published, rel_cowley, ""; Deprecated, rel_clearwater, "The VMPR feature was removed"] ~default_value:(Some (VRef (Ref.string_of Ref.null))) ~ty:(Ref _vmpp) "protection_policy" "Ref pointing to a protection policy for this VM";
+ field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO ~lifecycle:[Published, rel_cowley, ""; Deprecated, rel_clearwater, "The VMPR feature was removed"] ~default_value:(Some (VBool false)) ~ty:Bool "is_snapshot_from_vmpp" "true if this snapshot was created by the protection policy";
field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO ~ty:(Ref _vm_appliance) ~default_value:(Some (VRef (Ref.string_of Ref.null))) "appliance" "the appliance to which this VM belongs";
field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO ~in_product_since:rel_boston ~default_value:(Some (VInt 0L)) ~ty:Int "start_delay" "The delay to wait before proceeding to the next order in the startup sequence (seconds)";
field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO ~in_product_since:rel_boston ~default_value:(Some (VInt 0L)) ~ty:Int "shutdown_delay" "The delay to wait before proceeding to the next order in the shutdown sequence (seconds)";
@@ -6791,10 +6791,13 @@ let vm_guest_metrics =
()
(* VM protection policy *)
+let vmpr_removed = [
+ Published, rel_cowley, "";
+ Removed, rel_clearwater, "The VMPR feature was removed";
+]
let vmpp_protect_now = call ~flags:[`Session]
~name:"protect_now"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[Ref _vmpp, "vmpp", "The protection policy to execute";]
~doc:"This call executes the protection policy immediately"
~allowed_roles:_R_POOL_OP
@@ -6802,8 +6805,7 @@ let vmpp_protect_now = call ~flags:[`Session]
()
let vmpp_archive_now = call ~flags:[`Session]
~name:"archive_now"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[Ref _vm, "snapshot", "The snapshot to archive";]
~doc:"This call archives the snapshot provided as a parameter"
~allowed_roles:_R_VM_POWER_ADMIN
@@ -6811,8 +6813,7 @@ let vmpp_archive_now = call ~flags:[`Session]
()
let vmpp_create_alert = call ~flags:[`Session]
~name:"create_alert"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[Ref _vmpp, "vmpp", "The protection policy where the alert should be created";
String, "name", "The name of the message";
Int, "priority", "The priority of the message";
@@ -6825,8 +6826,7 @@ let vmpp_create_alert = call ~flags:[`Session]
()
let vmpp_get_alerts = call ~flags:[`Session]
~name:"get_alerts"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[Ref _vmpp, "vmpp", "The protection policy";
Int, "hours_from_now", "how many hours in the past the oldest record to fetch is";
]
@@ -6866,8 +6866,7 @@ let vmpp_archive_target_config_username = "username"
let vmpp_archive_target_config_password = "password"
let vmpp_set_backup_retention_value = call ~flags:[`Session]
~name:"set_backup_retention_value"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -6876,8 +6875,7 @@ let vmpp_set_backup_retention_value = call ~flags:[`Session]
()
let vmpp_set_is_backup_running = call ~flags:[`Session]
~name:"set_is_backup_running"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[
Ref _vmpp, "self", "The protection policy";
Bool, "value", "true to mark this protection policy's backup is running"
@@ -6888,8 +6886,7 @@ let vmpp_set_is_backup_running = call ~flags:[`Session]
()
let vmpp_set_is_archive_running = call ~flags:[`Session]
~name:"set_is_archive_running"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[
Ref _vmpp, "self", "The protection policy";
Bool, "value", "true to mark this protection policy's archive is running"
@@ -6900,8 +6897,7 @@ let vmpp_set_is_archive_running = call ~flags:[`Session]
()
let vmpp_set_is_alarm_enabled = call ~flags:[`Session]
~name:"set_is_alarm_enabled"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[
Ref _vmpp, "self", "The protection policy";
Bool, "value", "true if alarm is enabled for this policy"
@@ -6911,8 +6907,7 @@ let vmpp_set_is_alarm_enabled = call ~flags:[`Session]
()
let vmpp_set_archive_frequency = call ~flags:[`Session]
~name:"set_archive_frequency"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[
Ref _vmpp, "self", "The protection policy";
vmpp_archive_frequency, "value", "the archive frequency"
@@ -6922,8 +6917,7 @@ let vmpp_set_archive_frequency = call ~flags:[`Session]
()
let vmpp_set_archive_target_type = call ~flags:[`Session]
~name:"set_archive_target_type"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[
Ref _vmpp, "self", "The protection policy";
vmpp_archive_target_type, "value", "the archive target config type"
@@ -6933,8 +6927,7 @@ let vmpp_set_archive_target_type = call ~flags:[`Session]
()
let vmpp_set_backup_frequency = call ~flags:[`Session]
~name:"set_backup_frequency"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~params:[
Ref _vmpp, "self", "The protection policy";
vmpp_backup_frequency, "value", "the backup frequency"
@@ -6944,8 +6937,7 @@ let vmpp_set_backup_frequency = call ~flags:[`Session]
()
let vmpp_set_backup_schedule = call ~flags:[`Session]
~name:"set_backup_schedule"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -6954,8 +6946,7 @@ let vmpp_set_backup_schedule = call ~flags:[`Session]
()
let vmpp_set_archive_target_config = call ~flags:[`Session]
~name:"set_archive_target_config"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -6964,8 +6955,7 @@ let vmpp_set_archive_target_config = call ~flags:[`Session]
()
let vmpp_set_archive_schedule = call ~flags:[`Session]
~name:"set_archive_schedule"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -6974,8 +6964,7 @@ let vmpp_set_archive_schedule = call ~flags:[`Session]
()
let vmpp_set_alarm_config = call ~flags:[`Session]
~name:"set_alarm_config"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -6984,8 +6973,7 @@ let vmpp_set_alarm_config = call ~flags:[`Session]
()
let vmpp_set_backup_last_run_time = call ~flags:[`Session]
~name:"set_backup_last_run_time"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_LOCAL_ROOT_ONLY
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -6994,8 +6982,7 @@ let vmpp_set_backup_last_run_time = call ~flags:[`Session]
()
let vmpp_set_archive_last_run_time = call ~flags:[`Session]
~name:"set_archive_last_run_time"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_LOCAL_ROOT_ONLY
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7004,8 +6991,7 @@ let vmpp_set_archive_last_run_time = call ~flags:[`Session]
()
let vmpp_add_to_backup_schedule = call ~flags:[`Session]
~name:"add_to_backup_schedule"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7015,8 +7001,7 @@ let vmpp_add_to_backup_schedule = call ~flags:[`Session]
()
let vmpp_add_to_archive_target_config = call ~flags:[`Session]
~name:"add_to_archive_target_config"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7026,8 +7011,7 @@ let vmpp_add_to_archive_target_config = call ~flags:[`Session]
()
let vmpp_add_to_archive_schedule = call ~flags:[`Session]
~name:"add_to_archive_schedule"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7037,8 +7021,7 @@ let vmpp_add_to_archive_schedule = call ~flags:[`Session]
()
let vmpp_add_to_alarm_config = call ~flags:[`Session]
~name:"add_to_alarm_config"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7048,8 +7031,7 @@ let vmpp_add_to_alarm_config = call ~flags:[`Session]
()
let vmpp_remove_from_backup_schedule = call ~flags:[`Session]
~name:"remove_from_backup_schedule"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7058,8 +7040,7 @@ let vmpp_remove_from_backup_schedule = call ~flags:[`Session]
()
let vmpp_remove_from_archive_target_config = call ~flags:[`Session]
~name:"remove_from_archive_target_config"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7068,8 +7049,7 @@ let vmpp_remove_from_archive_target_config = call ~flags:[`Session]
()
let vmpp_remove_from_archive_schedule = call ~flags:[`Session]
~name:"remove_from_archive_schedule"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7078,8 +7058,7 @@ let vmpp_remove_from_archive_schedule = call ~flags:[`Session]
()
let vmpp_remove_from_alarm_config = call ~flags:[`Session]
~name:"remove_from_alarm_config"
- ~in_oss_since:None
- ~in_product_since:rel_cowley
+ ~lifecycle:vmpr_removed
~allowed_roles:_R_POOL_OP
~params:[
Ref _vmpp, "self", "The protection policy";
@@ -7087,8 +7066,9 @@ let vmpp_remove_from_alarm_config = call ~flags:[`Session]
]
()
let vmpp =
- create_obj ~in_db:true ~in_product_since:rel_cowley ~in_oss_since:None ~internal_deprecated_since:None ~persist:PersistEverything ~gen_constructor_destructor:true ~name:_vmpp ~descr:"VM Protection Policy"
+ create_obj ~in_db:true ~in_oss_since:None ~persist:PersistEverything ~gen_constructor_destructor:true ~name:_vmpp ~descr:"VM Protection Policy"
~gen_events:true
+ ~lifecycle:vmpr_removed
~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP
~messages:[
@@ -7119,25 +7099,25 @@ let vmpp =
vmpp_set_archive_last_run_time;
]
~contents:[
- uid _vmpp;
+ uid ~lifecycle:vmpr_removed _vmpp;
namespace ~name:"name" ~contents:(names None RW) ();
- field ~qualifier:RW ~ty:Bool "is_policy_enabled" "enable or disable this policy" ~default_value:(Some (VBool true));
- field ~qualifier:RW ~ty:vmpp_backup_type "backup_type" "type of the backup sub-policy";
- field ~qualifier:StaticRO ~ty:Int "backup_retention_value" "maximum number of backups that should be stored at any time" ~default_value:(Some (VInt 7L));
- field ~qualifier:StaticRO ~ty:vmpp_backup_frequency "backup_frequency" "frequency of the backup schedule";
- field ~qualifier:StaticRO ~ty:(Map (String,String)) "backup_schedule" "schedule of the backup containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone";
- field ~qualifier:DynamicRO ~ty:Bool "is_backup_running" "true if this protection policy's backup is running";
- field ~qualifier:DynamicRO ~ty:DateTime "backup_last_run_time" "time of the last backup" ~default_value:(Some(VDateTime(Date.of_float 0.)));
- field ~qualifier:StaticRO ~ty:vmpp_archive_target_type "archive_target_type" "type of the archive target config" ~default_value:(Some (VEnum "none"));
- field ~qualifier:StaticRO ~ty:(Map (String,String)) "archive_target_config" "configuration for the archive, including its 'location', 'username', 'password'" ~default_value:(Some (VMap []));
- field ~qualifier:StaticRO ~ty:vmpp_archive_frequency "archive_frequency" "frequency of the archive schedule" ~default_value:(Some (VEnum "never"));
- field ~qualifier:StaticRO ~ty:(Map (String,String)) "archive_schedule" "schedule of the archive containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone" ~default_value:(Some (VMap []));
- field ~qualifier:DynamicRO ~ty:Bool "is_archive_running" "true if this protection policy's archive is running";
- field ~qualifier:DynamicRO ~ty:DateTime "archive_last_run_time" "time of the last archive" ~default_value:(Some(VDateTime(Date.of_float 0.)));
- field ~qualifier:DynamicRO ~ty:(Set (Ref _vm)) "VMs" "all VMs attached to this protection policy";
- field ~qualifier:StaticRO ~ty:Bool "is_alarm_enabled" "true if alarm is enabled for this policy" ~default_value:(Some (VBool false));
- field ~qualifier:StaticRO ~ty:(Map (String,String)) "alarm_config" "configuration for the alarm" ~default_value:(Some (VMap []));
- field ~qualifier:DynamicRO ~ty:(Set (String)) "recent_alerts" "recent alerts" ~default_value:(Some (VSet []));
+ field ~lifecycle:vmpr_removed ~qualifier:RW ~ty:Bool "is_policy_enabled" "enable or disable this policy" ~default_value:(Some (VBool true));
+ field ~lifecycle:vmpr_removed ~qualifier:RW ~ty:vmpp_backup_type "backup_type" "type of the backup sub-policy" ~default_value:(Some (VEnum "snapshot"));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:Int "backup_retention_value" "maximum number of backups that should be stored at any time" ~default_value:(Some (VInt 7L));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:vmpp_backup_frequency "backup_frequency" "frequency of the backup schedule" ~default_value:(Some (VEnum "daily"));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:(Map (String,String)) "backup_schedule" "schedule of the backup containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone" ~default_value:(Some (VMap []));
+ field ~lifecycle:vmpr_removed ~qualifier:DynamicRO ~ty:Bool "is_backup_running" "true if this protection policy's backup is running";
+ field ~lifecycle:vmpr_removed ~qualifier:DynamicRO ~ty:DateTime "backup_last_run_time" "time of the last backup" ~default_value:(Some(VDateTime(Date.of_float 0.)));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:vmpp_archive_target_type "archive_target_type" "type of the archive target config" ~default_value:(Some (VEnum "none"));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:(Map (String,String)) "archive_target_config" "configuration for the archive, including its 'location', 'username', 'password'" ~default_value:(Some (VMap []));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:vmpp_archive_frequency "archive_frequency" "frequency of the archive schedule" ~default_value:(Some (VEnum "never"));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:(Map (String,String)) "archive_schedule" "schedule of the archive containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone" ~default_value:(Some (VMap []));
+ field ~lifecycle:vmpr_removed ~qualifier:DynamicRO ~ty:Bool "is_archive_running" "true if this protection policy's archive is running";
+ field ~lifecycle:vmpr_removed ~qualifier:DynamicRO ~ty:DateTime "archive_last_run_time" "time of the last archive" ~default_value:(Some(VDateTime(Date.of_float 0.)));
+ field ~lifecycle:vmpr_removed ~qualifier:DynamicRO ~ty:(Set (Ref _vm)) "VMs" "all VMs attached to this protection policy";
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:Bool "is_alarm_enabled" "true if alarm is enabled for this policy" ~default_value:(Some (VBool false));
+ field ~lifecycle:vmpr_removed ~qualifier:StaticRO ~ty:(Map (String,String)) "alarm_config" "configuration for the alarm" ~default_value:(Some (VMap []));
+ field ~lifecycle:vmpr_removed ~qualifier:DynamicRO ~ty:(Set (String)) "recent_alerts" "recent alerts" ~default_value:(Some (VSet []));
]
()
View
16 ocaml/xapi/cli_frontend.ml
@@ -2361,22 +2361,6 @@ add a mapping of 'path' -> '/tmp', the command line should contain the argument
; implementation = No_fd Cli_operations.secret_destroy
; flags = []
};
- "vmpp-create",
- {
- reqd=["name-label";"backup-type";"backup-frequency"];
- optn=["name-description";"is-policy-enabled";"backup-schedule:";"backup-retention-value";"archive-target-type";"archive-target-config:";"archive-frequency";"archive-schedule:";"is-alarm-enabled";"alarm-config:"];
- help="Create a new VM protection policy.";
- implementation=No_fd Cli_operations.vmpp_create;
- flags=[];
- };
- "vmpp-destroy",
- {
- reqd=["uuid"];
- optn=[];
- help="Destroy a VM protection policy.";
- implementation=No_fd Cli_operations.vmpp_destroy;
- flags=[];
- };
"appliance-create",
{
reqd=["name-label"];
View
44 ocaml/xapi/cli_operations.ml
@@ -768,7 +768,7 @@ let gen_cmds rpc session_id =
(make_param_funs (Client.Console.get_all) (Client.Console.get_all_records_where) (Client.Console.get_by_uuid) (console_record) "console" [] ["uuid";"vm-uuid";"vm-name-label";"protocol";"location"] rpc session_id) @
(make_param_funs (Client.VM.get_all) (Client.VM.get_all_records_where) (Client.VM.get_by_uuid) (vm_record) "vm" [("is-a-template","false")] ["name-label";"uuid";"power-state"] rpc session_id) @
(make_param_funs (Client.VM.get_all) (Client.VM.get_all_records_where) (Client.VM.get_by_uuid) (vm_record) "template" [("is-a-template","true");("is-a-snapshot","false")] ["name-label";"name-description";"uuid"] rpc session_id) @
- (make_param_funs (Client.VM.get_all) (Client.VM.get_all_records_where) (Client.VM.get_by_uuid) (vm_record) "snapshot" [("is-a-snapshot","true")] ["name-label";"name-description";"uuid";"snapshot_of"; "snapshot_time"; "is-snapshot-from-vmpp"] rpc session_id) @
+ (make_param_funs (Client.VM.get_all) (Client.VM.get_all_records_where) (Client.VM.get_by_uuid) (vm_record) "snapshot" [("is-a-snapshot","true")] ["name-label";"name-description";"uuid";"snapshot_of"; "snapshot_time"] rpc session_id) @
(make_param_funs (Client.Host.get_all) (Client.Host.get_all_records_where) (Client.Host.get_by_uuid) (host_record) "host" [] ["uuid";"name-label";"name-description"] rpc session_id) @
(make_param_funs (Client.Host_cpu.get_all) (Client.Host_cpu.get_all_records_where) (Client.Host_cpu.get_by_uuid) (host_cpu_record) "host-cpu" [] ["uuid";"number";"vendor";"speed";"utilisation"] rpc session_id) @
(make_param_funs (Client.Host_crashdump.get_all) (Client.Host_crashdump.get_all_records_where) (Client.Host_crashdump.get_by_uuid) (host_crashdump_record) "host-crashdump" [] ["uuid";"host";"timestamp";"size"] rpc session_id) @
@@ -782,7 +782,6 @@ let gen_cmds rpc session_id =
(make_param_funs (Client.Subject.get_all) (Client.Subject.get_all_records_where) (Client.Subject.get_by_uuid) (subject_record) "subject" [] ["uuid";"subject-identifier";"other-config";"roles"] rpc session_id) @
(make_param_funs (Client.Role.get_all) (fun ~rpc ~session_id ~expr -> Client.Role.get_all_records_where ~rpc ~session_id ~expr:Xapi_role.expr_no_permissions)
(Client.Role.get_by_uuid) (role_record) "role" [] ["uuid";"name";"description";"subroles"] rpc session_id) @
- (make_param_funs (Client.VMPP.get_all) (Client.VMPP.get_all_records_where) (Client.VMPP.get_by_uuid) (vmpp_record) "vmpp" [] ["uuid";"name-label";"name-description";"is-policy-enabled";"backup-type";"backup-retention-value";"backup-frequency";"backup-schedule";"is-backup-running";"backup-last-run-time";"archive-target-type";"archive-target-config";"archive-frequency";"archive-schedule";"is-archive-running";"archive-last-run-time";"is-alarm-enabled";"alarm-config";"VMs"] rpc session_id) @
(*
(make_param_funs (Client.Blob.get_all) (Client.Blob.get_all_records_where) (Client.Blob.get_by_uuid) (blob_record) "blob" [] ["uuid";"mime-type"] rpc session_id) @
*)
@@ -1617,7 +1616,6 @@ let event_wait_gen rpc session_id classname record_matches =
| "task" -> List.map (fun x -> (task_record rpc session_id x).fields) (Client.Task.get_all rpc session_id)
| "subject" -> List.map (fun x -> (subject_record rpc session_id x).fields) (Client.Subject.get_all rpc session_id)
| "role" -> List.map (fun x -> (role_record rpc session_id x).fields) (Client.Role.get_all rpc session_id)
- | "vmpp" -> List.map (fun x -> (vmpp_record rpc session_id x).fields) (Client.VMPP.get_all rpc session_id)
| "secret" -> List.map (fun x -> (secret_record rpc session_id x).fields) (Client.Secret.get_all rpc session_id)
(* | "alert" -> List.map (fun x -> (alert_record rpc session_id x).fields) (Client.Alert.get_all rpc session_id) *)
| _ -> failwith ("Cli listening for class '"^classname^"' not currently implemented")
@@ -1657,7 +1655,6 @@ let event_wait_gen rpc session_id classname record_matches =
| Event_helper.PBD (r,Some x) -> let record = pbd_record rpc session_id r in record.setrefrec (r,x); record.fields
| Event_helper.Pool (r,Some x) -> let record = pool_record rpc session_id r in record.setrefrec (r,x); record.fields
| Event_helper.Task (r,Some x) -> let record = task_record rpc session_id r in record.setrefrec (r,x); record.fields
- | Event_helper.VMPP (r,Some x) -> let record = vmpp_record rpc session_id r in record.setrefrec (r,x); record.fields
| Event_helper.Secret (r,Some x) -> let record = secret_record rpc session_id r in record.setrefrec (r,x); record.fields
| _ -> failwith ("Cli listening for class '"^classname^"' not currently implemented")
in
@@ -4235,45 +4232,6 @@ let secret_destroy printer rpc session_id params =
let ref = Client.Secret.get_by_uuid ~rpc ~session_id ~uuid in
Client.Secret.destroy ~rpc ~session_id ~self:ref
-let vmpp_create printer rpc session_id params =
- let get ?default param_name =
- if List.mem_assoc param_name params
- then List.assoc param_name params
- else match default with
- | Some default_value -> default_value
- | None -> failwith ("No default value for parameter "^param_name)
- in
- let map param_name ?default xmlrpc_to_type api_from_type =
- api_from_type param_name (xmlrpc_to_type (get ?default param_name))
- in
- let name_label = List.assoc "name-label" params in
- let backup_type = map "backup-type" XMLRPC.To.string API.Legacy.From.vmpp_backup_type in
- let backup_frequency = map "backup-frequency" XMLRPC.To.string API.Legacy.From.vmpp_backup_frequency in
- let backup_schedule = read_map_params "backup-schedule" params in
- (* optional parameters with default values *)
- let name_description = get "name-description" ~default:"" in
- let is_policy_enabled = Record_util.bool_of_string(get "is-policy-enabled" ~default:"true") in
- let backup_retention_value = map "backup-retention-value" ~default:"7" XMLRPC.To.string API.Legacy.From.int64 in
- let archive_frequency = map "archive-frequency" ~default:"never" XMLRPC.To.string API.Legacy.From.vmpp_archive_frequency in
- let archive_target_type = map "archive-target-type" ~default:"none" XMLRPC.To.string API.Legacy.From.vmpp_archive_target_type in
- let archive_target_config = read_map_params "archive-target-config" params in
- let archive_schedule = read_map_params "archive-schedule" params in
- let is_alarm_enabled = Record_util.bool_of_string(get "is-alarm-enabled" ~default:"false") in
- let alarm_config = read_map_params "alarm-config" params in
- let ref = Client.VMPP.create ~rpc ~session_id ~name_label ~name_description
- ~is_policy_enabled ~backup_type ~backup_retention_value ~backup_frequency
- ~backup_schedule ~archive_target_type
- ~archive_target_config ~archive_frequency ~archive_schedule
- ~is_alarm_enabled ~alarm_config
- in
- let uuid = Client.VMPP.get_uuid ~rpc ~session_id ~self:ref in
- printer (Cli_printer.PList [uuid])
-
-let vmpp_destroy printer rpc session_id params =
- let uuid = List.assoc "uuid" params in
- let ref = Client.VMPP.get_by_uuid ~rpc ~session_id ~uuid in
- Client.VMPP.destroy ~rpc ~session_id ~self:ref
-
let vm_appliance_create printer rpc session_id params =
let name_label = List.assoc "name-label" params in
let name_description =
View
14 ocaml/xapi/xapi_db_upgrade.ml
@@ -330,6 +330,19 @@ let upgrade_host_editions = {
hosts
}
+let remove_vmpp = {
+ description = "Removing VMPP metadata (feature was removed)";
+ version = (fun x -> x <= tampa);
+ fn = fun ~__context ->
+ let vmpps = Db.VMPP.get_all ~__context in
+ List.iter (fun self -> Db.VMPP.destroy ~__context ~self) vmpps;
+ let open Db_filter_types in
+ let vms = Db.VM.get_refs_where ~__context ~expr:(
+ Not (Eq (Field "protection_policy", Literal (Ref.string_of Ref.null)))
+ ) in
+ List.iter (fun self -> Db.VM.set_protection_policy ~__context ~self ~value:Ref.null) vms
+}
+
let rules = [
upgrade_vm_memory_overheads;
upgrade_wlb_configuration;
@@ -343,6 +356,7 @@ let rules = [
upgrade_auto_poweron;
upgrade_pif_metrics;
upgrade_host_editions;
+ remove_vmpp;
]
(* Maybe upgrade most recent db *)
View
6 ocaml/xapi/xapi_pool.ml
@@ -1642,11 +1642,7 @@ let audit_log_append ~__context ~line =
()
let test_archive_target ~__context ~self ~config =
- Xapi_plugins.call_plugin
- (Context.get_session_id __context)
- Xapi_vmpp.vmpr_plugin
- "test_archive_target"
- config
+ raise (Api_errors.Server_error (Api_errors.message_removed, []))
let enable_local_storage_caching ~__context ~self =
let srs = Db.SR.get_all_records ~__context in
View
13 ocaml/xapi/xapi_vm.ml
@@ -757,18 +757,7 @@ let s3_resume ~__context ~vm = Xapi_xenops.s3resume ~__context ~self:vm
let copy_bios_strings = Xapi_vm_helpers.copy_bios_strings
let set_protection_policy ~__context ~self ~value =
- if value <> Ref.null then begin
- if Db.VM.get_is_control_domain ~__context ~self then
- (* do not assign vmpps to the dom0 vm of any host in the pool *)
- raise (Api_errors.Server_error(Api_errors.invalid_value, [Ref.string_of value]));
- if Db.VM.get_is_a_template ~__context ~self then
- (* Do not assign templates to a VMPP. *)
- raise (Api_errors.Server_error(Api_errors.vm_is_template, [Ref.string_of self]));
- (* if unlicensed, allow only to change to protection policy to null *)
- Xapi_vmpp.assert_licensed ~__context;
- end;
- Db.VM.set_protection_policy ~__context ~self ~value;
- update_allowed_operations ~__context ~self
+ raise (Api_errors.Server_error (Api_errors.message_removed, []))
let set_start_delay ~__context ~self ~value =
if value < 0L then invalid_value
View
7 ocaml/xapi/xapi_vm_clone.ml
@@ -255,11 +255,6 @@ let copy_vm_record ?(snapshot_info_record) ~__context ~vm ~disk_op ~new_name ~ne
| Disk_op_clone | Disk_op_copy _-> Ref.null
| Disk_op_snapshot | Disk_op_checkpoint -> all.Db_actions.vM_parent in
- (* verify if this action is happening due to a VM protection policy *)
- let is_snapshot_from_vmpp =
- is_a_snapshot && (Xapi_vmpp.is_snapshot_from_vmpp ~__context)
- in
-
(* create a new VM *)
Db.VM.create ~__context
~ref
@@ -324,7 +319,7 @@ let copy_vm_record ?(snapshot_info_record) ~__context ~vm ~disk_op ~new_name ~ne
~tags:all.Db_actions.vM_tags
~bios_strings:all.Db_actions.vM_bios_strings
~protection_policy:Ref.null
- ~is_snapshot_from_vmpp
+ ~is_snapshot_from_vmpp:false
~appliance:Ref.null
~start_delay:0L
~shutdown_delay:0L
View
3  ocaml/xapi/xapi_vm_snapshot.ml
@@ -29,7 +29,6 @@ open D
let snapshot ~__context ~vm ~new_name =
debug "Snapshot: begin";
TaskHelper.set_cancellable ~__context;
- Xapi_vmpp.show_task_in_xencenter ~__context ~vm;
let res = Xapi_vm_clone.clone Xapi_vm_clone.Disk_op_snapshot ~__context ~vm ~new_name in
debug "Snapshot: end";
res
@@ -130,7 +129,6 @@ let wait_for_snapshot ~__context ~vm ~xs ~domid ~new_name =
(* dynamically by the xapi_vm_lifecycle.update_allowed_operations call. *)
let snapshot_with_quiesce ~__context ~vm ~new_name =
debug "snapshot_with_quiesce: begin";
- Xapi_vmpp.show_task_in_xencenter ~__context ~vm;
let domid = Int64.to_int (Db.VM.get_domid ~__context ~self:vm) in
let result = Vmopshelpers.with_xs (fun xs ->
(* 1. We first check if the VM supports quiesce-mode *)
@@ -169,7 +167,6 @@ let snapshot_with_quiesce ~__context ~vm ~new_name =
(* Checkpoint *)
(*************************************************************************************************)
let checkpoint ~__context ~vm ~new_name =
- Xapi_vmpp.show_task_in_xencenter ~__context ~vm;
let power_state = Db.VM.get_power_state ~__context ~self:vm in
let snapshot_info = ref [] in
(* live-suspend the VM if the VM is running *)
View
649 ocaml/xapi/xapi_vmpp.ml
@@ -14,681 +14,94 @@
module D = Debug.Debugger(struct let name="xapi" end)
open D
-open Fun
+let raise_removed () =
+ raise (Api_errors.Server_error (Api_errors.message_removed, []))
-let vmpr_plugin = "vmpr"
-let vmpr_username = "__dom0__vmpr"
-let vmpr_snapshot_other_config_show_in_xencenter = "ShowInXenCenter"
-let vmpr_snapshot_other_config_applies_to = "applies_to"
-
-let assert_licensed ~__context =
- if (not (Pool_features.is_enabled ~__context Features.VMPR))
- then
- raise (Api_errors.Server_error(Api_errors.license_restriction, []))
-
-let protect_now ~__context ~vmpp =
- assert_licensed ~__context;
- let vmpp_uuid = Db.VMPP.get_uuid ~__context ~self:vmpp in
- let args = [ "vmpp_uuid", vmpp_uuid ] in
- Xapi_plugins.call_plugin
- (Context.get_session_id __context)
- vmpr_plugin
- "protect_now"
- args
+let protect_now ~__context ~vmpp =
+ raise_removed ()
let archive_now ~__context ~snapshot =
- assert_licensed ~__context;
- let snapshot_uuid = Db.VM.get_uuid ~__context ~self:snapshot in
- let args = [ "snapshot_uuid", snapshot_uuid ] in
- Xapi_plugins.call_plugin
- (Context.get_session_id __context)
- vmpr_plugin
- "archive_now"
- args
+ raise_removed ()
let add_to_recent_alerts ~__context ~vmpp ~value =
- assert_licensed ~__context;
- let recent_alerts = value ::
- (Db.VMPP.get_recent_alerts ~__context ~self:vmpp)
- in
- (* keep up to 10 elements in the set *)
- let rec trunc i alerts =
- if i<1 then []
- else match alerts with [] -> []|x::xs -> x::(trunc (i-1) xs)
- in
- Db.VMPP.set_recent_alerts ~__context ~self:vmpp
- ~value:(trunc 10 recent_alerts)
+ raise_removed ()
let create_alert ~__context ~vmpp ~name ~priority ~body ~data =
- assert_licensed ~__context;
- let value = data in
- let msg =
- (* value is expected to be valid xml data,
- whereas body is not expected to be a valid xml string
- *)
- "<message><email>"
- (* escape any invalid xml string *)
- ^(Xml.to_string (Xml.PCData body))
- ^"</email><data>"^value^"</data></message>"
- in
- add_to_recent_alerts ~__context ~vmpp ~value;
- let cls = `VMPP in
- let obj_uuid = Db.VMPP.get_uuid ~__context ~self:vmpp in
- let (_: API.ref_message) = Xapi_message.create ~__context ~name ~priority ~cls ~obj_uuid ~body:msg in
- ()
-
-let unzip b64zdata = (* todo: remove i/o, make this more efficient *)
- try
- let zdata = Base64.decode b64zdata in
- let tmp_path = Filename.temp_file "unzip-" ".dat" in
- let data = ref "" in
- Pervasiveext.finally
- (fun ()->
- let fd = Unix.openfile tmp_path [ Unix.O_RDWR] 0o600 in
- Pervasiveext.finally
- (fun ()->let (_: int) = Unix.write fd zdata 0 (String.length zdata) in ())
- (fun ()->Unix.close fd;)
- ;
- Unixext.with_file tmp_path [ Unix.O_RDONLY ] 0o0
- (fun gz_fd_in ->
- Gzip.decompress_passive gz_fd_in
- (fun fd_in -> (*fd_in is closed by gzip module*)
- let cin = Unix.in_channel_of_descr fd_in in
- try
- while true do
- let line = input_line cin in
- data := !data ^ line
- done
- with End_of_file -> () (* ok, expected *)
- )
- )
- )
- (fun ()->Sys.remove tmp_path)
- ;
- (Some !data)
- with e->
- debug "error %s unzipping zdata: %s" (ExnHelper.string_of_exn e) b64zdata;
- None
+ raise_removed ()
let get_alerts ~__context ~vmpp ~hours_from_now =
- let vmpp_uuid = Db.VMPP.get_uuid ~__context ~self:vmpp in
- let filter=["unix-RPC|VMPP.create_alert";vmpr_username;vmpp_uuid] in
- let tmp_filename = Filename.temp_file "vmpp-alerts-" ".dat" in
- let fd = Unix.openfile tmp_filename [Unix.O_RDWR] 0o600 in
- let now = (Unix.time ()) in
- let since = Date.to_string (Date.of_float (now -. ( (Int64.to_float hours_from_now) *. 3600.0))) in
- let ()=Audit_log.transfer_all_audit_files fd ~filter since in
- let cout = Unix.out_channel_of_descr fd in
- flush cout;
- let cin = Unix.in_channel_of_descr fd in
- seek_in cin 0;
- let lines = ref [] in
- let i = ref 0 in (* hard limit on maximum number of lines to parse *)
- (try while !i<1000 do let line = input_line cin in lines:=line::!lines; i:=!i+1 done with End_of_file->());
- let lines = !lines in
- Unix.close fd;
- Sys.remove tmp_filename;
- let alerts = List.map (fun line->
- let sexpr_init = try (String.index line ']')+1 with Not_found -> -1 in
- if sexpr_init>=0 && sexpr_init<(String.length line) then (
- let sexpr_str = Stringext.String.sub_to_end line sexpr_init in
- let (sroot:SExpr.t) =
- (try SExpr_TS.of_string sexpr_str
- with e->
- debug "error %s parsing sexpr: %s"
- (ExnHelper.string_of_exn e) sexpr_str
- ;
- (SExpr.Node [])
- )
- in
- match sroot with
- |SExpr.Node (SExpr.String _::SExpr.String _::SExpr.String _::SExpr.String _::SExpr.String _::SExpr.String _::SExpr.String _::SExpr.Node params::[])->(
- let kvs = List.fold_right (fun (sexpr:SExpr.t) acc ->
- match sexpr with
- |SExpr.Node (SExpr.String name::SExpr.String value::SExpr.String _::SExpr.String _::[]) when name="data"->
- (name,value)::acc
- |_->acc
- ) params []
- in
- if kvs=[] then None else Some kvs
- )
- |_->None
- )
- else None
- ) lines
- in
- let alerts = List.fold_right (fun a acc->match a with None->acc|Some a->a::acc) alerts [] in
- let alerts = List.fold_right (fun a acc->if List.mem_assoc "data" a then (let data=(unzip(List.assoc "data" a)) in match data with None->acc|Some data->data::acc) else acc) alerts [] in
- alerts
+ raise_removed ()
let set_is_backup_running ~__context ~self ~value =
- assert_licensed ~__context;
- Db.VMPP.set_is_backup_running ~__context ~self ~value
+ raise_removed ()
let set_is_archive_running ~__context ~self ~value =
- assert_licensed ~__context;
- Db.VMPP.set_is_archive_running ~__context ~self ~value
-
-(* mini datamodel for type and key value restrictions in the vmpp map fields *)
-type key_type = Enum of string list | EnumSet of string list | IntRange of int*int | String | ReqValue of string | Secret
-let schedule_days_enum = ["Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"]
-let schedule_frequency_hourly = "hourly"
-let schedule_frequency_daily = "daily"
-let schedule_frequency_weekly = "weekly"
-let frequency_order = [schedule_frequency_hourly;schedule_frequency_daily;schedule_frequency_weekly]
-let schedule_min_enum = ["0";"15";"30";"45"]
-let backup_schedule_field = "backup-schedule"
-let archive_target_config_field = "archive-target-config"
-let archive_schedule_field = "archive-schedule"
-let alarm_config_field = "alarm-config"
-let archive_target_type_cifs = "cifs"
-let archive_target_type_nfs = "nfs"
-let is_alarm_enabled_true = "true"
-let is_alarm_enabled_false = "false"
-let btype b = if b then is_alarm_enabled_true else is_alarm_enabled_false
-let schedule_min_default = List.hd schedule_min_enum
-let schedule_hour_default = "0"
-let schedule_days_default = List.hd schedule_days_enum
-
-let more_frequent_than ~a ~b = (* is a more frequent than b? *)
- if a=b then false
- else
- if (List.mem a frequency_order) && (List.mem b frequency_order)
- then (let rec tst xs = match xs with
- |[]->false
- |x::xs->if a=x then true else if b=x then false else tst xs
- in tst frequency_order
- )
- else false (*incomparable*)
-
-(* relations between map types and map keys *)
-let archive_schedule_frequency_enum = [schedule_frequency_daily;schedule_frequency_weekly]
-let backup_schedule_frequency_enum = schedule_frequency_hourly :: archive_schedule_frequency_enum
-let backup_schedule_frequency_hourly_keys = backup_schedule_field,[schedule_frequency_hourly,[Datamodel.vmpp_schedule_min, ((Enum schedule_min_enum), schedule_min_default)]]
-let backup_schedule_frequency_daily_keys = backup_schedule_field,[schedule_frequency_daily,[Datamodel.vmpp_schedule_hour, ((IntRange(0,23)), schedule_hour_default);Datamodel.vmpp_schedule_min, ((Enum schedule_min_enum), schedule_min_default)]]
-let backup_schedule_frequency_weekly_keys = backup_schedule_field,[schedule_frequency_weekly,[Datamodel.vmpp_schedule_hour, ((IntRange(0,23)), schedule_hour_default);Datamodel.vmpp_schedule_min, ((Enum schedule_min_enum), schedule_min_default);Datamodel.vmpp_schedule_days, ((EnumSet schedule_days_enum), schedule_days_default)]]
-let archive_schedule_frequency_daily_keys = match backup_schedule_frequency_daily_keys with f,k -> archive_schedule_field,k
-let archive_schedule_frequency_weekly_keys = match backup_schedule_frequency_weekly_keys with f,k -> archive_schedule_field,k
-let archive_target_config_type_cifs_keys = archive_target_config_field,[archive_target_type_cifs,[Datamodel.vmpp_archive_target_config_location, ((String), "");Datamodel.vmpp_archive_target_config_username, ((String), "");Datamodel.vmpp_archive_target_config_password, ((Secret), "")]]
-let archive_target_config_type_nfs_keys = archive_target_config_field,[archive_target_type_nfs,[Datamodel.vmpp_archive_target_config_location, ((String), "")]]
-
-(* look-up structures, contain allowed map keys in a specific map type *)
-let backup_schedule_keys = backup_schedule_field, (List.map
- (function (f,[k])->k
- | _ -> assert false
- )
- [backup_schedule_frequency_hourly_keys;backup_schedule_frequency_daily_keys;backup_schedule_frequency_weekly_keys])
-let archive_target_config_keys = archive_target_config_field,(List.map
- (function (f,[k])->k
- | _ -> assert false
- )
- [archive_target_config_type_cifs_keys;archive_target_config_type_nfs_keys])
-let archive_schedule_keys = archive_schedule_field,(List.map
- (function (f,[k])->k
- | _ -> assert false
- )
-[archive_schedule_frequency_daily_keys;archive_schedule_frequency_weekly_keys])
-let alarm_config_keys = alarm_config_field,[is_alarm_enabled_true,["email_address", ((String), "");"smtp_server", ((String), "");"smtp_port", ((IntRange(1,65535)), "25")]]
-
-(* look-up structures, contain allowed map keys in all map types *)
-let backup_schedule_all_keys = backup_schedule_field,["",(List.fold_left (fun acc (sf,ks)->acc@ks) [] (let (f,kss)=backup_schedule_keys in kss))]
-let archive_target_config_all_keys = archive_target_config_field,["",(List.fold_left (fun acc (sf,ks)->acc@ks) [] (let (f,kss)=archive_target_config_keys in kss))]
-let archive_schedule_all_keys = archive_schedule_field,["",(List.fold_left (fun acc (sf,ks)->acc@ks) [] (let (f,kss)=archive_schedule_keys in kss))]
-let alarm_config_all_keys = alarm_config_field,["",(List.fold_left (fun acc (sf,ks)->acc@ks) [] (let (f,kss)=alarm_config_keys in kss))]
-
-(* functions to assert the mini datamodel above *)
-
-let err field key value =
- let msg = if key="" then field else field^":"^key in
- raise (Api_errors.Server_error (Api_errors.invalid_value, [msg;value]))
-
-let mem value range =
- try Some
- (List.find
- (fun r->(String.lowercase value)=(String.lowercase r))
- range
- )
- with Not_found -> None
-
-let assert_value ~field ~key ~attr ~value =
- let err v = err field key v in
- let (ty,default) = attr in
- match ty with
- | Enum range -> (match (mem value range) with None->err value|Some v->v)
- | EnumSet range -> (* enumset is a comma-separated string *)
- let vs = Stringext.String.split ',' value in
- List.fold_right
- (fun v acc->match (mem v range) with
- |None->err v
- |Some v->if acc="" then v else (v^","^acc)
- )
- vs
- ""
- | IntRange (min,max) ->
- let v=try int_of_string value with _->err value in
- if (v<min or v>max) then err value else value
- | ReqValue required_value -> if value <> required_value then err value else value
- | Secret|String -> value
-
-let with_ks ~kss ~fn =
- let field,kss=kss in
- let corrected_values = List.filter (fun cv->cv<>None) (List.map (fun ks-> fn field ks) kss) in
- if List.length corrected_values < 1
- then []
- else (match List.hd corrected_values with None->[]|Some cv->cv)
-
-let assert_req_values ~field ~ks ~vs =
- (* each required values in this ks must match the one in the vs map this key/value belongs to*)
- let req_values = List.fold_right
- (fun (k,attr) acc->match attr with(ReqValue rv),_->(k,rv)::acc|_->acc) ks []
- in
- (if vs<>[] then
- List.iter (fun (k,rv)->
- if (List.mem_assoc k vs) then (if rv<>(List.assoc k vs) then err field k rv)
- ) req_values
- )
-
-let merge xs ys = (* uses xs elements to overwrite ys elements *)
- let nys = List.map (fun (ky,vy)->if List.mem_assoc ky xs then (ky,(List.assoc ky xs)) else (ky,vy)) ys in
- let nxs = List.filter (fun (kx,_)->not(List.mem_assoc kx nys)) xs in
- nxs@nys
-
-let assert_key ~field ~ks ~key ~value =
- debug "assert_key: field=%s key=[%s] value=[%s]" field key value;
- (* check if the key and value conform to this ks *)
- (if not (List.mem_assoc key ks)
- then
- err field key value
- else
- assert_value ~field ~key ~attr:(List.assoc key ks) ~value
- )
-
-let assert_keys ~ty ~ks ~value ~db =
- let value = merge value db in
- with_ks ~kss:ks ~fn:
- (fun field (xt,ks) ->
- debug "assert_keys: field=%s xt=[%s] ty=[%s]" field xt ty;
- if (xt=ty) then Some
- (
- assert_req_values ~field ~ks ~vs:value;
- (* for this ks, each key value must be valid *)
- List.map (fun (k,v)-> k,(assert_key ~field ~ks ~key:k ~value:v)) value
- )
- else None
- )
-
-let assert_all_keys ~ty ~ks ~value ~db =
- let value = merge value db in
- with_ks ~kss:ks ~fn:
- (fun field (xt,ks)->
- debug "assert_all_keys: field=%s xt=[%s] ty=[%s]" field xt ty;
- if (xt=ty) then Some
- (
- assert_req_values ~field ~ks ~vs:value;
-
-(*
- currently disabled: too strong for api-bindings:
- - api-bindings change first the type, and later the maps,
- - so we cannot currently assert that all map keys are present:
-
- (* for this ks, all keys must be present *)
- let ks_keys = Listext.List.setify (let (x,y)=List.split ks in x) in
- let value_keys = Listext.List.setify (let (x,y)=List.split value in x) in
- let diff = Listext.List.set_difference ks_keys value_keys in
- (if diff<>[] then err field (List.hd diff) "");
-*)
-
- (* add missing keys with default values *)
- let value = List.map (fun (k,(kt,default))->if List.mem_assoc k value then (k,(List.assoc k value)) else (k,default)) ks in
-
- (* remove extra unexpected keys *)
- let value = List.fold_right (fun (k,v) acc->if List.mem_assoc k ks then (k,v)::acc else acc) value [] in
-
- (* for this ks, each key value must be valid *)
- List.map (fun (k,v)-> k,(assert_key ~field ~ks ~key:k ~value:v)) value
- )
- else None
- )
-
-let assert_non_required_key ~ks ~key ~db =
- ()
-(* (* currently disabled: unfortunately, key presence integrity is too strict for the CLI, which needs to remove and add keys at will *)
- with_ks ~kss:ks ~fn:
- (fun ks->
- assert_req_values ~ks ~key ~value:"" ~db;
- (* check if the key is not expected in this ks *)
- if (List.mem_assoc key ks) then err key ""
- )
-*)
-
-let map_password_to_secret ~__context ~new_password ~db =
- let secret_uuid = Uuid.to_string
- (if List.mem_assoc Datamodel.vmpp_archive_target_config_password db
- then
- Uuid.of_string
- (List.assoc Datamodel.vmpp_archive_target_config_password db)
- else
- Uuid.null
- )
- in
- try
- let secret_ref = Db.Secret.get_by_uuid ~__context ~uuid:secret_uuid in
- (* the uuid is a valid uuid in the secrets table *)
- (if (new_password <> secret_uuid)
- then (* new_password is not the secret uuid, then update secret *)
- Db.Secret.set_value ~__context ~self:secret_ref ~value:new_password
- );
- secret_uuid
- with e -> (
- (* uuid doesn't exist in secrets table, create a new one *)
- ignore (ExnHelper.string_of_exn e);
- let new_secret_ref = Ref.make() in
- let new_secret_uuid = Uuid.to_string(Uuid.make_uuid()) in
- Db.Secret.create ~__context ~ref:new_secret_ref ~uuid:new_secret_uuid ~value:new_password ~other_config:[];
- new_secret_uuid
- )
-
-let map_any_passwords_to_secrets ~__context ~value ~db =
- if List.mem_assoc Datamodel.vmpp_archive_target_config_password value
- then
- let secret = map_password_to_secret ~__context ~db
- ~new_password:(List.assoc Datamodel.vmpp_archive_target_config_password value)
- in
- merge [(Datamodel.vmpp_archive_target_config_password,secret)] value
- else
- value
-
-let remove_any_secrets ~__context ~config ~key =
- if List.mem_assoc key config
- then
- let secret_uuid = List.assoc key config in
- try
- let secret_ref = Db.Secret.get_by_uuid ~__context ~uuid:secret_uuid in
- Db.Secret.destroy ~__context ~self:secret_ref
- with _ -> (* uuid doesn't exist in secrets table, leave it alone *)
- ()
-
-let assert_set_backup_frequency ~backup_frequency ~backup_schedule=
- let ty = XMLRPC.From.string (API.Legacy.To.vmpp_backup_frequency backup_frequency) in
- assert_all_keys ~ty ~ks:backup_schedule_keys ~value:backup_schedule ~db:backup_schedule
-
-let assert_archive_target_type_not_none ~archive_target_type ~archive_target_config =
- let ty = XMLRPC.From.string (API.Legacy.To.vmpp_archive_target_type archive_target_type) in
- let archive_target_config = assert_all_keys ~ty ~ks:archive_target_config_keys ~value:archive_target_config ~db:archive_target_config in
- archive_target_config
-
-let assert_archive_target_type ~archive_target_type ~archive_target_config ~archive_frequency ~archive_schedule =
- match archive_target_type with
- | `none -> (* reset archive_frequency to never *)
- ([], `never, [])
- | _->
- let archive_target_config = assert_archive_target_type_not_none ~archive_target_type ~archive_target_config in
- (archive_target_config,archive_frequency,archive_schedule)
-
-let assert_set_archive_frequency ~archive_frequency ~archive_target_type ~archive_target_config ~archive_schedule =
- match archive_target_type with
- |`none -> (
- match archive_frequency with
- |`never-> ([],[])
- |_->err "archive_target_type" "" (XMLRPC.From.string (API.Legacy.To.vmpp_archive_target_type archive_target_type))
- )
- |_ -> (
- match archive_frequency with
- |`never -> (archive_target_config,[])
- |`always_after_backup ->
- let archive_target_config = assert_archive_target_type_not_none ~archive_target_type ~archive_target_config in
- (archive_target_config,[])
- | _ ->
- let archive_target_config = assert_archive_target_type_not_none ~archive_target_type ~archive_target_config in
- let ty = XMLRPC.From.string (API.Legacy.To.vmpp_archive_frequency archive_frequency) in
- let archive_schedule = assert_all_keys ~ty ~ks:archive_schedule_keys ~value:archive_schedule ~db:archive_schedule in
- (archive_target_config,archive_schedule)
- )
-
-let assert_set_is_alarm_enabled ~is_alarm_enabled ~alarm_config =
- if is_alarm_enabled
- then (
- assert_all_keys ~ty:(btype is_alarm_enabled) ~ks:alarm_config_keys ~value:alarm_config ~db:alarm_config
- )
- else (* do not erase alarm_config if alarm is disabled *)
- alarm_config
-
-let assert_frequency ~archive_frequency ~backup_frequency =
- let a = XMLRPC.From.string (API.Legacy.To.vmpp_archive_frequency archive_frequency) in
- let b = XMLRPC.From.string (API.Legacy.To.vmpp_backup_frequency backup_frequency) in
- if (more_frequent_than ~a ~b)
- then
- raise (Api_errors.Server_error (Api_errors.vmpp_archive_more_frequent_than_backup,[]))
-
-let assert_backup_retention_value ~backup_retention_value =
- let value = backup_retention_value in
- (if (value < 1L) or (value > 10L)
- then
- err "backup_retention_value" "" (Printf.sprintf "%Li" value)
- )
-
-(* == the setters with customized key cross-integrity checks == *)
-
-(* 1/3: values of non-map fields can only change if their corresponding maps contain the expected keys *)
+ raise_removed ()
let set_backup_frequency ~__context ~self ~value =
- assert_licensed ~__context;
- let archive_frequency = Db.VMPP.get_archive_frequency ~__context ~self in
- assert_frequency ~archive_frequency ~backup_frequency:value;
- let backup_schedule = Db.VMPP.get_backup_schedule ~__context ~self in
- let new_backup_schedule = assert_set_backup_frequency ~backup_frequency:value ~backup_schedule in
- Db.VMPP.set_backup_frequency ~__context ~self ~value;
- (* update dependent maps *)
- Db.VMPP.set_backup_schedule ~__context ~self ~value:new_backup_schedule
+ raise_removed ()
let set_archive_frequency ~__context ~self ~value =
- assert_licensed ~__context;
- let backup_frequency = Db.VMPP.get_backup_frequency ~__context ~self in
- assert_frequency ~archive_frequency:value ~backup_frequency;
- let archive_schedule = (Db.VMPP.get_archive_schedule ~__context ~self) in
- let archive_target_config = (Db.VMPP.get_archive_target_config ~__context ~self) in
- let archive_target_type = (Db.VMPP.get_archive_target_type ~__context ~self) in
- let (new_archive_target_config,new_archive_schedule) = assert_set_archive_frequency ~archive_frequency:value ~archive_target_type ~archive_target_config ~archive_schedule in
- Db.VMPP.set_archive_frequency ~__context ~self ~value;
- (* update dependent maps *)
- Db.VMPP.set_archive_target_config ~__context ~self ~value:new_archive_target_config;
- Db.VMPP.set_archive_schedule ~__context ~self ~value:new_archive_schedule
+ raise_removed ()
let set_archive_target_type ~__context ~self ~value =
- assert_licensed ~__context;
- let archive_target_config = Db.VMPP.get_archive_target_config ~__context ~self in
- let archive_frequency = Db.VMPP.get_archive_frequency ~__context ~self in
- let archive_schedule = Db.VMPP.get_archive_schedule ~__context ~self in
- let (new_archive_target_config,new_archive_frequency,new_archive_schedule) = assert_archive_target_type ~archive_target_type:value ~archive_target_config ~archive_frequency ~archive_schedule in
- Db.VMPP.set_archive_target_type ~__context ~self ~value;
- (* update dependent maps *)
- Db.VMPP.set_archive_target_config ~__context ~self ~value:new_archive_target_config;
- Db.VMPP.set_archive_frequency ~__context ~self ~value:new_archive_frequency;
- Db.VMPP.set_archive_schedule ~__context ~self ~value:new_archive_schedule
+ raise_removed ()
let set_is_alarm_enabled ~__context ~self ~value =
- assert_licensed ~__context;
- let alarm_config = Db.VMPP.get_alarm_config ~__context ~self in
- let new_alarm_config = assert_set_is_alarm_enabled ~is_alarm_enabled:value ~alarm_config in
- Db.VMPP.set_is_alarm_enabled ~__context ~self ~value;
- (* update dependent maps *)
- Db.VMPP.set_alarm_config ~__context ~self ~value:new_alarm_config
-
-(* 2/3: values of map fields can change as long as the key names and values are valid *)
+ raise_removed ()
let set_backup_schedule ~__context ~self ~value =
- assert_licensed ~__context;
- let value = assert_keys ~ty:"" ~ks:backup_schedule_all_keys ~value ~db:(Db.VMPP.get_backup_schedule ~__context ~self) in
- Db.VMPP.set_backup_schedule ~__context ~self ~value
+ raise_removed ()
let add_to_backup_schedule ~__context ~self ~key ~value =
- assert_licensed ~__context;
- let value = List.assoc key (assert_keys ~ty:"" ~ks:backup_schedule_all_keys ~value:[(key,value)] ~db:(Db.VMPP.get_backup_schedule ~__context ~self)) in
- Db.VMPP.add_to_backup_schedule ~__context ~self ~key ~value
+ raise_removed ()
let set_archive_target_config ~__context ~self ~value =
- assert_licensed ~__context;
- let config = (Db.VMPP.get_archive_target_config ~__context ~self) in
- let (_: (string*string) list) = assert_keys ~ty:"" ~ks:archive_target_config_all_keys ~value ~db:config in
- let value = map_any_passwords_to_secrets ~__context ~value ~db:config in
- Db.VMPP.set_archive_target_config ~__context ~self ~value
+ raise_removed ()
let add_to_archive_target_config ~__context ~self ~key ~value =
- assert_licensed ~__context;
- let config = (Db.VMPP.get_archive_target_config ~__context ~self) in
- let (_: (string*string) list) = assert_keys ~ty:"" ~ks:archive_target_config_all_keys ~value:[(key,value)] ~db:config in
- let value =
- if key=Datamodel.vmpp_archive_target_config_password
- then (map_password_to_secret ~__context ~db:config ~new_password:value)
- else value
- in
- Db.VMPP.add_to_archive_target_config ~__context ~self ~key ~value
+ raise_removed ()
let set_archive_schedule ~__context ~self ~value =
- assert_licensed ~__context;
- let value = assert_keys ~ty:"" ~ks:archive_schedule_all_keys ~value ~db:(Db.VMPP.get_archive_schedule ~__context ~self) in
- Db.VMPP.set_archive_schedule ~__context ~self ~value
+ raise_removed ()
let add_to_archive_schedule ~__context ~self ~key ~value =
- assert_licensed ~__context;
- let value = List.assoc key (assert_keys ~ty:"" ~ks:archive_schedule_all_keys ~value:[(key,value)] ~db:(Db.VMPP.get_archive_schedule ~__context ~self)) in
- Db.VMPP.add_to_archive_schedule ~__context ~self ~key ~value
+ raise_removed ()
let set_alarm_config ~__context ~self ~value =
- assert_licensed ~__context;
- let (_: (string*string) list) = assert_keys ~ty:"" ~ks:alarm_config_all_keys ~value ~db:(Db.VMPP.get_alarm_config ~__context ~self) in
- Db.VMPP.set_alarm_config ~__context ~self ~value
+ raise_removed ()
let add_to_alarm_config ~__context ~self ~key ~value =
- assert_licensed ~__context;
- let (_: (string*string) list) = assert_keys ~ty:"" ~ks:alarm_config_all_keys ~value:[(key,value)] ~db:(Db.VMPP.get_alarm_config ~__context ~self) in
- Db.VMPP.add_to_alarm_config ~__context ~self ~key ~value
-
-(* 3/3: the CLI requires any key in any map to be removed at will *)
+ raise_removed ()
let remove_from_backup_schedule ~__context ~self ~key =
- assert_licensed ~__context;
- assert_non_required_key ~ks:backup_schedule_keys ~key ~db:(Db.VMPP.get_backup_schedule ~__context ~self);
- Db.VMPP.remove_from_backup_schedule ~__context ~self ~key
+ raise_removed ()
let remove_from_archive_target_config ~__context ~self ~key =
- assert_licensed ~__context;
- let db = (Db.VMPP.get_archive_target_config ~__context ~self) in
- assert_non_required_key ~ks:archive_target_config_keys ~key ~db;
- remove_any_secrets ~__context ~config:db ~key:Datamodel.vmpp_archive_target_config_password;
- Db.VMPP.remove_from_archive_target_config ~__context ~self ~key
+ raise_removed ()
let remove_from_archive_schedule ~__context ~self ~key =
- assert_licensed ~__context;
- assert_non_required_key ~ks:archive_schedule_keys ~key ~db:(Db.VMPP.get_archive_schedule ~__context ~self);
- Db.VMPP.remove_from_archive_schedule ~__context ~self ~key
+ raise_removed ()
let remove_from_alarm_config ~__context ~self ~key =
- assert_licensed ~__context;
- assert_non_required_key ~ks:alarm_config_keys ~key ~db:(Db.VMPP.get_alarm_config ~__context ~self);
- Db.VMPP.remove_from_alarm_config ~__context ~self ~key
+ raise_removed ()
let set_backup_last_run_time ~__context ~self ~value =
- assert_licensed ~__context;
- Db.VMPP.set_backup_last_run_time ~__context ~self ~value
+ raise_removed ()
let set_archive_last_run_time ~__context ~self ~value =
- assert_licensed ~__context;
- Db.VMPP.set_archive_last_run_time ~__context ~self ~value
+ raise_removed ()
let set_backup_retention_value ~__context ~self ~value =
- assert_licensed ~__context;
- assert_backup_retention_value ~backup_retention_value:value;
- Db.VMPP.set_backup_retention_value ~__context ~self ~value
-
-(* constructors/destructors *)
+ raise_removed ()
let create ~__context ~name_label ~name_description ~is_policy_enabled
~backup_type ~backup_retention_value ~backup_frequency ~backup_schedule
~archive_target_type ~archive_target_config ~archive_frequency ~archive_schedule
~is_alarm_enabled ~alarm_config
: API.ref_VMPP =
-
- assert_licensed ~__context;
- (* assert all provided field values, key names and key values are valid *)
- let (_: (string*string) list) = assert_keys ~ty:(XMLRPC.From.string (API.Legacy.To.vmpp_backup_frequency backup_frequency)) ~ks:backup_schedule_keys ~value:backup_schedule ~db:[] in
- let (_: (string*string) list) = assert_keys ~ty:(XMLRPC.From.string (API.Legacy.To.vmpp_archive_frequency archive_frequency)) ~ks:archive_schedule_keys ~value:archive_schedule ~db:[] in
- let (_: (string*string) list) = assert_keys ~ty:(XMLRPC.From.string (API.Legacy.To.vmpp_archive_target_type archive_target_type)) ~ks:archive_target_config_keys ~value:archive_target_config ~db:[] in
- let (_: (string*string) list) = assert_keys ~ty:(btype is_alarm_enabled) ~ks:alarm_config_keys ~value:alarm_config ~db:[] in
-
- (* assert inter-field constraints and fix values if possible *)
- let backup_schedule = assert_set_backup_frequency ~backup_frequency ~backup_schedule in
- let (archive_target_config,archive_schedule) = assert_set_archive_frequency ~archive_frequency ~archive_target_type ~archive_target_config ~archive_schedule in