Exemplo n.º 1
0
        private void CreateDefaultConfig()
        {
            vmInfo.virtMachID     = 0;
            vmInfo.name           = "New VM " + vmInfo.virtMachID.ToString();
            vmInfo.machType       = string.Empty;
            vmInfo.defDir         = string.Empty;
            vmInfo.memSize        = 0;
            vmInfo.setClockToHost = true;
            vmInfo.cdRomEnable    = true;
            vmInfo.cdRomUsePhys   = true;
            vmInfo.cdRomPhysDrv   = string.Empty;
            vmInfo.cdRomUseIso    = false;
            vmInfo.cdRomIsoImg    = string.Empty;
            vmInfo.floppyEnable   = false;
            vmInfo.floppyUsePhys  = false;
            vmInfo.floppyPhysDrv  = string.Empty;
            vmInfo.floppyUseImg   = false;
            vmInfo.floppyIsoImg   = string.Empty;

            HardDriveInfo hdi = new HardDriveInfo();

            hdi.bootImg = true;
            hdi.diskID  = 1;
            hdi.drive   = string.Empty;
            hdi.name    = "root";
            hdi.path    = string.Empty;
            hdi.size    = 0;

            vmInfo.hardDrives = new List <HardDriveInfo>();
            vmInfo.hardDrives.Add(hdi);

            NetCardInfo nci = new NetCardInfo();

            nci.cardID     = 1;
            nci.hostname   = string.Empty;
            nci.macAddr    = string.Empty;
            nci.model      = string.Empty;
            nci.option     = string.Empty;
            nci.virtMachID = 0;
            nci.vlan       = 0;

            vmInfo.netCards = new List <NetCardInfo>();
            vmInfo.netCards.Add(nci);
        }
Exemplo n.º 2
0
        public bool LoadVmSettings()
        {
            bool bRet = false;

            if (dataSet != null)
            {
                if (virtMachInfo == null)
                {
                    virtMachInfo = new List <VirtMachInfo>();
                }

                try
                {
                    foreach (DataRow vmRow in dataSet.Tables["VMConfig"].Rows)
                    {
                        VirtMachInfo vmi = new VirtMachInfo();
                        vmi.virtMachID     = (int)vmRow["VirtMachID"];
                        vmi.name           = (string)vmRow["Name"];
                        vmi.machType       = (string)vmRow["MachType"];
                        vmi.defDir         = (string)vmRow["DefDir"];
                        vmi.memSize        = (int)vmRow["MemSize"];
                        vmi.setClockToHost = (bool)vmRow["SetClockToHost"];
                        vmi.cdRomEnable    = (bool)vmRow["CdRomEnable"];
                        vmi.cdRomUsePhys   = (bool)vmRow["CdRomUsePhys"];
                        vmi.cdRomPhysDrv   = (string)vmRow["CdRomPhysDrv"];
                        vmi.cdRomUseIso    = (bool)vmRow["CdRomUseIso"];
                        vmi.cdRomIsoImg    = (string)vmRow["CdRomIsoImg"];
                        vmi.floppyEnable   = (bool)vmRow["FloppyEnable"];
                        vmi.floppyUsePhys  = (bool)vmRow["FloppyUsePhys"];
                        vmi.floppyPhysDrv  = (string)vmRow["FloppyPhysDrv"];
                        vmi.floppyUseImg   = (bool)vmRow["FloppyUseImg"];
                        vmi.floppyIsoImg   = (string)vmRow["FloppyIsoImg"];

                        vmi.hardDrives = new List <HardDriveInfo>();
                        foreach (DataRow hdRow in dataSet.Tables["HardDisks"].Rows)
                        {
                            HardDriveInfo hdi = new HardDriveInfo();
                            hdi.diskID  = (int)hdRow["DiskID"];
                            hdi.name    = (string)hdRow["Name"];
                            hdi.drive   = (string)hdRow["Drive"];
                            hdi.path    = (string)hdRow["Path"];
                            hdi.size    = (int)hdRow["Size"];
                            hdi.bootImg = (bool)hdRow["BootImg"];

                            vmi.hardDrives.Add(hdi);
                        }

                        vmi.netCards = new List <NetCardInfo>();
                        foreach (DataRow hdRow in dataSet.Tables["NetCards"].Rows)
                        {
                            NetCardInfo nci = new NetCardInfo();
                            nci.cardID     = (int)hdRow["CardID"];
                            nci.virtMachID = (int)hdRow["VirtMachID"];
                            nci.option     = (string)hdRow["Option"];
                            nci.vlan       = (int)hdRow["Vlan"];
                            nci.macAddr    = (string)hdRow["MacAddr"];
                            nci.model      = (string)hdRow["Model"];
                            nci.hostname   = (string)hdRow["HostName"];

                            vmi.netCards.Add(nci);
                        }

                        virtMachInfo.Add(vmi);
                    }

                    bRet = true;
                }
                catch (Exception ex)
                {
                    Debug.LogMessage("error loading VM config", ex.Message, ex.StackTrace, true);
                }
            }

            return(bRet);
        }