protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM snapshot = (VM)selection[0].XenObject;

            // Generate list of all taken VM/snapshot/template names
            List <string> takenNames = new List <VM>(snapshot.Connection.Cache.VMs).ConvertAll(v => v.Name());

            // Generate a unique suggested name for the new template
            string defaultName = Helpers.MakeUniqueName(String.Format(Messages.TEMPLATE_FROM_SNAPSHOT_DEFAULT_NAME, snapshot.Name()), takenNames);

            using (var dialog = new InputPromptDialog {
                Text = Messages.SAVE_AS_TEMPLATE,
                PromptText = Messages.NEW_TEMPLATE_PROMPT,
                InputText = defaultName,
                HelpID = "VMSnapshotPage"
            })
            {
                if (dialog.ShowDialog(Parent) == DialogResult.OK)
                {
                    // TODO: work out what the new description should be
                    var action = new VMCloneAction(snapshot, dialog.InputText, "");
                    action.Completed += action_Completed;
                    action.RunAsync();
                }
            }
        }
Example #2
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM snapshot = (VM)selection[0].XenObject;

            // Generate list of all taken VM/snapshot/template names
            List <string> takenNames = new List <VM>(snapshot.Connection.Cache.VMs).ConvertAll(v => v.Name);

            // Generate a unique suggested name for the new template
            string defaultName = Helpers.MakeUniqueName(String.Format(Messages.TEMPLATE_FROM_SNAPSHOT_DEFAULT_NAME, snapshot.Name), takenNames);
            string newName     = InputPromptDialog.Prompt(Parent, Messages.NEW_TEMPLATE_PROMPT, Messages.SAVE_AS_TEMPLATE, defaultName, "VMSnapshotPage");

            if (newName != null) // is null if user cancelled
            {
                // TODO: work out what the new description should be
                var action = new VMCloneAction(snapshot, newName, "");
                action.Completed += action_Completed;
                action.RunAsync();
            }
        }