public void ProjectIDTest() { var value = 1; var virtualmachine = new VirtualMachine(); virtualmachine.ID = value; Assert.AreEqual(virtualmachine.ID, value); }
public void PoortNrTest() { var value = 1; var virtualmachine = new VirtualMachine(); virtualmachine.PoortNr = value; Assert.AreEqual(virtualmachine.PoortNr, value); }
public void NaamTest() { var value = "Test"; var virtualmachine = new VirtualMachine(); virtualmachine.Naam = value; Assert.AreEqual(virtualmachine.Naam, value); }
public void IPTest() { var value = "1.1.1.1"; var virtualmachine = new VirtualMachine(); virtualmachine.IP = value; Assert.AreEqual(virtualmachine.IP, value); }
public void RequiredTest() { var virtualmachine = new VirtualMachine { ID = 1, ProjectID = 1, Naam = null, Type = VirtualMachineTypes.Sharepoint, IP = null, VMuser = null, VMpass = null, PoortNr = 1 }; Assert.IsTrue(ValidateModel(virtualmachine).Count > 0); }
public void VMpassTest() { var value = "Test"; var virtualmachine = new VirtualMachine(); virtualmachine.VMpass = value; Assert.AreEqual(virtualmachine.VMpass, value); }
public void TypeTest() { var value = VirtualMachineTypes.Sharepoint; VirtualMachine virtualmachine = new VirtualMachine(); virtualmachine.Type = value; Assert.AreEqual(virtualmachine.Type, value); }
/// <author>Bart</author> /// <summary> /// Deze methode is om een nieuwe Virtual Machine aan te maken op Azure, wanneer er al een deployment is gemaakt. /// </summary> /// <param name="virtualMachine">Is het model van de Virtual Machine</param> /// <returns>Een true of false respectiefelijk aan of de actie geslaagt is of niet.</returns> private Boolean WithoutDeployment(VirtualMachine virtualMachine) { try { ComputeManagementClient client = new ComputeManagementClient(cloudCredentials); //Stap 1 : Het klaarzetten van de meeste data uit het VirtualMachine model. string vmName = virtualMachine.Naam; string uName = virtualMachine.VMuser; string uPassword = virtualMachine.VMpass; string cloudServiceName = virtualMachine.IP; int port = virtualMachine.PoortNr; string imageName = null; switch (virtualMachine.Type) { case VirtualMachineTypes.Sharepoint: imageName = sc.GetValue("sharepointImg"); break; case VirtualMachineTypes.SQLServer: imageName = sc.GetValue("sqlImg"); break; } //Stap 2 : Het maken van de configuratie van de VM. ResourceExtensionReference resourceExtensionReference = new ResourceExtensionReference() { ReferenceName = "VMAccessAgent", Name = "VMAccessAgent", Publisher = "Microsoft.Compute", Version = "2.0" }; ConfigurationSet configSet = new ConfigurationSet() { ConfigurationSetType = ConfigurationSetTypes.WindowsProvisioningConfiguration, EnableAutomaticUpdates = false, ComputerName = vmName, AdminUserName = uName, AdminPassword = uPassword, }; ConfigurationSet networkConfigSet = new ConfigurationSet() { ConfigurationSetType = ConfigurationSetTypes.NetworkConfiguration, InputEndpoints = new List<InputEndpoint> { new InputEndpoint() { LocalPort = int.Parse(sc.GetValue("rdpPort")), Name = "Remote Desktop", Port = port, Protocol = InputEndpointTransportProtocol.Tcp, EnableDirectServerReturn = false } } }; //Stap 3 : Het zetten van alle gegevens in één CreateParameters object. VirtualMachineCreateParameters virtualMachineParams = new VirtualMachineCreateParameters { RoleName = vmName, RoleSize = VirtualMachineRoleSize.Small, ProvisionGuestAgent = true, ConfigurationSets = new List<ConfigurationSet>(), ResourceExtensionReferences = new List<ResourceExtensionReference>(), OSVirtualHardDisk = new OSVirtualHardDisk() { MediaLink = GetVhdUri(string.Format("{0}.blob.core.windows.net/vhds", relatedStorageAccountName)), SourceImageName = GetSourceImageNameByFamilyName(imageName) } }; virtualMachineParams.ResourceExtensionReferences.Add(resourceExtensionReference); virtualMachineParams.ConfigurationSets.Add(configSet); virtualMachineParams.ConfigurationSets.Add(networkConfigSet); //Stap 4 : Het werkelijke creëren van de VM. client.VirtualMachines.Create(cloudServiceName, "VMs", virtualMachineParams); System.Diagnostics.Debug.Write("Create VM Succes"); return true; } catch (CloudException e) { throw e; } catch (Exception ex) { throw ex; } }
public Boolean CreateVM(VirtualMachine virtualMachine) { Boolean result = false; if (CheckDeployment(virtualMachine.IP)) { result = WithoutDeployment(virtualMachine); } else { result = WithDeployment(virtualMachine); } return result; }