/// <summary> /// Initializes a new instance of the <see cref="SessionResourceQuantity"/> class. /// </summary> /// <param name="resources">The Virtual Resources for a scenario.</param> public SessionResourceQuantity(IEnumerable <VirtualResource> resources) : this() { var packer = new VirtualResourcePacker(resources); IncrementQuantities(packer); }
private void IncrementQuantities(VirtualResourcePacker packer) { // Get a list of distinct resources based on the resource Id. Then for each distinct // resource increment the total user pool count by the instance count for the resource. var resourceList = packer.PackedSets .SelectMany(x => x) .DistinctBy(x => x.VirtualResourceId) .Where ( x => x.ResourceType.Equals("OfficeWorker") || x.ResourceType.Equals("CitrixWorker") || x.ResourceType.Equals("SolutionTester") ); foreach (var resource in resourceList) { SolutionTester tester = resource as SolutionTester; if (tester != null && tester.AccountType != SolutionTesterCredentialType.AccountPool) { continue; } IncrementDomainAccountQuantity(((OfficeWorker)resource).UserPool, resource.InstanceCount); } // For each packed set, which equates to the resources that will run on a given VM, increment // the VM count by platform used for each packed resource set. foreach (var packedResourceSet in packer.PackedSets) { IncrementVirtualMachineQuantity(packedResourceSet.Platform); } }
/// <summary> /// Initializes a new instance of the <see cref="SolutionTesterDetailBuilder"/> class. /// </summary> /// <param name="config">The configuration.</param> /// <param name="resourcePacker">The resource packer.</param> public SolutionTesterDetailBuilder(SystemManifestAgent config, VirtualResourcePacker resourcePacker) : base(config, resourcePacker, VirtualResourceType.SolutionTester) { }
/// <summary> /// Initializes a new instance of the <see cref="EventLogCollectorDetailBuilder"/> class. /// </summary> /// <param name="config">The builder.</param> /// <param name="resourcePacker">The resource packer.</param> public EventLogCollectorDetailBuilder(SystemManifestAgent config, VirtualResourcePacker resourcePacker) : base(config, resourcePacker, VirtualResourceType.EventLogCollector) { }
/// <summary> /// Initializes a new instance of the <see cref="DetailBuilderBase"/> class. /// </summary> /// <param name="config">The builder.</param> /// <param name="packer">The packer.</param> /// <param name="type">The type.</param> public DetailBuilderBase(SystemManifestAgent config, VirtualResourcePacker packer, VirtualResourceType type) { ManifestAgent = config; ResourcePacker = packer; ResourceType = type; }
/// <summary> /// Initializes a new instance of the <see cref="SessionResourceQuantity"/> class. /// </summary> /// <param name="packer">The packer.</param> public SessionResourceQuantity(VirtualResourcePacker packer) : this() { IncrementQuantities(packer); }
/// <summary> /// Initializes a new instance of the <see cref="OfficeWorkerDetailBuilder"/> class. /// </summary> /// <param name="config">The builder.</param> /// <param name="resourcePacker">The resource packer.</param> /// <param name="resourceType">Type of the resource.</param> public OfficeWorkerDetailBuilder(SystemManifestAgent config, VirtualResourcePacker resourcePacker, VirtualResourceType resourceType) : base(config, resourcePacker, resourceType) { }
/// <summary> /// Initializes a new instance of the <see cref="MachineReservationDetailBuilder"/> class. /// </summary> /// <param name="config">The configuration.</param> /// <param name="resourcePacker">The resource packer.</param> public MachineReservationDetailBuilder(SystemManifestAgent config, VirtualResourcePacker resourcePacker) : base(config, resourcePacker, VirtualResourceType.MachineReservation) { }
internal static DetailBuilderBase CreateDetailBuilder(VirtualResourceType resourceType, SystemManifestAgent systemManifestAgent, VirtualResourcePacker packer) { string className = "{0}.{1}DetailBuilder".FormatWith(typeof(SystemManifestAgent).Namespace, resourceType); return(Activator.CreateInstance(Type.GetType(className), systemManifestAgent, packer) as DetailBuilderBase); }
/// <summary> /// Builds all <see cref="SystemManifest"/>s for the defined <see cref="SessionTicket"/>. /// </summary> /// <param name="mockReserve">if set to <c>true</c> build dummy manifests, without any real reservations. Otherwise, build the real manifests.</param> public void BuildManifests(bool mockReserve = false) { Dictionary <Guid, DetailBuilderBase> detailBuilders = new Dictionary <Guid, DetailBuilderBase>(); VirtualResourcePacker packer = new VirtualResourcePacker(Resources); foreach (var packedResourceSet in packer.PackedSets) { // Create the custom resource builder var builder = VirtualResourceDetailBuilder.CreateDetailBuilder(packedResourceSet.ResourceType, this, packer); detailBuilders.Add(packedResourceSet.Id, builder); } string machineName = Environment.MachineName; // Get the user accounts needed for this session. If reserveItems is false // then there won't be actual accounts reserved in the database. UserAccounts = GetReservedAccounts(mockReserve); // Create a manifest for each packed set foreach (var packedResourceSet in packer.PackedSets) { SystemManifest manifest = new SystemManifest(machineName); manifest.ResourceType = packedResourceSet.ResourceType; TraceFactory.Logger.Debug("Manifest.ResourceType: {0}".FormatWith(manifest.ResourceType)); manifest.Platform = packedResourceSet.Platform; TraceFactory.Logger.Debug("Manifest.Platform: {0}".FormatWith(manifest.Platform)); manifest.SessionId = Ticket.SessionId; TraceFactory.Logger.Debug("Manifest.SessionId: {0}".FormatWith(manifest.SessionId)); manifest.SessionOwner = Ticket.SessionOwner; TraceFactory.Logger.Debug("Manifest.SessionOwner: {0}".FormatWith((manifest.SessionOwner != null ? manifest.SessionOwner.UserName : "******"))); manifest.CollectEventLogs = Ticket.CollectEventLogs; TraceFactory.Logger.Debug("Manifest.CollectEventLogs: {0}".FormatWith(manifest.CollectEventLogs)); TraceFactory.Logger.Debug("Processing Packed Set, Platform: {0}, Type: {1}".FormatWith(packedResourceSet.Platform, packedResourceSet.ResourceType)); //DEBUG TraceFactory.Logger.Debug($"User Pool Count: {UserAccounts.UserPools.Count}"); // Add all assets being used in this resource to the manifest foreach (AssetDetail asset in Assets) { manifest.Assets.Add(asset); } // Have all agents populate their respective portions of the manifest foreach (IManifestComponentAgent agent in _agents) { agent.AssignManifestInfo(manifest); } // Add software installers being used by this resource into the manifest var metadataTypes = packedResourceSet.SelectMany(x => x.VirtualResourceMetadataSet).Where(x => x.Enabled).Select(x => x.MetadataType).Distinct(); foreach (SoftwareInstallerDetail installer in DataCache.GetSoftwareInstallerDetails(manifest.ResourceType, metadataTypes)) { TraceFactory.Logger.Debug("Adding {0}".FormatWith(installer.Description)); manifest.SoftwareInstallers.Add(installer); } // Now call the resource specific detail builder to add any additional information specific to this resource type detailBuilders[packedResourceSet.Id].AddToManifest(packedResourceSet, manifest); ManifestSet.Add(manifest); } }
/// <summary> /// Initializes a new instance of the <see cref="AdminWorkerDetailBuilder"/> class. /// </summary> /// <param name="config">The builder.</param> /// <param name="resourcePacker">The resource packer.</param> public AdminWorkerDetailBuilder(SystemManifestAgent config, VirtualResourcePacker resourcePacker) : base(config, resourcePacker, VirtualResourceType.AdminWorker) { }