Permalink
Browse files

Merge pull request #2907 from sharady/CP-20891

CP-20891: Merge VMSS feature commits.
2 parents ba2d70b + e1f6575 commit 41a72320c990db5dd7e08ad0f5c3f8547d01e2d1 @robhoes robhoes committed on GitHub Feb 14, 2017
@@ -47,3 +47,4 @@ let pool = "pool"
let master = "master"
let bios_strings = "bios_strings"
let protection_policy = "protection_policy"
+let snapshot_schedule = "snapshot_schedule"
View
@@ -122,6 +122,7 @@ let _vm_guest_metrics = "VM_guest_metrics"
let _vm_appliance = "VM_appliance"
let _dr_task = "DR_task"
let _vmpp = "VMPP"
+let _vmss = "VMSS"
let _network = "network"
let _vif = "VIF"
let _vif_metrics = "VIF_metrics"
@@ -1338,6 +1339,11 @@ let _ =
~doc:"Archive more frequent than backup." ();
error Api_errors.vm_assigned_to_protection_policy ["vm"; "vmpp"]
~doc:"This VM is assigned to a protection policy." ();
+
+ error Api_errors.vmss_has_vm []
+ ~doc:"There is at least one VM assigned to snapshot schedule." ();
+ error Api_errors.vm_assigned_to_snapshot_schedule ["vm"; "vmss"]
+ ~doc:"This VM is assigned to a snapshot schedule." ();
error Api_errors.ssl_verify_error ["reason"]
~doc:"The remote system's SSL certificate failed to verify against our certificate library." ();
@@ -2492,6 +2498,17 @@ let vm_set_protection_policy = call
~allowed_roles:_R_POOL_OP
()
+let vm_set_snapshot_schedule = call
+ ~name:"set_snapshot_schedule"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~doc:"Set the value of the snapshot schedule field"
+ ~params:[Ref _vm, "self", "The VM";
+ Ref _vmss, "value", "The value"]
+ ~flags:[`Session]
+ ~allowed_roles:_R_POOL_OP
+ ()
+
let vm_set_start_delay = call
~name:"set_start_delay"
~in_product_since:rel_boston
@@ -3870,6 +3887,17 @@ let task_destroy = call ~flags:[`Session]
~params:[Ref _task, "self", "Reference to the task object"]
~allowed_roles:_R_READ_ONLY (* POOL_OP can destroy any tasks, others can destroy only owned tasks *)
()
+
+let task_set_status = call ~flags:[`Session]
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~name:"set_status"
+ ~doc:"Set the task status"
+ ~params:[Ref _task, "self", "Reference to the task object";
+ status_type, "value", "task status value to be set"]
+ ~allowed_roles:_R_READ_ONLY (* POOL_OP can set status for any tasks, others can set status only for owned tasks *)
+ ()
+
(* this permission allows to destroy any task, instead of only the owned ones *)
let extra_permission_task_destroy_any = "task.destroy/any"
@@ -3880,7 +3908,7 @@ let task =
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:oss_since_303 ~internal_deprecated_since:None ~persist:PersistNothing ~gen_constructor_destructor:false ~name:_task ~descr:"A long-running asynchronous task" ~gen_events:true
~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP
- ~messages: [ task_create; task_destroy; task_cancel ]
+ ~messages: [ task_create; task_destroy; task_cancel; task_set_status ]
~contents: ([
uid _task;
namespace ~name:"name" ~contents:(names oss_since_303 DynamicRO) ();
@@ -7637,6 +7665,7 @@ let vm =
vm_retrieve_wlb_recommendations;
vm_copy_bios_strings;
vm_set_protection_policy;
+ vm_set_snapshot_schedule;
vm_set_start_delay;
vm_set_shutdown_delay;
vm_set_order;
@@ -7717,6 +7746,10 @@ let 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 ~lifecycle:[Published, rel_cowley, ""; Deprecated, rel_clearwater, "The VMPR feature was removed"] ~default_value:(Some (VRef null_ref)) ~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_VM_POWER_ADMIN ~qualifier:StaticRO ~in_product_since:rel_falcon ~default_value:(Some (VRef (null_ref))) ~ty:(Ref _vmss) "snapshot_schedule" "Ref pointing to a snapshot schedule for this VM";
+ field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO ~in_product_since:rel_falcon ~default_value:(Some (VBool false)) ~ty:Bool "is_vmss_snapshot" "true if this snapshot was created by the snapshot schedule";
+
field ~writer_roles:_R_POOL_OP ~qualifier:StaticRO ~ty:(Ref _vm_appliance) ~default_value:(Some (VRef null_ref)) "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)";
@@ -8182,6 +8215,143 @@ let vmpp =
]
()
+(* VM schedule snapshot *)
+let vmss_snapshot_now = call ~flags:[`Session]
+ ~name:"snapshot_now"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~params:[Ref _vmss, "vmss", "Snapshot Schedule to execute";]
+ ~doc:"This call executes the snapshot schedule immediately"
+ ~allowed_roles:_R_POOL_OP
+ ~result:(String, "An XMLRPC result")
+ ()
+
+let vmss_type = Enum ("vmss_type",
+ [
+ "snapshot", "The snapshot is a disk snapshot";
+ "checkpoint", "The snapshot is a checkpoint";
+ "snapshot_with_quiesce", "The snapshot is a VSS";
+ ])
+
+let vmss_frequency = Enum ("vmss_frequency",
+ [
+ "hourly", "Hourly snapshots";
+ "daily", "Daily snapshots";
+ "weekly", "Weekly snapshots";
+ ])
+
+let vmss_schedule_min = "min"
+let vmss_schedule_hour = "hour"
+let vmss_schedule_days = "days"
+
+let vmss_set_retained_snapshots = call ~flags:[`Session]
+ ~name:"set_retained_snapshots"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~allowed_roles:_R_POOL_OP
+ ~params:[
+ Ref _vmss, "self", "The schedule snapshot";
+ Int, "value", "the value to set"
+ ]
+ ()
+
+let vmss_set_frequency = call ~flags:[`Session]
+ ~name:"set_frequency"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~params:[
+ Ref _vmss, "self", "The snapshot schedule";
+ vmss_frequency, "value", "the snapshot schedule frequency"
+ ]
+ ~doc:"Set the value of the frequency field"
+ ~allowed_roles:_R_POOL_OP
+ ()
+
+let vmss_set_schedule = call ~flags:[`Session]
+ ~name:"set_schedule"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~allowed_roles:_R_POOL_OP
+ ~params:[
+ Ref _vmss, "self", "The snapshot schedule";
+ Map(String,String), "value", "the value to set"
+ ]
+ ()
+
+let vmss_set_last_run_time = call ~flags:[`Session]
+ ~name:"set_last_run_time"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~allowed_roles:_R_LOCAL_ROOT_ONLY
+ ~params:[
+ Ref _vmss, "self", "The snapshot schedule";
+ DateTime, "value", "the value to set"
+ ]
+ ()
+
+let vmss_add_to_schedule = call ~flags:[`Session]
+ ~name:"add_to_schedule"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~allowed_roles:_R_POOL_OP
+ ~params:[
+ Ref _vmss, "self", "The snapshot schedule";
+ String, "key", "the key to add";
+ String, "value", "the value to add";
+ ]
+ ()
+
+let vmss_remove_from_schedule = call ~flags:[`Session]
+ ~name:"remove_from_schedule"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~allowed_roles:_R_POOL_OP
+ ~params:[
+ Ref _vmss, "self", "The snapshot schedule";
+ String, "key", "the key to remove";
+ ]
+ ()
+
+let vmss_set_type = call ~flags:[`Session]
+ ~name:"set_type"
+ ~in_oss_since:None
+ ~in_product_since:rel_falcon
+ ~allowed_roles:_R_POOL_OP
+ ~params:[
+ Ref _vmss, "self", "The snapshot schedule";
+ vmss_type, "value", "the snapshot schedule type"
+ ]
+ ()
+
+let vmss =
+ create_obj ~in_db:true ~in_oss_since:None ~internal_deprecated_since:None ~persist:PersistEverything ~gen_constructor_destructor:true ~name:_vmss ~descr:"VM Snapshot Schedule"
+ ~gen_events:true
+ ~in_product_since:rel_falcon
+ ~doccomments:[]
+ ~messages_default_allowed_roles:_R_POOL_OP
+ ~messages:[
+ vmss_snapshot_now;
+ vmss_set_retained_snapshots;
+ vmss_set_frequency;
+ vmss_set_schedule;
+ vmss_add_to_schedule;
+ vmss_remove_from_schedule;
+ vmss_set_last_run_time;
+ vmss_set_type;
+ ]
+ ~contents:[
+ uid _vmss;
+ namespace ~name:"name" ~contents:(names None RW) ();
+ field ~qualifier:RW ~ty:Bool "enabled" "enable or disable this snapshot schedule" ~default_value:(Some (VBool true));
+ field ~qualifier:StaticRO ~ty:vmss_type "type" "type of the snapshot schedule";
+ field ~qualifier:StaticRO ~ty:Int "retained_snapshots" "maximum number of snapshots that should be stored at any time" ~default_value:(Some (VInt 7L));
+ field ~qualifier:StaticRO ~ty:vmss_frequency "frequency" "frequency of taking snapshot from snapshot schedule";
+ field ~qualifier:StaticRO ~ty:(Map (String,String)) "schedule" "schedule of the snapshot containing 'hour', 'min', 'days'. Date/time-related information is in Local Timezone" ~default_value:(Some (VMap []));
+ field ~qualifier:DynamicRO ~ty:DateTime "last_run_time" "time of the last snapshot" ~default_value:(Some(VDateTime(Date.of_float 0.)));
+ field ~qualifier:DynamicRO ~ty:(Set (Ref _vm)) "VMs" "all VMs attached to this snapshot schedule";
+ ]
+ ()
+
(* VM appliance *)
let vm_appliance_operations = Enum ("vm_appliance_operation",
[
@@ -8453,6 +8623,7 @@ let message =
"SR", "SR";
"Pool","Pool";
"VMPP","VMPP";
+ "VMSS", "VMSS";
"PVS_proxy","PVS_proxy";
])
in
@@ -9321,6 +9492,7 @@ let all_system =
vm_metrics;
vm_guest_metrics;
vmpp;
+ vmss;
vm_appliance;
dr_task;
host;
@@ -9426,6 +9598,7 @@ let all_relations =
(_role, "subroles"), (_role, "subroles");
(_vm, "protection_policy"), (_vmpp, "VMs");
+ (_vm, "snapshot_schedule"), (_vmss, "VMs");
(_vm, "appliance"), (_vm_appliance, "VMs");
(_pgpu, "GPU_group"), (_gpu_group, "PGPUs");
@@ -9523,6 +9696,7 @@ let expose_get_all_messages_for = [
_secret;
_tunnel;
_vmpp;
+ _vmss;
_vm_appliance;
_pci;
_pgpu;
@@ -40,6 +40,7 @@ type event_record =
| Message of [`message] Ref.t * API.message_t option
| Secret of [`secret] Ref.t * API.secret_t option
| VMPP of [`VMPP] Ref.t * API.vMPP_t option
+ | VMSS of [`VMSS] Ref.t * API.vMSS_t option
let maybe f x =
match x with
@@ -76,5 +77,6 @@ let record_of_event ev =
| "message" -> Message (Ref.of_string ev.Event_types.reference, maybe (API.message_t_of_rpc) rpc)
| "secret" -> Secret (Ref.of_string ev.Event_types.reference, maybe (API.secret_t_of_rpc) rpc)
| "vmpp" -> VMPP (Ref.of_string ev.Event_types.reference, maybe (API.vMPP_t_of_rpc) rpc)
+ | "vmss" -> VMSS (Ref.of_string ev.Event_types.reference, maybe (API.vMSS_t_of_rpc) rpc)
| _ -> failwith "unknown event type"
@@ -499,6 +499,9 @@ let vmpp_has_vm = "VMPP_HAS_VM"
let vmpp_archive_more_frequent_than_backup = "VMPP_ARCHIVE_MORE_FREQUENT_THAN_BACKUP"
let vm_assigned_to_protection_policy = "VM_ASSIGNED_TO_PROTECTION_POLICY"
+let vmss_has_vm = "VMSS_HAS_VM"
+let vm_assigned_to_snapshot_schedule = "VM_ASSIGNED_TO_SNAPSHOT_SCHEDULE"
+
let ssl_verify_error = "SSL_VERIFY_ERROR"
let cannot_enable_redo_log = "CANNOT_ENABLE_REDO_LOG"
@@ -113,6 +113,14 @@ let vmpp_snapshot_missed_event = addMessage "VMPP_SNAPSHOT_MISSED_EVENT" 3L (*'A
let vmpp_archive_missed_event = addMessage "VMPP_ARCHIVE_MISSED_EVENT" 3L (*'A scheduled archive event was missed due to another on-going scheduled archive run. This is unexpected behaviour, please re-configure your archive sub-policy'*)
let vmpp_snapshot_archive_already_exists = addMessage "VMPP_SNAPSHOT_ARCHIVE_ALREADY_EXISTS" 3L (*'Failed to archive the snapshot, it has already been archived on the specified target'*)
+(* VMSS message types *)
+let vmss_snapshot_lock_failed = addMessage "VMSS_SNAPSHOT_LOCK_FAILED" 3L (*'The snapshot is already executing for schedule snapshot. Please try again later'*)
+let vmss_snapshot_succeeded = addMessage "VMSS_SNAPSHOT_SUCCEEDED" 5L (*'Successfully performed the snapshot of the schedule snapshot'*)
+let vmss_snapshot_failed = addMessage "VMSS_SNAPSHOT_FAILED" 3L (*'The snapshot of the schedule snapshot has failed.'*)
+let vmss_license_error = addMessage "VMSS_LICENSE_ERROR" 3L (*'This operation is not allowed under your license. Please contact your support representative'*)
+let vmss_xapi_logon_failure = addMessage "VMSS_XAPI_LOGON_FAILURE" 3L (*'Could not login to API session.'*)
+let vmss_snapshot_missed_event = addMessage "VMSS_SNAPSHOT_MISSED_EVENT" 3L (*'A scheduled snapshot event was missed due to another on-going scheduled snapshot run. This is unexpected behaviour, please re-configure your schedule snapshot',*)
+
let bond_status_changed = addMessage "BOND_STATUS_CHANGED" 3L (* A link in a bond went down or came back up *) (* Previously missing from table *)
let host_cpu_features_down = addMessage "HOST_CPU_FEATURES_DOWN" 3L
@@ -36,6 +36,7 @@ type feature =
| No_platform_filter
| No_nag_dialog
| VMPR
+ | VMSS
| IntelliCache
| GPU
| DR
@@ -79,6 +80,7 @@ let keys_of_features =
No_platform_filter, ("platform_filter", Negative, "Plat");
No_nag_dialog, ("regular_nag_dialog", Negative, "nonag");
VMPR, ("restrict_vmpr", Negative, "VMPR");
+ VMSS, ("restrict_vmss", Negative, "VMSS");
IntelliCache, ("restrict_intellicache", Negative, "IntelliCache");
GPU, ("restrict_gpu", Negative, "GPU");
DR, ("restrict_dr", Negative, "DR");
@@ -36,6 +36,7 @@ type feature =
| No_platform_filter (** Filter platform data *)
| No_nag_dialog (** Used by XenCenter *)
| VMPR (** Enable use of VM Protection and Recovery *)
+ | VMSS (** Enable use of VM Snapshot Schedule *)
| IntelliCache (** Enable use of IntelliCache feature *)
| GPU (** Enable use of GPU passthrough *)
| DR (** Enable disaster recovery *)
@@ -155,6 +155,7 @@ XAPI_MODULES = \
xapi_xenops \
xapi_xenops_queue \
xapi_vmpp \
+ xapi_vmss \
xapi_vm_appliance \
xapi_vm_appliance_lifecycle \
xapi_vm_lifecycle \
@@ -35,6 +35,7 @@ module Actions = struct
module VM_metrics = struct end
module VM_guest_metrics = struct end
module VMPP = Xapi_vmpp
+ module VMSS = Xapi_vmss
module VM_appliance = Xapi_vm_appliance
module DR_task = Xapi_dr_task
module LVHD = struct end
@@ -2566,6 +2566,25 @@ add a mapping of 'path' -> '/tmp', the command line should contain the argument
; implementation = No_fd Cli_operations.secret_destroy
; flags = []
};
+
+ "vmss-create",
+ {
+ reqd=["name-label";"type";"frequency"];
+ optn=["name-description";"enabled";"schedule:";"retained-snapshots"];
+ help="Create a VM snapshot schedule.";
+ implementation=No_fd Cli_operations.vmss_create;
+ flags=[];
+ };
+
+ "vmss-destroy",
+ {
+ reqd=["uuid"];
+ optn=[];
+ help="Destroy a VM snapshot schedule.";
+ implementation=No_fd Cli_operations.vmss_destroy;
+ flags=[];
+ };
+
"appliance-create",
{
reqd=["name-label"];
Oops, something went wrong.

0 comments on commit 41a7232

Please sign in to comment.