public void Add(VirtualMachine vm) { MyVirtualMachines.Add(vm); }
/// <summary> /// Returns a list of Permanent Virtual Machine roles. Each Virtual Machine object contains some metadata of the actual virtual machine /// </summary> /// <returns>A list of Permanent Virtual Machine Roles</returns> public VirtualMachines GetAllVirtualMachineRoles() { ComputeManagementClient client = new ComputeManagementClient(MyCloudCredentials); try { VirtualMachines vms = new VirtualMachines(new List<VirtualMachine>()); var hostedServices = client.HostedServices.List(); foreach (var service in hostedServices) { var deployment = GetAzureDeyployment(service.ServiceName, DeploymentSlot.Production); if (deployment != null) { if (deployment.Roles.Count > 0) { VirtualMachine vm = null; foreach (var role in deployment.Roles) { if (role.RoleType == VirtualMachineRoleType.PersistentVMRole.ToString()) { var operatingSystem = string.Format("{0}--{1}",role.OSVirtualHardDisk.OperatingSystem, role.OSVirtualHardDisk.SourceImageName); var rate = Configuration.GetAzureRates().GetMyRate(role.RoleSize); vm = new VirtualMachine(role.RoleName, role.RoleSize, role.RoleType, operatingSystem, rate); vms.Add(vm); } } } } } return vms; } catch (CloudException ce) { Logger.Warn(ce, String.Format("Exception during retrieval of Virtual Machine Roles Exception: {0}", ce)); } return null; }