コード例 #1
0
        public ActionResult Create(VirtualMachineFormViewModel vmForm)
        {
            if (vmRepo.GetAllRegisteredVirtualMachines().Count < configRepo.GetMaxVmCount() ||
                configRepo.GetMaxVmCount() <= 0)
            {
                if (ModelState.IsValid)
                {
                    var vm = new VirtualMachine(vmForm, configRepo.GetVmCreationTime());
                    vmRepo.CreateVirtualMachine(vm, vmForm.ProjectName);

                    return RedirectToAction("Index");
                }
            }
            //TODO: Add comments to what this does
            var projectName = new SelectList(vmRepo.GetAllProjects(),
                "ProjectName", "ProjectName");

            ViewBag.ProjectName = projectName;
            ViewBag.BaseImageFile = new SelectList(
                VMAT.Services.RegisteredVirtualMachineService.GetBaseImageFiles());
            ViewBag.Hostname = AppConfiguration.GetVMHostName();
            vmForm.IP = vmRepo.GetNextAvailableIP().ToString();

            return View(vmForm);
        }
コード例 #2
0
        //
        // GET: /VirtualMachine/Create
        public ActionResult Create()
        {
            var vmForm = new VirtualMachineFormViewModel();
            var projectName = new SelectList(vmRepo.GetAllProjects(),
                "ProjectName", "ProjectName");

            ViewBag.ProjectName = projectName;
            ViewBag.BaseImageFile = new SelectList(
                VMAT.Services.RegisteredVirtualMachineService.GetBaseImageFiles());
            vmForm.IP = vmRepo.GetNextAvailableIP().ToString();

            return View(vmForm);
        }
コード例 #3
0
ファイル: VirtualMachine.cs プロジェクト: tiger12506/VMAT
 public VirtualMachine(VirtualMachineFormViewModel vmForm, DateTime creationTime)
 {
     MachineName = "gapdev" + vmForm.ProjectName.Trim('G') + vmForm.MachineName;
     ImagePathName = AppConfiguration.GetDatastore() + vmForm.ProjectName + "/" +
         MachineName + "/" + MachineName + ".vmx";
     BaseImageFullPhysicalPath = vmForm.BaseImageFile;
     Hostname = MachineName; //nathan added
     IP = vmForm.IP;
     IsAutoStarted = vmForm.IsAutoStarted;
     Status = PENDING;
     IsPendingArchive = false;
     LastArchived = creationTime;
     LastBackuped = creationTime;
     LastStarted = creationTime;
     LastStopped = creationTime;
     CreatedTime = creationTime;
 }
コード例 #4
0
        public ActionResult Edit(VirtualMachineFormViewModel vm)
        {
            if (ModelState.IsValid)
            {
                // save changes (removed)
                return RedirectToAction("Index");
            }

            return View(vm);
        }
コード例 #5
0
        //
        // GET: /VirtualMachine/Edit
        public ActionResult Edit(int id)
        {
            VirtualMachine vm = vmRepo.GetVirtualMachine(id);
            var form = new VirtualMachineFormViewModel(vm);

            return View(form);
        }