Пример #1
0
        private static VirtualMachine CreateFromIso(VirtualMachineManager manager, string[] args)
        {
            string iso = Path.GetFullPath (args[1]);
            string name = null;

            if (args.Length > 2) {
                name = args[2];
            }

            VirtualMachine machine = manager.CreateMachineFromIso (name, iso);
            machine.Save ();
            manager.AddMachine (machine);

            return machine;
        }
Пример #2
0
        public static int Main(string[] args)
        {
            // for some reason the ditem stuff needs this
            Gnome.Vfs.Vfs.Initialize ();

            if (args.Length == 0) {
                RunGUI ();
                return 0;
            }

            VirtualMachineManager manager = new VirtualMachineManager ();
            VirtualMachine machine;

            switch (args[0]) {
            case "--create-from-iso":
                if (args.Length < 2) {
                    Usage ();
                    return 1;
                }

                CreateFromIso (manager, args);
                break;
            case "--boot-from-iso":
                if (args.Length < 2) {
                    Usage ();
                    return 1;
                }

                machine = CreateFromIso (manager, args);
                manager.StartMachine (machine);
                break;
            case "--create-blank":
                if (args.Length < 2) {
                    Usage ();
                    return 1;
                }

                machine = manager.CreateMachine (args[1]);
                machine.Save ();
                manager.AddMachine (machine);
                break;
            default:
                Usage ();
                break;
            }

            return 0;
        }
Пример #3
0
        public VMModel(VirtualMachineManager manager)
            : base(typeof (VirtualMachine))
        {
            manager.Added += delegate (object o, VirtualMachineArgs args) {
                Application.Invoke (delegate {
                    AddMachine (args.Machine);
                });
            };

            manager.Removed += delegate (object o, VirtualMachineArgs args) {
                Application.Invoke (delegate {
                    RemoveMachine (args.Machine);
                });
            };

            foreach (VirtualMachine machine in manager.Machines) {
                AddMachine (machine);
            }
        }
Пример #4
0
        public MainWindow()
            : base("Virtual Machine Manager")
        {
            IconThemeUtils.SetWindowIcon (this);

            manager = new VirtualMachineManager ();
            controller = new MainController ();
            controller.MainWindow = this;
            controller.Manager = manager;

            Glade.XML xml = new Glade.XML ("vmx-manager.glade", "mainContent");
            xml.Autoconnect (this);

            noMachinesWidget = new Viewport ();
            noMachinesWidget.ShadowType = ShadowType.None;
            MessagePane pane = new MessagePane ();
            pane.HeaderIcon = IconThemeUtils.LoadIcon (48, "face-surprise", Stock.DialogInfo);
            pane.HeaderMarkup = Catalog.GetString ("<b>There are currently no virtual machines.</b>");
            pane.Append (Catalog.GetString ("You can add or create a new virtual machine using the buttons on the left"), false);
            pane.Show ();
            noMachinesWidget.Add (pane);

            vmview = new VMView (controller);
            controller.VMView = vmview;

            vmmodel = new VMModel (manager);
            vmview.Model = vmmodel;

            treeContent.Add (vmview);
            Add (mainContent);

            ActionEntry[] actionList = {
                new ActionEntry ("Start", Stock.Execute,
                                 Catalog.GetString ("Start Machine"), "<control>r",
                                 Catalog.GetString ("Start the virtual machine"),
                                 controller.OnStart),
                new ActionEntry ("Configure", Stock.Properties,
                                 Catalog.GetString ("Configure Machine"), "<control>p",
                                 Catalog.GetString ("Configure the connected devices"),
                                 controller.OnConfigure),
                new ActionEntry ("Remove", Stock.Remove,
                                 Catalog.GetString ("Remove Machine"), "<control>d",
                                 Catalog.GetString ("Remove the virtual machine"),
                                 controller.OnRemove),
                new ActionEntry ("CreateBlank", Stock.New,
                                 Catalog.GetString ("Create Blank Machine"), null,
                                 Catalog.GetString ("Create a new empty virtual machine"),
                                 controller.OnCreateBlank),
                new ActionEntry ("CreateFromIso", Stock.New,
                                 Catalog.GetString ("Create Machine From ISO"), null,
                                 Catalog.GetString ("Create a new machine which boots from a ISO"),
                                 controller.OnCreateFromIso),
                new ActionEntry ("AddMachine", Stock.Add,
                                 Catalog.GetString ("Add Existing Machine"), null,
                                 Catalog.GetString ("Add an existing virtual machine"),
                                 controller.OnAddExisting)
            };

            actions = new ActionGroup ("VmxManager Actions");
            actions.Add (actionList);

            ui = new UIManager ();
            ui.InsertActionGroup (actions, 0);
            ui.AddUiFromResource ("vmx-manager.xml");

            havePlayer = Utility.CheckForPlayer ();
            if (!havePlayer) {
                HigMessageDialog dialog = new HigMessageDialog (this, DialogFlags.Modal, MessageType.Warning,
                                                                ButtonsType.Close,
                                                                Catalog.GetString ("VMware Player not found"),
                                                                Catalog.GetString ("It will not be possible to run virtual machines."));
                dialog.Run ();
                dialog.Destroy ();
            }

            SetActionsSensitive ();

            DefaultWidth = 600;
            DefaultHeight = 400;

            vmview.ButtonPressEvent += OnTreeButtonPress;

            startButton.Clicked += controller.OnStart;
            configureButton.Clicked += controller.OnConfigure;
            removeButton.Clicked += controller.OnRemove;
            createBlankButton.Clicked += controller.OnCreateBlank;
            createFromIsoButton.Clicked += controller.OnCreateFromIso;
            addExistingButton.Clicked += controller.OnAddExisting;

            vmview.Selection.Changed += delegate {
                SetActionsSensitive ();
            };

            vmview.Model.RowInserted += delegate {
                SetActionsSensitive ();
            };

            vmview.Model.RowDeleted += delegate {
                SetActionsSensitive ();
            };

            foreach (VirtualMachine machine in manager.Machines) {
                machine.Started += OnMachineChanged;
                machine.Stopped += OnMachineChanged;
            }

            manager.Added += delegate (object o, VirtualMachineArgs args) {
                args.Machine.Started += OnMachineChanged;
                args.Machine.Stopped += OnMachineChanged;
            };
        }