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); }
// // 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); }
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; }
public ActionResult Edit(VirtualMachineFormViewModel vm) { if (ModelState.IsValid) { // save changes (removed) return RedirectToAction("Index"); } return View(vm); }
// // GET: /VirtualMachine/Edit public ActionResult Edit(int id) { VirtualMachine vm = vmRepo.GetVirtualMachine(id); var form = new VirtualMachineFormViewModel(vm); return View(form); }