CA-339273: Mention source Host/Pool in VM clone action

Also removed useless `this` calls and tidied code

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2021-08-10 13:54:06 +01:00
parent 72a9979506
commit d41cd94baf

View File

@ -29,6 +29,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
using XenAdmin.Core;
using XenAPI; using XenAPI;
@ -40,14 +41,13 @@ namespace XenAdmin.Actions.VMActions
protected string _cloneName; protected string _cloneName;
protected string _cloneDescription; protected string _cloneDescription;
public VMCloneAction(VM vm, string name, string description) public VMCloneAction(VM vm, string name, string description)
: base(vm.Connection, string.Format(Messages.CREATEVM_CLONE, name, vm.Name())) : base(vm.Connection, string.Format(Messages.CREATEVM_CLONE, name, vm.NameWithLocation()))
{ {
this.Description = Messages.ACTION_PREPARING; VM = vm;
this.VM = vm; Host = vm.Home();
this.Host = vm.Home(); Pool = Helpers.GetPool(vm.Connection);
this.Pool = Core.Helpers.GetPool(vm.Connection);
if (vm.is_a_template) if (vm.is_a_template)
this.Template = vm; Template = vm;
_cloneName = name; _cloneName = name;
_cloneDescription = description; _cloneDescription = description;
ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList); ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList);
@ -58,15 +58,15 @@ namespace XenAdmin.Actions.VMActions
protected override void Run() protected override void Run()
{ {
this.Description = Messages.ACTION_TEMPLATE_CLONING; Description = Messages.ACTION_TEMPLATE_CLONING;
RelatedTask = XenAPI.VM.async_clone(Session, VM.opaque_ref, _cloneName); RelatedTask = VM.async_clone(Session, VM.opaque_ref, _cloneName);
PollToCompletion(); PollToCompletion();
{ {
VM created = Connection.WaitForCache(new XenRef<VM>(Result)); VM created = Connection.WaitForCache(new XenRef<VM>(Result));
XenAPI.VM.set_name_description(Session, created.opaque_ref, _cloneDescription); VM.set_name_description(Session, created.opaque_ref, _cloneDescription);
Result = created.opaque_ref; Result = created.opaque_ref;
} }
this.Description = Messages.ACTION_TEMPLATE_CLONED; Description = Messages.ACTION_TEMPLATE_CLONED;
} }
} }